From 5371cd3262eea83baa626edddb5a6b1a9ede3cae Mon Sep 17 00:00:00 2001
From: 935090232@qq.com <ak473600000>
Date: Thu, 01 Apr 2021 21:52:59 +0800
Subject: [PATCH] 业绩新增收款方式

---
 zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java |    9 +--
 zq-erp/src/test/java/com/matrix/JyyTests.java                                          |   11 +++
 zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml                        |    1 
 zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java     |   64 +++++++++++++++++++++
 zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml                        |   21 ++++--
 zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/orderXq-form.html     |   24 +++++++
 zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/order-form.html       |   39 +++++++-----
 zq-erp/src/main/resources/config/application.properties                                |    2 
 zq-erp/src/main/java/com/matrix/system/score/entity/ScoreVipDetail.java                |    6 ++
 zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java        |    2 
 10 files changed, 144 insertions(+), 35 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java b/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java
index 64dfd5e..d3b8671 100644
--- a/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java
+++ b/zq-erp/src/main/java/com/matrix/system/common/interceptor/ApiUserLoginInterceptor.java
@@ -3,7 +3,6 @@
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.matrix.component.redis.RedisClient;
-import com.matrix.component.redis.RedisUserLoginUtils;
 import com.matrix.core.constance.MatrixConstance;
 import com.matrix.core.pojo.AjaxResult;
 import com.matrix.core.tools.LogUtil;
@@ -11,8 +10,6 @@
 import com.matrix.core.tools.StringUtils;
 import com.matrix.system.common.bean.SysUsers;
 import com.matrix.system.common.dao.SysUsersDao;
-import com.matrix.system.hive.bean.SysVipInfo;
-import com.matrix.system.hive.dao.SysVipInfoDao;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
@@ -46,11 +43,11 @@
 
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
-       /*if ("dev".equals(evn)) {
-            SysUsers sysUsers = sysUsersDao.selectById(1012L);
+    if ("dev".equals(evn)) {
+            SysUsers sysUsers = sysUsersDao.selectById(2L);
             request.getSession().setAttribute(MatrixConstance.LOGIN_KEY, sysUsers);
             return true;
-        }*/
+        }
 
         String token = resolveToken(request,privateKey);
         AjaxResult ajaxResult = new AjaxResult();
diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java
index 922b7d9..bd847d1 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java
@@ -3,7 +3,10 @@
 import com.matrix.core.constance.MatrixConstance;
 import com.matrix.core.exception.GlobleException;
 import com.matrix.core.pojo.PaginationVO;
-import com.matrix.core.tools.*;
+import com.matrix.core.tools.DateUtil;
+import com.matrix.core.tools.EncrypUtil;
+import com.matrix.core.tools.StringUtils;
+import com.matrix.core.tools.WebUtil;
 import com.matrix.core.tools.excl.ExcelSheetPO;
 import com.matrix.core.tools.excl.ExcelUtil;
 import com.matrix.system.app.dto.AddVipDto;
@@ -11,7 +14,9 @@
 import com.matrix.system.app.dto.VipInfoListDto;
 import com.matrix.system.app.vo.VipInfoDetailVo;
 import com.matrix.system.app.vo.VipInfoListVo;
+import com.matrix.system.common.bean.BusParameterSettings;
 import com.matrix.system.common.bean.SysUsers;
+import com.matrix.system.common.dao.BusParameterSettingsDao;
 import com.matrix.system.common.tools.DataAuthUtil;
 import com.matrix.system.common.tools.ServiceUtil;
 import com.matrix.system.constance.Dictionary;
@@ -22,6 +27,9 @@
 import com.matrix.system.hive.plugin.util.CollectionUtils;
 import com.matrix.system.hive.pojo.VipInfoVo;
 import com.matrix.system.hive.service.SysVipInfoService;
+import com.matrix.system.score.constant.ScoreSettingConstant;
+import com.matrix.system.score.entity.ScoreVipDetail;
+import com.matrix.system.score.service.ScoreVipDetailService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
@@ -65,7 +73,11 @@
 
 	@Value("${default.vip.photo.man}")
 	String defaultMan;
+	@Autowired
+	BusParameterSettingsDao busParameterSettingsDao;
 
