提交代码

master
胡锐 6 months ago committed by yuanye
parent 2e4fb6cf6d
commit 63645f8a4f
  1. 5
      order/src/main/java/com/order/controller/OrderPayController.java
  2. 26
      service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java
  3. 14
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java
  4. 5
      service/src/main/java/com/hfkj/sysenum/UserIntegralRecordSourceTypeEnum.java

@ -92,8 +92,10 @@ public class OrderPayController {
Map<Object, Object> preorder = HuiPayService.preorder(merPay.getPayMerNo(), merPay.getPayMerKey(), body.getString("openId"), order); Map<Object, Object> preorder = HuiPayService.preorder(merPay.getPayMerNo(), merPay.getPayMerKey(), body.getString("openId"), order);
for (OrderChildModel orderChild : order.getOrderChildList()) { for (OrderChildModel orderChild : order.getOrderChildList()) {
orderChild.setSettleAccount(merPay.getPayMerNo()); orderChild.setSettleAccount(merPay.getPayMerNo());
orderChild.setSettleAccountKey(merPay.getPayMerKey());
orderChildService.editData(orderChild); orderChildService.editData(orderChild);
} }
orderService.cacheDelete(order.getOrderNo());
return ResponseMsgUtil.success(preorder); return ResponseMsgUtil.success(preorder);
} catch (Exception e) { } catch (Exception e) {
@ -135,7 +137,7 @@ public class OrderPayController {
orderChild.setSettleAccountKey(merPay.getPayMerKey()); orderChild.setSettleAccountKey(merPay.getPayMerKey());
orderChildService.editData(orderChild); orderChildService.editData(orderChild);
} }
orderService.cacheDelete(order.getOrderNo());
return ResponseMsgUtil.success(preorder); return ResponseMsgUtil.success(preorder);
} catch (Exception e) { } catch (Exception e) {
log.error("error!",e); log.error("error!",e);
@ -182,6 +184,7 @@ public class OrderPayController {
orderChild.setSettleAccountKey(merPay.getPayMerKey()); orderChild.setSettleAccountKey(merPay.getPayMerKey());
orderChildService.editData(orderChild); orderChildService.editData(orderChild);
} }
orderService.cacheDelete(order.getOrderNo());
return ResponseMsgUtil.success(orderPayService.hltCardPay(merPay.getHltInstCode(),order, card)); return ResponseMsgUtil.success(orderPayService.hltCardPay(merPay.getHltInstCode(),order, card));
} else { } else {

@ -19,6 +19,9 @@ import com.hfkj.service.order.BsOrderChildService;
import com.hfkj.service.order.BsOrderRefundService; import com.hfkj.service.order.BsOrderRefundService;
import com.hfkj.service.order.BsOrderService; import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.pay.HuiPayService; import com.hfkj.service.pay.HuiPayService;
import com.hfkj.service.user.UserIntegralService;
import com.hfkj.sysenum.UserIntegralRecordOpUserTypeEnum;
import com.hfkj.sysenum.UserIntegralRecordSourceTypeEnum;
import com.hfkj.sysenum.mer.PayPlatformEnum; import com.hfkj.sysenum.mer.PayPlatformEnum;
import com.hfkj.sysenum.order.*; import com.hfkj.sysenum.order.*;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
@ -32,6 +35,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -50,6 +54,8 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
@Resource @Resource
private BsOrderChildService orderChildService; private BsOrderChildService orderChildService;
@Resource @Resource
private UserIntegralService userIntegralService;
@Resource
private BsMerPayConfigService merPayConfigService; private BsMerPayConfigService merPayConfigService;
@Override @Override
public void editData(BsOrderRefund data) { public void editData(BsOrderRefund data) {
@ -174,10 +180,28 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
orderRefund.setRefundPrice(unitPrice.multiply(new BigDecimal(productCount.toString()))); orderRefund.setRefundPrice(unitPrice.multiply(new BigDecimal(productCount.toString())));
orderRefund.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue()); orderRefund.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue());
} }
if (orderRefund.getRefundIntegral() > 0L) {
Map<String,Object> opUser = new HashMap<>();
opUser.put("opUserType", orderRefund.getOpUserType());
opUser.put("opUserId", orderRefund.getUserId());
opUser.put("opUserPhone", orderRefund.getUserPhone());
Map<String,Object> source = new HashMap<>();
source.put("sourceType", UserIntegralRecordSourceTypeEnum.type2.getCode());
source.put("sourceId", orderChild.getId());
source.put("sourceOrderNo", orderChild.getChildOrderNo());
source.put("sourceContent", "商品订单退款退回积分");
// 退款积分
userIntegralService.entry(orderRefund.getUserId(),orderRefund.getRefundIntegral(), opUser, source);
}
orderRefund.setRefundRemark(remark); orderRefund.setRefundRemark(remark);
orderRefund.setRefundStatus(OrderRefundStatusEnum.status1.getCode()); orderRefund.setRefundStatus(OrderRefundStatusEnum.status1.getCode());
orderRefund.setAccountMerchantNo(orderChild.getSettleAccount()); orderRefund.setAccountMerchantNo(orderChild.getSettleAccount());
orderRefund.setAccountMerchantNo(orderChild.getSettleAccountKey()); orderRefund.setAccountMerchantKey(orderChild.getSettleAccountKey());
editData(orderRefund); editData(orderRefund);
// 资金退款 // 资金退款

