From 510678fe2f81501914ea4905fb7026b9c7be414f Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期六, 01 四月 2023 21:28:42 +0800 Subject: [PATCH] 退款重构 --- phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java | 77 +++++++++++++++---------- phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java | 67 ++++++++++------------ phi_platform_common/src/main/java/com/hx/phip/dao/mapper/RefundMapper.java | 6 +- phi_platform_common/src/main/resources/mapper/platform/RefundMapper.xml | 6 +- phi_platform_user/src/main/java/com/hx/phip/service/refund/impl/RefundRecordServiceImpl.java | 1 phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java | 2 6 files changed, 84 insertions(+), 75 deletions(-) diff --git a/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/RefundMapper.java b/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/RefundMapper.java index 13bcb81..187fd6a 100644 --- a/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/RefundMapper.java +++ b/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/RefundMapper.java @@ -7,10 +7,10 @@ import java.util.List; public interface RefundMapper { - /**鎬绘敮浠樻柟寮忚褰曡繑鍥�*/ + /**鎬绘敮浠樻柟寮忚褰曡繑鍥�-鏀粯缂栧彿姹傚拰*/ List<PayMethodVo> selectConsumePayList(@Param("orderId") String orderId); - /**涓�绾ф敮浠樻柟寮忚褰曡繑鍥�*/ + /**涓�绾ф敮浠樻柟寮忚褰曡繑鍥�-鏀粯缂栧彿姹傚拰*/ List<PayMethodVo> selectConsumePayOneList(@Param("typeId") String typeId); - /**浜岀骇鏀粯鏂瑰紡璁板綍杩斿洖*/ + /**浜岀骇鏀粯鏂瑰紡璁板綍杩斿洖-鏀粯缂栧彿姹傚拰*/ List<PayMethodVo> selectConsumePayTwoList(@Param("typeId") String typeId); } \ No newline at end of file diff --git a/phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java b/phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java index 1251be2..2fa17b5 100644 --- a/phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java +++ b/phi_platform_common/src/main/java/com/hx/phip/vo/order/refund/RefundCarryVo.java @@ -13,7 +13,7 @@ @Data public class RefundCarryVo { - /**閫�娆剧殑閫�娆炬柟寮忛噾棰�-璇ュ弬鏁颁竴寮�濮嬪氨鎼哄甫*/ + /**閫�娆剧殑閫�娆炬柟寮忛噾棰�-璇ュ弬鏁颁竴寮�濮嬪氨鎼哄甫锛屽叏灞�浣跨敤*/ private List<RefundRecordMethod> refundRecordMethodList; //***************鍐呴儴鎼哄甫浣滅敤鍙傛暟锛屽叏绋嬪彉鍖栵紝娉ㄦ剰浣跨敤******************** diff --git a/phi_platform_common/src/main/resources/mapper/platform/RefundMapper.xml b/phi_platform_common/src/main/resources/mapper/platform/RefundMapper.xml index 035195d..380550c 100644 --- a/phi_platform_common/src/main/resources/mapper/platform/RefundMapper.xml +++ b/phi_platform_common/src/main/resources/mapper/platform/RefundMapper.xml @@ -5,7 +5,7 @@ <!-- namespace:璇apper.xml鏄犲皠鏂囦欢鐨� 鍞竴鏍囪瘑 --> <mapper namespace="com.hx.phip.dao.mapper.RefundMapper"> - <!--涓�绾ф敮浠樻柟寮忚褰曡繑鍥�--> + <!--涓�绾ф敮浠樻柟寮忚褰曡繑鍥�-鏀粯缂栧彿姹傚拰--> <select id="selectConsumePayList" resultType="com.hx.phip.vo.order.payment.PayMethodVo"> SELECT ANY_VALUE(name) AS name ,numberNo @@ -17,7 +17,7 @@ </select> - <!--涓�绾ф敮浠樻柟寮忚褰曡繑鍥�--> + <!--涓�绾ф敮浠樻柟寮忚褰曡繑鍥�-鏀粯缂栧彿姹傚拰--> <select id="selectConsumePayOneList" resultType="com.hx.phip.vo.order.payment.PayMethodVo"> SELECT ANY_VALUE(name) AS name ,numberNo @@ -27,7 +27,7 @@ WHERE isDel = 0 AND typeId = #{typeId} GROUP BY numberNo </select> - <!--浜岀骇鏀粯鏂瑰紡璁板綍杩斿洖--> + <!--浜岀骇鏀粯鏂瑰紡璁板綍杩斿洖-鏀粯缂栧彿姹傚拰--> <select id="selectConsumePayTwoList" resultType="com.hx.phip.vo.order.payment.PayMethodVo" > SELECT ANY_VALUE(name) AS name ,numberNo diff --git a/phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java b/phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java index dd9e2f5..7b82e24 100644 --- a/phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java +++ b/phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java @@ -873,22 +873,27 @@ /**淇濆瓨閫�娆句俊鎭� * 淇濆瓨閫�娆句俊鎭紝骞舵病鏈夌湡姝i��娆� */ - public RefundRecord insertRefundInfo(OrderRefundDto orderRefundDto,OrdersTotal ordersTotal,StringBuilder orderNodeBuilder - , ThirtApplication thirtApplication){ + public RefundRecord insertRefundInfo(OrderRefundDto orderRefundDto,OrdersTotal ordersTotal + ,StringBuilder orderNodeBuilder, ThirtApplication thirtApplication){ + + //鎿嶄綔浜� + Employee employee = commonService.selectOneByKey(EmployeeMapper.class,orderRefundDto.getOperatorId()); + if(employee == null){ + throw new TipsException("鎿嶄綔浜烘爣璇嗛敊璇紒"); + } ///////閫�娆炬�昏〃鏁版嵁濉厖 //鐢熸垚閫�娆剧紪鍙� String totalCode = createNoService.createNo("R",System.currentTimeMillis()+"",8); RefundRecord refundRecord=new RefundRecord(totalCode,ordersTotal.getShopId(),ordersTotal.getShopName(),orderRefundDto.getRefundTotal() , RefundStatus.STATUS_APPLY_REFUND,0, RefundSoruceConstants.TYPE_SOURCE_ORDER,orderRefundDto.getRemarks(),ordersTotal.getId(),ordersTotal.getUserId()); + //鎿嶄綔浜轰俊鎭� refundRecord.setOperatorType(RefundRecord.OPERATOR_TYPE_EMPLOYEE); - Employee employee = commonService.selectOneByKey(EmployeeMapper.class,orderRefundDto.getOperatorId()); - if(employee == null){ - throw new TipsException("鎿嶄綔浜烘爣璇嗛敊璇紒"); - } refundRecord.setOperatorId(employee.getId()); - refundRecord.setRefundOperationType(orderRefundDto.getRefundOperationType()); + refundRecord.setOperatorNo(employee.getEmployeeNo()); refundRecord.setOperatorName(employee.getCnName()); + + refundRecord.setRefundOperationType(orderRefundDto.getRefundOperationType()); /////閫�娆剧殑澶囨敞 refundRecord.setRemarks(orderRefundDto.getRemarks()); refundRecord.setRefundReason(orderRefundDto.getRefundReason()); @@ -898,14 +903,13 @@ refundRecordService.insert(refundRecord); //閫�娆炬柟寮忓鐞� - List<RefundRecordMethod> refundRecordMethodList = null; if(orderRefundDto.getRefundPayMethod() !=null && orderRefundDto.getRefundPayMethod().size() > 0){ - refundRecordMethodList = handleRefundPayMethod(orderRefundDto,orderNodeBuilder,ordersTotal,refundRecord); + handleRefundPayMethod(orderRefundDto,orderNodeBuilder,ordersTotal,refundRecord); } //閫�娆剧殑瀛愰」澶勭悊 if(orderRefundDto.getRefundList()!=null && orderRefundDto.getRefundList().size()>0){ - insertRefundRecordItem(orderRefundDto,orderNodeBuilder,ordersTotal,refundRecord,refundRecordMethodList); + insertRefundRecordItem(orderRefundDto,orderNodeBuilder,refundRecord); } //鍥為��鐨勪紭鎯犲嵎澶勭悊 if(orderRefundDto.getCouponList() != null && orderRefundDto.getCouponList().size()>0){ @@ -1117,23 +1121,22 @@ public List<RefundRecordMethod> handleRefundPayMethod(OrderRefundDto orderRefundDto,StringBuilder orderNodeBuilder,OrdersTotal ordersTotal,RefundRecord refundRecord){ orderNodeBuilder.append("-璁板綍閫�娆炬柟寮忥細"); - //鑾峰彇璁㈠崟鍙��娆炬柟寮� + //鑾峰彇璁㈠崟鍙��娆炬柟寮忥紝灏辨槸鏀粯鏂瑰紡鎬昏〃鐨勪俊鎭紝宸茬粡鏀粯缂栧彿姹傚拰 List<PayMethodVo> payMethodVoList = refundMapper.selectConsumePayList(ordersTotal.getId()); - Map<String, PayMethodVo> payMethodVoMap = payMethodVoList.stream().collect( - Collectors.toMap(PayMethodVo::getNumberNo,(a) -> a)); + //鐢╩ap瑁呰浇锛屽悗闈㈡牴鎹敮浠樼紪鍙风洿鎺ヨ幏鍙栦究鍙� + Map<String, PayMethodVo> payMethodVoMap = payMethodVoList.stream().collect(Collectors.toMap(PayMethodVo::getNumberNo,(a) -> a)); List<RefundRecordMethod> refundRecordMethodList = new ArrayList<>(); PayMethodVo payMethodVo; - RefundRecordMethod refundRecordMethod=null; - RefundMethodTransformation refundMethodTransformation=null; + RefundRecordMethod refundRecordMethod; for (OrderPayMethodDto orderPayMethodDto : orderRefundDto.getRefundPayMethod()) { payMethodVo = payMethodVoMap.get(orderPayMethodDto.getPayMethodNo()); //鍒ゆ柇鏄笉鏄湪鏀粯鏂瑰紡閲岄潰鐨� if (payMethodVo == null){ - throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鍙��鏀粯鏂瑰紡鏈壘鍒板搴旂殑鏀粯:"+orderPayMethodDto.getPayMethodName()+"["+orderPayMethodDto.getPayMethodNo()+"]"); + throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鍙��鏀粯鏂瑰紡鏈壘鍒�:"+orderPayMethodDto.getPayMethodName()+"["+orderPayMethodDto.getPayMethodNo()+"]"); } //鍒ゆ柇鏀粯鏂瑰紡 PaymentMethod payMethod = paymentMethodService.selectNumberNoUncheckUp(orderPayMethodDto.getPayMethodNo()); @@ -1153,32 +1156,26 @@ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"閫�娆鹃噾棰濋敊璇�:"+orderPayMethodDto.getPayMethodName()+"["+orderPayMethodDto.getPayMethodNo()+"]"); } - //鏂板杞崲琛ㄨ褰� - refundMethodTransformation = new RefundMethodTransformation(); - BeanUtils.copyProperties(orderPayMethodDto, refundMethodTransformation); - refundMethodTransformation.setRefundTotal(orderPayMethodDto.getMoney()); - refundMethodTransformation.setRefundRecordId(refundRecord.getId()); - refundMethodTransformationMapper.insert(refundMethodTransformation); - - //閫�鍥炲鎴风殑鏀粯鏂瑰紡 + ////閫�娆炬柟寮忔暟鎹~鍏� refundRecordMethod = new RefundRecordMethod(); refundRecordMethod.setType(refundRecord.getSourceType()); + refundRecordMethod.setActualTotal(orderPayMethodDto.getMoney()); + //鏀粯鏂瑰紡淇℃伅 refundRecordMethod.setNumberNo(payMethod.getNumberNo()); refundRecordMethod.setPaymentMethodId(payMethod.getId()); refundRecordMethod.setName(payMethod.getName()); refundRecordMethod.setIsMoneyPay(payMethodVo.getIsMoneyPay()); refundRecordMethod.setIsExecute(payMethodVo.getIsExecute()); - + //閫�娆炬柟寮忎俊鎭� refundRecordMethod.setRefundNumberNo(refundMethod.getNumberNo()); refundRecordMethod.setRefundName(refundMethod.getName()); refundRecordMethod.setRefundMethodId(refundMethod.getId()); - refundRecordMethod.setActualTotal(orderPayMethodDto.getMoney()); + refundRecordMethod.setRefundMethodId(refundMethod.getId()); refundRecordMethod.setIsMoneyPayRefund(refundMethod.getIsMoneyPay()); refundRecordMethod.setIsExecuteRefund(refundMethod.getIsExecute()); - refundRecordMethod.setRefundMethodTransId(refundMethodTransformation.getId()); - refundRecordMethod.setRemarks(orderPayMethodDto.getRemarks()); + //refundRecordMethod.setRemarks(orderPayMethodDto.getRemarks()); refundRecordMethodService.insert(refundRecordMethod); refundRecordMethodList.add(refundRecordMethod); @@ -1189,7 +1186,7 @@ /** * 閫�娆捐褰曞瓙椤� */ - public void insertRefundRecordItem(OrderRefundDto orderRefundDto,StringBuilder orderNodeBuilder,OrdersTotal ordersTotal,RefundRecord refundRecord,List<RefundRecordMethod> refundRecordMethodList){ + public void insertRefundRecordItem(OrderRefundDto orderRefundDto,StringBuilder orderNodeBuilder,RefundRecord refundRecord){ orderNodeBuilder.append("-璁板綍閫�娆捐鎯�"); @@ -1255,9 +1252,8 @@ refundRecordItem.setRefundMoney(refundTotal); } refundRecordItemService.insert(refundRecordItem); - //璁$畻鍓╀綑瑕佸垎閰嶇殑閫�娆炬�婚噾棰� + //鍑忓幓宸茬粡鍒嗛厤鐨勯��娆鹃噾棰� refundTotal = refundTotal.subtract(refundRecordItem.getRefundMoney()).setScale(2,RoundingMode.HALF_UP); - //瀛愬崟瀛愰」澶勭悊 insertRefundRecordItemTwo(refundRecordItem,refundRecord,orderItemRefundDto.getOrderItemSourceRefundDtos()); } @@ -1336,7 +1332,6 @@ refundRecordItemSourceMapper.insert(refundRecordItemSource); //鍑忓幓宸茬粡鍒嗛厤閫�娆鹃噾棰� refundTotal = refundTotal.subtract(refundRecordItemSource.getRefundMoney()).setScale(2,RoundingMode.HALF_UP); - } if(refundTotal.compareTo(BigDecimal.ZERO) > 0){ @@ -1349,12 +1344,12 @@ * 璁板綍閫�娆捐褰曚紭鎯犲嵎 */ public void handleOrderCouponRefunDto(List<OrderCouponRefunDto> couponList,StringBuilder orderNodeBuilder,OrdersTotal ordersTotal,RefundRecord refundRecord){ - CouponOrderDiscountLog couponOrderDiscountLog=null; - RefundRecordCoupon refundRecordCoupon=null; + CouponOrderDiscountLog couponOrderDiscountLog; + RefundRecordCoupon refundRecordCoupon; orderNodeBuilder.append("-澶勭悊閫�娆句紭鎯犲嵎"); for (OrderCouponRefunDto orderCouponRefunDto : couponList) { couponOrderDiscountLog=couponOrderDiscountLogMapper.selectOneByKey(orderCouponRefunDto.getOrderCouponId()); - if(couponOrderDiscountLog==null){ + if( couponOrderDiscountLog == null){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"璁㈠崟浼樻儬鍗锋爣璇嗕笉姝g‘"); } refundRecordCoupon=new RefundRecordCoupon(ordersTotal.getId(),refundRecord.getId(),ordersTotal.getUserId(),1,1,couponOrderDiscountLog.getId(), @@ -1376,7 +1371,7 @@ orderNodeBuilder.append("-澶勭悊閫�娆炬敮浠樻柟寮忥紝鐢ㄦ埛寰呮墽琛岄」鐩�"); //澶勭悊涓讳笟鍔� - ordersTotal= PartialRefundUtil.refundProcess(commonService, operationId, operatorName, refundRecord.getId()); + ordersTotal = PartialRefundUtil.refundProcess(commonService, operationId, operatorName, refundRecord.getId()); //杩斿洖鏁版嵁 Map<String,Object> data=new HashMap<>(); diff --git a/phi_platform_user/src/main/java/com/hx/phip/service/refund/impl/RefundRecordServiceImpl.java b/phi_platform_user/src/main/java/com/hx/phip/service/refund/impl/RefundRecordServiceImpl.java index 0a7bea5..9dc94e3 100644 --- a/phi_platform_user/src/main/java/com/hx/phip/service/refund/impl/RefundRecordServiceImpl.java +++ b/phi_platform_user/src/main/java/com/hx/phip/service/refund/impl/RefundRecordServiceImpl.java @@ -489,7 +489,6 @@ refundRecordMethod.setIsPay(BaseEntity.NO); refundRecordMethod.setType(ConsumePayConstants.STATUS_WITHDRAW); refundRecordMethod.setRefundRecordId(refundRecord.getId()); - refundRecordMethod.setRefundMethodTransId(refundMethodTransformation.getId()); refundRecordMethod.setPayee(refundFundsDto.getPayee()); refundRecordMethod.setOpenBank(refundFundsDto.getOpenBank()); refundRecordMethod.setOpenBranch(refundFundsDto.getOpenBranch()); diff --git a/phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java b/phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java index cbca1c2..36b52b0 100644 --- a/phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java +++ b/phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java @@ -71,7 +71,7 @@ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鎿嶄綔澶辫触锛岄��娆惧崟鐘舵�佸凡鏀瑰彉锛�"); } - //鍥炲幓璁㈠崟淇℃伅 + //鑾峰彇璁㈠崟淇℃伅 OrdersTotal ordersTotal = commonService.selectOneByKeyBlob(OrdersTotalMapper.class,refundRecord.getOrderId()); if(ordersTotal == null ){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鏈壘鍒拌鍗曚俊鎭�!"); @@ -259,22 +259,37 @@ List<RefundRecordMethod> refundRecordMethodList = refundCarryVo.getRefundRecordMethodList(); + //瑁呰浇鍒嗛厤濂界殑鏀粯鏂瑰紡璁板綍鐨勯噾棰濇暟鎹� List<RefundRecordConsumePay> refundConsumePayList = new ArrayList<>(); RefundRecordConsumePay refundRecordConsumePay; - //寮曠敤瀵硅薄 - List<ConsumePay> consumePayList; + ///////鑾峰彇璁㈠崟鏀粯鏂瑰紡璁板綍 + map.put("orderId",refundRecord.getOrderId()); + sqlSentence.sqlSentence("SELECT *,ROUND(actualTotal-refundTotal,2) AS pTotal FROM consume_pay WHERE isDel = 0 AND orderId = #{m.orderId} ORDER BY pTotal ASC",map); + List<ConsumePay> consumePayList = commonService.selectList(ConsumePayMapper.class,sqlSentence); + //鏍规嵁鏀粯缂栧彿杩涜鍖哄垎锛宬ey鍊硷細鏀粯缂栧彿 + Map<String,List<ConsumePay>> consumePayMap = new HashMap<>(); + List<ConsumePay> consumePays; + for(ConsumePay consumePay:consumePayList){ + consumePays = consumePayMap.computeIfAbsent(consumePay.getNumberNo(),k->new ArrayList<>()); + consumePays.add(consumePay); + } + + ////寮曠敤瀵硅薄 + //閫�娆炬柟寮忕殑閲戦 BigDecimal mothedTotal; + //鍒嗛厤鏀粯鏂瑰紡閲戦 BigDecimal mothedCutTotal; for(RefundRecordMethod refundRecordMethod:refundRecordMethodList){ + if(refundRecordMethod.getActualTotal().compareTo(BigDecimal.ZERO) < 1){ + continue; + } mothedTotal = refundRecordMethod.getActualTotal(); - - //鑾峰彇鏀粯鏂瑰紡 - map.put("orderId",refundRecord.getOrderId()); - map.put("numberNo",refundRecordMethod.getNumberNo()); - sqlSentence.sqlSentence("SELECT *,ROUND(actualTotal-refundTotal,2) AS pTotal FROM consume_pay WHERE isDel = 0 AND orderId = #{m.orderId} AND numberNo = #{m.numberNo} ORDER BY pTotal ASC",map); - consumePayList = commonService.selectList(ConsumePayMapper.class,sqlSentence); - for(ConsumePay consumePay:consumePayList){ + consumePays = consumePayMap.get(refundRecordMethod.getNumberNo()); + if(consumePays == null){ + throw new TipsException("娌℃湁鎵惧埌璇ユ敮浠樿褰曪細"+refundRecordMethod.getName()+"["+refundRecordMethod.getNumberNo()+"]"); + } + for(ConsumePay consumePay:consumePays){ if(consumePay.getpTotal().compareTo(BigDecimal.ZERO) < 1){ continue; } @@ -321,7 +336,7 @@ public static RefundCarryVo refundRecordMotnedItemHandle(BigDecimal deductionTotalUser,RefundRecord refundRecord,RefundRecordItem refundRecordItem ,RefundCarryVo refundCarryVo,CommonService commonService){ - //娌℃湁閫�娆炬柟寮忥紝璺宠繃褰撳墠澶勭悊 + //娌℃湁閫�娆炬柟寮忥紝璺宠繃褰撳墠澶勭悊锛屽洜涓鸿繖閲屾槸澶勭悊閫�娆炬柟寮忛噾棰濈殑锛屽鏋滄病鏈夐��娆鹃噾棰濓紝閭d箞鍙互璺宠繃璇ョ幆鑺� if(refundCarryVo.getRefundRecordMethodList().size() == 0){ return refundCarryVo; } @@ -341,7 +356,7 @@ SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> values = new HashMap<>(); - //鏇存柊鐜伴噾鍜屽垝鎵i噾棰濅繚瀛� + //鏇存柊閫�娆惧瓙鍗曠殑淇℃伅锛屾洿鏂扮幇閲戝拰鍒掓墸閲戦淇濆瓨 values.put("deductionTotal",refundCarryVo.getDeductionTotal()); values.put("deductionTotalUser",deductionTotalUser==null?BigDecimal.ZERO:deductionTotalUser); values.put("cashTotal",refundCarryVo.getCashTotal()); @@ -419,23 +434,25 @@ //杩涜鍗囧簭鎺掑簭锛岄伩鍏嶅悗闈笉澶熷垎閰� refundRecordMethodList = refundRecordMethodList.stream().sorted(Comparator.comparing(RefundRecordMethod::getpTotal)).collect(Collectors.toList()); - //鑾峰彇瀛愬崟鐨勬敮浠樻柟寮忥紝瀛愬崟鏀粯璁板綍锛岃绠楀彲閫�娆鹃噾棰� + //鑾峰彇瀛愬崟鐨勬敮浠樻柟寮忚褰曪紝璁$畻鍙��娆鹃噾棰� List<ConsumePayItem> consumePayItemList; if(OrderSourceConstans.TYPE_PROJECT.equals(orderItemType)){ + //涓�绾ц鍗� consumePayItemList = getOrderItemOneConsumePay(orderItemId,commonService); }else{ + //浜岀骇璁㈠崟 consumePayItemList = getOrderItemTwoConsumePay(orderItemId,commonService); } - ////瀛樺偍鏀粯鏂瑰紡缂栧彿鐨勫彲閫�娆鹃噾棰濓紝鏍规嵁鏀粯缂栧彿姹傚拰锛屽悗闈㈢殑鍒ゆ柇浼氱敤鍒帮紝key鍊硷細鏀粯缂栧彿锛寁alue锛氬彲閫�閲戦 + ////瀛樺偍鏀粯鏂瑰紡缂栧彿鐨勫彲閫�娆鹃噾棰濓紝鏍规嵁鏀粯缂栧彿姹傚拰锛屽悗闈㈢殑涓氬姟鍒ゆ柇浼氱敤鍒帮紝key鍊硷細鏀粯缂栧彿锛寁alue锛氬彲閫�閲戦 Map<String,BigDecimal> noMap = new HashMap<>(); BigDecimal surplusTotal; - ////瀛樺偍鏀粯鏂瑰紡缂栧彿鐨勬敮浠樻柟寮忚褰曪紝鏍规嵁鏀粯缂栧彿鏁村悎锛屽悗闈㈢殑鍒ゆ柇浼氱敤鍒帮紝key鍊硷細鏀粯缂栧彿锛寁alue锛氭敮浠樿褰曢泦鍚� + ////瀛樺偍鏀粯鏂瑰紡缂栧彿鐨勬敮浠樻柟寮忚褰曪紝鏍规嵁鏀粯缂栧彿鏁村悎锛屽悗闈㈢殑涓氬姟浼氱敤鍒帮紝key鍊硷細鏀粯缂栧彿锛寁alue锛氭敮浠樿褰曢泦鍚� Map<String,List<ConsumePayItem>> noPayItemMap = new HashMap<>(); List<ConsumePayItem> noPayItemList; ////////濉厖鏀粯鏂瑰紡璁板綍鐨勯��娆鹃噾棰濓紝璁$畻鍓╀綑鍙��閲戦锛屾敮浠樻柟寮忚褰曠殑閫�娆鹃噾棰濋渶瑕佸幓鏌ヨ璁$畻鑾峰彇 - //鑾峰彇宸茬粡閫�娆剧殑閫�娆炬柟寮忛噾棰濓紝鏍规嵁鏀粯鏂瑰紡璁板綍鐨勬爣璇嗘眰鍜岃繑鍥� + //鑾峰彇璁㈠崟瀛愬崟宸茬粡閫�娆剧殑閫�娆炬柟寮忛噾棰濓紝鏍规嵁鏀粯鏂瑰紡璁板綍鐨勬爣璇嗘眰鍜岃繑鍥� List<RefundRecordConsumePay> refundRecordConsumePayList = getRefundRecordConsumePay(orderItemId,null,false,true,commonService); //杞寲鎴恗ap锛屽彲浠ユ牴鎹敮浠樻柟寮忚褰曠殑鏍囪瘑鐩存帴鑾峰彇鍒版暟鎹� Map<String, RefundRecordConsumePay> refundRecordConsumePayMap = refundRecordConsumePayList.stream().collect( @@ -454,10 +471,6 @@ surplusTotal = surplusTotal.add(consumePayItem.getpTotal()).setScale(2,RoundingMode.HALF_UP); noMap.put(consumePayItem.getNumberNo(),surplusTotal); - } - //杩涜鍗囧簭鎺掑簭锛岄伩鍏嶅悗闈笉澶熷垎閰� - consumePayItemList = consumePayItemList.stream().sorted(Comparator.comparing(ConsumePayItem::getpTotal)).collect(Collectors.toList()); - for(ConsumePayItem consumePayItem:consumePayItemList){ //鏀粯缂栫爜闆嗗悎鏁村悎 noPayItemList = noPayItemMap.computeIfAbsent(consumePayItem.getNumberNo(),k->new ArrayList<>()); noPayItemList.add(consumePayItem); @@ -533,7 +546,10 @@ noMap.put(refundRecordItemMethod.getNumberNo(),surplusTotal); ///////鐢熸垚鍏宠仈鏀粯鏂瑰紡璁板綍鍜岄��娆炬柟寮忓叧鑱� + //鏍规嵁鏀粯缂栧彿鑾峰彇鏀粯鏂瑰紡璁板綍 noPayItemList = noPayItemMap.computeIfAbsent(refundRecordItemMethod.getNumberNo(),k->new ArrayList<>()); + //杩涜鍗囧簭鎺掑簭锛岄伩鍏嶅悗闈笉澶熷垎閰� + noPayItemList = noPayItemList.stream().sorted(Comparator.comparing(ConsumePayItem::getpTotal)).collect(Collectors.toList()); mothedTotal = refundRecordItemMethod.getActualTotal(); for(ConsumePayItem consumePayItem:noPayItemList){ if(consumePayItem.getpTotal().compareTo(BigDecimal.ZERO) < 1){ @@ -704,7 +720,7 @@ refundCarryVo.setRefundConsumePayList(new ArrayList<>()); refundCarryVo.setDeductionTotal(BigDecimal.ZERO); refundCarryVo.setCashTotal(BigDecimal.ZERO); - + //鍟嗗搧绫诲瀷鍒ゆ柇 switch (refundRecordItem.getType()){ case OrderItemConstants.TYPE_RETAIL: refundCarryVo = handRefundRerail(refundRecord,refundRecordItem,refundCarryVo,commonService); @@ -874,7 +890,7 @@ userCard= userCardList.get(i); map.put("id",userCard.getId()); map.put("effectiveStatus", UserProjectConstants.EFF_STATUS_CANCEL); - sqlSentence.sqlSentence(" effectiveStatus=#{m.effectiveStatus} where id = #{m.id}",map); + sqlSentence.sqlSentence(" effectiveStatus=#{m.effectiveStatus} WHERE id = #{m.id}",map); commonService.updateWhere(UserCardMapper.class,sqlSentence); //鐢熸垚閫�娆惧叧鑱� @@ -1018,7 +1034,7 @@ //鍥犱负鏈変簺鏄畻娆℃暟鎶垫墸鐨勶紝鎵�浠ヨ绠� if(CardEquity.EQUITY_TYPE_TIME_CARD.equals(cardEquity.getEquityType())){ //娆″崱锛氭�绘鏁�=寮�鍗曠殑鎬绘鏁�*姣忔鍒掓墸鐨勬鏁� - returnNum= refundNum *cardItemInfo.getEveryDrawNum(); + returnNum= refundNum * cardItemInfo.getEveryDrawNum(); }else if(CardEquity.EQUITY_TYPE_N_M.equals(cardEquity.getEquityType())){ returnNum = refundNum; }else{ @@ -1052,7 +1068,6 @@ */ private static RefundCarryVo handRefundPromotion(String operationId, RefundRecord refundRecord, OrdersTotal ordersTotal , RefundRecordItem refundRecordItem,RefundCarryVo refundCarryVo,CommonService commonService) { - //鏌ョ湅璁㈠崟淇℃伅 OrderItem orderItem = commonService.selectOneByKey(OrderItemMapper.class,refundRecordItem.getOrderItemId()); @@ -1168,14 +1183,14 @@ ,RefundCarryVo refundCarryVo,CommonService commonService) { //鍒ゆ柇鎿嶄綔瀹屼簡鍘讳慨鏀瑰瓙璁㈠崟鐘舵�� - OrderItemSon orderItemSon=commonService.selectOneByKey(OrderItemSonMapper.class,refundRecordItemSource.getOrderItemSonId()); + OrderItemSon orderItemSon = commonService.selectOneByKey(OrderItemSonMapper.class,refundRecordItemSource.getOrderItemSonId()); if (orderItemSon==null){ - throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鏈壘鍒颁簩绾у瓙璁㈠崟淇℃伅"); + throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鏈壘鍒颁簩绾у瓙璁㈠崟淇℃伅[02]"); } UserProjectItem userProjectItem = getUserProject(orderItemSon.getId(),commonService); if(userProjectItem == null){ - throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鐢ㄦ埛椤圭洰鑾峰彇澶辫触锛�"); + throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鐢ㄦ埛椤圭洰鑾峰彇澶辫触[06]锛�"); } if(userProjectItem.getNotUsedNum()<refundRecordItemSource.getRefundNum()){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"閫�娆炬鏁板ぇ浜庡彲閫�娆℃暟[83]锛�"); @@ -1184,7 +1199,7 @@ //璁$畻瀛愬崟鏄惁杩樻湁鍓╀綑鐨勫彲鎵g枟绋嬫暟 int surplusNum = orderItemSon.getUsedTotal() - orderItemSon.getHasReNum(); if(refundRecordItemSource.getRefundNum() > surplusNum){ - throw new PlatTipsException(PlatformCode.ERROR_TIPS,"閫�娆炬鏁板ぇ浜庡彲閫�娆℃暟[84]锛�"); + throw new PlatTipsException(PlatformCode.ERROR_TIPS,"閫�娆炬鏁板ぇ浜庡彲閫�娆℃暟[56]锛�"); } //澶勭悊鐢ㄦ埛椤圭洰锛屽噺鍘荤敤鎴烽」鐩暟閲� @@ -1267,13 +1282,13 @@ SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> values = new HashMap<>(); - values.put("orderItemId", orderItem.getId()); + values.put("id", orderItem.getId()); values.put("refundStatus", refundStatus); values.put("refundTotal",refundTotal); values.put("refundNum",refundNum); values.put("oldHasReNum",orderItem.getHasReNum()); sqlSentence.sqlUpdate(" refundStatus=#{m.refundStatus},reTotal=reTotal+#{m.refundTotal},hasReNum=hasReNum+#{m.refundNum}" + - " where isDel=0 AND id=#{m.orderItemId} AND hasReNum = #{m.oldHasReNum}",values); + " WHERE isDel = 0 AND id = #{m.id} AND hasReNum = #{m.oldHasReNum}",values); if(commonService.updateWhere(OrderItemMapper.class,sqlSentence) != 1){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"褰撳墠璁㈠崟淇℃伅宸插彂鐢熷彉鍖栵紝璇烽噸璇昜012]锛�"); } @@ -1296,7 +1311,7 @@ values.put("refundTotal",refundTotal); values.put("refundNum",refundNum); values.put("oldHasReNum",orderItemSon.getHasReNum()); - sqlSentence.sqlUpdate(" refundStatus=#{m.refundStatus},reTotal=reTotal+#{m.refundTotal},hasReNum=hasReNum+#{m.refundNum}" + + sqlSentence.sqlUpdate(" refundStatus = #{m.refundStatus},reTotal=reTotal+#{m.refundTotal},hasReNum=hasReNum+#{m.refundNum}" + " where isDel=0 AND id = #{m.id} AND hasReNum = #{m.oldHasReNum}",values); if(commonService.updateWhere(OrderItemSonMapper.class,sqlSentence) != 1){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"褰撳墠璁㈠崟淇℃伅宸插彂鐢熷彉鍖栵紝璇烽噸璇昜012]锛�"); -- Gitblit v1.8.0