From cfedbfad423aa6fd758da748967122819b1787e2 Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期五, 01 三月 2024 18:14:57 +0800 Subject: [PATCH] 爆款活动-退款处理 --- phi_platform_user/src/main/java/com/hx/phip/tool/refund/PartialRefundUtil.java | 48 ++++++++++++++++++++++- phi_platform_user/src/main/java/com/hx/phip/tool/refund/OrderRefundCancelTool.java | 53 ++++++++++++++++++++++++++ phi_platform_common/src/main/java/com/hx/phip/tool/order/OrderTool.java | 13 ++++++ 3 files changed, 111 insertions(+), 3 deletions(-) diff --git a/phi_platform_common/src/main/java/com/hx/phip/tool/order/OrderTool.java b/phi_platform_common/src/main/java/com/hx/phip/tool/order/OrderTool.java index eefb7cb..8c37ebe 100644 --- a/phi_platform_common/src/main/java/com/hx/phip/tool/order/OrderTool.java +++ b/phi_platform_common/src/main/java/com/hx/phip/tool/order/OrderTool.java @@ -43,5 +43,18 @@ return commonService.selectOne(UserMoneyUnclaimedMapper.class,sqlSentence); } + /**鑾峰彇鐢ㄦ埛娲诲姩璧犻�佽祫閲戝鍔辫褰�-鏈夋晥*/ + public static List<UserMoneyUnclaimed> getActivityGive(String userId,String commonId, CommonService commonService){ + //鏌ユ壘棰嗗彇璁板綍閲婃斁瀛樺湪 + //棰嗗彇璁板綍鏄惁宸查鍙� + SqlSentence sqlSentence = new SqlSentence(); + Map<String,Object> values = new HashMap<>(); + + values.put("userId",userId); + values.put("commonId",commonId); + sqlSentence.sqlSentence("SELECT * FROM user_money_unclaimed WHERE isDel = 0 AND isValid = 1 AND userId = #{m.userId} AND commonId = #{m.commonId}",values); + return commonService.selectList(UserMoneyUnclaimedMapper.class,sqlSentence); + } + } 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 80722a0..f1595d3 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 @@ -22,6 +22,7 @@ import com.hx.phiappt.model.userMoney.UserMoneyUnclaimed; import com.hx.phip.dao.mapper.*; import com.hx.phip.service.order.impl.OrderRefundServiceImpl; +import com.hx.phip.tool.order.OrderTool; import com.hx.phip.tool.user.UserCardTool; import com.hx.phip.tool.user.UserProjectTool; import com.hx.phip.util.api.UserMoneyUtil; @@ -435,6 +436,58 @@ } } + /**浣滃簾閫�娆�-鐖嗘娲诲姩璧犻�佸鐞�*/ + public static void burstActivityHandle(StringBuilder orderNodeBuilder,OrdersTotal ordersTotal,RefundRecord refundRecord,CommonService commonService){ + //涓嶆槸鐖嗘娲诲姩 + if(ordersTotal.getActivityPageType() != OrderTotalConstants.ACTIVITY_TYPE_BURST){ + return; + } + + //鏌ユ壘鏄惁澶勭悊浜嗚禒閫佺殑澧炲�奸噾 + SqlSentence sqlSentence = new SqlSentence(); + Map<String,Object> values = new HashMap<>(); + values.put("isDel",102); + values.put("orderId",refundRecord.getOrderId()); + sqlSentence.sqlSentence("SELECT * FROM refund_user_assets rua WHERE rua.isDel = #{m.isDel} AND rua.status = 1 AND rua.amountStatus IN(1,3) AND rua.orderId = #{m.orderId}",values); + List<RefundUserAssets> refundUserAssetsList = commonService.selectList(RefundUserAssetsMapper.class,sqlSentence); + if(refundUserAssetsList.size() == 0){ + return; + } + + for(RefundUserAssets refundUserAssets:refundUserAssetsList){ + //鍒ゆ柇鏄惁宸茬粡瀛樺湪浜嗗埆鐨勮禒閫佽褰� + if(OrderTool.getActivityGive(refundUserAssets.getUserId(),ordersTotal.getActivityPageCode(),commonService).size() == 0){ + //鏄惁鏈夋墸鍑忕敤鎴疯祫浜� + if(refundUserAssets.getAmountStatus() == RefundUserAssets.AMOUNT_STATUS_NORMAL){ + orderNodeBuilder.append("锛屾椿鍔ㄨ禒閫佸鍔犳垚鍔�"); + UserMoneyUtil.setNewUserMoneyUnclaimed(refundUserAssets.getUserId(),refundRecord.getRemarks(),"閫�娆句綔搴�:娲诲姩璧犻�佽祫閲戝洖閫�浣滃簾",refundUserAssets.getOperatorId() + ,refundRecord.getOrderId(),refundRecord.getOperatorAppCode(),refundUserAssets.getId(),refundUserAssets.getAmount().negate(),refundUserAssets.getAmountType() + ,OperationReasonConstants.OP_REASON_BRING_NEW_USER_GIFT_RETRU_CANCEL,commonService,UserMoneyUnclaimed.YES); + }else if(refundUserAssets.getAmountStatus() == RefundUserAssets.AMOUNT_STATUS_NOT_RECEIVE){ + //鐢ㄦ埛鏈鍙栬褰曪紝杩樺師 + orderNodeBuilder.append("锛屾椿鍔ㄨ禒閫佺敤鎴锋湭棰嗗彇锛屼綔搴熺殑棰嗗彇璁板綍杩樺師"); + values.clear(); + values.put("id",refundUserAssets.getUserMoneyUnclaimedId()); + values.put("status",UserMoneyUnclaimed.STATUS_WAI); + sqlSentence.sqlUpdate("isDel = 0,isValid = 1 WHERE id = #{m.id} AND isDel = 1 AND isValid = 0 AND status = #{m.status}",values); + if(commonService.updateWhere(UserMoneyUnclaimedMapper.class,sqlSentence) != 1){ + throw new TipsException("娲诲姩璧犻�佽祫浜ц褰曠姸鎬佸凡鍙樺寲[浣滃簾]锛�"); + } + } + } + + //璁板綍浣滃簾 + values.clear(); + values.put("id",refundUserAssets.getId()); + values.put("status",RefundUserAssets.STATUS_CANCEL); + values.put("oldStatus",RefundUserAssets.STATUS_NORMAL); + sqlSentence.sqlSentence("status = #{m.status} WHERE id = #{m.id} AND status = #{m.oldStatus}",values); + if(commonService.updateWhere(RefundUserAssetsMapper.class,sqlSentence) != 1){ + throw new TipsException("娲诲姩璧犻�佽祫浜ч��娆捐褰曠姸鎬佸凡鍙樺寲[浣滃簾]锛�"); + } + } + } + /**閫�娆惧瓙椤瑰鐞�*/ public static void refundRecordItemHandle(OrdersTotal ordersTotal,RefundRecord refundRecord,CommonService commonService){ 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 4f70c87..25d96b7 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 @@ -915,7 +915,7 @@ return; } //璁㈠崟鍙栨秷鐘舵�佹墠澶勭悊 - if(ordersTotal.getStatus() != OrderTotalConstants.STATUS_CANCEL){ + if(ordersTotal.getRefundStatus() != OrderTotalConstants.STATUS_REFUND_FINSH){ return; } @@ -925,20 +925,40 @@ if(userMoneyUnclaimed == null){ return; } + SqlSentence sqlSentence = new SqlSentence(); + Map<String,Object> values = new HashMap<>(); + + //-----鐢熸垚涓�鏉¤褰曪紝鍙互鍥炴函 + RefundUserAssets refundUserAssets; + //鐢熸垚璁板綍 + refundUserAssets = new RefundUserAssets(); + //璁剧疆鏈�102鏄綋鍓嶇殑璁板綍绫诲瀷 + refundUserAssets.setIsDel(102); + refundUserAssets.setType(userMoneyUnclaimed.getOperationReason()); + refundUserAssets.setStatus(RefundUserAssets.STATUS_NORMAL); + refundUserAssets.setAmountType(userMoneyUnclaimed.getFundType()); + refundUserAssets.setAmount(userMoneyUnclaimed.getOpNumber().negate()); + refundUserAssets.setOperatorId(refundRecord.getOperatorId()); + refundUserAssets.setOperatorNo(refundRecord.getOperatorNo()); + refundUserAssets.setOperatorName(refundRecord.getOperatorName()); + refundUserAssets.setOrderId(refundRecord.getOrderId()); + refundUserAssets.setRefundRecordId(refundRecord.getId()); + refundUserAssets.setUserMoneyUnclaimedId(userMoneyUnclaimed.getId()); + refundUserAssets.setUserId(userMoneyUnclaimed.getUserId()); if(userMoneyUnclaimed.getStatus() == UserMoneyUnclaimed.STATUS_SUCCEED){ //宸查鍙栵紝閭d箞灏辨墸鍥炴潵 if(userMoneyUnclaimed.getOpNumber().compareTo(BigDecimal.ZERO) < 1){ return; } + refundUserAssets.setAmountStatus(RefundUserAssets.AMOUNT_STATUS_NORMAL); UserMoneyUtil.setUserMoneyHandle(userMoneyUnclaimed.getUserId(),UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND,userMoneyUnclaimed.getOpNumber().negate(),BaseEntity.NO,OperationReasonConstants.OP_REASON_INVITE_ORDER_CANCEL,"濂藉弸璁㈠崟閫�娆�-娲诲姩璧犻�佹墸闄"+ordersTotal.getOrderNo()+"]","鎿嶄綔鍘熷洜:閫�娆惧鏍搁�氳繃锛屾椿鍔ㄨ禒閫佹墸闄よ祫閲戯紝閫�娆炬柟寮�:閫�鍥炲鍊奸噾",ordersTotal.getOperatorId() ,ordersTotal.getId(),ordersTotal.getActivityPageCode(),null,commonService); }else{ if(!UserMoneyUnclaimed.YES.equals(userMoneyUnclaimed.getIsValid())){ return; } - SqlSentence sqlSentence = new SqlSentence(); - Map<String,Object> values = new HashMap<>(); + refundUserAssets.setAmountStatus(RefundUserAssets.AMOUNT_STATUS_NOT_RECEIVE); //娌℃湁棰嗗彇灏变綔搴� values.put("id",userMoneyUnclaimed.getId()); values.put("isValid",UserMoneyUnclaimed.NO); @@ -949,6 +969,28 @@ activityPageGiveIncrease(ordersTotal,refundRecord,operationId,circulateNum,commonService); } } + //淇濆瓨璁板綍锛屾甯告墸鍑忓拰鏈鍙栨墠鍘讳繚瀛樿繖涓褰� + commonService.insert(RefundUserAssetsMapper.class,refundUserAssets); + + //鏌ョ湅鏄惁鏈夌浜屽紶璁㈠崟绗﹀悎 + values.clear(); + values.put("status",OrderTotalConstants.STATUS_CANCEL); + values.put("payStatus",OrderTotalConstants.PAY_STATUS_SUC); + values.put("id",ordersTotal.getId()); + values.put("activityPageType",ordersTotal.getActivityPageType()); + values.put("activityPageCode",ordersTotal.getActivityPageCode()); + sqlSentence.sqlSentence("SELECT * FROM orders_total WHERE isDel = 0 AND status != #{m.status} AND payStatus = #{m.payStatus}" + + " AND id != #{m.id} AND activityPageType = #{m.activityPageType} AND activityPageCode = #{m.activityPageCode} ORDER BY createTime ASC LIMIT 1",values); + OrdersTotal ordersTotal1 = commonService.selectOne(OrdersTotalMapper.class,sqlSentence); + if(ordersTotal1 != null){ + Integer opType = BaseEntity.NO; + if(userMoneyUnclaimed.getStatus() == UserMoneyUnclaimed.STATUS_SUCCEED){ + opType = BaseEntity.YES; + } + //澧炲�奸噾鍒拌处澶勭悊 + UserMoneyUtil.setUserMoneyHandle(userMoneyUnclaimed.getUserId(), UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND,userMoneyUnclaimed.getOpNumber(),opType, OperationReasonConstants.OP_REASON_INVITE_ORDER,userMoneyUnclaimed.getOriginSubject(),userMoneyUnclaimed.getRemarks(),userMoneyUnclaimed.getOperatorId() + ,ordersTotal1.getId(),ordersTotal.getActivityPageCode(),userMoneyUnclaimed.getMoneyRuleId(),commonService); + } } -- Gitblit v1.8.0