From d83d729f80576bb4c7e73bcfff5c403a23f23b82 Mon Sep 17 00:00:00 2001
From: chenjiahe <763432473@qq.com>
Date: 星期五, 19 一月 2024 10:59:41 +0800
Subject: [PATCH] 再生俱乐部首次提交

---
 phi_platform_common/src/main/resources/mapper/platform/UserClubMemberMapper.xml         |   90 +++++++
 phi_platform_common/src/main/java/com/hx/phip/dao/mapper/MarketSystemMapper.java        |   37 +++
 phi_platform_common/src/main/java/com/hx/phip/dao/mapper/UserClubMemberMapper.java      |   37 +++
 phi_platform_common/src/main/resources/mapper/platform/MarketSystemMapper.xml           |   90 +++++++
 phi_platform_common/src/main/java/com/hx/phip/AutoDomeUtil.java                         |    5 
 phi_platform_common/src/main/java/com/hx/phip/dao/mapper/MarketSystemProjectMapper.java |   37 +++
 phi_platform_common/src/main/java/com/hx/phip/tool/club/UserCluebMemberTool.java        |  285 +++++++++++++++++++++++
 phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java               |    4 
 phi_platform_common/src/main/resources/mapper/platform/MarketSystemProjectMapper.xml    |   90 +++++++
 9 files changed, 672 insertions(+), 3 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 6cbda0b..1b8b115 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
@@ -10,10 +10,13 @@
 import com.hx.phiappt.model.cardItem.CardEquity;
 import com.hx.phiappt.model.consume.ConsumeNotify;
 import com.hx.phiappt.model.consume.PayNo;
+import com.hx.phiappt.model.market.system.MarketSystem;
+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.refund.*;
 import com.hx.phiappt.model.user.*;