+	@Autowired
+	ScoreVipDetailService scoreVipDetailService;
 
 
 	/**
@@ -454,6 +466,7 @@
 	}
 
 	@Override
+	@Transactional
 	public int apiAddVip(AddVipDto addVipDto) {
 		SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
 
@@ -512,12 +525,61 @@
 		if (CollectionUtils.isNotEmpty(addVipDto.getLabels())) {
 			batchInsertLabel(addVipDto.getLabels(), vipInfo.getId());
 		}
+		//添加推荐人积分
+		addReferrerVipScore(vipInfo);
 
 		//创建用户默认储值卡
 		addVipDefaultCard(vipInfo.getId());
 		return i;
 	}
 
+	/**
+	 * 添加推荐人积分
+	 * @param vipInfo
+	 */
+	public void addReferrerVipScore(SysVipInfo vipInfo) {
+		if(vipInfo.getRecommendId()!=null){
+			SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
+			BusParameterSettings referrerScoreSetting = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.REFERRALS_CONSUMPTION, user.getCompanyId());
+			//推荐注册老带新积分奖励
+			SysVipInfo referrerVip = sysVipInfoDao.selectById(vipInfo.getRecommendId());
+
+			if(StringUtils.isNotBlank(referrerScoreSetting.getParamValue())){
+
+				scoreVipDetailService.addScore(referrerVip.getOpenId(),
+						referrerVip.getId(),
+						user.getSuId(),
+						vipInfo.getShopId(),
+						Integer.parseInt(referrerScoreSetting.getParamValue()),
+						vipInfo.getId(),
+						ScoreVipDetail.SCORE_VIP_TYPE_REFERRER,
+						"推荐会员"
+						);
+			}
+
+			//推荐注册二级带新积分奖励
+
+			if(referrerVip.getRecommendId()!=null){
+
+				SysVipInfo topVipInfo = sysVipInfoDao.selectById(referrerVip.getRecommendId());
+
+
+				if(StringUtils.isNotBlank(referrerScoreSetting.getParamValue1())){
+					scoreVipDetailService.addScore(topVipInfo.getOpenId(),
+							topVipInfo.getId(),
+							user.getSuId(),
+							vipInfo.getShopId(),
+							Integer.parseInt(referrerScoreSetting.getParamValue1()),
+							vipInfo.getId(),
+							ScoreVipDetail.SCORE_VIP_TYPE_REFERRER,
+							"推荐人"+topVipInfo.getVipName()+"推荐会员"
+					);
+				}
+			}
+
+		}
+	}
+
 	@Override
 	public int apiModifyVip(ModifyVipDto modifyVipDto) {
 		SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
diff --git a/zq-erp/src/main/java/com/matrix/system/score/entity/ScoreVipDetail.java b/zq-erp/src/main/java/com/matrix/system/score/entity/ScoreVipDetail.java
index 8c6b859..4ef9e66 100644
--- a/zq-erp/src/main/java/com/matrix/system/score/entity/ScoreVipDetail.java
+++ b/zq-erp/src/main/java/com/matrix/system/score/entity/ScoreVipDetail.java
@@ -23,10 +23,16 @@
 	 */
 	public static final int SCORE_VIP_TYPE_CASH=1;
 
+
 	/**
 	 * 获取类型(2:赠送等)
 	 */
 	public static final int SCORE_VIP_TYPE_CONSUME=2;
+	/**
+	 * 获取类型(3推荐客户)
+	 */
+	public static final int SCORE_VIP_TYPE_REFERRER=3;
+
 	/** 有效*/
 	public static final int SCORE_STATUS_YX=1;
 	/** 无效*/
diff --git a/zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java b/zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java
index 9002b42..037fbd0 100644
--- a/zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java
+++ b/zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java
@@ -142,7 +142,7 @@
         Calendar cal=Calendar.getInstance();
         int year = cal.get(Calendar.YEAR);
         int sxYear=year+(Integer.parseInt(yxqSetting.getParamValue())-1);
-        Date sxys=DateUtil.stringToDate(year+"-12-31 23:59",DateUtil.DATE_FORMAT_MM );
+        Date sxys=DateUtil.stringToDate(sxYear+"-12-31 23:59",DateUtil.DATE_FORMAT_MM );
 
         ScoreVipDetail scoreVipDetail=new ScoreVipDetail();
 
diff --git a/zq-erp/src/main/resources/config/application.properties b/zq-erp/src/main/resources/config/application.properties
index a250611..fa3a268 100644
--- a/zq-erp/src/main/resources/config/application.properties
+++ b/zq-erp/src/main/resources/config/application.properties
@@ -1,4 +1,4 @@
-evn=jyy
+evn=dev
 server.port=8080
 
 
diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml
index c99b814..408bb1b 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml
@@ -44,12 +44,12 @@
 		<result property="guwen" column="guwen" />
 		<result property="meiliao" column="meiliao" />
 		<result property="zkTotal" column="zk_total" />
-
+		<result property="payMethod" column="pay_method" />
 		<result property="arriveCnt" column="arrive_cnt" />
 
 		<result property="goodsNo" column="goodsNo" />
 		<result property="goodsName" column="goodsName" />
-		<result property="payMethod" column="pay_method" />
+
 		<result property="cateName" column="cateName" />
 
 	</resultMap>
@@ -287,7 +287,7 @@
 		<result property="remark" column="remark" />
 		<result property="orderType" column="order_type" />
 		<result property="projPercentage" column="proj_percentage" />
-
+		<result property="payMethod" column="pay_method" />
 		<result property="t1" column="t1" />
 		<result property="t2" column="t2" />
 		<result property="achieveType" column="achieveType" />
@@ -330,7 +330,8 @@
 		t6,
 		t8,
 		t9,
-		company_id
+		company_id,
+pay_method
 	</sql>
 
 	<!-- 属性sql -->
@@ -364,7 +365,8 @@
 		#{item.t6},
 		#{item.t8},
 		#{item.t9},
-		#{item.companyId}
+		#{item.companyId},
+		#{item.payMethod}
 	</sql>
 
 	<!-- where sql -->
@@ -612,6 +614,9 @@
 			<if test="_parameter.containsKey('t9')">
 				t9 = #{t9},
 			</if>
+			<if test="_parameter.containsKey('payMethod')">
+				pay_method = #{payMethod},
+			</if>
 		</set>
 		WHERE id=#{id}
 	</update>
@@ -724,6 +729,9 @@
 			</if>
 			<if test="record.t9 != null and record.t9 != '' ">
 				t9 = #{record.t9},
+			</if>
+			<if test="record.payMethod != null and record.payMethod != '' ">
+				pay_method = #{record.payMethod},
 			</if>
 		</set>
 		WHERE id=#{record.id}
@@ -1002,8 +1010,7 @@
 			b.code goodsNo,
 			b.name goodsName,
 			c.su_name meiliao,
-			d.count*d.zk_price zk_total,
-		    d.pay_method
+			d.count*d.zk_price zk_total
 		from achieve_new a
 		left join shopping_goods b on a.shopping_goods_id=b.id
 		left join sys_users c on a.beault_id=c.su_id
diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
index 5203a47..02ebd34 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml
@@ -953,6 +953,7 @@
 		c.su_name as STAFF_NAME,
 		d.SHOP_NAME,
 		a.blood,
+		       a.company_id,
 		a.sfCard,
 		a.link,
 		a.marry,
diff --git a/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/order-form.html b/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/order-form.html
index 63aaa8b..6bdb364 100644
--- a/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/order-form.html
+++ b/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/order-form.html
@@ -287,22 +287,7 @@
                             <el-input @change="calculationTotal" v-model="scope.row.zkPrice"></el-input>
                         </template>
                     </el-table-column>
-                    <el-table-column
-                            label="支付方式"
-                            width="130">
-                        <template slot-scope="scope">
-                            <el-select  v-model="scope.row.payMethod"
-                                        placeholder="请选择支付方式">
-                                <el-option
-                                        v-for="item in itemSimplePayMethods"
-                                        :key="item.value"
-                                        :label="item.label"
-                                        :value="item.value"
-                                        :disabled="item.disabled">
-                                </el-option>
-                            </el-select>
-                        </template>
-                    </el-table-column>
+
                     <el-table-column
                             label="小计">
                         <template slot-scope="scope">
@@ -431,6 +416,22 @@
                                 label="收款">
                         </el-table-column>
                         <el-table-column
+                                label="支付方式"
+                                width="130">
+                            <template slot-scope="scope">
+                                <el-select  v-model="scope.row.payMethod"
+                                            placeholder="请选择支付方式">
+                                    <el-option
+                                            v-for="item in itemSimplePayMethods"
+                                            :key="item.value"
+                                            :label="item.label"
+                                            :value="item.value"
+                                            :disabled="item.disabled">
+                                    </el-option>
+                                </el-select>
+                            </template>
+                        </el-table-column>
+                        <el-table-column
                                 label="业绩类型" width="150">
                             <template slot-scope="scope">
                                 <el-select v-model="scope.row.achieveType" @change="calculationAchieve" placeholder="请选择业绩类型">
@@ -443,6 +444,7 @@
                                 </el-select>
                             </template>
                         </el-table-column>
+
                         <el-table-column
                                 label="业绩" >
                             <template slot-scope="scope">
@@ -748,6 +750,7 @@
                                                     commission : 0,
                                                     achieveType : _this.achieveTypeList[0].value,
                                                     isShare: false,
+                                                    payMethod:item.payMethod,
                                                 });
                                             });
                                             _this.order.payMoney = orderPayMoney;
