店铺配送不展示已经禁用的物流公司

This commit is contained in:
lifenlong 2021-07-05 15:45:57 +08:00
parent 177cd86366
commit acc40dc6fc
3 changed files with 64 additions and 22 deletions

View File

@ -2,6 +2,7 @@ package cn.lili.modules.distribution.serviceimpl;
import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.json.JSONUtil;
import cn.lili.common.utils.CurrencyUtil; import cn.lili.common.utils.CurrencyUtil;
import cn.lili.common.utils.PageUtil; import cn.lili.common.utils.PageUtil;
import cn.lili.modules.distribution.entity.dos.Distribution; import cn.lili.modules.distribution.entity.dos.Distribution;
@ -13,8 +14,12 @@ import cn.lili.modules.distribution.service.DistributionOrderService;
import cn.lili.modules.distribution.service.DistributionService; import cn.lili.modules.distribution.service.DistributionService;
import cn.lili.modules.order.order.entity.dos.Order; import cn.lili.modules.order.order.entity.dos.Order;
import cn.lili.modules.order.order.entity.dos.StoreFlow; import cn.lili.modules.order.order.entity.dos.StoreFlow;
import cn.lili.modules.order.order.entity.enums.PayStatusEnum;
import cn.lili.modules.order.order.service.OrderService; import cn.lili.modules.order.order.service.OrderService;
import cn.lili.modules.order.order.service.StoreFlowService; import cn.lili.modules.order.order.service.StoreFlowService;
import cn.lili.modules.system.entity.dos.Setting;
import cn.lili.modules.system.entity.dto.DistributionSetting;
import cn.lili.modules.system.entity.enums.SettingEnum;
import cn.lili.modules.system.service.SettingService; import cn.lili.modules.system.service.SettingService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -56,6 +61,13 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
} }
/**
* 1.查看订单是否为分销订单
* 2.查看店铺流水计算分销总佣金
* 3.修改分销员的分销总金额可提现金额
*
* @param orderSn 订单编号
*/
@Override @Override
public void payOrder(String orderSn) { public void payOrder(String orderSn) {
@ -68,11 +80,11 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
List<StoreFlow> storeFlowList = storeFlowService.list(new LambdaQueryWrapper<StoreFlow>() List<StoreFlow> storeFlowList = storeFlowService.list(new LambdaQueryWrapper<StoreFlow>()
.eq(StoreFlow::getOrderSn, orderSn) .eq(StoreFlow::getOrderSn, orderSn)
.isNotNull(StoreFlow::getDistributionRebate)); .isNotNull(StoreFlow::getDistributionRebate));
Double rebate=0.0; Double rebate = 0.0;
//循环店铺流水记录判断是否包含分销商品 //循环店铺流水记录判断是否包含分销商品
//包含分销商品则进行记录分销订单计算分销总额 //包含分销商品则进行记录分销订单计算分销总额
for (StoreFlow storeFlow : storeFlowList) { for (StoreFlow storeFlow : storeFlowList) {
rebate=CurrencyUtil.add(rebate,storeFlow.getDistributionRebate()); rebate = CurrencyUtil.add(rebate, storeFlow.getDistributionRebate());
DistributionOrder distributionOrder = new DistributionOrder(storeFlow); DistributionOrder distributionOrder = new DistributionOrder(storeFlow);
distributionOrder.setDistributionId(order.getDistributionId()); distributionOrder.setDistributionId(order.getDistributionId());
//分销员信息 //分销员信息
@ -80,26 +92,59 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
distributionOrder.setDistributionName(distribution.getMemberName()); distributionOrder.setDistributionName(distribution.getMemberName());
//设置结算天数(解冻日期) //设置结算天数(解冻日期)
// Setting setting = settingService.get(SettingEnum.DISTRIBUTION_SETTING.name()); Setting setting = settingService.get(SettingEnum.DISTRIBUTION_SETTING.name());
// DistributionSetting distributionSetting = JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class); DistributionSetting distributionSetting = JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class);
DateTime dateTime = new DateTime(); DateTime dateTime = new DateTime();
//默认解冻1天 //默认解冻1天
// dateTime.offsetNew(DateField.DAY_OF_MONTH,distributionSetting.getCashDay()); dateTime.offsetNew(DateField.DAY_OF_MONTH, distributionSetting.getCashDay());
dateTime.offsetNew(DateField.DAY_OF_MONTH,1);
distributionOrder.setSettleCycle(dateTime); distributionOrder.setSettleCycle(dateTime);
this.save(distributionOrder); this.save(distributionOrder);
} }
//如果包含分销商品则记录会员的分销总额 //如果包含分销商品则记录会员的分销总额
if(rebate!=0.0){ if (rebate != 0.0) {
distributionService.addRebate(rebate,order.getDistributionId()); distributionService.addRebate(rebate, order.getDistributionId());
} }
} }
} }
/**
* 1.获取订单判断是否为已付款的分销订单
* 2.查看店铺流水记录分销佣金
* 3.修改分销员的分销总金额可提现金额
*
* @param orderSn 订单编号
*/
@Override @Override
public void cancelOrder(String orderSn) { public void cancelOrder(String orderSn) {
//根据订单编号获取订单数据
Order order = orderService.getBySn(orderSn);
//判断是否为已付款的分销订单则获取分销佣金
if (order.getDistributionId() != null && order.getPayStatus().equals(PayStatusEnum.PAID.name())) {
//根据订单编号获取有分销金额的店铺流水记录
List<DistributionOrder> distributionOrderList = this.list(new LambdaQueryWrapper<DistributionOrder>()
.eq(DistributionOrder::getOrderSn, orderSn));
//分销金额
Double rebate = 0.0;
//包含分销商品则进行记录分销订单计算分销总额
for (DistributionOrder distributionOrder : distributionOrderList) {
rebate = CurrencyUtil.add(rebate, distributionOrder.getRebate());
}
//如果包含分销商品则记录会员的分销总额
if (rebate != 0.0) {
distributionService.addRebate(CurrencyUtil.sub(0, rebate), order.getDistributionId());
}
}
//修改分销订单的状态
this.update(new LambdaUpdateWrapper<DistributionOrder>().eq(DistributionOrder::getOrderSn, orderSn) this.update(new LambdaUpdateWrapper<DistributionOrder>().eq(DistributionOrder::getOrderSn, orderSn)
.set(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.CANCEL.name())); .set(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.CANCEL.name()));
} }
@Override @Override
@ -117,18 +162,15 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
//已提交无法重复提交 //已提交无法重复提交
//如果未结算则将分销订单取消 //如果未结算则将分销订单取消
//如果已结算则创建退款分销订单 //如果已结算则创建退款分销订单
if(distributionOrder.getDistributionOrderStatus().equals(DistributionOrderStatusEnum.CANCEL.name())){ if (distributionOrder.getDistributionOrderStatus().equals(DistributionOrderStatusEnum.CANCEL.name())) {
return ; return;
} else if(distributionOrder.getDistributionOrderStatus().equals(DistributionOrderStatusEnum.WAIT_BILL.name())){ } else if (distributionOrder.getDistributionOrderStatus().equals(DistributionOrderStatusEnum.WAIT_BILL.name())) {
this.update(new LambdaUpdateWrapper<DistributionOrder>().eq(DistributionOrder::getOrderItemSn, storeFlow.getOrderItemSn()) this.update(new LambdaUpdateWrapper<DistributionOrder>()
.eq(DistributionOrder::getOrderItemSn, storeFlow.getOrderItemSn())
.set(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.CANCEL.name())); .set(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.CANCEL.name()));
}else{ } else {
//创建分销退款订单
DistributionOrder backDistributionOrder = new DistributionOrder();
this.save(backDistributionOrder);
//修改分销员提成金额 //修改分销员提成金额
distributionService.subCanRebate(CurrencyUtil.sub(0,storeFlow.getDistributionRebate()),distributionOrder.getDistributionId()); distributionService.subCanRebate(CurrencyUtil.sub(0, storeFlow.getDistributionRebate()), distributionOrder.getDistributionId());
} }
} }
} }

