From b3fdeac8c313971112a6245513f7215b39da537d Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期一, 15 五月 2023 10:07:43 +0800 Subject: [PATCH] 作废退款-测 --- phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java | 68 ++++++++++++++++++++-- phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java | 91 ++++++++++++++++++++++------- 2 files changed, 128 insertions(+), 31 deletions(-) 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 df2733e..e5177d3 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 @@ -925,10 +925,10 @@ //鍒ゆ柇鏄惁鏄厖鍊艰鍗曪紝鏄殑璇濆厛鍐荤粨鍌ㄥ�奸噾锛屽氨鏄墸鎺夛紝瀹℃壒閫氳繃灏变笉澶勭悊鍌ㄥ�奸噾浜嗭紝涓嶉�氳繃杩樺師璧勯噾 if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType())){ - OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_EXECUTE,"鐢宠閫�娆�",commonService); + OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_EXECUTE,"鐢宠閫�娆�",orderNodeBuilder,commonService); } //娲诲姩澶勭悊 - OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_EXECUTE,"鐢宠閫�娆�",commonService); + OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_EXECUTE,"鐢宠閫�娆�",orderNodeBuilder,commonService); return refundRecord; } @@ -2011,10 +2011,10 @@ if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType())){ //鍒ゆ柇閲戦涓嶇瓑浜�0锛屾墠鎵ц鎿嶄綔锛屼笉鐒舵搷浣滀綑棰濈殑鏃跺�欎細鐖嗘搷浣滄暟閲忔垨閲戦涓嶈兘涓�0 //鍏呭�奸噾棰� - OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"鎷掔粷瀹℃壒",commonService); + OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"鎷掔粷瀹℃壒",orderNodeBuilder,commonService); } //娲诲姩瑙勫垯閫�娆惧鐞� - OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"鎷掔粷瀹℃壒",commonService); + OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"鎷掔粷瀹℃壒",orderNodeBuilder,commonService); ordersNodeLog.setCommonType(OrdersNodeLog.TYPE_COMMON_ORDER_REFUND); ordersNodeLog.setContent(orderNodeBuilder.toString()); @@ -2420,21 +2420,35 @@ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鎿嶄綔澶辫触锛岄��娆惧崟鐘舵�佸凡鍙戠敓鍙樺寲锛�"); } + //璁㈠崟绯荤粺鏃ュ織 + StringBuilder orderNodeBuilder = new StringBuilder(); + orderNodeBuilder.append("寮�濮嬩綔搴熼��娆�"); + //鍒ゆ柇璁㈠崟绫诲瀷 if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType())){ //鍏呭�艰鍗� - OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"浣滃簾閫�娆�",commonService); + OrderRefundCancelTool.rechargeHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"浣滃簾閫�娆�",orderNodeBuilder,commonService); }else{ //澶勭悊瀛愬崟 OrderRefundCancelTool.refundRecordItemHandle(ordersTotal,refundRecord,commonService); } //澶勭悊璁㈠崟娲诲姩 - OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"浣滃簾閫�娆�",commonService); + OrderRefundCancelTool.activityRuleHandle(ordersTotal,refundRecord,OrderRefundCancelTool.OPT_TYPE_CANCEL,"浣滃簾閫�娆�",orderNodeBuilder,commonService); //澶勭悊璁㈠崟浼樻儬鍒� - OrderRefundCancelTool.handCoupon(ordersTotal,refundRecord,commonService); + OrderRefundCancelTool.handCoupon(ordersTotal,refundRecord,orderNodeBuilder,commonService); //澶勭悊鎬婚��娆炬柟寮� - OrderRefundCancelTool.refundRecordMotnedHandle(refundRecord,ordersTotal,commonService); + List<RefundRecordMethod> refundRecordMethodList= OrderRefundCancelTool.refundRecordMotnedHandle(refundRecord,ordersTotal,orderNodeBuilder,commonService); + + //鎿嶄綔鐨勭幇閲戦噾棰� + BigDecimal cashTotal = BigDecimal.ZERO; + for(RefundRecordMethod refundRecordMethod:refundRecordMethodList){ + if(refundRecordMethod.getIsMoneyPay().equals(RefundRecordMethod.YES)){ + cashTotal = cashTotal.add(refundRecordMethod.getActualTotal()); + } + } + + //鎶ラ敊璁㈠崟绯荤粺鏃ュ織 //****鏇存敼鎬昏鍗曢��娆剧姸鎬� values.clear(); @@ -2493,6 +2507,44 @@ throw new TipsException("浣滃簾澶辫触锛岃鍗曠姸鎬佸凡鍙戠敓鏀瑰彉锛�"); } + //棰濆鐨勬搷浣滐紝鍗囬檷绾э紝鏀跺叆纭琛� + additionalOperate(ordersTotal,refundRecord,cashTotal,orderNodeBuilder,customParameter,commonService); + + //璁板綍鏃ュ織(澶勭悊鍒板叿浣撹妭鐐�(鎴愬姛鍜屽け璐�)) + OrdersNodeLog ordersNodeLog = new OrdersNodeLog(); + orderNodeBuilder.append("-浣滃簾閫�娆惧崟缁撴潫"); + ordersNodeLog.setCommonType(OrdersNodeLog.TYPE_COMMON_ORDER_REFUND_CANCEL); + ordersNodeLog.setContent(orderNodeBuilder.toString()); + ordersNodeLog.setOrderId(ordersTotal.getId()); + commonService.insert(OrdersNodeLogMapper.class,ordersNodeLog); + + } + + /**棰濆鎿嶄綔锛屼笉褰卞搷涓绘祦绋�*/ + public static void additionalOperate(OrdersTotal ordersTotal,RefundRecord refundRecord,BigDecimal total,StringBuilder orderNodeBuilder,CustomParameter customParameter,CommonService commonService){ + if(BigDecimal.ZERO.compareTo(total) < 0){ + try { + orderNodeBuilder.append("-寮�濮嬪鐞嗙敤鎴峰崌闄嶇骇锛岄噾棰�:").append(total); + UserLevelUtil.refund(ordersTotal.getUserId(),ordersTotal.getId(),total,ordersTotal.getAppIdCode()); + orderNodeBuilder.append("-澶勭悊鐢ㄦ埛鍗囬檷绾ф垚鍔�"); + }catch (Exception e){ + String snapshot="澶勭悊鐢ㄦ埛鍗囬檷绾уけ璐�"; + orderNodeBuilder.append("-澶勭悊鐢ㄦ埛鍗囬檷绾уけ璐�,寮傚父鍘熷洜:").append(e.getMessage()); + logger.error("澶勭悊鐢ㄦ埛鍗囬檷绾уけ璐ワ細" + e.getMessage()); + //鍙戦�佷紒涓氬井淇¢�氱煡缁欏伐浣滀汉鍛� + SendNoticeUtil.failOrderSendNotice(ordersTotal,e.getMessage(),snapshot,commonService,customParameter); + } + } + try{ + orderNodeBuilder.append("-寮�濮嬭褰曟敹鍏ョ‘璁よ〃"); + PerformanceInfoTool.refundCancelPerformanceInfo(commonService,refundRecord); + orderNodeBuilder.append("-璁板綍鏀跺叆纭琛ㄦ垚鍔�"); + }catch (Exception e){ + orderNodeBuilder.append("-璁板綍鏀跺叆纭琛ㄥけ璐�"); + logger.info("璁板綍鏀跺叆纭琛�,寮傚父:{}",e.getMessage(),e); + // 娣诲姞閿欒鏃ュ織 + PerformanceInfoTool.addErrorLog(commonService, refundRecord.getId(), PerformanceInfo.ASSOCIATION_TYPE_GOODS_REFUND, e.getMessage()); + } } } diff --git a/phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java b/phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java index b08daef..91362f2 100644 --- a/phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java +++ b/phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java @@ -54,7 +54,7 @@ /**澶勭悊鎬婚��娆炬柟寮忔暟鎹�*/ - public static void refundRecordMotnedHandle(RefundRecord refundRecord,OrdersTotal ordersTotal,CommonService commonService){ + public static List<RefundRecordMethod> refundRecordMotnedHandle(RefundRecord refundRecord,OrdersTotal ordersTotal,StringBuilder orderNodeBuilder,CommonService commonService){ SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> values = new HashMap<>(); @@ -90,7 +90,7 @@ } - //澶勭悊鍥為��鍒拌处 + //澶勭悊鎵e噺璐﹀彿璧勯噾 for(RefundRecordMethod refundRecordMethod:refundRecordMethodList){ if(PayMethodTypeConstants.PAY_STORED.equals(refundRecordMethod.getRefundNumberNo())){ //鍌ㄥ�奸噾棰濄�� @@ -99,6 +99,9 @@ UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getInvalidRemarks(),"浣滃簾閫�娆�:鏀粯鏂瑰紡鍌ㄥ�奸噾棰濇墸鍑�",refundRecord.getInvalidId(),refundRecord.getOrderId(),refundRecord.getInvalidAppCode(),refundRecord.getId(),refundRecordMethod.getRealRefundTotal().negate(), UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND, OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.NO); OrderLog orderLog = RefundToolUtil.setOrderLog(refundRecord, refundRecord.getInvalidId(), refundRecord.getInvalidName(), refundRecordMethod.getName()+"浣滃簾閫�娆鹃噾棰�:"+refundRecordMethod.getRealRefundTotal(), 1, OrderLogConstants.LOG_TYPE_REFUND_UNDO); commonService.insert(OrderLogMapper.class,orderLog); + if(orderNodeBuilder != null){ + orderNodeBuilder.append("-[浣滃簾閫�娆綸鎵e噺閫�娆鹃噾棰濓紙鍌ㄥ�奸噾锛夛細").append(refundRecordMethod.getRealRefundTotal()); + } } }else if(PayMethodTypeConstants.PAY_ADD_FUND.equals(refundRecordMethod.getRefundNumberNo())){ //澧炲�奸噾 @@ -107,6 +110,9 @@ UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getRemarks(),"浣滃簾閫�娆�:鏀粯鏂瑰紡澧炲�奸噾閫�鍥�",refundRecord.getInvalidId(),refundRecord.getOrderId(),refundRecord.getInvalidAppCode(),refundRecord.getId(),refundRecordMethod.getRealRefundTotal().negate(), UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND, OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.NO); OrderLog orderLog = RefundToolUtil.setOrderLog(refundRecord,refundRecord.getInvalidId(),refundRecord.getInvalidName(),refundRecordMethod.getName(),1, OrderLogConstants.LOG_TYPE_REFUND_UNDO); commonService.insert(OrderLogMapper.class,orderLog); + if(orderNodeBuilder != null){ + orderNodeBuilder.append("-[浣滃簾閫�娆綸鎵e噺閫�娆鹃噾棰濓紙澧炲�奸噾锛夛細").append(refundRecordMethod.getRealRefundTotal()); + } } }else if(PayMethodTypeConstants.PAY_INTEGRAL.equals(refundRecordMethod.getRefundNumberNo())){ //绉垎 @@ -115,6 +121,9 @@ UserMoneyUtil.setNewUserMoneyUnclaimed(ordersTotal.getPayUserId()==null?ordersTotal.getUserId():ordersTotal.getPayUserId(),refundRecord.getRemarks(),"浣滃簾閫�娆�:鏀粯鏂瑰紡绉垎閫�鍥�",refundRecord.getInvalidId(),refundRecord.getOrderId(),refundRecord.getInvalidAppCode(),refundRecord.getId(),refundRecordMethod.getRealRefundTotal().negate(), UserMoneyUnclaimed.FUND_TYPE_INTEGRAL,OperationReasonConstants.OP_REASON_RECHARGE_REFUND,commonService,UserMoneyUnclaimed.NO); OrderLog orderLog = RefundToolUtil.setOrderLog(refundRecord,refundRecord.getInvalidId(),refundRecord.getInvalidName(),refundRecordMethod.getName()+"浣滃簾閫�娆鹃噾棰�:"+refundRecordMethod.getRealRefundTotal(),1, OrderLogConstants.LOG_TYPE_REFUND_UNDO); commonService.insert(OrderLogMapper.class,orderLog); + if(orderNodeBuilder != null){ + orderNodeBuilder.append("-[浣滃簾閫�娆綸鎵e噺閫�娆鹃噾棰濓紙绉垎锛夛細").append(refundRecordMethod.getRealRefundTotal()); + } } }else { //鐜伴噾鏀粯 @@ -126,6 +135,7 @@ commonService.insert(OrderLogMapper.class,orderLog); } } + return refundRecordMethodList; } /**鍏呭�煎崟鐗归渶澶勭悊 @@ -135,7 +145,7 @@ * @param optName 鎿嶄綔鍚嶇О锛屽锛氱敵璇烽��娆俱�佷綔搴熼��娆俱�佸鏍告嫆缁� * @param commonService 鏄犲皠 */ - public static void rechargeHandle(OrdersTotal ordersTotal, RefundRecord refundRecord,int optType,String optName, CommonService commonService){ + public static void rechargeHandle(OrdersTotal ordersTotal, RefundRecord refundRecord,int optType,String optName,StringBuilder orderNodeBuilder, CommonService commonService){ if(!OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType())){ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鎿嶄綔澶辫触锛屼笉鏄厖鍊煎崟锛�"); @@ -148,12 +158,16 @@ //鍏呭�奸噾棰濇墸鍑� UserMoneyUtil.setNewUserMoneyUnclaimed(refundRecord.getUserId(),refundRecord.getInvalidRemarks(),"閫�娆惧崟锛�"+refundRecord.getCode()+"锛�"+optName+"锛屾墸鍑忓厖鍊艰祫閲�:"+ordersTotal.getTotal(),refundRecord.getOperatorId(),refundRecord.getOrderId(),refundRecord.getInvalidAppCode(),refundRecord.getId(),ordersTotal.getTotal().negate(), UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND, OperationReasonConstants.OP_REASON_REFUND_CANCEL,commonService,UserMoneyUnclaimed.NO); orderLog = RefundToolUtil.setOrderLog(refundRecord, refundRecord.getOperatorId(), refundRecord.getOperatorName(), "鍏呭�煎崟锛�"+ordersTotal.getOrderNo()+"锛�"+optName+"锛岄鎵i櫎閲戦锛�"+ordersTotal.getTotal(), 0, OrderLogConstants.LOG_TYPE_REFUND); + }else if(optType == OPT_TYPE_CANCEL){ //鍏呭�奸噾棰濆洖閫� UserMoneyUtil.setNewUserMoneyUnclaimed(refundRecord.getUserId(),refundRecord.getInvalidRemarks(),"閫�娆惧崟锛�"+refundRecord.getCode()+"锛�"+optName+"锛岄��鍥炲厖鍊艰祫閲�:"+ordersTotal.getTotal(),refundRecord.getInvalidId(),refundRecord.getOrderId(),refundRecord.getInvalidAppCode(),refundRecord.getId(),ordersTotal.getTotal(), UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND, OperationReasonConstants.OP_REASON_REFUND_CANCEL,commonService,UserMoneyUnclaimed.NO); orderLog = RefundToolUtil.setOrderLog(refundRecord, refundRecord.getOperatorId(), refundRecord.getOperatorName(), "鍏呭�煎崟锛�"+ordersTotal.getOrderNo()+"锛�"+optName+"锛岄��鍥為鎵i櫎閲戦锛�"+ordersTotal.getTotal(), 0, OrderLogConstants.LOG_TYPE_REFUND); }else{ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鎿嶄綔绫诲瀷閿欒[1]["+optType+"]锛�"); + } + if(orderNodeBuilder !=null){ + orderNodeBuilder.append("-[").append(optName).append("]鍏呭�煎崟鍏呭�奸噾鎿嶄綔锛堝偍鍊奸噾锛夛細").append(ordersTotal.getTotal()); } orderLog.setOrderId(ordersTotal.getId()); commonService.insert(OrderLogMapper.class,orderLog); @@ -166,7 +180,7 @@ * @param optName 鎿嶄綔鍚嶇О锛屽锛氱敵璇烽��娆俱�佷綔搴熼��娆俱�佸鏍告嫆缁� * @param commonService 鏄犲皠 */ - public static void activityRuleHandle(OrdersTotal ordersTotal, RefundRecord refundRecord,int optType,String optName,CommonService commonService){ + public static void activityRuleHandle(OrdersTotal ordersTotal, RefundRecord refundRecord,int optType,String optName,StringBuilder orderNodeBuilder,CommonService commonService){ //鍏堣幏鍙栨椿鍔ㄨ鍒� SqlSentence sqlSentence = new SqlSentence(); @@ -177,7 +191,7 @@ List<OrdersActivityInfo> ordersActivityInfoList = commonService.selectList(OrdersActivityInfoMapper.class,sqlSentence); if(ordersActivityInfoList.size() > 0){ //璁㈠崟娲诲姩淇℃伅澶勭悊 - activityRulePollingHandle2(ordersActivityInfoList,optType,optName,ordersTotal,refundRecord,commonService); + activityRulePollingHandle2(ordersActivityInfoList,optType,optName,ordersTotal,refundRecord,orderNodeBuilder,commonService); }else{ //娌℃湁璁㈠崟娲诲姩淇℃伅澶勭悊锛屽氨鑾峰彇淇濆瓨鍦ㄨ鍗曢噷闈㈢殑娲诲姩鏍囪瘑 values.clear(); @@ -185,7 +199,7 @@ sqlSentence.sqlSentence("SELECT * FROM orders_info WHERE isDel = 0 AND orderId = #{m.orderId}",values); OrderInfo orderInfo = commonService.selectOne(OrderInfoMapper.class,sqlSentence); if(orderInfo!=null && StringUtils.noNull(orderInfo.getActivityId())){ - activityRulePollingHandle1(orderInfo.getActivityId(),optType,optName,ordersTotal,refundRecord,commonService); + activityRulePollingHandle1(orderInfo.getActivityId(),optType,optName,ordersTotal,refundRecord,orderNodeBuilder,commonService); } } } @@ -198,7 +212,8 @@ * @param refundRecord 閫�娆惧崟 * @param commonService 鏄犲皠 */ - public static void activityRulePollingHandle1(String activityId,int optType,String optName,OrdersTotal ordersTotal,RefundRecord refundRecord,CommonService commonService){ + public static void activityRulePollingHandle1(String activityId,int optType,String optName,OrdersTotal ordersTotal,RefundRecord refundRecord + ,StringBuilder orderNodeBuilder,CommonService commonService){ SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> values = new HashMap<>(); @@ -228,6 +243,9 @@ }else{ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鎿嶄綔绫诲瀷閿欒[2]["+optType+"]锛�"); } + if(orderNodeBuilder !=null){ + orderNodeBuilder.append("-[").append(optName).append("]澶勭悊娲诲姩璧犻�侊紙绉垎锛夛細").append(activityAction.getWorth()); + } }else if(ActivityAction.TYPE_VALUEADDEDFUND.equals(activityAction.getType())){ //鍒ゆ柇閲戦涓嶇瓑浜�0锛屾墠鎵ц鎿嶄綔锛屼笉鐒舵搷浣滀綑棰濈殑鏃跺�欎細鐖嗘搷浣滄暟閲忔垨閲戦涓嶈兘涓�0 if(new BigDecimal(activityAction.getWorth()).compareTo(BigDecimal.ZERO) == 0 ){ @@ -240,13 +258,20 @@ }else{ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鎿嶄綔绫诲瀷閿欒[3]["+optType+"]锛�"); } + if(orderNodeBuilder !=null){ + orderNodeBuilder.append("-[").append(optName).append("]澶勭悊娲诲姩璧犻�侊紙澧炲�奸噾锛夛細").append(activityAction.getWorth()); + } }else if(ActivityAction.TYPE_COUPON.equals(activityAction.getType())){ values.put("oldValidState",optType==OPT_TYPE_EXECUTE? BaseEntity.YES:BaseEntity.NO); values.put("newValidState",optType==OPT_TYPE_EXECUTE?BaseEntity.NO:BaseEntity.YES); values.put("couponId",activityAction.getCrmCouponId()); values.put("commonId",ordersTotal.getId()); sqlSentence.sqlSentence(" validState=#{m.newValidState} where couponId=#{m.couponId} and commonId=#{m.commonId} and validState=#{m.oldValidState} ",values); - commonService.updateWhere(CouponNumberMapper.class,sqlSentence); + if(commonService.updateWhere(CouponNumberMapper.class,sqlSentence) != 0){ + if(orderNodeBuilder !=null){ + orderNodeBuilder.append("-[").append(optName).append("]澶勭悊娲诲姩璧犻�侊紙浼樻儬鍒革級锛�").append(activityAction.getWorthName()); + } + } } } } @@ -261,13 +286,15 @@ * @param commonService 鏄犲皠 */ public static void activityRulePollingHandle2(List<OrdersActivityInfo> ordersActivityInfoList,int optType,String optName,OrdersTotal ordersTotal - ,RefundRecord refundRecord,CommonService commonService){ + ,RefundRecord refundRecord,StringBuilder orderNodeBuilder,CommonService commonService){ if(ordersActivityInfoList == null || ordersActivityInfoList.size()==0){ return; } SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> values = new HashMap<>(); + //鏄惁鍙樻洿璁㈠崟娲诲姩鐘舵�� + boolean changeStatus; //鑾峰彇璁㈠崟娲诲姩鏉$洰 List<OrdersActivityInfoItem> ordersActivityInfoItemList; for(OrdersActivityInfo ordersActivityInfo:ordersActivityInfoList){ @@ -278,6 +305,7 @@ sqlSentence.sqlSentence("SELECT * FROM orders_activity_info_item WHERE isDel = 0 AND activityInfoId = #{m.activityInfoId} AND performStatus = #{m.performStatus} AND handleStatus = #{m.handleStatus}",values); ordersActivityInfoItemList = commonService.selectList(OrdersActivityInfoItemMapper.class,sqlSentence); for(OrdersActivityInfoItem ordersActivityInfoItem:ordersActivityInfoItemList){ + changeStatus = false; if(ActivityAction.TYPE_INTEGRAL.equals(ordersActivityInfoItem.getType())){ //鍒ゆ柇閲戦涓嶇瓑浜�0锛屾墠鎵ц鎿嶄綔锛屼笉鐒舵搷浣滀綑棰濈殑鏃跺�欎細鐖嗘搷浣滄暟閲忔垨閲戦涓嶈兘涓�0 if(new BigDecimal(ordersActivityInfoItem.getWorth()).compareTo(BigDecimal.ZERO) == 0){ @@ -290,6 +318,10 @@ }else{ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鎿嶄綔绫诲瀷閿欒[2]["+optType+"]锛�"); } + if(orderNodeBuilder !=null){ + orderNodeBuilder.append("-[").append(optName).append("]澶勭悊娲诲姩璧犻�侊紙绉垎锛夛細").append(ordersActivityInfoItem.getWorth()); + } + changeStatus = true; }else if(ActivityAction.TYPE_VALUEADDEDFUND.equals(ordersActivityInfoItem.getType())){ //鍒ゆ柇閲戦涓嶇瓑浜�0锛屾墠鎵ц鎿嶄綔锛屼笉鐒舵搷浣滀綑棰濈殑鏃跺�欎細鐖嗘搷浣滄暟閲忔垨閲戦涓嶈兘涓�0 if(new BigDecimal(ordersActivityInfoItem.getWorth()).compareTo(BigDecimal.ZERO) == 0 ){ @@ -302,6 +334,10 @@ }else{ throw new PlatTipsException(PlatformCode.ERROR_TIPS,"鎿嶄綔绫诲瀷閿欒[3]["+optType+"]锛�"); } + if(orderNodeBuilder !=null){ + orderNodeBuilder.append("-[").append(optName).append("]澶勭悊娲诲姩璧犻�侊紙澧炲�奸噾锛夛細").append(ordersActivityInfoItem.getWorth()); + } + changeStatus = true; }else if(ActivityAction.TYPE_COUPON.equals(ordersActivityInfoItem.getType())){ values.clear(); values.put("oldValidState",optType==OPT_TYPE_EXECUTE? BaseEntity.YES:BaseEntity.NO); @@ -309,18 +345,24 @@ values.put("id",ordersActivityInfoItem.getCouponNumberId()); sqlSentence.sqlSentence(" validState=#{m.newValidState} where id=#{m.id} AND validState = #{m.oldValidState} ",values); //浼樻儬鍒镐笉鍒ゆ柇鍥為�� - commonService.updateWhere(CouponNumberMapper.class,sqlSentence); + if(commonService.updateWhere(CouponNumberMapper.class,sqlSentence) != 0){ + if(orderNodeBuilder !=null){ + orderNodeBuilder.append("-[").append(optName).append("]澶勭悊娲诲姩璧犻�侊紙浼樻儬鍒革級锛�").append(ordersActivityInfoItem.getWorthName()); + } + changeStatus = true; + } } - - //鏇存柊璁㈠崟娲诲姩淇℃伅鐘舵�� - values.clear(); - values.put("handleStatus",optType==OPT_TYPE_EXECUTE?OrdersActivityInfoItem.HANDLE_STATUS_CANCEL:OrdersActivityInfoItem.HANDLE_STATUS_SUCCESS); - values.put("handleStatusOld",optType==OPT_TYPE_EXECUTE?OrdersActivityInfoItem.HANDLE_STATUS_SUCCESS:OrdersActivityInfoItem.HANDLE_STATUS_CANCEL); - values.put("performStatusOld",OrdersActivityInfoItem.STATUS_PERFORM_SEND_OUT); - values.put("id",ordersActivityInfoItem.getId()); - sqlSentence.sqlSentence("handleStatus = #{m.handleStatus} WHERE id = #{m.id} AND handleStatus = #{m.handleStatusOld} AND performStatus = #{m.performStatusOld}",values); - if(commonService.updateWhere(OrdersActivityInfoItemMapper.class,sqlSentence) != 1){ - throw new PlatTipsException(PlatformCode.ERROR_TIPS,"娲诲姩鏉$洰鐘舵�佸彉鍖栭敊璇細"); + if(changeStatus){ + //鏇存柊璁㈠崟娲诲姩淇℃伅鐘舵�� + values.clear(); + values.put("handleStatus",optType==OPT_TYPE_EXECUTE?OrdersActivityInfoItem.HANDLE_STATUS_CANCEL:OrdersActivityInfoItem.HANDLE_STATUS_SUCCESS); + values.put("handleStatusOld",optType==OPT_TYPE_EXECUTE?OrdersActivityInfoItem.HANDLE_STATUS_SUCCESS:OrdersActivityInfoItem.HANDLE_STATUS_CANCEL); + values.put("performStatusOld",OrdersActivityInfoItem.STATUS_PERFORM_SEND_OUT); + values.put("id",ordersActivityInfoItem.getId()); + sqlSentence.sqlSentence("handleStatus = #{m.handleStatus} WHERE id = #{m.id} AND handleStatus = #{m.handleStatusOld} AND performStatus = #{m.performStatusOld}",values); + if(commonService.updateWhere(OrdersActivityInfoItemMapper.class,sqlSentence) != 1){ + throw new PlatTipsException(PlatformCode.ERROR_TIPS,"娲诲姩鏉$洰鐘舵�佸彉鍖栭敊璇細"); + } } } } @@ -332,7 +374,7 @@ * @param refundRecord 閫�娆炬�绘暟鎹� * @param commonService 鏄犲皠 */ - public static void handCoupon(OrdersTotal ordersTotal,RefundRecord refundRecord,CommonService commonService) { + public static void handCoupon(OrdersTotal ordersTotal,RefundRecord refundRecord,StringBuilder orderNodeBuilder,CommonService commonService) { //鍥為��鐨勪紭鎯犲埜鍙樻垚浣跨敤鐘舵�� //濡傛灉璇ヤ紭鎯犲埜鍦ㄥ埆鐨勮鍗曚娇鐢ㄤ簡锛岄偅涔堝氨涓嶅啀鐞嗕細 @@ -372,7 +414,10 @@ values.put("useType", CouponNumber.USE_TYPE_USER); values.put("id", couponOrderDiscountLog.getCouponNumberId()); sqlSentence.sqlSentence(" isUse=#{m.isUse},useTime=#{m.useTime},useType=#{m.useType},isUse=#{m.isUse} WHERE id = #{m.id} AND isUse = #{m.isUseOld}",values); - if(commonService.updateWhere(CouponNumberMapper.class,sqlSentence) == 1){ + if(commonService.updateWhere(CouponNumberMapper.class,sqlSentence) != 0){ + if(orderNodeBuilder != null){ + orderNodeBuilder.append("-[浣滃簾閫�娆綸浣跨敤浼樻儬鍒稿鐞嗭細"+couponOrderDiscountLog.getTitle()); + } //鍙樻洿璁㈠崟浼樻儬鍒歌褰曠姸鎬� values.clear(); values.put("status", BaseEntity.NO); @@ -740,7 +785,7 @@ StringBuilder sql; for(UserCardUsed userCardUsed:userCardUsedList){ //鍒ゆ柇鏄惁澶熶簡锛岃烦鍑哄惊鐜� - if(opNum == returnNum){ + if(opNum <= 0){ break; } if(userCardUsed.getCancelNum() <= 0){ -- Gitblit v1.8.0