Bläddra i källkod

用户价值体系,佣金计算

huangzhiguo 2 år sedan
förälder
incheckning
ab946c4476

+ 2 - 0
src/main/java/com/caimei/modules/order/dao/CmOfflineCollectionDao.java

@@ -41,6 +41,8 @@ public interface CmOfflineCollectionDao extends CrudDao<CmOfflineCollection> {
     // 银行账号逻辑删除
     void updateBank(@Param("id") String id);
 
+    // 旧表银行账号删除
+    void delReceipt(@Param("id") Integer id);
     // 获取下拉列表
     List<CmOfflineCollection> downList();
 

+ 3 - 0
src/main/java/com/caimei/modules/order/dao/CmPayShopDao.java

@@ -3,6 +3,7 @@ package com.caimei.modules.order.dao;
 import com.caimei.modules.order.entity.CmDiscernReceipt;
 import com.caimei.modules.order.entity.CmPayShop;
 import com.caimei.modules.order.entity.NewShopOrder;
+import com.caimei.modules.product.entity.Product;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import org.apache.ibatis.annotations.Param;
@@ -30,4 +31,6 @@ public interface CmPayShopDao extends CrudDao<CmPayShop> {
     List<Integer> getShopOrderIdsList(@Param("payShopID") String payShopID);
 
     List<CmDiscernReceipt> getDiscernReceipts(Integer shopOrderId);
+
+    List<Product> priceNum(@Param("orderNo") String orderNo);
 }

+ 31 - 5
src/main/java/com/caimei/modules/order/service/CmOfflineCollectionService.java

@@ -46,12 +46,12 @@ public class CmOfflineCollectionService extends CrudService<CmOfflineCollectionD
         int typeMax = cmOfflineCollectionDao.typeMax();
         typeMax = typeMax +1;
         cmOfflineCollection.setType(typeMax);
-        // 酒标银行账号添加
+        // 旧表银行账号添加
         CmReceiType receiType = new CmReceiType();
         receiType.setId(cmOfflineCollection.getType());
         receiType.setType(cmOfflineCollection.getBankAccount());
-        // 线下银行账号数据添加
         cmOfflineCollectionDao.insReceipt(receiType);
+        // 线下银行账号数据添加
         int i = cmOfflineCollectionDao.insBank(cmOfflineCollection);
         if (i > 0) {
             return true;
@@ -59,6 +59,11 @@ public class CmOfflineCollectionService extends CrudService<CmOfflineCollectionD
         return false;
     }
 
+    /**
+     * 设置商城显示
+     * @param cmOfflineCollection
+     * @return
+     */
     @Transactional(readOnly = false)
     public Boolean upBankDisplay (CmOfflineCollection cmOfflineCollection) {
         int i = cmOfflineCollectionDao.upBankDisplay(cmOfflineCollection);
@@ -68,6 +73,11 @@ public class CmOfflineCollectionService extends CrudService<CmOfflineCollectionD
         return false;
     }
 
+    /**
+     * 设为商城不显示
+      * @param cmOfflineCollection
+     * @return
+     */
     @Transactional(readOnly = false)
     public Boolean NoBankDisplay (CmOfflineCollection cmOfflineCollection) {
         int i = cmOfflineCollectionDao.upNoBankDisplay(cmOfflineCollection);
@@ -83,23 +93,39 @@ public class CmOfflineCollectionService extends CrudService<CmOfflineCollectionD
         return bankData;
     }
 
-    // 编辑页面修改保存
+    /**
+     * 编辑页面修改保存
+      * @param cmOfflineCollection
+     */
     @Transactional(readOnly = false)
     public void editData(CmOfflineCollection cmOfflineCollection) {
         cmOfflineCollectionDao.edit(cmOfflineCollection);
     }
 
+    /**
+     * 银行账号禁用
+     * @param cmOfflineCollection
+     */
     @Transactional(readOnly = false)
     public void updateBank(CmOfflineCollection cmOfflineCollection) {
+        // 线下收款列表银行禁用
         cmOfflineCollectionDao.updateBank(cmOfflineCollection.getId());
+        // 旧表银行删除
+        cmOfflineCollectionDao.delReceipt(cmOfflineCollection.getType());
     }
 
-    // 线下收款账号下拉列表
+    /**
+     * 线下收款账号下拉列表
+     * @return
+     */
     public List<CmOfflineCollection> downListData() {
         return cmOfflineCollectionDao.downList();
     }
 
-    // 下拉列表获取所有线下收款账号
+    /**
+     * 下拉列表获取所有线下收款账号
+      * @return
+     */
     public List<CmReceiType> downAllListData() {
         return cmOfflineCollectionDao.downAllList();
     }

+ 32 - 5
src/main/java/com/caimei/modules/order/service/CmPayShopService.java

@@ -11,6 +11,7 @@ import com.caimei.modules.order.utils.Disguiser;
 import com.caimei.modules.order.utils.MyBeanUtils;
 import com.caimei.modules.order.utils.RSA;
 import com.caimei.modules.order.utils.SettlePostFormUtil;
+import com.caimei.modules.product.entity.Product;
 import com.caimei.modules.sys.utils.UploadImageUtils;
 import com.caimei.modules.user.dao.NewCmShopDao;
 import com.caimei.modules.user.entity.NewCmShop;
@@ -232,9 +233,14 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                  1. 若发生退货,数量要减去已退货和已取消的数量
                  2. 有赠品的商品只能全退
                  */
+                Integer returnNum = 0;
+                Double commission = 0.0;
+                Double money = 0.0;
                 for (NewOrderProduct p : orderProductList) {
-                    Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
+                    returnNum = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
                     returnNum = returnNum == null ? 0 : returnNum;
+
+                    commission = p.getDiscountPrice() - p.getCostPrice();
                     p.setReturnedNum(returnNum);
                 }
                 so.setNewOrderProducts(orderProductList);
@@ -279,8 +285,15 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 List<String> strings = newShopOrderDao.findShopOrderNos(so.getOrderID());
                 so.setShopOrderNos(strings);
                 //主订单总佣金
+//                List<Product> product = cmPayShopDao.priceNum(so.getOrderNo());
+                // 计算订单总佣金
                 Double income = newShopOrderDao.findIncome(so.getOrderID());
-                so.setIncome(income);
+                if(returnNum != null) {
+                    money =  income - (commission * returnNum);
+                    so.setIncome(money);
+                } else {
+                    so.setIncome(income);
+                }
                 //若成本下降太多导致部分收款的钱,已经大于成本重新计算佣金
                 if ("0".equals(newOrder.getOnlinePayFlag()) && so.getShopReceiptStatus() == 2) {
                     double mum = so.getProductAmount();
@@ -346,9 +359,11 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 }
                 List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(so.getShopOrderID());
                 /* 退货数量 */
+                Integer count = 0;
                 for (NewOrderProduct p : orderProductList) {
-                    Integer count = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
-                    p.setReturnedNum(count == null ? 0 : count);
+                    count = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
+                    count = count == null ? 0 : count;
+                    p.setReturnedNum(count);
                 }
                 if (so.getShopPostFee() == null) so.setShopPostFee(0D);
                 if (so.getShopTaxFee() == null) so.setShopTaxFee(0D);
@@ -392,8 +407,20 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 List<String> strings = newShopOrderDao.findShopOrderNos(so.getOrderID());
                 so.setShopOrderNos(strings);
                 //主订单总佣金
+                List<Product> product = cmPayShopDao.priceNum(so.getOrderNo());
+                // 计算佣金
                 Double income = newShopOrderDao.findIncome(so.getOrderID());
-                so.setIncome(income);
+                if(count != 0) {
+                    Double commission = 0.0;
+                    Double money = 0.0;
+                    for(Product pro: product) {
+                        commission = pro.getPrice() - Double.parseDouble(pro.getCostPrice());
+                        money = income - (commission * count);
+                    }
+                    so.setIncome(money);
+                } else {
+                    so.setIncome(income);
+                }
             }
 
             cmPayShop.setShopOrders(csos);

