zq-erp/src/main/java/com/matrix/system/hive/bean/SysOrder.java
@@ -42,7 +42,7 @@ private Date orderTime; /** * 收款 * calculationType: 1, */ @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") private Date payTime; zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java
@@ -1,6 +1,7 @@ package com.matrix.system.hive.service.imp; import cn.hutool.core.collection.CollUtil; import cn.hutool.json.JSONUtil; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.PaginationVO; @@ -16,13 +17,11 @@ import com.matrix.system.common.dao.SysUsersDao; import com.matrix.system.constance.Dictionary; import com.matrix.system.hive.bean.*; import com.matrix.system.hive.dao.AchieveNewDao; import com.matrix.system.hive.dao.ShoppingGoodsDao; import com.matrix.system.hive.dao.SysBeauticianStateDao; import com.matrix.system.hive.dao.SysProjUseDao; import com.matrix.system.hive.dao.*; import com.matrix.system.hive.plugin.util.CollectionUtils; import com.matrix.system.hive.service.AchieveNewService; import com.matrix.system.hive.service.SysProjServicesService; import com.matrix.system.hiveErp.pojo.AchieveRuleItem; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -185,8 +184,14 @@ // 是否为赠送业绩 if (Dictionary.TAOCAN_SOURCE_ZS.equals(projUse.getSource())) { achieveNew.setFreeConsume(projUse.getPrice()*beauticianState.getCount()); //计算提成 achieveNew.setProjPercentage( calculationProjPercentage(AchieveRuleItem.ACHIEVE_TYPE_ZS,achieveNew.getFreeConsume(),beauticianState.getProjId())); } else { achieveNew.setHisConsume(projUse.getPrice()*beauticianState.getCount()); //计算提成 achieveNew.setProjPercentage( calculationProjPercentage(AchieveRuleItem.ACHIEVE_TYPE_BJ,achieveNew.getHisConsume(),beauticianState.getProjId())); } achieveNew.setT2(projUse.getSource()); achieveNew.setDatatime(new Date()); @@ -239,6 +244,36 @@ } @Autowired AchieveRuleDao achieveRuleDao; private Double calculationProjPercentage(int type, Double consume, Long goodsId) { ShoppingGoods shoppingGoods = shoppingGoodsDao.selectById(goodsId); if(shoppingGoods.getAchieveRuleId()!=null){ AchieveRule achieveRule = achieveRuleDao.selectById(shoppingGoods.getAchieveRuleId()); if(achieveRule!=null){ List<AchieveRuleItem> achieveRuleItems = JSONUtil.toList(JSONUtil.parseArray(achieveRule.getRules()), AchieveRuleItem.class); double percentage=0D; for(AchieveRuleItem item:achieveRuleItems){ if(item.getAchieveType()==type && (item.getLower() == consume || (item.getLower()< consume && consume < item.getUpper() ))){ if(AchieveRuleItem.ACHIEVE_TYPE_FIXED==item.getCalculationType()){ percentage=item.getAchieve(); }else{ percentage= consume * (item.getAchieve()/100); } break; } } return percentage; } } return 0D; } /** * 顾问人头业绩 * @param achieveNew zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
@@ -1205,13 +1205,20 @@ } else { puse.setPrice(goodsAssemble.getPrice() * zk); } puse.setBalance(MoneyUtil.mul(puse.getPrice(), Double.valueOf(puse.getSurplusCount()))); // 赠送和打折后金额为0的都视为赠送项目 if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0) { puse.setSource(Dictionary.TAOCAN_SOURCE_GM); } else { //赠送产品按原价计算消耗 puse.setSource(Dictionary.TAOCAN_SOURCE_ZS); if (taocanId == null) { puse.setPrice(goodsAssemble.getShoppingGoods().getPrice() ); } else { puse.setPrice(goodsAssemble.getPrice()); } } puse.setBalance(MoneyUtil.mul(puse.getPrice(), Double.valueOf(puse.getSurplusCount()))); puse.setFailTime(failTime); sysProjUseDao.insert(puse); return puse; @@ -1291,18 +1298,22 @@ puse.setVipId(order.getVipId()); puse.setStatus(Dictionary.TAOCAN_STATUS_YX); puse.setType(Dictionary.SHOPPING_GOODS_TYPE_XM); puse.setBalance(sysOrderItem.getZkPrice()); puse.setPrice(sysOrderItem.getZkPrice()); puse.setProjName(sysOrderItem.getShoppingGoods().getName()); // 赠送和打折后金额为0的都视为赠送项目 if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0) { puse.setSource(Dictionary.TAOCAN_SOURCE_GM); puse.setPrice(sysOrderItem.getZkPrice()); } else { puse.setSource(Dictionary.TAOCAN_SOURCE_ZS); //赠送产品按原价计算消耗 puse.setPrice(sysOrderItem.getShoppingGoods().getSealPice()); } // 设置失效时间 Date invalidTime = shoppingGoodsService.calInvalidTime(sysOrderItem.getShoppingGoods(), 1, null); puse.setFailTime(invalidTime); puse.setBalance(sysOrderItem.getShoppingGoods().getSealPice()*puse.getSurplusCount()); sysProjUseDao.insert(puse); } zq-erp/src/main/java/com/matrix/system/hiveErp/action/AchieveRuleAction.java
@@ -92,7 +92,7 @@ @GetMapping("/removeById/{id}") public AjaxResult removeById(@PathVariable Long id) { achieveRuleDao.deleteById(id); return AjaxResult.buildFailInstance("删除成功"); return AjaxResult.buildSuccessInstance("删除成功"); } zq-erp/src/main/java/com/matrix/system/hiveErp/pojo/AchieveRuleItem.java
@@ -16,7 +16,7 @@ /** * 类型,2赠送消耗 */ public static final int ACHIEVE_TYPE_CONSUME=2; public static final int ACHIEVE_TYPE_ZS =2; /** * 计算类型 1 固定值 */ zq-erp/src/main/resources/templates/views/admin/hive-erp/products/achieverule-list.html
@@ -44,7 +44,7 @@ <div class="panel-body" id="app"> <el-row class="buttonPanel"> <el-button @click="openAdd" type="primary">新增</el-button> <el-button @click="openForm('add')" type="primary">新增</el-button> </el-row> <el-row class="rowPanel"> @@ -62,8 +62,7 @@ <el-table id="proj" :data="table.rows" :height="height" stripe @sort-change="sortChange"> <el-table-column prop="name" label="规则名称" width="180"> label="规则名称"> </el-table-column> <el-table-column prop="updateTime" @@ -86,12 +85,13 @@ </el-table-column> <el-table-column prop="createBy" label="创建人"> label="创建人" width="180"> </el-table-column> <el-table-column label="操作"> <template slot-scope="scope"> <el-button type="text" @click="openModify(scope.$index, scope.row)" size="small">修改</el-button> <el-button type="text" @click="openForm('modify', scope.row)" size="small">修改</el-button> <el-button type="text" @click="remove(scope.$index, scope.row)" size="small">删除</el-button> </template> </el-table-column> @@ -110,14 +110,71 @@ </el-row> <el-dialog title="title" :title="title" :visible.sync="dialogVisible" width="60%" :before-close="handleClose"> <span>这是一段信息</span> <el-form :model="formData" ref="ruleForm" label-width="100px" class="demo-ruleForm"> <el-form-item label="规则名称" > <el-input style="width: 200px" v-model="formData.name"></el-input> <el-button type="primary" @click="addRuleItem()" size="small">添加规则</el-button> </el-form-item> <el-form-item label="绩效方案" > <el-table :data="formData.ruleItemList" style="width: 100%"> <el-table-column label="业绩类型" > <template slot-scope="scope"> <el-select v-model="scope.row.achieveType" placeholder="请选择业绩类型"> <el-option label="本金消耗" :value="1"></el-option> <el-option label="赠送消耗" :value="2"></el-option> </el-select> </template> </el-table-column> <el-table-column label="计算方式" > <template slot-scope="scope"> <el-select v-model="scope.row.calculationType" placeholder="请选择计算方式"> <el-option label="固定金额" :value="1"></el-option> <el-option label="百分比(%)" :value="2"></el-option> </el-select> </template> </el-table-column> <el-table-column label="区间" width="240"> <template slot-scope="scope"> <el-input style="width: 100px" v-model="scope.row.lower"></el-input> - <el-input style="width: 100px" v-model="scope.row.upper"></el-input> </template> </el-table-column> <el-table-column label="业绩"> <template slot-scope="scope"> <el-input v-model="scope.row.achieve"></el-input> </template> </el-table-column> <el-table-column label="操作"> <template slot-scope="scope"> <el-button type="text" @click="removeRuleItem(scope.$index, scope.row)" size="small">删除</el-button> </template> </el-table-column> </el-table> </el-form-item> </el-form> <span slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">取 消</el-button> <el-button type="primary" @click="dialogVisible = false">确 定</el-button> <el-button type="primary" @click="submitForm">确 定</el-button> </span> </el-dialog> @@ -151,33 +208,19 @@ title: '', formData: { name: '', ruleItemList: [this.defaultRuleItem] }, defaultRuleItem: { ruleItemList: [ { achieveType: 1, calculationType: 1, Lower: '', lower: '', upper: '', achieve: '', } ] }, type: '', achieveTypeList: [{ label: '本金消耗', value: 1 } , { label: '赠送消耗', value: 2 }], calculationTypeList: [ { label: '固定值', value: 1 } , { label: '百分比', value: 2 }] }, created: function () { this.loadData(); @@ -249,12 +292,11 @@ type: 'GET', url: basePath + "/admin/achieveRule/removeById/" + row.id, callback: function (data) { _this.loadData(); _this.$message({ type: 'success', message: data.info, }); debugger _this.loadData(); } }); }).catch(() => { @@ -269,7 +311,8 @@ if (type == 'add') { this.title = '新增规则'; this.$refs['formName'].resetFields(); //this.$refs['formName'].resetFields(); } else { this.title = '修改规则'; this.formData = data; @@ -278,13 +321,74 @@ this.dialogVisible = true; }, //提交表单 submit() { submitForm() { let url = basePath + "/admin/achieveRule/add"; if (this.type == 'modify') { url = basePath + "/admin/achieveRule/update"; } let data=this.formData; if(MTools.isBlank(data.name)){this.$message.error("请输入规则名称");return;} if(data.ruleItemList.length<1){ this.$message.error("最少需要一个计算规则");;return;} let flag=true; data.ruleItemList.forEach(item=>{ if(MTools.isBlank(item.lower)){ this.$message.error("请输入业绩下限");flag=false;} else if(MTools.isBlank(item.upper)){ this.$message.error("请输入业绩上限");flag=false;} else if(MTools.isBlank(item.achieve)){ this.$message.error("请输入业绩金额或者比例");flag=false;} }) if(flag){ var _this=this; AjaxProxy.requst({ app: _this, data:data, url:url, callback: function (data) { _this.$message.success(data.info); _this.loadData(); _this.dialogVisible = false; _this.formData={ name: '', ruleItemList: [ { achieveType: 1, calculationType: 1, lower: '', upper: '', achieve: '', } ] }; } }); } }, handleClose(done) { this.$confirm('确认关闭?') .then(_ => { done(); }) .catch(_ => { }); }, addRuleItem(){ this.formData.ruleItemList.push( { achieveType: 1, calculationType: 1, lower: '', upper: '', achieve: '', } ); }, removeRuleItem(index,row){ this.formData.ruleItemList.splice(index, 1); },