|
@@ -18,6 +18,7 @@ import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
|
|
|
import cn.newfeifan.mall.module.pay.dal.mysql.order.PayOrderMapper;
|
|
|
import cn.newfeifan.mall.module.pay.service.app.PayAppService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -45,6 +46,7 @@ import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
|
|
|
*/
|
|
|
@Service
|
|
|
@Validated
|
|
|
+@Slf4j
|
|
|
public class UserTopUpConsumptionPointsOrderServiceImpl implements UserTopUpConsumptionPointsOrderService {
|
|
|
|
|
|
@Resource
|
|
@@ -66,13 +68,9 @@ public class UserTopUpConsumptionPointsOrderServiceImpl implements UserTopUpCons
|
|
|
|
|
|
@Override
|
|
|
public UserTopUpConsumptionPointsOrderInfoRespVO createUserTopUpConsumptionPointsOrder(UserTopUpConsumptionPointsOrderSaveReqVO createReqVO) {
|
|
|
- // 计算百分比
|
|
|
- OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
|
|
|
-
|
|
|
// 初始化订单
|
|
|
- orderInit(createReqVO, orderPercentageDO);
|
|
|
+ orderInit(createReqVO);
|
|
|
|
|
|
- createReqVO.setPercentTemplate(JSON.toJSONString(orderPercentageDO));
|
|
|
UserTopUpConsumptionPointsOrderDO userTopUpConsumptionPointsOrder = BeanUtils.toBean(createReqVO, UserTopUpConsumptionPointsOrderDO.class);
|
|
|
userTopUpConsumptionPointsOrderMapper.insert(userTopUpConsumptionPointsOrder);
|
|
|
|
|
@@ -110,11 +108,12 @@ public class UserTopUpConsumptionPointsOrderServiceImpl implements UserTopUpCons
|
|
|
* 订单转换
|
|
|
*
|
|
|
* @param createReqVO 订单信息
|
|
|
- * @param orderPercentageDO 百分比计算规则
|
|
|
*/
|
|
|
- private void orderInit(UserTopUpConsumptionPointsOrderSaveReqVO createReqVO, OrderPercentageDO orderPercentageDO) {
|
|
|
+ private void orderInit(UserTopUpConsumptionPointsOrderSaveReqVO createReqVO) {
|
|
|
+ // 计算百分比
|
|
|
+ OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
|
|
|
|
|
|
- if(createReqVO.getPayPrice() < Long.parseLong(orderPercentageDO.getUserTopUpConsumptionPoints())){
|
|
|
+ if(createReqVO.getPayPrice() < Double.parseDouble(orderPercentageDO.getUserTopUpConsumptionPoints())){
|
|
|
ErrorCode ERROR = new ErrorCode(1_002_030_038, "用户充值金额不得小于:" + orderPercentageDO.getUserTopUpConsumptionPoints());
|
|
|
throw exception(ERROR);
|
|
|
}
|
|
@@ -130,6 +129,7 @@ public class UserTopUpConsumptionPointsOrderServiceImpl implements UserTopUpCons
|
|
|
createReqVO.setPayPrice(createReqVO.getPayPrice() * DistriConstants.ONE_HUNDRED);
|
|
|
createReqVO.setTopUpConsumptionPoints(createReqVO.getPayPrice() * DistriConstants.PERCENT);
|
|
|
createReqVO.setPracticalConsumptionPoints((long) (createReqVO.getTopUpConsumptionPoints() * Double.parseDouble(orderPercentageDO.getConsumptionMagnification())));
|
|
|
+ createReqVO.setPercentTemplate(JSON.toJSONString(orderPercentageDO));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -169,7 +169,9 @@ public class UserTopUpConsumptionPointsOrderServiceImpl implements UserTopUpCons
|
|
|
public void topUpConsumptionPoints(PayOrderDO payOrderDO) {
|
|
|
UserTopUpConsumptionPointsOrderDO topUpOrder = userTopUpConsumptionPointsOrderMapper.selectById(payOrderDO.getMerchantOrderId());
|
|
|
|
|
|
+ log.info("充值订单对象:{}", topUpOrder);
|
|
|
if(topUpOrder.getPayStatus()){
|
|
|
+ log.info("充值订单状态为已支付,return结束!");
|
|
|
return;
|
|
|
}
|
|
|
|