+ 1 - 1
src/main/java/com/caimei/modules/order/service/CmReturnedPurchaseService.java

@@ -569,7 +569,7 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
                 //部分退货
                 newOrder.setRefundType("1");
             }
-            if (newOrder.getRechargeGoods() != null) {
+            if (newOrder.getRechargeGoods() != null && newOrder.getRechargeGoods() != 3) {
                 newOrder.setStatus(NewOrderStatus.WAIT_COMMENT.getCode());
             }
             newOrderService.update(newOrder);

+ 1 - 10
src/main/java/com/caimei/modules/user/web/newUser/AgencyController.java

@@ -165,16 +165,7 @@ private VisitRemarkDao visitRemarkDao;
         }
 
         Page<NewCmClub> page = newCmClubService.findPage(new Page<NewCmClub>(request, response, 20), newCmClub);
-        List<NewCmClub> list = page.getList();
-        List<NewCmClub> newCmClubs = newCmClubDao.textUserValue();
-        for(NewCmClub cmClub: list) {
-            for(NewCmClub club: newCmClubs) {
-                if(cmClub.getUserID().equals(club.getValueID())) {
-                    cmClub.setActiveState(club.getActiveState());
-                    cmClub.setCustomerValue(club.getCustomerValue());
-                }
-            }
-        }
+
         model.addAttribute("newCmClub", newCmClub);
         model.addAttribute("page", page);
         return "modules/userNew/cmAgencyList";

