|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.yeepay.yop.sdk.service.common.response.YopResponse;
|
|
import com.yeepay.yop.sdk.service.common.response.YopResponse;
|
|
|
import io.jsonwebtoken.lang.Assert;
|
|
import io.jsonwebtoken.lang.Assert;
|
|
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -49,46 +50,22 @@ import java.util.Optional;
|
|
|
|
|
|
|
|
@Service
|
|
@Service
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
|
|
+@AllArgsConstructor
|
|
|
public class PointExchangeServiceImpl implements PointExchangeService {
|
|
public class PointExchangeServiceImpl implements PointExchangeService {
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
private IPointGoodsService pointGoodsService;
|
|
private IPointGoodsService pointGoodsService;
|
|
|
- @Autowired
|
|
|
|
|
private IPointRecordService pointRecordService;
|
|
private IPointRecordService pointRecordService;
|
|
|
- @Autowired
|
|
|
|
|
private IUserPufaPointService userPufaPointService;
|
|
private IUserPufaPointService userPufaPointService;
|
|
|
- @Autowired
|
|
|
|
|
private IUserAddressService userAddressService;
|
|
private IUserAddressService userAddressService;
|
|
|
- @Autowired
|
|
|
|
|
private IGoodsOrderService goodsOrderService;
|
|
private IGoodsOrderService goodsOrderService;
|
|
|
- @Autowired
|
|
|
|
|
private HttpServletRequest request;
|
|
private HttpServletRequest request;
|
|
|
- @Autowired
|
|
|
|
|
private YeepaySaasService yeepaySaasService;
|
|
private YeepaySaasService yeepaySaasService;
|
|
|
- @Autowired
|
|
|
|
|
private IYeepayOrderService yeepayOrderService;
|
|
private IYeepayOrderService yeepayOrderService;
|
|
|
- @Autowired
|
|
|
|
|
private YeePayConst yeePayConst;
|
|
private YeePayConst yeePayConst;
|
|
|
- @Autowired
|
|
|
|
|
private BladeLogger bladeLogger;
|
|
private BladeLogger bladeLogger;
|
|
|
- @Autowired
|
|
|
|
|
private YeePayService yeePayService;
|
|
private YeePayService yeePayService;
|
|
|
- @Autowired
|
|
|
|
|
private ConfigForOfficial configForOfficial;
|
|
private ConfigForOfficial configForOfficial;
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
- public void pointExchange(YeepayOrder yeepayOrder) {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
- public HashMap<String, Object> cashExchange(YeepayOrder yeepayOrder) throws Exception {
|
|
|
|
|
-
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
void createOrder(YeepayOrder yeepayOrder) {
|
|
void createOrder(YeepayOrder yeepayOrder) {
|
|
|
|
|
|
|
@@ -167,14 +144,7 @@ public class PointExchangeServiceImpl implements PointExchangeService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HashMap<String, Object> hybridExchange(YeepayOrder yeepayOrder) throws Exception {
|
|
|
|
|
-
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
- public HashMap<String, Object> merge(YeepayOrder yeepayOrder, int type) throws Exception {
|
|
|
|
|
|
|
+ public HashMap<String, Object> mergePay(YeepayOrder yeepayOrder, int type) throws Exception {
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
if (yeepayOrder.getUsePoint() != null && (yeepayOrder.getUsePoint().compareTo(BigDecimal.ZERO) < 0)) {
|
|
if (yeepayOrder.getUsePoint() != null && (yeepayOrder.getUsePoint().compareTo(BigDecimal.ZERO) < 0)) {
|
|
|
throw new PointExchangeException("请输入有效积分值");
|
|
throw new PointExchangeException("请输入有效积分值");
|
|
@@ -218,6 +188,7 @@ public class PointExchangeServiceImpl implements PointExchangeService {
|
|
|
Assert.isTrue(userPufaPointService.saveOrUpdate(user), "兑换失败");
|
|
Assert.isTrue(userPufaPointService.saveOrUpdate(user), "兑换失败");
|
|
|
yeepayOrder.setUserId(user.getUserId());
|
|
yeepayOrder.setUserId(user.getUserId());
|
|
|
yeepayOrder.setUsePoint(exchangePoint);
|
|
yeepayOrder.setUsePoint(exchangePoint);
|
|
|
|
|
+ yeepayOrder.setPhone(address.getPhone());
|
|
|
//下单
|
|
//下单
|
|
|
createOrder(yeepayOrder);
|
|
createOrder(yeepayOrder);
|
|
|
//添加积分消费
|
|
//添加积分消费
|
|
@@ -242,7 +213,7 @@ public class PointExchangeServiceImpl implements PointExchangeService {
|
|
|
//如果用户输入的积分足够,则使用积分支付
|
|
//如果用户输入的积分足够,则使用积分支付
|
|
|
if (yeepayOrder.getUsePoint().compareTo(exchangePoint) > 0) {
|
|
if (yeepayOrder.getUsePoint().compareTo(exchangePoint) > 0) {
|
|
|
type = 1;
|
|
type = 1;
|
|
|
- return this.merge(yeepayOrder, type);
|
|
|
|
|
|
|
+ return this.mergePay(yeepayOrder, type);
|
|
|
}
|
|
}
|
|
|
//需要的现金
|
|
//需要的现金
|
|
|
BigDecimal usePoint = exchangePoint.subtract(yeepayOrder.getUsePoint());
|
|
BigDecimal usePoint = exchangePoint.subtract(yeepayOrder.getUsePoint());
|