From 7132399202b75a84afaeab4c94065cc5dcf1480d Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Wed, 24 Mar 2021 11:52:17 +0800
Subject: [PATCH] 分销设置自购返佣
---
zq-erp/src/main/resources/templates/views/admin/fenxiao/fenxiao-setting.html | 33 +++++++++++
zq-erp/src/main/java/com/matrix/system/fenxiao/entity/ShopSalesmanGrade.java | 7 ++
zq-erp/src/main/resources/config/db/increment/推广员.sql | 8 ++
zq-erp/src/main/java/com/matrix/system/fenxiao/action/FenXiaoSettingAction.java | 6 ++
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderTask.java | 35 +++++++++++
zq-erp/src/main/java/com/matrix/system/common/service/impl/InitBusParameterSettingService.java | 3
zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopSku.java | 13 ++++
zq-erp/src/main/java/com/matrix/system/fenxiao/constant/FenxiaoSettingConstant.java | 7 ++
zq-erp/src/main/java/com/matrix/system/fenxiao/dto/UpdateFyfaDto.java | 3 +
zq-erp/src/main/java/com/matrix/system/fenxiao/vo/FyfaManageVo.java | 3 +
zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopSalesmanGradeDao.xml | 1
zq-erp/src/main/resources/templates/views/admin/fenxiao/fenxiao-user.html | 9 +++
zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java | 8 ++
13 files changed, 132 insertions(+), 4 deletions(-)
diff --git a/zq-erp/src/main/java/com/matrix/system/common/service/impl/InitBusParameterSettingService.java b/zq-erp/src/main/java/com/matrix/system/common/service/impl/InitBusParameterSettingService.java
index 2e93055..0c35449 100644
--- a/zq-erp/src/main/java/com/matrix/system/common/service/impl/InitBusParameterSettingService.java
+++ b/zq-erp/src/main/java/com/matrix/system/common/service/impl/InitBusParameterSettingService.java
@@ -43,7 +43,7 @@
}
/**
- * 初始化默认积分规则设置
+ * 初始化默认分销规则设置
*/
public void initBusParameterFenxiaoSetting(SysCompany sysCompany) {
long companyId = sysCompany.getComId();
@@ -55,6 +55,7 @@
ruleSettings.add(addScoreRuleSetting(FenxiaoSettingConstant.FX_APPLY_CONDITION, companyId));
ruleSettings.add(addScoreRuleSetting(FenxiaoSettingConstant.FX_TG_PLAN, companyId));
ruleSettings.add(addScoreRuleSetting(FenxiaoSettingConstant.FX_TG_POSTER, companyId));
+ ruleSettings.add(addScoreRuleSetting(FenxiaoSettingConstant.FX_ZGFY, companyId));
busParameterSettingsDao.batchInsert(ruleSettings);
}
diff --git a/zq-erp/src/main/java/com/matrix/system/fenxiao/action/FenXiaoSettingAction.java b/zq-erp/src/main/java/com/matrix/system/fenxiao/action/FenXiaoSettingAction.java
index 2795142..1252651 100644
--- a/zq-erp/src/main/java/com/matrix/system/fenxiao/action/FenXiaoSettingAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/fenxiao/action/FenXiaoSettingAction.java
@@ -60,6 +60,12 @@
String[] FXKGName={"分销开关"};
List<FenXiaoSettingVo> fxkgRuleSettingsVo = getRuleSettingsVo(FXKGCode,FXKGName,companyId);
result.putInMap("fxkg", fxkgRuleSettingsVo);
+ //自购返佣
+ String[] ZGFYCode={FenxiaoSettingConstant.FX_ZGFY};
+ String[] ZGFYName={"自购返佣"};
+ List<FenXiaoSettingVo> zgfyRuleSettingsVo = getRuleSettingsVo(ZGFYCode,ZGFYName,companyId);
+ result.putInMap("zgfy", zgfyRuleSettingsVo);
+
//分销模式
String[] FXMSCode={FenxiaoSettingConstant.FX_MODEL};
String[] FXMSName={"分销模式"};
diff --git a/zq-erp/src/main/java/com/matrix/system/fenxiao/constant/FenxiaoSettingConstant.java b/zq-erp/src/main/java/com/matrix/system/fenxiao/constant/FenxiaoSettingConstant.java
index de2bc10..3153b35 100644
--- a/zq-erp/src/main/java/com/matrix/system/fenxiao/constant/FenxiaoSettingConstant.java
+++ b/zq-erp/src/main/java/com/matrix/system/fenxiao/constant/FenxiaoSettingConstant.java
@@ -10,6 +10,13 @@
*/
public final static String FX_MODEL = "FX_MODEL";
/**
+ * 自购返佣 1:是 2:否
+ */
+ public final static String FX_ZGFY = "FX_ZGFY";
+
+ public final static String FX_ZGFY_YES = "1";
+ public final static String FX_ZGFY_NO = "2";
+ /**
* 申请方式
*/
public final static String FX_APPLY_WAY = "FX_APPLY_WAY";
diff --git a/zq-erp/src/main/java/com/matrix/system/fenxiao/dto/UpdateFyfaDto.java b/zq-erp/src/main/java/com/matrix/system/fenxiao/dto/UpdateFyfaDto.java
index ea89977..31dcf80 100644
--- a/zq-erp/src/main/java/com/matrix/system/fenxiao/dto/UpdateFyfaDto.java
+++ b/zq-erp/src/main/java/com/matrix/system/fenxiao/dto/UpdateFyfaDto.java
@@ -14,6 +14,9 @@
@ApiModelProperty(value = "方案名称")
private String name;
+ @ApiModelProperty(value = "自购返佣%")
+ private Double selfCommission;
+
@ApiModelProperty(value = "推广提成%")
private Double sealesCommission;
diff --git a/zq-erp/src/main/java/com/matrix/system/fenxiao/entity/ShopSalesmanGrade.java b/zq-erp/src/main/java/com/matrix/system/fenxiao/entity/ShopSalesmanGrade.java
index a29b2c3..999b02c 100644
--- a/zq-erp/src/main/java/com/matrix/system/fenxiao/entity/ShopSalesmanGrade.java
+++ b/zq-erp/src/main/java/com/matrix/system/fenxiao/entity/ShopSalesmanGrade.java
@@ -33,6 +33,13 @@
private Double sealesCommission;
+
+ /**
+ * 自购返佣比例%
+ */
+
+ private Double selfCommission;
+
/**
* 邀请提成 %
diff --git a/zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java b/zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java
index 37e9b50..df2e1dc 100644
--- a/zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java
+++ b/zq-erp/src/main/java/com/matrix/system/fenxiao/service/ShopSalesmanApplyService.java
@@ -54,7 +54,7 @@
ShopSalesmanGradeDao shopSalesmanGradeDao;
@Autowired
- private BizUserDao bizUserDao;
+ BizUserDao bizUserDao;
@Autowired
BizUserService bizUserService;
@@ -371,6 +371,10 @@
if(StrUtil.isEmpty(name)) {
return AjaxResult.buildFailInstance("请输入方案名称");
}
+ Double selfCommission = updateFyfaDto.getSelfCommission();
+ if(ObjectUtil.isEmpty(selfCommission)) {
+ return AjaxResult.buildFailInstance("请输入正确的自购返佣");
+ }
Double sealesCommission = updateFyfaDto.getSealesCommission();
if(ObjectUtil.isEmpty(sealesCommission)) {
return AjaxResult.buildFailInstance("请输入正确的推广提成");
@@ -384,6 +388,7 @@
ShopSalesmanGrade shopSalesmanGrade = new ShopSalesmanGrade();
shopSalesmanGrade.setCompanyId(updateFyfaDto.getCompanyId());
shopSalesmanGrade.setName(updateFyfaDto.getName());
+ shopSalesmanGrade.setSelfCommission(selfCommission);
shopSalesmanGrade.setSealesCommission(sealesCommission);
shopSalesmanGrade.setInvitationCommission(invitationCommission);
shopSalesmanGrade.setGradeCondition(updateFyfaDto.getGradeCondition());
@@ -398,6 +403,7 @@
}
selectById.setCompanyId(updateFyfaDto.getCompanyId());
selectById.setName(updateFyfaDto.getName());
+ selectById.setSelfCommission(selfCommission);
selectById.setSealesCommission(sealesCommission);
selectById.setInvitationCommission(invitationCommission);
selectById.setGradeCondition(updateFyfaDto.getGradeCondition());
diff --git a/zq-erp/src/main/java/com/matrix/system/fenxiao/vo/FyfaManageVo.java b/zq-erp/src/main/java/com/matrix/system/fenxiao/vo/FyfaManageVo.java
index 97dc22d..6ce68e6 100644
--- a/zq-erp/src/main/java/com/matrix/system/fenxiao/vo/FyfaManageVo.java
+++ b/zq-erp/src/main/java/com/matrix/system/fenxiao/vo/FyfaManageVo.java
@@ -14,6 +14,9 @@
@ApiModelProperty(value = "方案名称")
private String name;
+ @ApiModelProperty(value = "自购返佣%")
+ private Double selfCommission;
+
@ApiModelProperty(value = "推广提成%")
private Double sealesCommission;
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopSku.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopSku.java
index e33cd09..5597740 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopSku.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/bean/ShopSku.java
@@ -49,6 +49,11 @@
* 价格
*/
private BigDecimal price;
+
+ /**
+ *自购提成
+ */
+ private BigDecimal selfPrice;
/**
*推广提成
*/
@@ -282,4 +287,12 @@
return id.equals(((ShopSku) obj).getId());
}
+ public BigDecimal getSelfPrice() {
+ return selfPrice;
+ }
+
+ public void setSelfPrice(BigDecimal selfPrice) {
+ this.selfPrice = selfPrice;
+ }
+
}
\ No newline at end of file
diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderTask.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderTask.java
index 86c6c9a..c1fccd0 100644
--- a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderTask.java
+++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderTask.java
@@ -1,13 +1,17 @@
package com.matrix.system.shopXcx.mqTask;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.matrix.biz.bean.BizUser;
import com.matrix.biz.service.BizUserService;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.StringUtils;
+import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.dao.BusParameterSettingsDao;
+import com.matrix.system.fenxiao.constant.FenxiaoSettingConstant;
import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao;
import com.matrix.system.fenxiao.dao.ShopSalesmanOrderDao;
import com.matrix.system.fenxiao.entity.ShopSalesmanGrade;
@@ -20,6 +24,7 @@
import com.matrix.system.hive.service.SysOrderService;
import com.matrix.system.shopXcx.bean.ShopOrder;
import com.matrix.system.shopXcx.bean.ShopOrderDetails;
+import com.matrix.system.shopXcx.bean.ShopProduct;
import com.matrix.system.shopXcx.dao.ShopOrderDao;
import com.matrix.system.shopXcx.dao.ShopOrderDetailsDao;
import com.matrix.system.shopXcx.dao.ShopSkuDao;
@@ -129,6 +134,7 @@
salesmanOrder.setRevenueType(ShopSalesmanOrder.REVENUE_TYPE_SALES);
salesmanOrder.setOrderStatus(ShopSalesmanOrder.STATUS_DJS);
Double salesAmount=0D;
+ Double selfAmount=0D;
Double invitationAmount=0D;
Double orderTotal=0D;
Double zk=1D;
@@ -137,7 +143,7 @@
BizUser invitationMan=null;
ShopSalesmanOrder invitationOrder=null;
boolean hasInvitationMan=StringUtils.isNotBlank(salesMan.getParentOpenId());
-
+
//判断推广员是否还存在上级,存在则计算邀请收益
if(hasInvitationMan){
invitationMan=bizUserService.findByOpenId(salesMan.getParentOpenId());
@@ -150,7 +156,7 @@
//收益计算
for (ShopOrderDetails item:order.getDetails() ){
if(StringUtils.isNotBlank(item.getShopProduct().getAttrValues())
- && item.getShopProduct().getAttrValues().contains("分销商城")){
+ && item.getShopProduct().getAbleSales()==ShopProduct.ABLE_SALES){
if(item.getShopSku().getSealesPrice()==null
||item.getShopSku().getSealesPrice().doubleValue()==0){
//按分销等级计算
@@ -169,9 +175,34 @@
invitationAmount+=item.getShopSku().getInvitationPrice().doubleValue()*item.getCount();
}
}
+ //分销规则是否开启自购返佣
+ BusParameterSettings zgfy = parameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_ZGFY, bizUser.getCompanyId());
+ if(ObjectUtil.isNotEmpty(zgfy)) {
+ //获取商品的自购返佣价格,如果没有设置,在去获取当前推广人的等级的自购返佣比例
+ if(StrUtil.isNotEmpty(zgfy.getParamValue()) &&
+ FenxiaoSettingConstant.FX_ZGFY_YES.equals(zgfy.getParamValue())) {
+ if(item.getShopSku().getSelfPrice() == null
+ ||item.getShopSku().getSealesPrice().doubleValue() == 0){
+ //按分销等级计算
+ ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectById(salesMan.getSalesmanGrade());
+ selfAmount+=item.getTotalPrice().doubleValue()*(shopSalesmanGrade.getSelfCommission()/100);
+ }else {
+ //按产品设置的自购返佣金额计算
+ selfAmount+=item.getShopSku().getSelfPrice().doubleValue()*item.getCount();
+ }
+ }
+ }
orderTotal+=item.getTotalPrice().doubleValue();
}
}
+ //自购返佣记录生成
+ if(selfAmount > 0) {
+ //整体的优惠金额折算成折扣,* 佣金
+ zk=order.getOrderMoney().doubleValue()/orderTotal;
+ selfAmount=selfAmount*zk;
+ salesmanOrder.setAmount(selfAmount);
+ shopSalesmanOrderDao.insert(salesmanOrder);
+ }
if(salesAmount>0){
//整体的优惠金额折算成折扣,* 佣金
zk=order.getOrderMoney().doubleValue()/orderTotal;
diff --git "a/zq-erp/src/main/resources/config/db/increment/\346\216\250\345\271\277\345\221\230.sql" "b/zq-erp/src/main/resources/config/db/increment/\346\216\250\345\271\277\345\221\230.sql"
index 6976b41..f725cae 100644
--- "a/zq-erp/src/main/resources/config/db/increment/\346\216\250\345\271\277\345\221\230.sql"
+++ "b/zq-erp/src/main/resources/config/db/increment/\346\216\250\345\271\277\345\221\230.sql"
@@ -213,3 +213,11 @@
ALTER TABLE `shop_advertis`
ADD COLUMN `page_id` bigint(0) NULL COMMENT '连接页面' AFTER `company_id`;
+
+ALTER TABLE `shop_sku`
+DROP COLUMN `self_price`,
+ADD COLUMN `self_price` decimal(20,2) NULL AFTER `score_count`;
+
+ALTER TABLE `shop_salesman_grade`
+DROP COLUMN `self_commission`,
+ADD COLUMN `self_commission` double(20,2) NULL COMMENT '自购返佣比例%' AFTER `company_id`;
\ No newline at end of file
diff --git a/zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopSalesmanGradeDao.xml b/zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopSalesmanGradeDao.xml
index 00dd2d4..3b3a30a 100644
--- a/zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopSalesmanGradeDao.xml
+++ b/zq-erp/src/main/resources/mybatis/mapper/fenxiao/ShopSalesmanGradeDao.xml
@@ -49,6 +49,7 @@
SELECT
a.id id,
a.name name,
+ a.self_commission selfCommission,
a.seales_commission sealesCommission,
a.invitation_commission invitationCommission,
a.grade_condition gradeCondition,
diff --git a/zq-erp/src/main/resources/templates/views/admin/fenxiao/fenxiao-setting.html b/zq-erp/src/main/resources/templates/views/admin/fenxiao/fenxiao-setting.html
index a23b23d..888cad5 100644
--- a/zq-erp/src/main/resources/templates/views/admin/fenxiao/fenxiao-setting.html
+++ b/zq-erp/src/main/resources/templates/views/admin/fenxiao/fenxiao-setting.html
@@ -39,6 +39,22 @@
<el-row style="margin-top: 20px;">
<el-col>
+ <template v-for="paramSettingzgfy in zgfy">
+ <el-form-item>
+ <span slot="label">{{paramSettingzgfy.paramName}}</span>
+ <el-col>
+ <el-radio-group v-model="paramSettingzgfy.paramValue">
+ <el-radio :label="'1'">是</el-radio>
+ <el-radio :label="'2'">否</el-radio>
+ </el-radio-group>
+ </el-col>
+ </el-form-item >
+ </template>
+ </el-col>
+ </el-row>
+
+ <el-row style="margin-top: 20px;">
+ <el-col>
<template v-for="paramSettingTwo in fxms">
<el-form-item>
<span slot="label">{{paramSettingTwo.paramName}}</span>
@@ -287,6 +303,7 @@
sqfs:[],
shfs:[],
sqtj:[],
+ zgfy:[],
},
created: function () {
this.loadInfo();
@@ -315,6 +332,7 @@
_this.fxkg = data.mapInfo.fxkg;
_this.fxms = data.mapInfo.fxms;
_this.sqfs = data.mapInfo.sqfs;
+ _this.zgfy = data.mapInfo.zgfy;
if(_this.sqfs.length > 0){
let paramssqfs = _this.sqfs[0].paramValue;
if(paramssqfs == 2){
@@ -444,6 +462,21 @@
}
submitDate.push(obj);
}
+ for (let i = 0; i < _this.zgfy.length; i++) {
+ let paramSetting = _this.zgfy[i];
+ let paramCode = paramSetting.paramCode;
+ let paramValue = paramSetting.paramValue;
+ let paramValue1 = paramSetting.paramValue1;
+ let paramValue2 = paramSetting.paramValue2;
+
+ let obj = {
+ paramCode: paramCode,
+ paramValue: paramValue,
+ paramValue1: paramValue1,
+ paramValue2: paramValue2,
+ }
+ submitDate.push(obj);
+ }
for (let i = 0; i < _this.fxms.length; i++) {
let paramSetting = _this.fxms[i];
let paramCode = paramSetting.paramCode;
diff --git a/zq-erp/src/main/resources/templates/views/admin/fenxiao/fenxiao-user.html b/zq-erp/src/main/resources/templates/views/admin/fenxiao/fenxiao-user.html
index f9966e4..b71fa3c 100644
--- a/zq-erp/src/main/resources/templates/views/admin/fenxiao/fenxiao-user.html
+++ b/zq-erp/src/main/resources/templates/views/admin/fenxiao/fenxiao-user.html
@@ -199,6 +199,13 @@
</el-table-column>
<el-table-column
prop="sealesCommission"
+ label="自购返佣 %">
+ <template slot-scope="scope">
+ <el-input class="edit-input" v-model="scope.row.selfCommission" oninput ="value=value.replace(/[^0-9.]/g,'')" placeholder="自购返佣"></el-input>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="sealesCommission"
label="推广提成 %">
<template slot-scope="scope">
<el-input class="edit-input" v-model="scope.row.sealesCommission" oninput ="value=value.replace(/[^0-9.]/g,'')" placeholder="推广提成"></el-input>
@@ -474,12 +481,14 @@
let id = row.id;
let name = row.name;
let sealesCommission = row.sealesCommission;
+ let selfCommission = row.selfCommission;
let invitationCommission = row.invitationCommission;
let gradeCondition = row.gradeCondition;
let obj = {
id: id,
name: name,
sealesCommission: sealesCommission,
+ selfCommission: selfCommission,
invitationCommission: invitationCommission,
gradeCondition: gradeCondition,
}
--
Gitblit v1.9.1