+ 3 - 0
src/main/resources/mappings/modules/order/CmOfflineCollectionMapper.xml

@@ -62,6 +62,9 @@
         UPDATE cm_offline_collection
         SET isDisable = 0 WHERE id =#{id}
     </update>
+    <delete id="delReceipt">
+        delete from cm_receipt_type where id = #{id}
+    </delete>
 
     <select id="downList" resultType="com.caimei.modules.order.entity.CmOfflineCollection">
         SELECT id,bankAccount,type FROM cm_offline_collection WHERE isDisable != 0

+ 5 - 1
src/main/resources/mappings/modules/order/CmPayShopMapper.xml

@@ -150,7 +150,11 @@
 			</otherwise>
 		</choose>
 	</select>
-
+	<select id="priceNum" resultType="com.caimei.modules.product.entity.Product">
+		SELECT IFNULL(p.price, 0) as price,IFNULL(p.costPrice, 0) as costPrice FROM cm_order co
+		LEFT JOIN cm_order_product cop ON co.orderID = cop.orderID
+		LEFT JOIN product p ON cop.productID = p.productID WHERE co.orderNo = #{orderNo}
+	</select>
 	<insert id="insert" parameterType="CmPayShop"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO cm_pay_shop(
 			shopID,

+ 11 - 10
src/main/resources/mappings/modules/user/NewCmClubMapper.xml

@@ -92,15 +92,16 @@
         SELECT userID as valueID, activeState, customerValue FROM cm_organ_value_system WHERE stage = 0 AND delType = 1
     </select>
 
+
     <select id="findList" resultType="NewCmClub">
         SELECT
         <include refid="newCmClubColumns"/>
-        <include refid="otherColumns"/>,u.userPermission,u.source -- ,covs.activeState,covs.customerValue
+        <include refid="otherColumns"/>,u.userPermission,u.source, covs.activeState,covs.customerValue
         FROM club a
         <include refid="newCmClubJoins"/>
-        -- left join cm_organ_value_system covs on a.userID = covs.userID
+        left join cm_organ_value_system covs on a.userID = covs.userID
         <where>
-            -- covs.stage = 0 AND covs.delType = 1
+            covs.stage = 0 AND covs.delType = 1
             <if test="clubID != null and clubID != ''">
                 AND a.clubID = #{clubID}
             </if>
@@ -152,13 +153,13 @@
             <if test="newDeal != null">
                 AND a.newDeal =#{newDeal}
             </if>
-<!--            <if test="activeState != null and activeState != ''">-->
-<!--                AND covs.activeState = #{activeState}-->
-<!--            </if>-->
-<!--            <if test="customerValue != null and customerValue != ''">-->
-<!--                AND covs.customerValue = #{customerValue}-->
-<!--            </if>-->
-             (u.userOrganizeID IN(0,1) or u.clubStatus != 92)
+            <if test="activeState != null and activeState != ''">
+                AND covs.activeState = #{activeState}
+            </if>
+            <if test="customerValue != null and customerValue != ''">
+                AND covs.customerValue = #{customerValue}
+            </if>
+             AND (u.userOrganizeID IN(0,1) or u.clubStatus != 92)
         </where>
         <choose>
             <when test="page !=null and page.orderBy != null and page.orderBy != ''">

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/order/cmPayShopForm.jsp

@@ -943,7 +943,7 @@
         });
 
         $('.pay-table').each(function () {
-            debugger
+            // debugger
             var thisEle = $(this),
                 totalComissionVal = 0,
                 resVal = '';

+ 5 - 2
src/main/webapp/WEB-INF/views/modules/order/cmPayShopOtherCheck.jsp

@@ -589,7 +589,10 @@
             <label style="font-weight: bold; font-size:18px">转账支付:</label>
             <span id="transferPayFee" style="font-weight: bold; font-size:18px"><fmt:formatNumber value="${cmPayShop.transferPayFee}" pattern="#,##0.00"/> </span>
             <label>付款银行:</label><span>
-					<select name="payType">
+            <c:forEach  items="${offlineCollections}" var="offlineCollections" varStatus="index">
+                <option value="${offlineCollections.type}">${offlineCollections.bankAccount}</option>
+            </c:forEach>
+					<%--<select name="payType">
 						<option value="1">建设银行7297</option>
 						<option value="2">中信银行0897</option>
 						<option value="3">中信银行7172</option>
@@ -597,7 +600,7 @@
 						<option value="5">广发银行5461</option>
 						<option value="7">华夏银行2400</option>
 						<option value="8">中国银行9452</option>
-					</select>
+					</select>--%>
 				</span>
             <label>付款时间:</label>
             <span>${cmPayShop.payTime}</span>

+ 27 - 20
src/main/webapp/WEB-INF/views/modules/userNew/cmAgencyList.jsp

@@ -45,6 +45,7 @@
         #alertModal .alert-content{width:260px;height:60px;padding:20px}
         #alertModal .alertModal-btn{width:260px;height:49px;padding:0 20px;border-top:1px solid #EBEBEB}
         #alertModal .alertModal-btn button{float:right;margin:5px}
+        .acticer_span{display: inline-block;width: 14px;height: 14px;border-radius: 50%;box-sizing: border-box;border: 1px solid #999999;text-align: center;color: #333333;font-size: 12px;line-height: 14px;float: none;margin-left: 3px;}
     </style>
 </head>
 <body>
@@ -100,6 +101,7 @@
             <form:option value="流失用户" label="流失用户"/>
             <form:option value="回流用户" label="回流用户"/>
             <form:option value="忠诚用户" label="忠诚用户"/>
+            <form:option value="沉默用户" label="沉默用户"/>
         </form:select>
 
         <label class="control-label">客户价值:</label>
@@ -148,8 +150,8 @@
         <th>状态</th>
         <th>审核人</th>
         <th>机构类别</th>
-        <th>活跃状态<button type="button" class="tipButton" style="color: lightslategray;border-radius: 25px" onmousemove="activeStageMessage()">?</button></th>
-        <th>客户价值<button type="button" class="tipButton" style="color: lightslategray;border-radius: 25px" onmousemove="customerValueMessage()">?</button></th>
+        <th>活跃状态<span class="acticer_span" onmousemove="activeStageMessage(1)">?</span></th>
+        <th>客户价值<span class="acticer_span" onmousemove="activeStageMessage(2)">?</span></th>
         <th>注册IP</th>
         <th>注册时间</th>
         <th>审核时间</th>
@@ -842,24 +844,29 @@
         };
         $.jBox(html, {title: "审核", submit: submit});
     }
-    function activeStageMessage() {
-        alertx('1.新增用户:30天内新注册的用户'+'<br/>'+
-        '2.活跃用户:30天内登录过商城的用户(排除新增用户和回流客户)'+'<br/>'+
-        '3.不活跃用户:30天内未登录过商城的用户(排除流失用户)'+'<br/>'+
-        '4.流失用户:两年内未登录且没有订单的机构'+'<br/>'+
-        '5.回流用户:上一统计阶段的流失用户中后续登录商城的用户或者后续有订单的用户'+'<br/>'+
-        '6.忠诚用户:90天内登录过商城且一年内有订单记录的用户'+'<br/>'+
-        '7.沉默用户:未登录过商城,但是在30天内存在订单的用户(排除回流客户')
-    }
-    function customerValueMessage() {
-        alertx('1. 一般保持客户,指最近一次交易距今时间大于60天,交易频率大于等于一月一次,上个月交易金额小于¥100000的客户'+'<br/>'+
-        '2. 一般发展客户,指最近一次交易距今时间小于等于60天,交易频率小于一月一次,上个月交易金额小于¥100000的客户'+'<br/>'+
-        '3. 一般价值客户,指最近一次交易距今时间小于等于60天,交易频率大于等于一月一次,上个月交易金额小于¥100000的客户'+'<br/>'+
-        '4. 一般挽留客户,指最近一次交易距今时间大于60天,交易频率小于一月一次,上个月交易金额小于¥100000的客户'+'<br/>'+
-        '5.重要保持客户,指最近一次交易距今时间大于60天,交易频率大于等于一月一次,上个月交易金额大于等于¥100000的客户'+'<br/>'+
-        '6.重要发展客户,指最近一次交易距今时间小于等于60天,交易频率小于一月一次,上个月交易金额大于等于¥100000的客户'+'<br/>'+
-        '7.重要价值客户,指最近一次交易距今时间小于等于60天,交易频率大于等于一月一次,上个月交易金额大于等于¥100000的客户'+'<br/>'+
-        '8.重要挽留客户,指最近一次交易距今时间大于60天,交易频率小于一月一次,上个月交易金额大于等于¥100000的客户')
+    function activeStageMessage(type) {// 客户价值提示语
+        var content = '1.新增用户:30天内新注册的用户'+'<br/>'+
+            '2.活跃用户:90天内登录过商城的用户(排除新增用户和回流客户)'+'<br/>'+
+            '3.不活跃用户:90天内未登录过商城的用户(排除流失用户)'+'<br/>'+
+            '4.流失用户:两年内未登录且没有订单的机构'+'<br/>'+
+            '5.回流用户:上一统计阶段的流失用户中后续登录商城的用户或者后续有订单的用户'+'<br/>'+
+            '6.忠诚用户:90天内登录过商城且一年内有订单记录的用户'+'<br/>'+
+            '7.沉默用户:两年内未登录过商城,但是在90天内存在订单的用户(排除回流客户)';
+
+        var content2 = '1. 一般保持客户,指最近一次交易距今时间大于60天,交易频率大于等于一月一次,上个月交易金额小于¥100000的客户'+'<br/>'+
+            '2. 一般发展客户,指最近一次交易距今时间小于等于60天,交易频率小于一月一次,上个月交易金额小于¥100000的客户'+'<br/>'+
+            '3. 一般价值客户,指最近一次交易距今时间小于等于60天,交易频率大于等于一月一次,上个月交易金额小于¥100000的客户'+'<br/>'+
+            '4. 一般挽留客户,指最近一次交易距今时间大于60天,交易频率小于一月一次,上个月交易金额小于¥100000的客户'+'<br/>'+
+            '5.重要保持客户,指最近一次交易距今时间大于60天,交易频率大于等于一月一次,上个月交易金额大于等于¥100000的客户'+'<br/>'+
+            '6.重要发展客户,指最近一次交易距今时间小于等于60天,交易频率小于一月一次,上个月交易金额大于等于¥100000的客户'+'<br/>'+
+            '7.重要价值客户,指最近一次交易距今时间小于等于60天,交易频率大于等于一月一次,上个月交易金额大于等于¥100000的客户'+'<br/>'+
+            '8.重要挽留客户,指最近一次交易距今时间大于60天,交易频率小于一月一次,上个月交易金额大于等于¥100000的客户';
+
+        var typeMap = {
+                1:content,
+                2:content2
+            }
+        $.jBox.alert(typeMap[type],'提示',{ width: 450 })
     }
 </script>
 </body>