@ -1,5 +1,6 @@
package com.hfkj.service.order.impl; package com.hfkj.service.order.impl;
import com.hfkj.common.exception.BaseException;
import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode; import com.hfkj.common.exception.SysCode;
@ -228,11 +229,14 @@ public class BsOrderServiceImpl implements BsOrderService {
)); ));
} }
childOrder.setIntegralDiscountPrice(childOrder.getSurplusRefundIntegral());
childOrder.setCouponDiscountPrice( childOrder.setCouponDiscountPrice(
// 可退款金额大于0 可退款金额+可退款积分=优惠券优惠
childOrder.getSurplusRefundPrice().compareTo(BigDecimal.ZERO) == 1 childOrder.getSurplusRefundPrice().compareTo(BigDecimal.ZERO) == 1
? childOrder.getProductTotalPrice().subtract(childOrder.getSurplusRefundPrice()) ? childOrder.getProductTotalPrice().subtract(
childOrder.getSurplusRefundPrice().add(new BigDecimal(childOrder.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100"))))
: childOrder.getSurplusRefundPrice()); : childOrder.getSurplusRefundPrice());
childOrder.setIntegralDiscountPrice(childOrder.getSurplusRefundIntegral());
childOrder.setTotalDeductionPrice( childOrder.setTotalDeductionPrice(
childOrder.getCouponDiscountPrice() childOrder.getCouponDiscountPrice()
.add(new BigDecimal(childOrder.getIntegralDiscountPrice().toString()).divide(new BigDecimal("100"))) .add(new BigDecimal(childOrder.getIntegralDiscountPrice().toString()).divide(new BigDecimal("100")))
@ -307,12 +311,12 @@ public class BsOrderServiceImpl implements BsOrderService {
deduction.setCouponDiscountPrice(discount.getPrice()); deduction.setCouponDiscountPrice(discount.getPrice());
// 卡卷类型 1:满减 2:抵扣 3:折扣 // 卡卷类型 1:满减 2:抵扣 3:折扣
if (1 == discount.getType()) { if (1 == discount.getType()) {
deduction.setCouponDiscountActualPrice(discount.getPrice());
} else if (2 == discount.getType()) {
if (discount.getCondition().compareTo(order.getProductTotalPrice()) < 0) { if (discount.getCondition().compareTo(order.getProductTotalPrice()) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未满足优惠券满减条件"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未满足优惠券满减条件");
} }
deduction.setCouponDiscountActualPrice(discount.getPrice()); deduction.setCouponDiscountActualPrice(discount.getPrice());
} else if (2 == discount.getType()) {
deduction.setCouponDiscountActualPrice(discount.getPrice());
} else if (3 == discount.getType()) { } else if (3 == discount.getType()) {
deduction.setCouponDiscountPrice(discount.getPercentage()); deduction.setCouponDiscountPrice(discount.getPercentage());
deduction.setCouponDiscountActualPrice( deduction.setCouponDiscountActualPrice(
@ -326,6 +330,8 @@ public class BsOrderServiceImpl implements BsOrderService {
deduction.setTotalDeductionPrice(deduction.getCouponDiscountActualPrice() deduction.setTotalDeductionPrice(deduction.getCouponDiscountActualPrice()
.add(new BigDecimal(deduction.getIntegralDiscountPrice().toString()).divide(new BigDecimal("100")))); .add(new BigDecimal(deduction.getIntegralDiscountPrice().toString()).divide(new BigDecimal("100"))));
orderDeductionService.editData(deduction); orderDeductionService.editData(deduction);
} catch (BaseException e) {
throw e;
} catch (Exception e) { } catch (Exception e) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券使用异常"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券使用异常");
} finally { } finally {

@ -14,6 +14,11 @@ public enum UserIntegralRecordSourceTypeEnum {
* 交易订单 * 交易订单
*/ */
type1(1, "交易订单"), type1(1, "交易订单"),
/**
* 商品订单
*/
type2(1, "商品订单"),
; ;
private int code; private int code;

Loading…
Cancel
Save