@@ -852,7 +855,6 @@
                     item.price = goods.sealPice;
                     item.goodsId = goods.id;
                     item.isFree = '否';
-                    item.payMethod = '现金';
                     if (type == BUY_TYPE_NOT_FREE) {
                         //购买
                         item.zkPrice = goods.sealPice;
@@ -875,6 +877,7 @@
                             achieveType : _this.achieveTypeList[0].value,
                             commission: 0,
                             isShare: false,
+                            payMethod:'现金',
                         });
                     } else {
                         //加入业绩
@@ -886,6 +889,7 @@
                             achieveType : _this.achieveTypeList[0].value,
                             commission: 0,
                             isShare: false,
+                            payMethod:'现金',
                         });
                     }
                     this.order.items.push(item);
@@ -1027,6 +1031,7 @@
                                     projPercentage: achieve.commission,
                                     achieveType: achieve.achieveType,
                                     goodsCash: achieve.goodsCash,
+                                    payMethod: achieve.payMethod,
                                 };
                                item.achieveList.push(achieveNew);
                                 break;
diff --git a/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/orderXq-form.html b/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/orderXq-form.html
index 1982dfd..c43d2ce 100644
--- a/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/orderXq-form.html
+++ b/zq-erp/src/main/resources/templates/views/admin/hive/beautySalon/orderXq-form.html
@@ -314,9 +314,22 @@
                                 prop="zkTotal"
                                 label="收款">
                         </el-table-column>
