From b60e18cb5228abe7bc9cdd46c508481bdde69fdd Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期五, 26 一月 2024 17:42:56 +0800 Subject: [PATCH] 再生俱乐部提交 --- phi_platform_user/src/main/java/com/hx/phip/controller/order/OrderControllerV2.java | 11 phi_platform_common/src/main/resources/mapper/platform/ProjectTypeRelationMapper.xml | 90 ++++++++ phi_platform_user/src/main/java/com/hx/phip/service/order/impl/OrderRefundServiceImpl.java | 26 ++ phi_platform_common/src/main/java/com/hx/phip/service/club/impl/UserClubMemberServiceImpl.java | 70 ++++++ phi_platform_common/src/main/resources/mapper/platform/UserClubMemberMapper.xml | 10 phi_platform_common/src/main/java/com/hx/phip/service/club/UserClubMemberService.java | 20 + phi_platform_common/src/main/java/com/hx/phip/AutoDomeUtil.java | 1 phi_platform_user/src/main/java/com/hx/phip/common/TestController.java | 25 +- phi_platform_common/src/main/java/com/hx/phip/dao/mapper/ProjectTypeRelationMapper.java | 37 +++ phi_platform_common/src/main/java/com/hx/phip/service/tool/club/UserCluebMemberServiceTool.java | 354 +++++++++++++++++++++++++------ phi_platform_user/src/main/java/com/hx/phip/util/api/OrderPayMoneyUtil.java | 5 11 files changed, 553 insertions(+), 96 deletions(-) diff --git a/phi_platform_common/src/main/java/com/hx/phip/AutoDomeUtil.java b/phi_platform_common/src/main/java/com/hx/phip/AutoDomeUtil.java index 1b8b115..b9218d8 100644 --- a/phi_platform_common/src/main/java/com/hx/phip/AutoDomeUtil.java +++ b/phi_platform_common/src/main/java/com/hx/phip/AutoDomeUtil.java @@ -14,6 +14,7 @@ import com.hx.phiappt.model.market.system.MarketSystemProject; import com.hx.phiappt.model.order.*; import com.hx.phiappt.model.project.ProjectShopPrice; +import com.hx.phiappt.model.project.ProjectTypeRelation; import com.hx.phiappt.model.refund.*; import com.hx.phiappt.model.user.*; import com.hx.phiappt.model.user.club.UserClubMember; diff --git a/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/ProjectTypeRelationMapper.java b/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/ProjectTypeRelationMapper.java new file mode 100644 index 0000000..c8931df --- /dev/null +++ b/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/ProjectTypeRelationMapper.java @@ -0,0 +1,37 @@ +package com.hx.phip.dao.mapper; + +import java.util.List; +import java.util.Map; +import com.hx.mybatisTool.SqlSentence; +import com.hx.phiappt.model.project.ProjectTypeRelation; + +public interface ProjectTypeRelationMapper { + /**鏂板锛岃繑鍥炰富閿�*/ + int insert(ProjectTypeRelation projectTypeRelation); + /**鏂板锛岃繑鍥炰富閿�*/ + int insertById(ProjectTypeRelation projectTypeRelation); + /**鏌ヨ鏉℃暟*/ + int selectCount(SqlSentence sqlSentence); + /**鏌ヨ鏉℃暟*/ + int selectCountSql(SqlSentence sqlSentence); + /**鏌ヨ鍒楄〃锛岃繑鍥炲疄浣撶被鐨凩ist*/ + List<ProjectTypeRelation> selectList(SqlSentence sqlSentence); + /**鏌ヨ鍒楄〃锛岃繑鍥濵ap鐨凩ist*/ + List<Map<String,Object>> selectListMap(SqlSentence sqlSentence); + /**鏌ヨ锛岃繑鍥炲崟涓疄浣�*/ + ProjectTypeRelation selectOne(SqlSentence sqlSentence); + /**鏌ヨ锛岃繑鍥炲崟涓猰ap*/ + Map<String,Object> selectOneMap(SqlSentence sqlSentence); + /**鏌ヨ锛岃繑鍥炲疄浣撶被娌℃湁澶ф暟鎹殑*/ + ProjectTypeRelation selectOneByKey(Object object); + /**鏌ヨ锛岃繑鍥炲疄浣撶被鏈夊ぇ鏁版嵁鐨�*/ + ProjectTypeRelation selectOneByKeyBlob(Object object); + /**鏇存柊锛岃繑鍥炴洿鏂版暟閲�*/ + int updateWhere(SqlSentence sqlSentence); + /**鏇存柊锛岃繑鍥炴洿鏂版暟閲�*/ + int updateAll(ProjectTypeRelation projectTypeRelation); + /**鍒犻櫎锛岃繑鍥炲垹闄ゆ暟閲�*/ + int deleteWhere(SqlSentence sqlSentence); + /**鍒犻櫎锛岃繑鍥炲垹闄ゆ暟閲�*/ + int deleteById(Object object); +} \ No newline at end of file diff --git a/phi_platform_common/src/main/java/com/hx/phip/service/club/UserClubMemberService.java b/phi_platform_common/src/main/java/com/hx/phip/service/club/UserClubMemberService.java new file mode 100644 index 0000000..02b9140 --- /dev/null +++ b/phi_platform_common/src/main/java/com/hx/phip/service/club/UserClubMemberService.java @@ -0,0 +1,20 @@ +package com.hx.phip.service.club; + +import com.hx.mybatisTool.SqlSentence; +import com.hx.phiappt.model.user.club.UserClubMember; + +import java.util.Date; + +/** + * @author CJH + */ +public interface UserClubMemberService { + + /**鍒涘缓淇变箰閮ㄤ細鍛�*/ + void createClubMember(Integer type, Integer durationType, Date startTime, Date endTime, Integer sourceType, String sourceId, String sourceOtherId + , String userId); + + /**浣滃簾淇变箰閮ㄤ細鍛�*/ + void cancelClubMember(Integer discardSource,String discardId,String discardOtherId,String discardReason, UserClubMember userClubMember); + +} diff --git a/phi_platform_common/src/main/java/com/hx/phip/service/club/impl/UserClubMemberServiceImpl.java b/phi_platform_common/src/main/java/com/hx/phip/service/club/impl/UserClubMemberServiceImpl.java new file mode 100644 index 0000000..f552907 --- /dev/null +++ b/phi_platform_common/src/main/java/com/hx/phip/service/club/impl/UserClubMemberServiceImpl.java @@ -0,0 +1,70 @@ +package com.hx.phip.service.club.impl; + +import com.hx.mybatisTool.SqlSentence; +import com.hx.phiappt.model.user.club.UserClubMember; +import com.hx.phip.dao.mapper.UserClubMemberMapper; +import com.hx.phip.service.club.UserClubMemberService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Transactional +@Service +public class UserClubMemberServiceImpl implements UserClubMemberService { + + @Resource + private UserClubMemberMapper userClubMemberMapper; + + + /**鏂板淇变箰閮�*/ + @Override + public void createClubMember(Integer type, Integer durationType, Date startTime, Date endTime, Integer sourceType, String sourceId, String sourceOtherId + , String userId) { + + SqlSentence sqlSentence = new SqlSentence(); + Map<String,Object> values = new HashMap<>(); + + //鏈夌粦瀹氱殑鍏ㄩ儴杩涜鍙栨秷 + values.put("type",type); + values.put("status", UserClubMember.STATUS_NORMAL); + values.put("userId",userId); + sqlSentence.sqlUpdate(" isDel = 2 WHERE isDel = 0 AND type = #{m.type} AND status = #{m.status} AND userId = #{m.userId}",values); + userClubMemberMapper.updateWhere(sqlSentence); + + UserClubMember userClubMember = new UserClubMember(); + userClubMember.setType(type); + userClubMember.setStatus(UserClubMember.STATUS_NORMAL); + userClubMember.setDurationType(durationType); + userClubMember.setStartTime(startTime); + userClubMember.setEndTime(endTime); + userClubMember.setSourceType(sourceType); + userClubMember.setSourceId(sourceId); + userClubMember.setSourceOtherId(sourceOtherId); + userClubMember.setUserId(userId); + userClubMemberMapper.insert(userClubMember); + + } + + /**浣滃簾淇变箰閮�*/ + @Override + public void cancelClubMember(Integer discardSource,String discardId,String discardOtherId,String discardReason, UserClubMember userClubMember) { + SqlSentence sqlSentence = new SqlSentence(); + Map<String,Object> values = new HashMap<>(); + + values.put("status",UserClubMember.STATUS_DISCARD); + values.put("discardSource",discardSource); + values.put("discardId",discardId); + values.put("discardOtherId",discardOtherId); + values.put("discardReason",discardReason); + values.put("discardTime",new Date()); + values.put("id",userClubMember.getId()); + values.put("oldStatus",UserClubMember.STATUS_NORMAL); + sqlSentence.sqlWhere(" status = #{m.status},discardSource=#{m.discardSource},discardId =#{m.discardId},discardOtherId = #{m.discardOtherId}" + + ",discardReason = #{m.discardReason},discardTime = #{m.discardTime} WHERE id = #{m.id} AND status = #{m.oldStatus}",values); + userClubMemberMapper.updateWhere(sqlSentence); + } +} diff --git a/phi_platform_common/src/main/java/com/hx/phip/tool/club/UserCluebMemberTool.java b/phi_platform_common/src/main/java/com/hx/phip/service/tool/club/UserCluebMemberServiceTool.java similarity index 62% rename from phi_platform_common/src/main/java/com/hx/phip/tool/club/UserCluebMemberTool.java rename to phi_platform_common/src/main/java/com/hx/phip/service/tool/club/UserCluebMemberServiceTool.java index cde1c39..a48c488 100644 --- a/phi_platform_common/src/main/java/com/hx/phip/tool/club/UserCluebMemberTool.java +++ b/phi_platform_common/src/main/java/com/hx/phip/service/tool/club/UserCluebMemberServiceTool.java @@ -1,14 +1,13 @@ -package com.hx.phip.tool.club; +package com.hx.phip.service.tool.club; +import com.alibaba.fastjson.JSON; import com.hx.common.service.CommonService; import com.hx.exception.TipsException; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.common.OrderItemConstants; import com.hx.phiappt.common.OrderTotalConstants; import com.hx.phiappt.common.UserProjectConstants; -import com.hx.phiappt.constants.enums.GroupTypeEnum; import com.hx.phiappt.constants.enums.ProjectRelationTypeEnum; -import com.hx.phiappt.dao.mapper.ProjectTypeRelationMapper; import com.hx.phiappt.model.cardItem.CardEquity; import com.hx.phiappt.model.cardItem.CardItemInfo; import com.hx.phiappt.model.market.system.MarketSystem; @@ -21,26 +20,108 @@ import com.hx.phiappt.model.user.UserCardUsed; import com.hx.phiappt.model.user.club.UserClubMember; import com.hx.phip.dao.mapper.*; +import com.hx.phip.service.club.UserClubMemberService; import com.hx.phip.vo.club.ChekCureVo; import com.hx.util.DateUtil; +import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; /**鐢ㄦ埛淇变箰閮ㄤ細鍛� * @author CJH */ -public class UserCluebMemberTool { +@Component +public class UserCluebMemberServiceTool { - /**璁㈠崟涓嬪崟缁撹处鏍¢獙鏄惁绗﹀悎浼氬憳鏉′欢*/ - public static void orderChekMember(String orderId,Integer marketType, CommonService commonService){ + @Resource + private CommonService commonService; + @Resource + private UserClubMemberService userClubMemberService; - OrdersTotal ordersTotal = commonService.selectOneByKey(OrdersTotalMapper.class,orderId); + /**鏍¢獙缁撴灉-涓嶅弬涓庤鍒�*/ + public static final int RESULT_NOT_JOIN = 1; + /**鏍¢獙缁撴灉-绗﹀悎瑙勫垯*/ + public static final int RESULT_CONFORM = 2; + /**鏍¢獙缁撴灉-涓嶇鍚堣鍒�*/ + public static final int RESULT_NON_CONFORM = 3; + + /**璁㈠崟涓嬪崟缁撹处鏍¢獙鏄惁绗﹀悎浼氬憳鏉′欢 + * @param orderId 璁㈠崟鏍囪瘑锛屼笌ordersTotal閫変竴涓紝涓や釜閮芥湁榛樿ordersTotal + * @param ordersTotal 璁㈠崟鏍囪瘑锛屼笌orderId閫変竴涓紝涓や釜閮芥湁榛樿ordersTotal + * @param marketSystem 瑙勫垯閰嶇疆锛屼笉浼犳嬁鏈�鏂扮殑 + * @param marketType 淇变箰閮ㄧ被鍨嬶紝MarketSystem閲岄潰鐨勭被鍨� + * @return 鏄惁鐢熸垚浼氬憳 + */ + public boolean orderChekMember(String orderId,OrdersTotal ordersTotal,MarketSystem marketSystem,Integer marketType){ if(ordersTotal == null){ - throw new TipsException("璁㈠崟鏍囪瘑閿欒锛�"); + ordersTotal = commonService.selectOneByKey(OrdersTotalMapper.class,orderId); + if(ordersTotal == null){ + throw new TipsException("璁㈠崟鏍囪瘑閿欒锛�"); + } + } + + //鍏呭�煎崟璺宠繃 + if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType()) + || OrderTotalConstants.TYPE_CARD_BAG.equals(ordersTotal.getType())){ + return false; + } + //鏈敮浠樿烦杩� + if(ordersTotal.getPayStatus() != OrderTotalConstants.PAY_STATUS_SUC){ + return false; + } + + SqlSentence sqlSentence = new SqlSentence(); + Map<String,Object> values = new HashMap<>(); + + //鏄惁鏈変紶鍏ョ殑 + if(marketSystem == null){ + //鏌ヨ娲诲姩閰嶇疆 + values.put("type",marketType); + sqlSentence.sqlSentence("SELECT * FROM market_system WHERE isDel = 0 AND isUp = 1 AND type = #{m.type}",values); + marketSystem = commonService.selectOne(MarketSystemMapper.class,sqlSentence); + //娌℃湁娲诲姩涓�寰嬭烦杩� + if(marketSystem == null){ + return false; + } + } + + //---鍒ゆ柇鏄惁鍦ㄦ椿鍔ㄦ椂闂村唴 + if(marketSystem.getStartTime() != null){ + if(ordersTotal.getPayTime().getTime() < marketSystem.getStartTime().getTime()){ + return false; + } + } + if(marketSystem.getEndTime() != null){ + if(ordersTotal.getPayTime().getTime() > marketSystem.getEndTime().getTime()){ + return false; + } + } + //寮�濮嬫牎楠屾槸鍚︾鍚堣鍒� + if(commonChekMember(null,null,ordersTotal,marketSystem) == RESULT_CONFORM){ + //鐢熸垚淇变箰閮ㄤ細鍛� + createClubMember(UserClubMember.TYPE_REGENERATION,ordersTotal,marketSystem,userClubMemberService); + return true; + } + return false; + } + + /**璁㈠崟閫�娆炬牎楠屾槸鍚︾鍚堜細鍛樻潯浠� + * @param orderId 璁㈠崟鏍囪瘑锛屼笌ordersTotal閫変竴涓紝涓や釜閮芥湁榛樿ordersTotal + * @param ordersTotal 璁㈠崟鏍囪瘑锛屼笌orderId閫変竴涓紝涓や釜閮芥湁榛樿ordersTotal + * @param marketType 淇变箰閮ㄧ被鍨嬶紝MarketSystem閲岄潰鐨勭被鍨� + */ + public void refundChekMember(String orderId,OrdersTotal ordersTotal,String refundId,Integer marketType){ + if(ordersTotal == null){ + ordersTotal = commonService.selectOneByKey(OrdersTotalMapper.class,orderId); + if(ordersTotal == null){ + throw new TipsException("璁㈠崟鏍囪瘑閿欒锛�"); + } } //鍏呭�煎崟璺宠繃 - if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType())){ + if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType()) + || OrderTotalConstants.TYPE_CARD_BAG.equals(ordersTotal.getType())){ return; } //鏈敮浠樿烦杩� @@ -48,31 +129,152 @@ return; } - //鏌ヨ娲诲姩閰嶇疆 - SqlSentence sqlSentence = new SqlSentence(); - Map<String,Object> values = new HashMap<>(); + //鏌ユ壘鏄惁鏈変細鍛� + UserClubMember userClubMember = getUserClubMember(ordersTotal.getUserId(),marketType,new Date(),commonService); + //娌℃湁浼氬憳灏变笉闇�瑕佸啀璺戜笅闈㈡祦绋� + if(userClubMember == null){ + return; + } - values.put("type",marketType); - sqlSentence.sqlSentence("SELECT * FROM market_system WHERE isDel = 0 AND isUp = 1 AND type = #{m.type}",values); - MarketSystem marketSystem = commonService.selectOneByKey(MarketSystemMapper.class,sqlSentence); + MarketSystem marketSystem = commonService.selectOneByKey(MarketSystemMapper.class,userClubMember.getSourceOtherId()); if(marketSystem == null){ return; } - //---鍒ゆ柇鏄惁鍦ㄦ椿鍔ㄦ椂闂村唴 - if(marketSystem.getStartTime() != null){ - if(ordersTotal.getPayTime().getTime() < marketSystem.getStartTime().getTime()){ + //鍒ゆ柇鏄惁鏃堕棿鍐呯殑 + Date startTime = null; + Date endTime = userClubMember.getStartTime(); + if(marketSystem.getTimeType() == MarketSystem.TIME_TYPE_HOUR){ + startTime = DateUtil.addhour(endTime,-marketSystem.getTimeNum()); + } + if(startTime != null ){ + if(marketSystem.getStartTime() != null && marketSystem.getStartTime().getTime() > startTime.getTime()){ + startTime = marketSystem.getStartTime(); + } + }else{ + startTime = marketSystem.getStartTime(); + } + if(endTime != null ){ + if(marketSystem.getEndTime() != null && marketSystem.getEndTime().getTime() < endTime.getTime()){ + endTime = marketSystem.getEndTime(); + } + }else{ + endTime = marketSystem.getEndTime(); + } + + //鍒ゆ柇璁㈠崟鏄惁鍦ㄨ繖涓椂闂翠箣鍐� + if(startTime != null){ + if(ordersTotal.getPayTime().getTime() < startTime.getTime()){ return; } } - if(marketSystem.getEndTime() != null){ - if(ordersTotal.getPayTime().getTime() > marketSystem.getEndTime().getTime()){ + if(endTime != null){ + if(ordersTotal.getPayTime().getTime() > endTime.getTime()){ return; } } + //褰撳墠閫�娆剧殑璁㈠崟鏄湪閫昏緫鍐呯殑锛屼絾涓嶇鍚堣鍒� + if(commonChekMember(startTime,endTime,ordersTotal,marketSystem) == RESULT_NON_CONFORM){ + //涓嶇鍚堝氨浣滃簾浼氬憳淇℃伅 + userClubMemberService.cancelClubMember(UserClubMember.DISCARD_SOURCE_REFUND,refundId,ordersTotal.getId(),"璁㈠崟閫�娆�",userClubMember); + //閲嶆柊绠楀嚭绗﹀悎鐨勫嚭鏉� + SqlSentence sqlSentence = new SqlSentence(); + Map<String,Object> values = new HashMap<>(); + StringBuilder sql = new StringBuilder(); + + int pageNum = 0; + int pageSize = 10; + + values.put("userId",ordersTotal.getId()); + sql.append("SELECT * FROM orders_total WHERE isDel = 0 AND userId = #{m.userId} AND status IN(2,3,9) AND payStatus = 3"); + if(startTime != null){ + values.put("startTime",startTime); + sql.append(" AND payTime >= #{m.startTime}"); + } + if(endTime != null){ + values.put("endTime",endTime); + sql.append(" AND payTime <= #{m.endTime}"); + } + sql.append(" ORDER BY payTime DESC LIMIT #{m.pageNum},#{m.pageSize}"); + sqlSentence.sqlSentence(sql.toString(),values); + + List<OrdersTotal> ordersTotalList; + boolean result = false; + while (true){ + values.put("pageNum",pageNum); + values.put("pageSize",pageSize); + ordersTotalList = commonService.selectList(OrdersTotalMapper.class,sqlSentence); + for(OrdersTotal ordersTotal1:ordersTotalList){ + //鏄惁鐢熸垚浜嗕細鍛橈紝濡傛灉鏄紝閭d箞灏辫烦鍑哄惊鐜� + result = orderChekMember(null,ordersTotal1,marketSystem,MarketSystem.TYPE_REGENERATION); + if(result){ + break; + } + } + if(result){ + break; + } + if(ordersTotalList.size() < pageSize){ + break; + } + pageNum = pageNum+pageSize; + } + } + } + + /**璁㈠崟閫�娆炬牎楠屾槸鍚︾鍚堜細鍛樻潯浠� + * @param orderId 璁㈠崟鏍囪瘑 + * @param marketType 淇变箰閮ㄧ被鍨嬶紝MarketSystem閲岄潰鐨勭被鍨� + */ + public void refundCancelChekMember(String orderId,OrdersTotal ordersTotal,String refundId,Integer marketType){ + if(ordersTotal == null){ + ordersTotal = commonService.selectOneByKey(OrdersTotalMapper.class,orderId); + if(ordersTotal == null){ + throw new TipsException("璁㈠崟鏍囪瘑閿欒锛�"); + } + } + + //鍏呭�煎崟璺宠繃 + if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType()) + || OrderTotalConstants.TYPE_CARD_BAG.equals(ordersTotal.getType())){ + return; + } + //鏈敮浠樿烦杩� + if(ordersTotal.getPayStatus() != OrderTotalConstants.PAY_STATUS_SUC){ + return; + } + + //鏌ユ壘鏄惁鏈変細鍛� + UserClubMember userClubMember = getUserClubMember(ordersTotal.getUserId(),marketType,new Date(),commonService); + if(userClubMember == null){ + //褰撳墠娌℃湁浼氬憳 + orderChekMember(null,ordersTotal,null,MarketSystem.TYPE_REGENERATION); + return; + }else{ + //---宸茬粡瀛樺湪浼氬憳浜嗘儏鍐典笅锛岄渶瑕佸垽鏂垚涓轰細鍛樼殑鏃堕棿浜嗭紝鍙互浣滃簾閫�娆捐繖涓瘮杩欎釜杩樿鏂� + MarketSystem marketSystem = commonService.selectOneByKey(MarketSystemMapper.class,userClubMember.getSourceOtherId()); + if(marketSystem == null){ + return; + } + if(userClubMember.getStartTime().getTime() < ordersTotal.getPayTime().getTime()){ + //閲嶆柊鐢熸垚浼氬憳 + orderChekMember(null,ordersTotal,marketSystem,MarketSystem.TYPE_REGENERATION); + } + } + } + + /**鍏敤鏍¢獙 + * @param startTime 瑙勫垯鍐呭紑濮嬫椂闂存椂闂达紝涓嶄紶浠rdersTotal鏀粯鏃堕棿閲嶆柊绠� + * @param endTime 瑙勫垯鍐呯粨鏉熸椂闂存椂闂达紝涓嶄紶浠rdersTotal鏀粯鏃堕棿閲嶆柊绠� + * @param ordersTotal 褰撳墠璁㈠崟 + * @param marketSystem 褰撳墠閰嶇疆 + */ + public int commonChekMember(Date startTime,Date endTime,OrdersTotal ordersTotal,MarketSystem marketSystem){ + SqlSentence sqlSentence = new SqlSentence(); + Map<String,Object> values = new HashMap<>(); + //----鑾峰彇鎸囧畾鐨勯」鐩厤缃� - values.clear(); values.put("marketSystemId",marketSystem.getId()); sqlSentence.sqlSentence("SELECT type,typeCode,typeId FROM market_system_project WHERE isDel = 0 AND marketSystemId = #{m.marketSystemId}",values); List<MarketSystemProject> marketSystemProjectList = commonService.selectList(MarketSystemProjectMapper.class,sqlSentence); @@ -93,33 +295,46 @@ if(itemNameSql.length() > 0){ values.clear(); values.put("moduleType", ProjectRelationTypeEnum.MODULE_TYPE_ZS_PROJECT.getCode()); - values.put("itemNameList",itemNameSql.toString()); - sqlSentence.sqlSentence("SELECT skuNo FROM project_type_relation WHERE isDel = 0 AND moduleType = 7 AND itemName IN(${m.itemNameList})",values); + sqlSentence.sqlSentence("SELECT skuNo FROM project_type_relation WHERE isDel = 0 AND moduleType = 7 AND itemName IN("+ itemNameSql +")",values); List<ProjectTypeRelation> projectTypeRelationList = commonService.selectList(ProjectTypeRelationMapper.class,sqlSentence); for(ProjectTypeRelation projectTypeRelation:projectTypeRelationList){ skuNoSet.add(projectTypeRelation.getSkuNo()); } } - //鎬荤枟绋嬫暟锛屾墍鏈夌殑椤圭洰鐤楃▼鏁版�诲拰 + + //褰撳墠璁㈠崟鐨勶紝鎬荤枟绋嬫暟锛屾墍鏈夌殑椤圭洰鐤楃▼鏁版�诲拰 ChekCureVo chekCureVo = orderHandle(ordersTotal,skuNoSet,commonService); if(!chekCureVo.isCureProject()){ - return; + return RESULT_NOT_JOIN; } int cureNum = chekCureVo.getCureNum(); //鍒ゆ柇鏄惁绗﹀悎瑙勫垯 - if(cureNum >= marketSystem.getCureNum()){ - //鐢熸垚淇变箰閮ㄤ細鍛� - createClubMember(UserClubMember.TYPE_REGENERATION,ordersTotal,marketSystem,commonService); - }else { - //鏃堕棿娈靛唴鐨勮鍗曠畻娉� + if(cureNum < marketSystem.getCureNum()){ + //鏃堕棿娈靛唴鐨勮鍗曠畻娉�,姹備粬浠殑鍜� values.clear(); - - Date startTime = null; - Date endTime = null; - if(marketSystem.getTimeType() == MarketSystem.TIME_TYPE_HOUR){ + if(endTime == null){ endTime = ordersTotal.getPayTime(); - startTime = DateUtil.addhour(endTime,marketSystem.getTimeNum()); } + if(marketSystem.getTimeType() == MarketSystem.TIME_TYPE_HOUR){ + if(startTime == null){ + startTime = DateUtil.addhour(endTime,-marketSystem.getTimeNum()); + } + } + if(startTime != null ){ + if(marketSystem.getStartTime() != null && marketSystem.getStartTime().getTime() > startTime.getTime()){ + startTime = marketSystem.getStartTime(); + } + }else{ + startTime = marketSystem.getStartTime(); + } + if(endTime != null ){ + if(marketSystem.getEndTime() != null && marketSystem.getEndTime().getTime() < endTime.getTime()){ + endTime = marketSystem.getEndTime(); + } + }else{ + endTime = marketSystem.getEndTime(); + } + itemNameSql = new StringBuilder(); values.put("userId",ordersTotal.getUserId()); values.put("newId",ordersTotal.getId()); @@ -139,14 +354,18 @@ for(OrdersTotal ordersTotal1:ordersTotalList){ chekCureVo = orderHandle(ordersTotal1,skuNoSet,commonService); cureNum =cureNum + chekCureVo.getCureNum(); + //鍒ゆ柇鏄惁绗﹀悎鏉′欢浜嗭紝濡傛灉绗﹀悎锛岄偅涔堝氨璺冲嚭寰幆 + if(cureNum >= marketSystem.getCureNum()){ + break; + } } } + //鏌ユ壘绗﹀悎鐨勮鍗� if(cureNum >= marketSystem.getCureNum()){ - //鐢熸垚淇变箰閮ㄤ細鍛� - createClubMember(UserClubMember.TYPE_REGENERATION,ordersTotal,marketSystem,commonService); + return RESULT_CONFORM; } - + return RESULT_NON_CONFORM; } /**鍗曡鍗曞鐞�*/ @@ -188,7 +407,6 @@ return chekCureVo; } - /**鑾峰彇浜岀骇瀛愯鍗�*/ public static List<OrderItemSon> getOrderItemSonList(String orderItemId,String goodsType,CommonService commonService){ SqlSentence sqlSentence = new SqlSentence(); @@ -206,6 +424,7 @@ SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> values = new HashMap<>(); + //鑾峰彇鏈��娆剧殑鐢ㄦ埛鍗″寘 values.put("effectiveStatus", UserProjectConstants.EFF_STATUS_CANCEL); values.put("sourceId", orderItem.getId()); sqlSentence.sqlSentence("SELECT id FROM user_card WHERE isDel = 0 AND effectiveStatus != #{m.effectiveStatus} AND sourceId = #{m.sourceId}",values); @@ -221,8 +440,9 @@ values.clear(); values.put("cardItemId",orderItem.getCommonId()); sqlSentence.sqlSentence("SELECT cii.id,cii.cardEquityId,cii.commonCode,cii.commonId,cii.commonName,cii.commonType,cii.maxNum,cii.everyDrawNum,p.treatmentItemsNum AS userNum" + - " LEFT JOIN project p ON p.id = cii.commonId AND p.isExecutable = 1" + - " FROM card_item_info cii WHERE cii.isDel = 0 AND cii.cardItemId = #{m.cardItemId} AND cii.commonType IN('project')",values); + " FROM card_item_info cii" + + " LEFT JOIN project p ON p.id = cii.commonId" + + " WHERE cii.isDel = 0 AND cii.cardItemId = #{m.cardItemId} AND cii.commonType IN('project')",values); List<CardItemInfo> cardItemInfoListAll = commonService.selectList(CardItemInfoMapper.class,sqlSentence); //瀛樺偍鍗¢」鎵�鏈夌殑瀛愰」锛宬鍊硷細鏉冪泭鏍囪瘑 Map<String,List<CardItemInfo>> cardItemInfoMapList = new HashMap<>(); @@ -248,13 +468,14 @@ Set<String> NMSet; for(UserCard userCard:userCardList){ - //鑾峰彇宸查��娆剧殑椤圭洰鏁伴噺 + //鑾峰彇宸查��娆剧殑鍗¢」鏉$洰娆℃暟 values.clear(); values.put("sourceType", UserCardUsed.SOURCE_TYPE_USER_CARD_REFUND); values.put("userCardId", userCard.getId()); - sqlSentence.sqlSentence("SELECT cardEquityId,cardItemInfoId,usedNum FROM user_card_used uc WHERE uc.isDel = 0 AND uc.userCardId #{m.userCardId} AND uc.sourceType = #{m.sourceType}",values); + sqlSentence.sqlSentence("SELECT uc.cardEquityId,uc.cardItemInfoId,uc.usedNum FROM user_card_used uc WHERE uc.isDel = 0 AND uc.userCardId = #{m.userCardId} AND uc.sourceType = #{m.sourceType}",values); userCardUsedList = commonService.selectList(UserCardUsedMapper.class,sqlSentence); + //鏍规嵁鏉冪泭鍒嗙粍宸查��娆剧殑鍗¢」鏉$洰娆℃暟 refundItemMapList = new HashMap<>(); for(UserCardUsed userCardUsed:userCardUsedList){ userCardUsedList2 = refundItemMapList.computeIfAbsent(userCardUsed.getCardEquityId(),k->new ArrayList<>()); @@ -309,8 +530,7 @@ //鏈�灏忓叕鍊嶆暟绠楁硶 minCommonMultiple(cardItemInfoList); //鎺掑簭锛岄檷搴� - cardItemInfoList = cardItemInfoList.stream().sorted(Comparator.comparing(CardItemInfo::getCommonMultiple).reversed()) - .collect(Collectors.toList()); + cardItemInfoList = cardItemInfoList.stream().sorted(Comparator.comparing(CardItemInfo::getCommonMultiple).reversed()).collect(Collectors.toList()); for(CardItemInfo cardItemInfo:cardItemInfoList){ if(deductionSurp <= 0){ break; @@ -347,7 +567,7 @@ cardItemInfoList = cardItemInfoList.stream().sorted(Comparator.comparing(CardItemInfo::getCommonMultiple).reversed()).collect(Collectors.toList()); NMSet = new HashSet<>(); - //宸茬粡閫�娆剧殑鍏堢畻 + //宸茬粡閫�娆剧殑鍏堢畻锛屽彲浠ョ畻鏄凡閫変釜鏁� for (Map.Entry <String, UserCardUsed> entry : userCardUsedMap.entrySet()) { for(CardItemInfo cardItemInfo:cardItemInfoList){ if(cardItemInfo.getId().equals(entry.getValue().getCardItemInfoId())){ @@ -427,10 +647,10 @@ } /**璁㈠崟鐢熸垚鍐嶇敓淇变箰閮ㄤ細鍛�*/ - public static void createClubMember(Integer type,OrdersTotal ordersTotal,MarketSystem marketSystem,CommonService commonService){ + public static void createClubMember(Integer type,OrdersTotal ordersTotal,MarketSystem marketSystem,UserClubMemberService userClubMemberService){ Integer durationType = UserClubMember.DURATION_TYPE_PARAGRAPH; - Date startTime = null; + Date startTime = ordersTotal.getPayTime(); Date endTime = null; if(marketSystem.getDurationType() == MarketSystem.DURATION_TYPE_ALL){ durationType = UserClubMember.DURATION_TYPE_ALL; @@ -438,7 +658,6 @@ startTime = marketSystem.getDurationStart(); endTime = marketSystem.getDurationEnd(); }else{ - startTime = ordersTotal.getPayTime(); endTime = startTime; if(marketSystem.getDurationYear() != null){ endTime = DateUtil.addYear(endTime,marketSystem.getDurationYear()); @@ -452,34 +671,29 @@ //鏃堕棿绮剧‘鍒板綋澶╂渶鍚庝竴绉� endTime = DateUtil.dayToEndDateNoMillisecond(endTime); } - insertClubMember(type,durationType,startTime,endTime,UserClubMember.SOURCE_TYPE_ORDER,ordersTotal.getId(),marketSystem.getId(),ordersTotal.getUserId(),commonService); + userClubMemberService.createClubMember(type,durationType,startTime,endTime,UserClubMember.SOURCE_TYPE_ORDER,ordersTotal.getId(),marketSystem.getId(),ordersTotal.getUserId()); } - /**淇濆瓨淇变箰閮ㄤ細鍛�*/ - public static void insertClubMember(Integer type,Integer durationType,Date startTime,Date endTime,Integer sourceType,String sourceId,String sourceOtherId - ,String userId,CommonService commonService){ - + /**鑾峰彇鏈夋晥鐨勪勘涔愰儴浼氬憳*/ + public static UserClubMember getUserClubMember(String userId,Integer marketType,Date curTime,CommonService commonService){ SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> values = new HashMap<>(); - //鏈夌粦瀹氱殑鍏ㄩ儴杩涜鍙栨秷 - values.put("type",type); - values.put("status",UserClubMember.STATUS_NORMAL); + values.put("type",marketType); + values.put("status", UserClubMember.STATUS_NORMAL); values.put("userId",userId); - sqlSentence.sqlUpdate(" isDel = 2 WHERE isDel = 0 AND type = #{m.type} AND status = #{m.status} AND userId = #{m.userId}",values); - commonService.updateWhere(UserClubMemberMapper.class,sqlSentence); + sqlSentence.sqlSentence("SELECT * FROM user_club_member WHERE isDel = 0 AND type = #{m.type} AND status = #{m.status} AND userId = #{m.userId} ORDER BY durationType ASC,startTime DESC",values); + List<UserClubMember> userClubMemberList = commonService.selectList(UserClubMemberMapper.class,sqlSentence); - UserClubMember userClubMember = new UserClubMember(); - userClubMember.setType(type); - userClubMember.setStatus(UserClubMember.STATUS_NORMAL); - userClubMember.setDurationType(durationType); - userClubMember.setStartTime(startTime); - userClubMember.setEndTime(endTime); - userClubMember.setSourceType(sourceType); - userClubMember.setSourceId(sourceId); - userClubMember.setSourceOtherId(sourceOtherId); - userClubMember.setUserId(userId); - commonService.insert(UserClubMemberMapper.class,userClubMember); + for(UserClubMember userClubMember:userClubMemberList){ + if(userClubMember.getEndTime() != null){ + if(userClubMember.getEndTime().getTime() < curTime.getTime()){ + continue; + } + } + return userClubMember; + } + return null; } } diff --git a/phi_platform_common/src/main/resources/mapper/platform/ProjectTypeRelationMapper.xml b/phi_platform_common/src/main/resources/mapper/platform/ProjectTypeRelationMapper.xml new file mode 100644 index 0000000..6660edd --- /dev/null +++ b/phi_platform_common/src/main/resources/mapper/platform/ProjectTypeRelationMapper.xml @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE mapper +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<!-- namespace:璇apper.xml鏄犲皠鏂囦欢鐨� 鍞竴鏍囪瘑 --> +<mapper namespace="com.hx.phip.dao.mapper.ProjectTypeRelationMapper"> + + <!-- 鏁翠釜瀹炰綋绫讳慨鏀癸紝琛ㄥ瓧娈�=瀹炰綋绫诲瓧娈�--> + <sql id="Update_Column_All"> + <trim prefixOverrides=","> + ,moduleType = #{moduleType},traditionFirstTypeName = #{traditionFirstTypeName},traditionSecondTypeName = #{traditionSecondTypeName},skuType = #{skuType},skuId = #{skuId},skuNo = #{skuNo},skuName = #{skuName},itemName = #{itemName},isDel = #{isDel},createTime = #{createTime},editTime = #{editTime} + </trim> + </sql> + + <!-- 鍚庣画閫氳繃 namespace.id--> + <!--parameterType:杈撳叆鍙傛暟鐨勭被鍨� + resultType锛氭煡璇㈣繑鍥炵粨鏋滃�肩殑绫诲瀷 锛岃繑鍥炵被鍨� --> + <insert id="insert" parameterType="com.hx.phiappt.model.project.ProjectTypeRelation"> + <selectKey keyProperty="id" resultType="String" order="BEFORE"> + select replace(uuid(),'-','') from dual + </selectKey> + insert into project_type_relation (id,moduleType,traditionFirstTypeName,traditionSecondTypeName,skuType,skuId,skuNo,skuName,itemName,isDel,createTime,editTime) values (#{id},#{moduleType},#{traditionFirstTypeName},#{traditionSecondTypeName},#{skuType},#{skuId},#{skuNo},#{skuName},#{itemName},#{isDel},#{createTime},#{editTime}) + </insert> + + <insert id="insertById" parameterType="com.hx.phiappt.model.project.ProjectTypeRelation"> + insert into project_type_relation (id,moduleType,traditionFirstTypeName,traditionSecondTypeName,skuType,skuId,skuNo,skuName,itemName,isDel,createTime,editTime) values (#{id},#{moduleType},#{traditionFirstTypeName},#{traditionSecondTypeName},#{skuType},#{skuId},#{skuNo},#{skuName},#{itemName},#{isDel},#{createTime},#{editTime}) + </insert> + + <select id="selectList" resultType="com.hx.phiappt.model.project.ProjectTypeRelation" parameterType="com.hx.mybatisTool.SqlSentence" > + ${sqlSentence} + </select> + + <select id="selectListMap" resultType="java.util.Map" parameterType="com.hx.mybatisTool.SqlSentence" > + ${sqlSentence} + </select> + + <select id="selectOne" resultType="com.hx.phiappt.model.project.ProjectTypeRelation" parameterType="com.hx.mybatisTool.SqlSentence" > + ${sqlSentence} + </select> + + <select id="selectOneMap" resultType="java.util.Map" parameterType="com.hx.mybatisTool.SqlSentence" > + ${sqlSentence} + </select> + + <select id="selectCount" resultType="int" parameterType="com.hx.mybatisTool.SqlSentence" > + select + COUNT(*) + from project_type_relation + WHERE ${sqlSentence} + </select> + + <select id="selectCountSql" resultType="int" parameterType="com.hx.mybatisTool.SqlSentence" > + ${sqlSentence} + </select> + + <select id="selectOneByKey" resultType="com.hx.phiappt.model.project.ProjectTypeRelation" parameterType="java.lang.Object" > + select + id,moduleType,traditionFirstTypeName,traditionSecondTypeName,skuType,skuId,skuNo,skuName,itemName,isDel,createTime,editTime + from project_type_relation + WHERE id = #{value} + </select> + + <select id="selectOneByKeyBlob" resultType="com.hx.phiappt.model.project.ProjectTypeRelation" parameterType="java.lang.Object" > + select + id,moduleType,traditionFirstTypeName,traditionSecondTypeName,skuType,skuId,skuNo,skuName,itemName,isDel,createTime,editTime + from project_type_relation + WHERE id = #{value} + </select> + + <update id="updateWhere" parameterType="com.hx.mybatisTool.SqlSentence"> + update + project_type_relation + SET ${sqlSentence} + </update> + + <update id="updateAll" parameterType="com.hx.phiappt.model.project.ProjectTypeRelation"> + update project_type_relation + SET <include refid="Update_Column_All"/> + WHERE id = #{id} + </update> + + <delete id="deleteWhere" parameterType="com.hx.mybatisTool.SqlSentence"> + delete from project_type_relation WHERE ${sqlSentence} + </delete> + + <delete id="deleteById" parameterType="java.lang.Object"> + delete from project_type_relation WHERE id = #{value} + </delete> + +</mapper> \ No newline at end of file diff --git a/phi_platform_common/src/main/resources/mapper/platform/UserClubMemberMapper.xml b/phi_platform_common/src/main/resources/mapper/platform/UserClubMemberMapper.xml index 38ef75e..448bcd9 100644 --- a/phi_platform_common/src/main/resources/mapper/platform/UserClubMemberMapper.xml +++ b/phi_platform_common/src/main/resources/mapper/platform/UserClubMemberMapper.xml @@ -8,7 +8,7 @@ <!-- 鏁翠釜瀹炰綋绫讳慨鏀癸紝琛ㄥ瓧娈�=瀹炰綋绫诲瓧娈�--> <sql id="Update_Column_All"> <trim prefixOverrides=","> - ,type = #{type},status = #{status},startTime = #{startTime},endTime = #{endTime},sourceType = #{sourceType},sourceId = #{sourceId},discardSource = #{discardSource},discardSourceId = #{discardSourceId},discardReason = #{discardReason},userId = #{userId},isDel = #{isDel},createTime = #{createTime},editTime = #{editTime} + ,type = #{type},status = #{status},durationType = #{durationType},startTime = #{startTime},endTime = #{endTime},sourceType = #{sourceType},sourceId = #{sourceId},sourceOtherId = #{sourceOtherId},discardSource = #{discardSource},discardSourceId = #{discardSourceId},discardReason = #{discardReason},userId = #{userId},isDel = #{isDel},createTime = #{createTime},editTime = #{editTime} </trim> </sql> @@ -19,11 +19,11 @@ <selectKey keyProperty="id" resultType="String" order="BEFORE"> select replace(uuid(),'-','') from dual </selectKey> - insert into user_club_member (id,type,status,startTime,endTime,sourceType,sourceId,discardSource,discardSourceId,discardReason,userId,isDel,createTime,editTime) values (#{id},#{type},#{status},#{startTime},#{endTime},#{sourceType},#{sourceId},#{discardSource},#{discardSourceId},#{discardReason},#{userId},#{isDel},#{createTime},#{editTime}) + insert into user_club_member (id,type,status,durationType,startTime,endTime,sourceType,sourceId,sourceOtherId,discardSource,discardSourceId,discardReason,userId,isDel,createTime,editTime) values (#{id},#{type},#{status},#{durationType},#{startTime},#{endTime},#{sourceType},#{sourceId},#{sourceOtherId},#{discardSource},#{discardSourceId},#{discardReason},#{userId},#{isDel},#{createTime},#{editTime}) </insert> <insert id="insertById" parameterType="com.hx.phiappt.model.user.club.UserClubMember"> - insert into user_club_member (id,type,status,startTime,endTime,sourceType,sourceId,discardSource,discardSourceId,discardReason,userId,isDel,createTime,editTime) values (#{id},#{type},#{status},#{startTime},#{endTime},#{sourceType},#{sourceId},#{discardSource},#{discardSourceId},#{discardReason},#{userId},#{isDel},#{createTime},#{editTime}) + insert into user_club_member (id,type,status,durationType,startTime,endTime,sourceType,sourceId,sourceOtherId,discardSource,discardSourceId,discardReason,userId,isDel,createTime,editTime) values (#{id},#{type},#{status},#{durationType},#{startTime},#{endTime},#{sourceType},#{sourceId},#{sourceOtherId},#{discardSource},#{discardSourceId},#{discardReason},#{userId},#{isDel},#{createTime},#{editTime}) </insert> <select id="selectList" resultType="com.hx.phiappt.model.user.club.UserClubMember" parameterType="com.hx.mybatisTool.SqlSentence" > @@ -55,14 +55,14 @@ <select id="selectOneByKey" resultType="com.hx.phiappt.model.user.club.UserClubMember" parameterType="java.lang.Object" > select - id,type,status,startTime,endTime,sourceType,sourceId,discardSource,discardSourceId,discardReason,userId,isDel,createTime,editTime + id,type,status,durationType,startTime,endTime,sourceType,sourceId,sourceOtherId,discardSource,discardSourceId,discardReason,userId,isDel,createTime,editTime from user_club_member WHERE id = #{value} </select> <select id="selectOneByKeyBlob" resultType="com.hx.phiappt.model.user.club.UserClubMember" parameterType="java.lang.Object" > select - id,type,status,startTime,endTime,sourceType,sourceId,discardSource,discardSourceId,discardReason,userId,isDel,createTime,editTime + id,type,status,durationType,startTime,endTime,sourceType,sourceId,sourceOtherId,discardSource,discardSourceId,discardReason,userId,isDel,createTime,editTime from user_club_member WHERE id = #{value} </select> diff --git a/phi_platform_user/src/main/java/com/hx/phip/common/TestController.java b/phi_platform_user/src/main/java/com/hx/phip/common/TestController.java index 3caa431..2efaa03 100644 --- a/phi_platform_user/src/main/java/com/hx/phip/common/TestController.java +++ b/phi_platform_user/src/main/java/com/hx/phip/common/TestController.java @@ -2,19 +2,22 @@ import com.hx.common.BaseController; import com.hx.phiappt.model.Employee; +import com.hx.phiappt.model.market.system.MarketSystem; import com.hx.phip.dao.mapper.EmployeeMapper; import com.hx.phip.tool.EmployeeTool; +import com.hx.phip.service.tool.club.UserCluebMemberServiceTool; import com.hx.redis.RedisUtil; +import com.hz.crm.vo.order.OrderPayVo; import com.platform.resultTool.PlatformResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; -import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; @@ -32,22 +35,16 @@ private static final Logger logger = LoggerFactory.getLogger(TestController.class.getName()); @Resource private RedisUtil redisUtil; - + @Resource + private UserCluebMemberServiceTool userCluebMemberServiceTool; /** - * + *淇变箰閮ㄤ細鍛樻祴璇� */ - @RequestMapping(value = "/redi",method = RequestMethod.POST) - public PlatformResult typeList(HttpServletRequest request) { - - Map<String,Object> data = new HashMap<>(); - - String key = "app_id"; - - redisUtil.set(key,"娴嬭瘯redis"); - data.put("data",redisUtil.get(key)); - - return PlatformResult.success(data); + @RequestMapping(value = "/club/member",method = RequestMethod.POST) + public PlatformResult typeList(@RequestBody OrderPayVo orderPayVo) { + userCluebMemberServiceTool.orderChekMember(orderPayVo.getOrderId(), null,null,MarketSystem.TYPE_REGENERATION); + return PlatformResult.success(); } /** diff --git a/phi_platform_user/src/main/java/com/hx/phip/controller/order/OrderControllerV2.java b/phi_platform_user/src/main/java/com/hx/phip/controller/order/OrderControllerV2.java index f098e3e..220f6e8 100644 --- a/phi_platform_user/src/main/java/com/hx/phip/controller/order/OrderControllerV2.java +++ b/phi_platform_user/src/main/java/com/hx/phip/controller/order/OrderControllerV2.java @@ -8,7 +8,6 @@ * @Description: */ -import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hx.common.BaseController; import com.hx.common.service.CommonService; @@ -18,14 +17,13 @@ import com.hx.phiappt.common.PlatformConstants; import com.hx.phiappt.common.UserStatusConstants; import com.hx.phiappt.constants.tool.PerformanceInfoTool; -import com.hx.phiappt.constants.tool.UserInfoTool; import com.hx.phiappt.constants.tool.UserStatusTool; import com.hx.phiappt.constants.tool.clubEquity.ClubEquityTool; import com.hx.phiappt.dao.mapper.CouponNumberMapper; import com.hx.phiappt.model.*; import com.hx.phiappt.model.coupon.Coupon; import com.hx.phiappt.model.coupon.CouponNumber; -import com.hx.phiappt.model.micro.MicroRecord; +import com.hx.phiappt.model.market.system.MarketSystem; import com.hx.phiappt.model.order.*; import com.hx.phiappt.model.performance.PerformanceInfo; import com.hx.phiappt.model.userStatus.UserStatusLog; @@ -39,11 +37,11 @@ import com.hx.phip.service.UserService; import com.hx.phip.service.init.OrderInitService; import com.hx.phip.service.order.OrderServiceV2; +import com.hx.phip.service.tool.club.UserCluebMemberServiceTool; import com.hx.phip.util.api.ApiOrderUtil; import com.hx.phip.util.api.OrderCreateUtil; import com.hx.phip.util.api.OrderPayMoneyUtil; import com.hx.phip.util.api.SendNoticeUtil; -import com.hx.util.DateUtil; import com.hx.util.StringUtils; import com.hx.util.thread.ExecutorServiceTool; import com.hz.crm.dto.oldBrinNew.OldBrinNewDto; @@ -106,6 +104,8 @@ private SUserTagInfoService sUserTagInfoService; @Resource private BotoxClubConfig botoxClubConfig; + @Resource + private UserCluebMemberServiceTool userCluebMemberServiceTool; /**鍥哄畾绾跨▼姹�-鏀�*/ public static ExecutorServiceTool threadPool = new ExecutorServiceTool(5,100); @@ -364,9 +364,10 @@ if(map!=null && map.containsKey("orderId")){ OrdersTotal sucOrdersTotal=commonService.selectOneByKey(OrdersTotalMapper.class,map.get("orderId")); if(OrderTotalConstants.PAY_STATUS_SUC==sucOrdersTotal.getPayStatus()){ + //澶勭悊鍐嶇敓淇变箰閮ㄤ細鍛� + threadPool.getThreadPool().execute(() -> userCluebMemberServiceTool.orderChekMember(ordersTotal.getId(),null,null,MarketSystem.TYPE_REGENERATION)); //澶勭悊鑰佸甫鏂� JSONObject commissionObject = handOrderOldNew(ordersTotal, user); - //鏇存柊鐢ㄦ埛鏈�鍚庝笅鍗曟椂闂� updateUserLastTime(ordersTotal, user); 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 5be72e5..3efcc2f 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 @@ -16,6 +16,7 @@ import com.hx.phiappt.model.consume.ConsumeNotify; import com.hx.phiappt.model.consume.ConsumePay; import com.hx.phiappt.model.coupon.CouponOrderDiscountLog; +import com.hx.phiappt.model.market.system.MarketSystem; import com.hx.phiappt.model.order.*; import com.hx.phiappt.model.performance.PerformanceInfo; import com.hx.phiappt.model.refund.*; @@ -26,6 +27,7 @@ import com.hx.phiappt.vo.refund.RefundCashVo; import com.hx.phip.config.BotoxClubConfig; import com.hx.phip.config.CustomParameter; +import com.hx.phip.controller.order.OrderControllerV2; import com.hx.phip.dao.mapper.*; import com.hx.phip.service.CreateNoService; import com.hx.phip.service.PaymentMethodService; @@ -35,6 +37,7 @@ import com.hx.phip.service.refund.RefundRecordItemService; import com.hx.phip.service.refund.RefundRecordMethodService; import com.hx.phip.service.refund.RefundRecordService; +import com.hx.phip.service.tool.club.UserCluebMemberServiceTool; import com.hx.phip.service.userLevel.UserLevelRuleService; import com.hx.phip.tool.CreateNo; import com.hx.phip.tool.deduction.DeductionSingleTool; @@ -144,6 +147,8 @@ private SUserTagInfoService sUserTagInfoService; @Resource private BotoxClubConfig botoxClubConfig; + @Resource + private UserCluebMemberServiceTool userCluebMemberServiceTool; /** * 鑾峰彇閫�娆鹃〉闈㈣鎯� @@ -1800,6 +1805,18 @@ //鎾ら攢銆愪繚濡ラ�備細鍛樸�戞爣绛� ClubEquityTool.refundCancelLabel(commonService,sUserTagInfoService,ordersTotal,botoxClubConfig.getLabelTypeNo(),botoxClubConfig.getLabelNo()); + //淇变箰閮ㄤ細鍛樺鐞� + if(StringUtils.noNull(refundRecord.getOrderId())){ + RefundRecord finalRefundRecord = refundRecord; + OrderControllerV2.threadPool.getThreadPool().execute(() ->{ + try{ + Thread.sleep(5000); + }catch (Exception ignored){ + } + userCluebMemberServiceTool.refundChekMember(finalRefundRecord.getOrderId(),null, finalRefundRecord.getId(), MarketSystem.TYPE_REGENERATION); + }); + } + return data; } /** @@ -2785,6 +2802,15 @@ ordersNodeLog.setOrderId(ordersTotal.getId()); commonService.insert(OrdersNodeLogMapper.class,ordersNodeLog); + //淇变箰閮ㄤ細鍛� + OrderControllerV2.threadPool.getThreadPool().execute(() ->{ + try{ + Thread.sleep(5000); + }catch (Exception ignored){ + } + userCluebMemberServiceTool.refundCancelChekMember(refundRecord.getOrderId(),null, refundRecord.getId(), MarketSystem.TYPE_REGENERATION); + }); + } /**棰濆鎿嶄綔锛屼笉褰卞搷涓绘祦绋�*/ diff --git a/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderPayMoneyUtil.java b/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderPayMoneyUtil.java index f331757..cb03f02 100644 --- a/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderPayMoneyUtil.java +++ b/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderPayMoneyUtil.java @@ -2102,14 +2102,15 @@ }else{ //-----澶嶈喘璁㈠崟 //鏌ユ壘琚個璇蜂汉涓嬪崟锛堝垵璇婂崟) - //澶嶈喘鍗曟暟閲忥紝鏄湁鐜伴噾娑堣垂鐨勫璐崟 + //澶嶈喘鍗曟暟閲忥紝鏄湁鐜伴噾娑堣垂鐨勫璐崟锛屽垵璇婂崟鍚�6鏈堝唴 values.clear(); values.put("userId",user.getId()); values.put("newId",ordersTotal.getId()); sqlSentence.sqlSentence("SELECT ot.id,ot.payTime,(SELECT COUNT(*) FROM orders_total a" + " JOIN orders_info info2 ON info2.orderId = a.id" + " WHERE a.isDel = 0 AND a.userId = #{m.userId} AND a.status IN(2,3,9)" + - " AND a.payStatus = 3 AND info2.isBothTheOne = 3 AND a.snapPayTotal > 0 AND a.id != #{m.newId}) AS num" + + " AND a.payTime >= ot.payTime AND a.payTime <= DATE_FORMAT(DATE_ADD(ot.payTime,INTERVAL 6 MONTH),'%Y-%m-%d 23:59:59')" + + " AND a.payStatus = 3 AND info2.isBothTheOne = 3 AND info2.snapPayTotal > 0 AND a.id != #{m.newId}) AS num" + " FROM orders_total ot" + " JOIN orders_info info ON info.orderId = ot.id" + " WHERE ot.isDel = 0 AND ot.userId = #{m.userId} AND ot.status IN(2,3,9)" + -- Gitblit v1.8.0