加价拆分逻辑/下单到付逻辑

This commit is contained in:
kuang.yife 2023-10-05 01:24:05 +08:00
parent 73f9cd14e6
commit 6b6886f3f3
11 changed files with 156 additions and 19 deletions

View File

@ -230,6 +230,7 @@ public class OrderController extends BaseController {
orderMaster.setGoodsId(goods.getGoodsId());
orderMaster.setPayType(0);
orderMaster.setOrderMode(request.getOrderMode());
orderMaster.setPayMode(request.getPayMode());
// 存在登陆用户的情况下
if(getSysUser() != null){
orderMaster.setCreateBy(getSysUser().getUserId().toString());

View File

@ -348,7 +348,7 @@
<div class="oper-banner-end col-sm-5">
<div class="m-r">
<div class="checkbox">
<label><input id="payOnDoorMode" type="checkbox" value="02" name="orderMode" onclick="changePayOnDoorMode(this)">上门到付/保外单</label>
<label><input id="payOnDoorMode" type="checkbox" value="02" name="payMode" onclick="changePayOnDoorMode(this)">上门到付/保外单</label>
</div>
</div>
<div class="m-r">
@ -540,9 +540,11 @@
}
function changePayOnDoorMode(e) {
<!-- if ($(e).is(':checked')) {-->
<!-- $('#publishWithPrice').prop("checked", false);-->
<!-- }-->
if ($(e).is(':checked')) {
$('#payOnDoorMode').prop("value", '01');
} else {
$('#payOnDoorMode').prop("value", '02');
}
}
function validSpecialComponent() {
@ -597,6 +599,7 @@
params.cityId = areaCascader.getCheckedPaths()[0][1];
params.districtId = areaCascader.getCheckedPaths()[0][2];
params.streetId = areaCascader.getCheckedPaths()[0][3];
params.payMode = $('#payOnDoorMode').val();
return params;
}

View File

@ -189,6 +189,7 @@
var payTypes = [[${@dict.getType('pay_type')}]];
var orderTypes = [[${@dict.getType('goods_category_type')}]];
var orderModes = [[${@dict.getType('order_mode')}]];
var payModes = [[${@dict.getType('pay_mode')}]];
var payStatus = [[${@dict.getType('pay_status')}]];
var orderStatus = [[${@dict.getType('order_status')}]];
@ -463,8 +464,18 @@
{
field: 'changeMoney',
title: '商家追加金额',
align: 'center'
},{
align: 'center',
visible: false
},
{
field: 'payMode',
title: '商家付费模式',
align: 'center',
formatter: function (value, row, index) {
return $.table.selectDictLabel(payModes, value);
}
},
{
field: 'orderMode',
title: '下单模式',
align: 'center',

View File

@ -144,6 +144,8 @@ public class OrderMaster extends BaseEntity {
private String orderMode;
private String payMode;
private Integer sysPayStatus;
/**

View File

@ -37,6 +37,7 @@ public class OrderTemplate extends BaseEntity {
private String customerPhone;
// 下单模式 1=带价发布 2=一票价发布 3=回收模式
private Integer orderMode;
private String payMode;
// 发布价格(限制整数)
private Integer price;
// 上门代收款(限制整数)

View File

@ -50,4 +50,6 @@ public class SysOrderAssignRequest {
private String orderMode;
private String payMode;
}

View File

@ -900,6 +900,23 @@ public class OrderDetailServiceImpl implements OrderDetailService {
if (orderDetail == null) {
throw new BaseException("子单不存在!");
}
// 主单
OrderMaster orderMaster = orderMasterService.selectById(orderDetail.getOrderMasterId());
// 主师傅
Worker workerMaster = workerService.selectById(orderMaster.getWorkerId());
// 三级类目
List<OrderGoods> orderGoods = orderGoodsService.selectByOrderDetailId(orderDetailId);
if (CollectionUtils.isEmpty(orderGoods)) {
throw new BaseException("找不到子订单对应的商品");
}
Long goodsStandardId = orderGoods.get(0).getGoodsStandardId();
GoodsStandard goodsStandard = goodsStandardService.selectById(goodsStandardId);
// 第四级规格
DeptGoodsCategory childCategory = deptGoodsCategoryService.get(goodsStandard.getDeptGoodsCategoryId());
// 需要找第三级规格
DeptGoodsCategory deptGoodsCategory = deptGoodsCategoryService.selectOneByGoodsCategoryId(childCategory.getParentCategoryId());
FinancialChangeRecord param = new FinancialChangeRecord();
param.setPayStatus(0);
param.setOrderDetailId(orderDetailId);
@ -918,6 +935,7 @@ public class OrderDetailServiceImpl implements OrderDetailService {
financialChangeRecord.setChangeMoney(changeMoney);
financialChangeRecord.setType(type);
financialChangeRecord.setRemark(remark);
this.buildSettle(financialChangeRecord, deptGoodsCategory, workerMaster);
affectedRows = financialChangeRecordService.update(financialChangeRecord);
} else {
// 创建改单记录
@ -929,6 +947,7 @@ public class OrderDetailServiceImpl implements OrderDetailService {
financialChangeRecord.setPayStatus(0);
financialChangeRecord.setType(type);
financialChangeRecord.setRemark(remark);
this.buildSettle(financialChangeRecord, deptGoodsCategory, workerMaster);
affectedRows = financialChangeRecordService.insert(financialChangeRecord);
}
if (changeMoney.compareTo(BigDecimal.ZERO) != 0 && affectedRows != 1) {
@ -938,6 +957,60 @@ public class OrderDetailServiceImpl implements OrderDetailService {
return affectedRows;
}
/**
* <p>构建各分销所得金额</p>
* @param deptGoodsCategory 三级类目用来计算扣点
* @param financialChangeRecord 加价记录
*
*/
private void buildSettle(FinancialChangeRecord financialChangeRecord, DeptGoodsCategory deptGoodsCategory, Worker workerMaster){
// 一级分销追加扣点
BigDecimal saleRateOne = new BigDecimal(deptGoodsCategory.getOneRate());
saleRateOne = MoneyUtil.lt0(saleRateOne) ? BigDecimal.ZERO : saleRateOne;
BigDecimal saleOneMoney = financialChangeRecord.getChangeMoney().multiply(saleRateOne);
financialChangeRecord.setOneMoney(saleOneMoney);
// 二级分销追加扣点
BigDecimal saleRateTwo = new BigDecimal(deptGoodsCategory.getTwoRate());
saleRateTwo = MoneyUtil.lt0(saleRateTwo) ? BigDecimal.ZERO : saleRateTwo;
BigDecimal saleTwoMoney = financialChangeRecord.getChangeMoney().multiply(saleRateTwo);
financialChangeRecord.setTwoMoney(saleTwoMoney);
// 三级分销追加扣点
BigDecimal saleRateThree = new BigDecimal(deptGoodsCategory.getThreeRate());
saleRateThree = MoneyUtil.lt0(saleRateThree) ? BigDecimal.ZERO : saleRateThree;
BigDecimal saleThreeMoney = financialChangeRecord.getChangeMoney().multiply(saleRateThree);
financialChangeRecord.setThreeMoney(saleThreeMoney);
// 大师傅提成
BigDecimal teamRete = new BigDecimal(workerMaster.getLeaderTeamRate());
teamRete = MoneyUtil.lt0(teamRete) ? BigDecimal.ZERO : teamRete;
BigDecimal teamMoney = new BigDecimal(workerMaster.getLeaderTeamMoney());
teamMoney = MoneyUtil.lt0(teamMoney) ? BigDecimal.ZERO : teamMoney;
BigDecimal leaderMoney = financialChangeRecord.getChangeMoney().multiply(teamRete).add(teamMoney);
financialChangeRecord.setLeaderMoney(leaderMoney);
// 平台加价抽成
BigDecimal deptRate = new BigDecimal(deptGoodsCategory.getDeptRate());
deptRate = MoneyUtil.lt0(deptRate) ? BigDecimal.ZERO : deptRate;
BigDecimal deptMoney = MoneyUtil.lt0(deptGoodsCategory.getDeptMoney()) ? BigDecimal.ZERO : deptGoodsCategory.getDeptMoney();
BigDecimal deptChangeMoney = deptMoney.add(financialChangeRecord.getChangeMoney().multiply(deptRate));
financialChangeRecord.setDeptMoney(deptChangeMoney);
// 截留扣点
BigDecimal pcDeptRate = new BigDecimal(deptGoodsCategory.getPcDeptRate());
pcDeptRate = MoneyUtil.lt0(pcDeptRate) ? BigDecimal.ZERO : pcDeptRate;
BigDecimal pcDeptMoney = MoneyUtil.lt0(deptGoodsCategory.getPcDeptMoney()) ? BigDecimal.ZERO : deptGoodsCategory.getPcDeptMoney();
BigDecimal deptAddMoney = financialChangeRecord.getChangeMoney().multiply(pcDeptRate).add(pcDeptMoney);
financialChangeRecord.setDeptAddMoney(deptAddMoney);
// 师傅剩余服务金额
financialChangeRecord.setWorkerMoney(financialChangeRecord.getChangeMoney().subtract(saleOneMoney)
.subtract(saleTwoMoney).subtract(saleThreeMoney).subtract(leaderMoney)
.subtract(deptChangeMoney).subtract(deptAddMoney));
}
@Override
public int sureChange(Long financialChangeRecordId) {
return 0;

View File

@ -12,6 +12,7 @@
<result property="addressId" column="address_id"/>
<result property="orderType" column="order_type"/>
<result property="orderMode" column="order_mode"/>
<result property="payMode" column="pay_mode"/>
<result property="orderStatus" column="order_status"/>
<result property="payType" column="pay_type"/>
<result property="payStatus" column="pay_status"/>
@ -42,6 +43,7 @@
address_id,
order_type,
order_mode,
pay_mode,
order_status,
pay_type,
pay_status,
@ -70,6 +72,7 @@
om.address_id,
om.order_type,
om.order_mode,
om.pay_mode,
om.order_status,
om.pay_type,
om.pay_status,
@ -352,6 +355,7 @@
<if test="goodsId != null and goodsId != 0">goods_id,</if>
<if test="orderType != null">order_type,</if>
<if test="orderMode != null">order_mode,</if>
<if test="payMode != null">pay_mode,</if>
<if test="orderStatus != null">order_status,</if>
<if test="payType != null">pay_type,</if>
<if test="payStatus != null">pay_status,</if>
@ -371,6 +375,7 @@
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
<if test="orderType != null">#{orderType},</if>
<if test="orderMode != null">#{orderMode},</if>
<if test="payMode != null">#{payMode},</if>
<if test="orderStatus != null">#{orderStatus},</if>
<if test="payType != null">#{payType},</if>
<if test="payStatus != null">#{payStatus},</if>

View File

@ -18,6 +18,7 @@
<result property="customerName" column="customer_name"/>
<result property="customerPhone" column="customer_phone"/>
<result property="orderMode" column="order_mode"/>
<result property="payMode" column="pay_mode"/>
<result property="price" column="price"/>
<result property="agencyFund" column="agency_fund"/>
<result property="informationFee" column="information_fee"/>
@ -75,6 +76,7 @@
<if test="customerName != null ">customer_name,</if>
<if test="customerPhone != null ">customer_phone,</if>
<if test="orderMode != null">order_mode,</if>
<if test="payMode != null">pay_mode,</if>
<if test="price != null">price,</if>
<if test="agencyFund != null">agency_fund,</if>
<if test="informationFee != null">information_fee,</if>
@ -97,6 +99,7 @@
<if test="customerName != null">#{customerName},</if>
<if test="customerPhone != null">#{customerPhone},</if>
<if test="orderMode != null">#{orderMode},</if>
<if test="payMode != null">#{payMode},</if>
<if test="price != null">#{price},</if>
<if test="agencyFund != null">#{agencyFund},</if>
<if test="informationFee != null">#{informationFee},</if>
@ -142,7 +145,7 @@
<sql id="selectColumns">
SELECT id, user_id, template_name,goods_brand, goods_specification, video_url, image_url,
address_id, street_id, full_address, customer_name, customer_phone, order_mode,
address_id, street_id, full_address, customer_name, customer_phone, order_mode,pay_mode,
price, agency_fund, information_fee, bonus, logistics_code, need_wagon, need_carry, floor,
create_by, create_time, update_by, update_time, remark
FROM order_template

View File

@ -70,16 +70,24 @@ public class FinancialChangeRecord extends BaseEntity {
@Excel(name = "剩余分账金额")
private BigDecimal leftMoney;
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("orderDetailId", getOrderDetailId())
.append("changeMoney", getChangeMoney())
.append("status", getStatus())
.append("payStatus", getPayStatus())
.append("type", getType())
.append("leftMoney", getLeftMoney())
.toString();
}
@Excel(name = "一级分销")
private BigDecimal oneMoney;
@Excel(name = "二级分销")
private BigDecimal twoMoney;
@Excel(name = "三级分销")
private BigDecimal threeMoney;
@Excel(name = "平台扣点")
private BigDecimal deptMoney;
@Excel(name = "平台追加扣点")
private BigDecimal deptAddMoney;
@Excel(name = "团队师傅扣点")
private BigDecimal leaderMoney;
@Excel(name = "工作师傅剩余金额")
private BigDecimal workerMoney;
}

View File

@ -11,6 +11,13 @@
<result property="paymentId" column="payment_id"/>
<result property="reverseId" column="reverse_id"/>
<result property="changeMoney" column="change_money"/>
<result property="oneMoney" column="one_money"/>
<result property="twoMoney" column="two_money"/>
<result property="threeMoney" column="three_money"/>
<result property="deptMoney" column="dept_money"/>
<result property="deptAddMoney" column="dept_add_money"/>
<result property="leaderMoney" column="leader_money"/>
<result property="workerMoney" column="worker_money"/>
<result property="status" column="status"/>
<result property="payStatus" column="pay_status"/>
<result property="leftMoney" column="left_money"/>
@ -59,6 +66,13 @@
<if test="orderMasterId != null">order_master_id,</if>
<if test="paymentId != null">payment_id,</if>
<if test="reverseId != null">reverse_id,</if>
<if test="oneMoney != null">one_money,</if>
<if test="twoMoney != null">two_money,</if>
<if test="threeMoney != null">three_money,</if>
<if test="deptMoney != null">dept_money,</if>
<if test="deptAddMoney != null">dept_add_money,</if>
<if test="leaderMoney != null">leader_money,</if>
<if test="workerMoney != null">worker_money,</if>
<if test="changeMoney != null">change_money,</if>
<if test="status != null">status,</if>
<if test="payStatus != null">pay_status,</if>
@ -70,6 +84,13 @@
<if test="orderMasterId != null">#{orderMasterId},</if>
<if test="paymentId != null">#{paymentId},</if>
<if test="reverseId != null">#{reverseId},</if>
<if test="oneMoney != null">#{oneMoney},</if>
<if test="twoMoney != null">#{twoMoney},</if>
<if test="threeMoney != null">#{threeMoney},</if>
<if test="deptMoney != null">#{deptMoney},</if>
<if test="deptAddMoney != null">#{deptAddMoney},</if>
<if test="leaderMoney != null">#{leaderMoney},</if>
<if test="workerMoney != null">#{workerMoney},</if>
<if test="changeMoney != null">#{changeMoney},</if>
<if test="status != null">#{status},</if>
<if test="payStatus != null">#{payStatus},</if>
@ -86,6 +107,13 @@
<if test="paymentId != null">payment_id = #{paymentId},</if>
<if test="reverseId != null">reverse_id = #{reverseId},</if>
<if test="changeMoney != null">change_money = #{changeMoney},</if>
<if test="oneMoney != null">one_money = #{oneMoney},</if>
<if test="twoMoney != null">two_money = #{twoMoney},</if>
<if test="threeMoney != null">three_money = #{threeMoney},</if>
<if test="deptMoney != null">dept_money = #{deptMoney},</if>
<if test="deptAddMoney != null">dept_add_money = #{deptAddMoney},</if>
<if test="leaderMoney != null">leader_money = #{leaderMoney},</if>
<if test="workerMoney != null">worker_money = #{workerMoney},</if>
<if test="status != null">status = #{status},</if>
<if test="payStatus != null">pay_status = #{payStatus},</if>
<if test="type != null">type = #{type},</if>