+
                         <el-table-column
-                                prop="payMethod"
-                                label="支付方式">
+                                label="支付方式"
+                                width="130">
+                            <template slot-scope="scope">
+                                <el-select  v-model="scope.row.payMethod"
+                                            placeholder="请选择支付方式">
+                                    <el-option
+                                            v-for="item in itemSimplePayMethods"
+                                            :key="item.value"
+                                            :label="item.label"
+                                            :value="item.value"
+                                            :disabled="item.disabled">
+                                    </el-option>
+                                </el-select>
+                            </template>
                         </el-table-column>
                         <el-table-column
                                 prop="t3"
@@ -501,6 +514,13 @@
             isRefund : false,
             isReturnAchieve : false,
             totalRefund : "",
+            itemSimplePayMethods:[{
+                value: '现金',
+                label:'现金',
+            },{
+                value: '划扣',
+                label:'划扣',
+            }],
             payMethods: [{
                 value: '现金支付',
                 img: '/images/pay/cash.png',
diff --git a/zq-erp/src/test/java/com/matrix/JyyTests.java b/zq-erp/src/test/java/com/matrix/JyyTests.java
index 744c5e5..00e55c5 100644
--- a/zq-erp/src/test/java/com/matrix/JyyTests.java
+++ b/zq-erp/src/test/java/com/matrix/JyyTests.java
@@ -1,5 +1,7 @@
 package com.matrix;
 
+import com.matrix.system.hive.bean.SysVipInfo;
+import com.matrix.system.hive.service.imp.SysVipInfoServiceImpl;
 import com.matrix.system.score.dao.ScoreVipDetailDao;
 import com.matrix.system.score.service.ScoreVipDetailService;
 import com.matrix.system.shopXcx.dao.ShopOrderV2Dao;
@@ -30,6 +32,15 @@
 	@Autowired
 	ScoreVipDetailService scoreVipDetailService;
 
+
+	@Autowired
+	SysVipInfoServiceImpl sysVipInfoService;
+
+
+
+
+
+
 	@Test
 	public void scoreVipDetailService() throws InterruptedException {
 		scoreVipDetailService.addScore("oJkRK4yelehsY4S7I6Ee1ydWtQMI",null,null,null,15,1L,1,"测试");

--
Gitblit v1.9.1