+import com.hx.phiappt.model.user.club.UserClubMember;
 
 /**
  * 鑷姩鐢熸垚宸ュ叿 
@@ -42,7 +45,7 @@
 		urlData.serviceImplUrlData(controllerPackRoot,packageName + ".service.impl");
 		urlData.mapperUrlData(commonPackRootResourse, "mapper.platform");
 
-		Class<?> clas = OrderInfo.class;
+		Class<?> clas = UserClubMember.class;
 		//dao
 		 GeneratorUtil.generatorDao(clas,urlData);
 		//mapper
diff --git a/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/MarketSystemMapper.java b/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/MarketSystemMapper.java
new file mode 100644
index 0000000..764a525
--- /dev/null
+++ b/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/MarketSystemMapper.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.market.system.MarketSystem;
+
+public interface MarketSystemMapper {
+	/**鏂板锛岃繑鍥炰富閿�*/
+    int insert(MarketSystem marketSystem);
+    /**鏂板锛岃繑鍥炰富閿�*/
+    int insertById(MarketSystem marketSystem);
+    /**鏌ヨ鏉℃暟*/
+    int selectCount(SqlSentence sqlSentence);
+    /**鏌ヨ鏉℃暟*/
+    int selectCountSql(SqlSentence sqlSentence);
+    /**鏌ヨ鍒楄〃锛岃繑鍥炲疄浣撶被鐨凩ist*/
+    List<MarketSystem> selectList(SqlSentence sqlSentence);
+    /**鏌ヨ鍒楄〃锛岃繑鍥濵ap鐨凩ist*/
+    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
+    /**鏌ヨ锛岃繑鍥炲崟涓疄浣�*/
+    MarketSystem selectOne(SqlSentence sqlSentence);
+    /**鏌ヨ锛岃繑鍥炲崟涓猰ap*/
+    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
+    /**鏌ヨ锛岃繑鍥炲疄浣撶被娌℃湁澶ф暟鎹殑*/
+    MarketSystem selectOneByKey(Object object);
+    /**鏌ヨ锛岃繑鍥炲疄浣撶被鏈夊ぇ鏁版嵁鐨�*/
+    MarketSystem selectOneByKeyBlob(Object object);
+    /**鏇存柊锛岃繑鍥炴洿鏂版暟閲�*/
+    int updateWhere(SqlSentence sqlSentence);
+    /**鏇存柊锛岃繑鍥炴洿鏂版暟閲�*/
+    int updateAll(MarketSystem marketSystem);
+    /**鍒犻櫎锛岃繑鍥炲垹闄ゆ暟閲�*/
+    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/dao/mapper/MarketSystemProjectMapper.java b/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/MarketSystemProjectMapper.java
new file mode 100644
index 0000000..bcb5350
--- /dev/null
+++ b/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/MarketSystemProjectMapper.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.market.system.MarketSystemProject;
+
+public interface MarketSystemProjectMapper {
+	/**鏂板锛岃繑鍥炰富閿�*/
+    int insert(MarketSystemProject marketSystemProject);
+    /**鏂板锛岃繑鍥炰富閿�*/
+    int insertById(MarketSystemProject marketSystemProject);
+    /**鏌ヨ鏉℃暟*/
+    int selectCount(SqlSentence sqlSentence);
+    /**鏌ヨ鏉℃暟*/
+    int selectCountSql(SqlSentence sqlSentence);
+    /**鏌ヨ鍒楄〃锛岃繑鍥炲疄浣撶被鐨凩ist*/
+    List<MarketSystemProject> selectList(SqlSentence sqlSentence);
+    /**鏌ヨ鍒楄〃锛岃繑鍥濵ap鐨凩ist*/
+    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
+    /**鏌ヨ锛岃繑鍥炲崟涓疄浣�*/
+    MarketSystemProject selectOne(SqlSentence sqlSentence);
+    /**鏌ヨ锛岃繑鍥炲崟涓猰ap*/
+    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
+    /**鏌ヨ锛岃繑鍥炲疄浣撶被娌℃湁澶ф暟鎹殑*/
+    MarketSystemProject selectOneByKey(Object object);
+    /**鏌ヨ锛岃繑鍥炲疄浣撶被鏈夊ぇ鏁版嵁鐨�*/
+    MarketSystemProject selectOneByKeyBlob(Object object);
+    /**鏇存柊锛岃繑鍥炴洿鏂版暟閲�*/
+    int updateWhere(SqlSentence sqlSentence);
+    /**鏇存柊锛岃繑鍥炴洿鏂版暟閲�*/
+    int updateAll(MarketSystemProject marketSystemProject);
+    /**鍒犻櫎锛岃繑鍥炲垹闄ゆ暟閲�*/
+    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/dao/mapper/UserClubMemberMapper.java b/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/UserClubMemberMapper.java
new file mode 100644
index 0000000..bb2adf9
--- /dev/null
+++ b/phi_platform_common/src/main/java/com/hx/phip/dao/mapper/UserClubMemberMapper.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.user.club.UserClubMember;
+
+public interface UserClubMemberMapper {
+	/**鏂板锛岃繑鍥炰富閿�*/
+    int insert(UserClubMember userClubMember);
+    /**鏂板锛岃繑鍥炰富閿�*/
+    int insertById(UserClubMember userClubMember);
+    /**鏌ヨ鏉℃暟*/
+    int selectCount(SqlSentence sqlSentence);
+    /**鏌ヨ鏉℃暟*/
+    int selectCountSql(SqlSentence sqlSentence);
+    /**鏌ヨ鍒楄〃锛岃繑鍥炲疄浣撶被鐨凩ist*/
+    List<UserClubMember> selectList(SqlSentence sqlSentence);
+    /**鏌ヨ鍒楄〃锛岃繑鍥濵ap鐨凩ist*/
+    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
+    /**鏌ヨ锛岃繑鍥炲崟涓疄浣�*/
+    UserClubMember selectOne(SqlSentence sqlSentence);
+    /**鏌ヨ锛岃繑鍥炲崟涓猰ap*/
+    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
+    /**鏌ヨ锛岃繑鍥炲疄浣撶被娌℃湁澶ф暟鎹殑*/
+    UserClubMember selectOneByKey(Object object);
+    /**鏌ヨ锛岃繑鍥炲疄浣撶被鏈夊ぇ鏁版嵁鐨�*/
+    UserClubMember selectOneByKeyBlob(Object object);
+    /**鏇存柊锛岃繑鍥炴洿鏂版暟閲�*/
+    int updateWhere(SqlSentence sqlSentence);
+    /**鏇存柊锛岃繑鍥炴洿鏂版暟閲�*/
+    int updateAll(UserClubMember userClubMember);
+    /**鍒犻櫎锛岃繑鍥炲垹闄ゆ暟閲�*/
+    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/tool/club/UserCluebMemberTool.java b/phi_platform_common/src/main/java/com/hx/phip/tool/club/UserCluebMemberTool.java
new file mode 100644
index 0000000..114a1cb
--- /dev/null
+++ b/phi_platform_common/src/main/java/com/hx/phip/tool/club/UserCluebMemberTool.java
@@ -0,0 +1,285 @@
+package com.hx.phip.tool.club;
+
+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.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;
+import com.hx.phiappt.model.market.system.MarketSystemProject;
+import com.hx.phiappt.model.order.OrderItem;
+import com.hx.phiappt.model.order.OrderItemSon;
+import com.hx.phiappt.model.order.OrdersTotal;
+import com.hx.phiappt.model.project.ProjectTypeRelation;
+import com.hx.phiappt.model.user.club.UserClubMember;
+import com.hx.phip.dao.mapper.*;
+import com.hx.util.DateUtil;
+
+import java.util.*;
+
+/**鐢ㄦ埛淇变箰閮ㄤ細鍛�
+ * @author CJH
+ */
+public class UserCluebMemberTool {
+
+    /**璁㈠崟涓嬪崟缁撹处鏍¢獙鏄惁绗﹀悎浼氬憳鏉′欢*/
+    public static void orderChekMember(String orderId,Integer marketType, CommonService commonService){
+
+        OrdersTotal ordersTotal = commonService.selectOneByKey(OrdersTotalMapper.class,orderId);
+        if(ordersTotal == null){
+            throw new TipsException("璁㈠崟鏍囪瘑閿欒锛�");
+        }
+        //鍏呭�煎崟璺宠繃
+        if(OrderTotalConstants.TYPE_RECHARGE.equals(ordersTotal.getType())){
+            return;
+        }
+        //鏈敮浠樿烦杩�
+        if(ordersTotal.getPayStatus() != OrderTotalConstants.PAY_STATUS_SUC){
+            return;
+        }
+
+        //鏌ヨ娲诲姩閰嶇疆
+        SqlSentence sqlSentence = new SqlSentence();
+        Map<String,Object> values = new HashMap<>();
+
+        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);
+        if(marketSystem == null){
+            return;
+        }
+
+        //---鍒ゆ柇鏄惁鍦ㄦ椿鍔ㄦ椂闂村唴
+        if(marketSystem.getStartTime() != null){
+            if(ordersTotal.getPayTime().getTime() < marketSystem.getStartTime().getTime()){
+                return;
+            }
+        }
+        if(marketSystem.getEndTime() != null){
+            if(ordersTotal.getPayTime().getTime() > marketSystem.getEndTime().getTime()){
+                return;
+            }
+        }
+
+        //----鑾峰彇鎸囧畾鐨勯」鐩厤缃�
+        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);
+
+        //鎸囧畾娲诲姩椤圭洰缂栧彿鍖归厤瀛樺偍
+        Set<String> skuNoSet = new HashSet<>();
+        StringBuilder itemNameSql = new StringBuilder();
+        for(MarketSystemProject marketSystemProject:marketSystemProjectList){
+            if(marketSystemProject.getType() == MarketSystemProject.TYPE_PROJECT_MAPPER){
+                if(itemNameSql.length() > 0){
+                    itemNameSql.append(",");
+                }
+                itemNameSql.append("'").append(marketSystemProject.getTypeCode()).append("'");
+            }else{
+                skuNoSet.add(marketSystemProject.getTypeCode());
+            }
+        }
+        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);
+            List<ProjectTypeRelation> projectTypeRelationList = commonService.selectList(ProjectTypeRelationMapper.class,sqlSentence);
+            for(ProjectTypeRelation projectTypeRelation:projectTypeRelationList){
+                skuNoSet.add(projectTypeRelation.getSkuNo());
+            }
+        }
+
+        //---鑾峰彇璐拱鐨勫瓙鍗�
+        values.clear();
+        values.put("orderId",ordersTotal.getId());
+        sqlSentence.sqlSentence("SELECT id,type,commonId,goodsNo,goodsName,usedTotal,hasReNum FROM order_item WHERE isDel = 0 AND orderId = #{m.orderId}",values);
+        List<OrderItem> orderItemList = commonService.selectList(OrderItemMapper.class,sqlSentence);
+
+        //宸茬粡绠椾簡鐤楃▼鏁扮殑椤圭洰缂栧彿
+        Set<String> mateSkuNoSet = new HashSet<>();
+        //鎬荤枟绋嬫暟锛屾墍鏈夌殑椤圭洰鐤楃▼鏁版�诲拰
+        int cureNum = 0;
+
+        //瀛樺偍鍗¢」鎵�鏈夌殑瀛愰」锛宬鍊硷細鏉冪泭鏍囪瘑
+        Map<String,List<CardItemInfo>> cardItemInfoMapList;
+        List<OrderItemSon> orderItemSonList;
+        List<CardEquity> cardEquityList;
+        List<CardItemInfo> cardItemInfoList;
+        int cureItemMax;
+        int cureItemNum;
+        int deductionSurp;
+        int deductionNum;
+        for(OrderItem orderItem:orderItemList){
+            if(OrderItemConstants.TYPE_PROJECT.equals(orderItem.getType())){
+                //椤圭洰锛屾病鏈夊寘鍚�
+                if(skuNoSet.contains(orderItem.getGoodsNo())){
+                    //鐤楃▼娆℃暟鍙犲姞锛岄��娆剧殑涔熼渶瑕佸噺鍘�
+                    cureNum = cureNum+orderItem.getUsedTotal()-orderItem.getHasReNum();
+                }
+            }else if(OrderItemConstants.TYPE_PROMOTION.equals(orderItem.getType())){
+                //淇冮攢
+                orderItemSonList = getOrderItemSonList(orderItem.getId(),OrderItemConstants.TYPE_PROJECT,commonService);
+                for(OrderItemSon orderItemSon:orderItemSonList){
+                    if(skuNoSet.contains(orderItemSon.getGoodsNo())){
+                        //鐤楃▼娆℃暟鍙犲姞锛岄��娆剧殑涔熼渶瑕佸噺鍘�
+                        cureNum = cureNum+orderItem.getUsedTotal()-orderItem.getHasReNum();
+                    }
+                }
+            }else if(OrderItemConstants.TYPE_CARD.equals(orderItem.getType())){
+                //鍗¢」锛屾敞鎰忥紝涓嶆槸鍗″寘
+                //TODO 閫�娆炬病鏈夊噺鍘�
+                cardEquityList = getCardEquityList(orderItem.getCommonId(),commonService);
+                cardItemInfoMapList = getCardItemInfoList(orderItem.getCommonId(),commonService);
+                for(CardEquity cardEquity:cardEquityList){
+                    cardItemInfoList = cardItemInfoMapList.get(cardEquity.getId());
+                    if(cardItemInfoList==null || cardItemInfoList.size()==0){
+                        continue;
+                    }
+                    //鍒ゆ柇鏉冪泭绫诲瀷
+                    if(cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_PROJECT)){
+                        for(CardItemInfo cardItemInfo:cardItemInfoList){
+                            //鍥哄畾椤圭洰绫诲瀷
+                            if(cardItemInfo.getUserNum() != null){
+                                cureNum = cureNum+cardItemInfo.getUserNum()*cardItemInfo.getMaxNum()*orderItem.getBuyNum();
+                            }
+                        }
+                    }else if(cardEquity.getEquityType().equals(CardEquity.EQUITY_TYPE_TIME_CARD)){
+                        //TODO 杩欓噷杩樻病鏈夊仛瀹�
+                        //鍙瓨鍌ㄦ渶澶х殑涓�涓枟绋嬫暟
+                        cureItemMax = 0;
+                        //鍓╀綑鎶垫墸娆℃暟
+                        deductionSurp = cardEquity.getValue();
+                        //娆″崱
+                        for(CardItemInfo cardItemInfo:cardItemInfoList){
+
+                            if(cardItemInfo.getUserNum() != null){
+                                deductionNum = cardEquity.getValue()/cardItemInfo.getEveryDrawNum();
+                                cureItemNum = cardItemInfo.getUserNum()*deductionNum*orderItem.getBuyNum();
+                                if(cureItemNum>cureItemMax){
+                                    cureItemMax = cureItemMax;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        //鍒ゆ柇鏄惁绗﹀悎瑙勫垯
+        if(cureNum >= marketSystem.getCureNum()){
+            //鐢熸垚淇变箰閮ㄤ細鍛�
+            createClubMember(UserClubMember.TYPE_REGENERATION,ordersTotal,marketSystem,commonService);
+        }
+
+    }
+
+    /**鑾峰彇浜岀骇瀛愯鍗�*/
+    public static List<OrderItemSon> getOrderItemSonList(String orderItemId,String goodsType,CommonService commonService){
+        SqlSentence sqlSentence = new SqlSentence();
+        Map<String,Object> values = new HashMap<>();
+
+        values.put("orderItemId",orderItemId);
+        values.put("goodsType",goodsType);
+        sqlSentence.sqlSentence("SELECT id,type,goodsId,goodsNo,goodsName,usedTotal,hasReNum FROM order_item_source WHERE isDel = 0 AND orderItemId = #{m.orderItemId} AND type = #{m.type}",values);
+        return commonService.selectList(OrderItemSonMapper.class,sqlSentence);
+    }
+
+    /**鑾峰彇鎵�鏈夌殑鏉冪泭*/
+    public static List<CardEquity> getCardEquityList(String cardItemId, CommonService commonService){
+        SqlSentence sqlSentence = new SqlSentence();
+        Map<String,Object> values = new HashMap<>();
+
+        values.put("cardItemId",cardItemId);
+        sqlSentence.sqlSentence("SELECT cii.id,cii.equityType,cii.value,cii.shareMoney" +
+                " FROM card_equity cii WHERE cii.isDel = 0 AND cii.cardItemId = #{m.cardItemId}",values);
+
+        return commonService.selectList(CardEquityMapper.class,sqlSentence);
+    }
+
+    /**鑾峰彇鍗¢」鎵�鏈夌殑椤圭洰*/
+    public static Map<String,List<CardItemInfo>> getCardItemInfoList(String cardItemId, CommonService commonService){
+        SqlSentence sqlSentence = new SqlSentence();
+        Map<String,Object> values = new HashMap<>();
+
+        values.put("cardItemId",cardItemId);
+        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);
+        List<CardItemInfo> cardItemInfoList = commonService.selectList(CardItemInfoMapper.class,sqlSentence);
+
+        Map<String,List<CardItemInfo>> cardItemInfoMapList = new HashMap<>();
+        List<CardItemInfo> cardItemInfoList1;
+        for(CardItemInfo cardItemInfo:cardItemInfoList){
+            cardItemInfoList1 = cardItemInfoMapList.computeIfAbsent(cardItemInfo.getCardEquityId(),k->new ArrayList<>());
+            cardItemInfoList1.add(cardItemInfo);
+        }
+
+        return cardItemInfoMapList;
+    }
+
+    /**璁㈠崟鐢熸垚鍐嶇敓淇变箰閮ㄤ細鍛�*/
+    public static void createClubMember(Integer type,OrdersTotal ordersTotal,MarketSystem marketSystem,CommonService commonService){
+
+        Integer durationType = UserClubMember.DURATION_TYPE_PARAGRAPH;
+        Date startTime = null;
+        Date endTime = null;
+        if(marketSystem.getDurationType() == MarketSystem.DURATION_TYPE_ALL){
+            durationType = UserClubMember.DURATION_TYPE_ALL;
+        }else if(marketSystem.getDurationType() == MarketSystem.DURATION_TYPE_PARAGRAPH){
+            startTime = marketSystem.getDurationStart();
+            endTime = marketSystem.getDurationEnd();
+        }else{
+            startTime = ordersTotal.getPayTime();
+            endTime = startTime;
+            if(marketSystem.getDurationYear() != null){
+                endTime = DateUtil.addYear(endTime,marketSystem.getDurationYear());
+            }
+            if(marketSystem.getDurationMonth() != null){
+                endTime = DateUtil.addMonth(endTime,marketSystem.getDurationMonth());
+            }
+            if(marketSystem.getDurationDay() != null){
+                endTime = DateUtil.addDay(endTime,marketSystem.getDurationDay());
+            }
+            //鏃堕棿绮剧‘鍒板綋澶╂渶鍚庝竴绉�
+            endTime = DateUtil.dayToEndDateNoMillisecond(endTime);
+        }
+        insertClubMember(type,durationType,startTime,endTime,UserClubMember.SOURCE_TYPE_ORDER,ordersTotal.getId(),marketSystem.getId(),ordersTotal.getUserId(),commonService);
+    }
+
+    /**淇濆瓨淇变箰閮ㄤ細鍛�*/
+    public static void insertClubMember(Integer type,Integer durationType,Date startTime,Date endTime,Integer sourceType,String sourceId,String sourceOtherId
+            ,String userId,CommonService commonService){
+
+        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);
+        commonService.updateWhere(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);
+    }
+
+
+
+}
diff --git a/phi_platform_common/src/main/resources/mapper/platform/MarketSystemMapper.xml b/phi_platform_common/src/main/resources/mapper/platform/MarketSystemMapper.xml
new file mode 100644
index 0000000..ac648d2
--- /dev/null
+++ b/phi_platform_common/src/main/resources/mapper/platform/MarketSystemMapper.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.MarketSystemMapper">
+
+	<!-- 鏁翠釜瀹炰綋绫讳慨鏀癸紝琛ㄥ瓧娈�=瀹炰綋绫诲瓧娈�-->
+	<sql id="Update_Column_All">
+		<trim prefixOverrides=",">
+			,title = #{title},type = #{type},isUp = #{isUp},timeType = #{timeType},timeNum = #{timeNum},startTime = #{startTime},endTime = #{endTime},headId = #{headId},headName = #{headName},ruleInfo = #{ruleInfo},isDel = #{isDel},createTime = #{createTime},editTime = #{editTime}
+		</trim>
+	</sql>
+	 
+	<!--  鍚庣画閫氳繃  namespace.id-->
+	<!--parameterType:杈撳叆鍙傛暟鐨勭被鍨�
+	resultType锛氭煡璇㈣繑鍥炵粨鏋滃�肩殑绫诲瀷  锛岃繑鍥炵被鍨�  -->
+	<insert id="insert" parameterType="com.hx.phiappt.model.market.system.MarketSystem">
+	    <selectKey keyProperty="id" resultType="String" order="BEFORE">
+               select replace(uuid(),'-','') from dual
+        </selectKey>
+        insert into market_system (id,title,type,isUp,timeType,timeNum,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime)  values (#{id},#{title},#{type},#{isUp},#{timeType},#{timeNum},#{startTime},#{endTime},#{headId},#{headName},#{ruleInfo},#{isDel},#{createTime},#{editTime})
+	</insert>
+
+	<insert id="insertById" parameterType="com.hx.phiappt.model.market.system.MarketSystem">
+        insert into market_system (id,title,type,isUp,timeType,timeNum,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime)  values (#{id},#{title},#{type},#{isUp},#{timeType},#{timeNum},#{startTime},#{endTime},#{headId},#{headName},#{ruleInfo},#{isDel},#{createTime},#{editTime})
+    </insert>
+
+	<select id="selectList" resultType="com.hx.phiappt.model.market.system.MarketSystem" 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.market.system.MarketSystem" 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 market_system
+    			WHERE ${sqlSentence}
+    </select>
+
+    <select id="selectCountSql" resultType="int" parameterType="com.hx.mybatisTool.SqlSentence" >
+        	${sqlSentence}
+     </select>
+
+	<select id="selectOneByKey" resultType="com.hx.phiappt.model.market.system.MarketSystem" parameterType="java.lang.Object" >
+		select 
+			id,title,type,isUp,timeType,timeNum,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime
+		from market_system
+		WHERE id = #{value}
+	</select>
+
+	<select id="selectOneByKeyBlob" resultType="com.hx.phiappt.model.market.system.MarketSystem" parameterType="java.lang.Object" >
+		select 
+			id,title,type,isUp,timeType,timeNum,startTime,endTime,headId,headName,ruleInfo,isDel,createTime,editTime
+		from market_system
+		WHERE id = #{value}
+	</select>
+
+	<update id="updateWhere" parameterType="com.hx.mybatisTool.SqlSentence">
+		update
+		    market_system
+        SET ${sqlSentence}
+	</update>
+
+	<update id="updateAll" parameterType="com.hx.phiappt.model.market.system.MarketSystem">
+		update market_system
+			SET <include refid="Update_Column_All"/>
+		WHERE id = #{id}
+	</update>
+
+	<delete id="deleteWhere"  parameterType="com.hx.mybatisTool.SqlSentence">
+		delete from market_system WHERE ${sqlSentence}
+	</delete>
+
+	<delete id="deleteById"  parameterType="java.lang.Object">
+		delete from market_system WHERE id = #{value}
+	</delete>
+	
+</mapper>
\ No newline at end of file
diff --git a/phi_platform_common/src/main/resources/mapper/platform/MarketSystemProjectMapper.xml b/phi_platform_common/src/main/resources/mapper/platform/MarketSystemProjectMapper.xml
new file mode 100644
index 0000000..239738c
--- /dev/null
+++ b/phi_platform_common/src/main/resources/mapper/platform/MarketSystemProjectMapper.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.MarketSystemProjectMapper">
+
+	<!-- 鏁翠釜瀹炰綋绫讳慨鏀癸紝琛ㄥ瓧娈�=瀹炰綋绫诲瓧娈�-->
+	<sql id="Update_Column_All">
+		<trim prefixOverrides=",">
+			,type = #{type},typeCode = #{typeCode},typeId = #{typeId},marketSystemId = #{marketSystemId},isDel = #{isDel},createTime = #{createTime},editTime = #{editTime}
+		</trim>
+	</sql>
+	 
+	<!--  鍚庣画閫氳繃  namespace.id-->
+	<!--parameterType:杈撳叆鍙傛暟鐨勭被鍨�
+	resultType锛氭煡璇㈣繑鍥炵粨鏋滃�肩殑绫诲瀷  锛岃繑鍥炵被鍨�  -->
+	<insert id="insert" parameterType="com.hx.phiappt.model.market.system.MarketSystemProject">
+	    <selectKey keyProperty="id" resultType="String" order="BEFORE">
+               select replace(uuid(),'-','') from dual
+        </selectKey>
+        insert into market_system_project (id,type,typeCode,typeId,marketSystemId,isDel,createTime,editTime)  values (#{id},#{type},#{typeCode},#{typeId},#{marketSystemId},#{isDel},#{createTime},#{editTime})
+	</insert>
+
+	<insert id="insertById" parameterType="com.hx.phiappt.model.market.system.MarketSystemProject">
+        insert into market_system_project (id,type,typeCode,typeId,marketSystemId,isDel,createTime,editTime)  values (#{id},#{type},#{typeCode},#{typeId},#{marketSystemId},#{isDel},#{createTime},#{editTime})
+    </insert>
+
+	<select id="selectList" resultType="com.hx.phiappt.model.market.system.MarketSystemProject" 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.market.system.MarketSystemProject" 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 market_system_project
+    			WHERE ${sqlSentence}
+    </select>
+
+    <select id="selectCountSql" resultType="int" parameterType="com.hx.mybatisTool.SqlSentence" >
+        	${sqlSentence}
+     </select>
+
+	<select id="selectOneByKey" resultType="com.hx.phiappt.model.market.system.MarketSystemProject" parameterType="java.lang.Object" >
+		select 
+			id,type,typeCode,typeId,marketSystemId,isDel,createTime,editTime
+		from market_system_project
+		WHERE id = #{value}
+	</select>
+
+	<select id="selectOneByKeyBlob" resultType="com.hx.phiappt.model.market.system.MarketSystemProject" parameterType="java.lang.Object" >
+		select 
+			id,type,typeCode,typeId,marketSystemId,isDel,createTime,editTime
+		from market_system_project
+		WHERE id = #{value}
+	</select>
+
+	<update id="updateWhere" parameterType="com.hx.mybatisTool.SqlSentence">
+		update
+		    market_system_project
+        SET ${sqlSentence}
+	</update>
+
+	<update id="updateAll" parameterType="com.hx.phiappt.model.market.system.MarketSystemProject">
+		update market_system_project
+			SET <include refid="Update_Column_All"/>
+		WHERE id = #{id}
+	</update>
+
+	<delete id="deleteWhere"  parameterType="com.hx.mybatisTool.SqlSentence">
+		delete from market_system_project WHERE ${sqlSentence}
+	</delete>
+
+	<delete id="deleteById"  parameterType="java.lang.Object">
+		delete from market_system_project 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
new file mode 100644
index 0000000..38ef75e
--- /dev/null
+++ b/phi_platform_common/src/main/resources/mapper/platform/UserClubMemberMapper.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.UserClubMemberMapper">
+
+	<!-- 鏁翠釜瀹炰綋绫讳慨鏀癸紝琛ㄥ瓧娈�=瀹炰綋绫诲瓧娈�-->
+	<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}
+		</trim>
+	</sql>
+	 
+	<!--  鍚庣画閫氳繃  namespace.id-->
+	<!--parameterType:杈撳叆鍙傛暟鐨勭被鍨�
+	resultType锛氭煡璇㈣繑鍥炵粨鏋滃�肩殑绫诲瀷  锛岃繑鍥炵被鍨�  -->
+	<insert id="insert" parameterType="com.hx.phiappt.model.user.club.UserClubMember">
+	    <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>
+
+	<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>
+
+	<select id="selectList" resultType="com.hx.phiappt.model.user.club.UserClubMember" 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.user.club.UserClubMember" 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 user_club_member
+    			WHERE ${sqlSentence}
+    </select>
+
+    <select id="selectCountSql" resultType="int" parameterType="com.hx.mybatisTool.SqlSentence" >
+        	${sqlSentence}
+     </select>
+
+	<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
+		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
+		from user_club_member
+		WHERE id = #{value}
+	</select>
+
+	<update id="updateWhere" parameterType="com.hx.mybatisTool.SqlSentence">
+		update
+		    user_club_member
+        SET ${sqlSentence}
+	</update>
+
+	<update id="updateAll" parameterType="com.hx.phiappt.model.user.club.UserClubMember">
+		update user_club_member
+			SET <include refid="Update_Column_All"/>
+		WHERE id = #{id}
+	</update>
+
+	<delete id="deleteWhere"  parameterType="com.hx.mybatisTool.SqlSentence">
+		delete from user_club_member WHERE ${sqlSentence}
+	</delete>
+
+	<delete id="deleteById"  parameterType="java.lang.Object">
+		delete from user_club_member WHERE id = #{value}
+	</delete>
+	
+</mapper>
\ No newline at end of file
diff --git a/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java b/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java
index 517a80a..0b9ada9 100644
--- a/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java
+++ b/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java
@@ -640,10 +640,10 @@
         //鑽g埛璇撮」鐩枟绋嬫鏁颁负绌哄�硷紝榛樿涓�1
         //璁剧疆涓�绾у瓙璁㈠崟鍗曟鐤楃▼鏁伴噺,璇ュ�艰幏鍙栫殑鏄」鐩殑鐤楃▼娆℃暟(涓轰簡璁$畻璁㈠崟鐨勬�荤枟绋嬫鏁�)
         if(project.getIsExecutable()!=null && project.getIsExecutable()==BaseEntity.YES){
-            Integer useredTotal=project==null?0:project.getTreatmentItemsNum()==null?1:project.getTreatmentItemsNum()==0?1:project.getTreatmentItemsNum();
+            Integer useredTotal= project.getTreatmentItemsNum() == null ?1: project.getTreatmentItemsNum() == 0 ?1:project.getTreatmentItemsNum();
             vo.setSingle(useredTotal);//璁㈠崟鍗曟鐤楃▼鏁伴噺
         }else if(project.getIsExecutable()!=null && project.getIsExecutable()==BaseEntity.NO){
-            Integer useredTotal=project==null?0:project.getTreatmentItemsNum()==null?0:project.getTreatmentItemsNum();
+            Integer useredTotal= project.getTreatmentItemsNum() == null ?0:project.getTreatmentItemsNum();
             vo.setSingle(useredTotal);//璁㈠崟鍗曟鐤楃▼鏁伴噺
         }else{
             vo.setSingle(0);//璁㈠崟鍗曟鐤楃▼鏁伴噺

--
Gitblit v1.8.0