View File

@ -41,7 +41,7 @@ public interface OrderMapper extends BaseMapper<Order> {
@Select("SELECT o.sn,o.create_time,o.member_name,o.consignee_name,o.consignee_mobile,o.consignee_address_path,o.consignee_detail," + @Select("SELECT o.sn,o.create_time,o.member_name,o.consignee_name,o.consignee_mobile,o.consignee_address_path,o.consignee_detail," +
"o.payment_method, o.logistics_name,o.freight_price,o.goods_price,o.discount_price,o.flow_price,oi.goods_name,oi.num," + "o.payment_method, o.logistics_name,o.freight_price,o.goods_price,o.discount_price,o.flow_price,oi.goods_name,oi.num," +
"o.remark,o.order_status,o.pay_status,o.deliver_status,o.need_receipt,o.store_name FROM li_order_item oi INNER JOIN li_order o ON oi.order_sn=o.sn") "o.remark,o.order_status,o.pay_status,o.deliver_status,o.need_receipt,o.store_name FROM li_order_item oi INNER JOIN li_order o ON oi.order_sn=o.sn ${ew.customSqlSegment}")
List<OrderExportDTO> queryExportOrder(@Param(Constants.WRAPPER) Wrapper<OrderSimpleVO> queryWrapper); List<OrderExportDTO> queryExportOrder(@Param(Constants.WRAPPER) Wrapper<OrderSimpleVO> queryWrapper);
@Select("select * from li_order ${ew.customSqlSegment} ") @Select("select * from li_order ${ew.customSqlSegment} ")

View File

@ -15,13 +15,13 @@ import java.util.List;
*/ */
public interface StoreLogisticsMapper extends BaseMapper<StoreLogistics> { public interface StoreLogisticsMapper extends BaseMapper<StoreLogistics> {
@Select("SELECT l.* FROM li_logistics l RIGHT JOIN li_store_logistics sl ON l.id=sl.logistics_id WHERE sl.store_id=#{storeId}") @Select("SELECT l.* FROM li_logistics l RIGHT JOIN li_store_logistics sl ON l.id=sl.logistics_id WHERE sl.store_id=#{storeId} AND l.disabled='OPEN'")
List<StoreLogisticsVO> getSelectedStoreLogistics(String storeId); List<StoreLogisticsVO> getSelectedStoreLogistics(String storeId);
@Select("SELECT l.name FROM li_logistics l RIGHT JOIN li_store_logistics sl ON l.id=sl.logistics_id WHERE sl.store_id=#{storeId}") @Select("SELECT l.name FROM li_logistics l RIGHT JOIN li_store_logistics sl ON l.id=sl.logistics_id WHERE sl.store_id=#{storeId} AND l.disabled='OPEN'")
List<String> getSelectedStoreLogisticsName(String storeId); List<String> getSelectedStoreLogisticsName(String storeId);
@Select("SELECT *, ( SELECT sl.id FROM li_store_logistics sl WHERE l.id = sl.logistics_id AND sl.store_id=#{storeId} ) AS selected FROM li_logistics l;") @Select("SELECT *, ( SELECT sl.id FROM li_store_logistics sl WHERE l.id = sl.logistics_id AND sl.store_id=#{storeId} ) AS selected FROM li_logistics l AND l.disabled='OPEN';")
List<StoreLogisticsVO> getStoreLogistics(String storeId); List<StoreLogisticsVO> getStoreLogistics(String storeId);
} }