大大的豆芽 2 сар өмнө
parent
commit
15d0933b93

+ 4 - 4
admin-ui/src/views/components/OrderTrendChart.vue

@@ -53,7 +53,7 @@ export default {
           }
         },
         legend: {
-          data: ['洗衣金额', '撤单金额']
+          data: ['洗衣金额','实付金额']
         },
         grid: {
           left: '3%',
@@ -84,10 +84,10 @@ export default {
             emphasis: {
               focus: 'series'
             },
-            data: this.data.map(item => item.dailyInFactoryAmount || 0)
+            data: this.data.map(item => item.clothOrderAmount || 0)
           },
           {
-            name: '撤单金额',
+            name: '实付金额',
             type: 'line',
             stack: 'Total',
             areaStyle: {
@@ -96,7 +96,7 @@ export default {
             emphasis: {
               focus: 'series'
             },
-            data: this.data.map(item => item.dailyRefundAmount || 0)
+            data: this.data.map(item => item.clothReceiveAmount || 0)
           }
         ]
       }

+ 1 - 1
admin-ui/src/views/index_store.vue

@@ -19,7 +19,7 @@
               <div class="stat-card stat-card-green">
                 <div class="stat-card-title">洗衣金额</div>
                 <div class="stat-card-value">
-                  <count-to :start-val="0" :end-val="orderStats.clothCashAmount || 0" :duration="2600" prefix="¥" />
+                  <count-to :start-val="0" :end-val="orderStats.clothOrderAmount || 0" :duration="2600" prefix="¥" />
                 </div>
               </div>
             </el-col>

+ 0 - 41
yiqi-common/src/main/java/com/yiqi/core/domain/SettlementManageStore.java

@@ -305,7 +305,6 @@ public class SettlementManageStore
     /** 福利结算表id */
     @Excel(name = "福利结算表id")
     @ApiModelProperty("福利结算表id")
-
     private Long welfareSettleId;
 
     /** 卡密金额 */
@@ -333,46 +332,6 @@ public class SettlementManageStore
     @ApiModelProperty("已付卡密押金")
     private BigDecimal paidCardPasswordDeposit;
 
-    /** 工厂结算费率(门店洗衣费率)/云洗费率 */
-    @Excel(name = "工厂结算费率", readConverterExp = "门=店洗衣费率")
-    @ApiModelProperty("工厂结算费率(门店洗衣费率)/云洗费率")
-    private BigDecimal factoryRate;
-
-    /** 材料费率 */
-    @Excel(name = "材料费率")
-    @ApiModelProperty("材料费率")
-    private BigDecimal materialRate;
-
-    /** 管理费率 */
-    @Excel(name = "管理费率")
-    @ApiModelProperty("管理费率")
-    private BigDecimal manageRate;
-
-    /** 押金费率 */
-    @Excel(name = "押金费率")
-    @ApiModelProperty("押金费率")
-    private BigDecimal depositRate;
-
-    /** 异店消费费率 */
-    @Excel(name = "异店消费费率")
-    @ApiModelProperty("异店消费费率")
-    private BigDecimal otherStoreRate;
-
-    /** 支付宝费率 */
-    @Excel(name = "支付宝费率")
-    @ApiModelProperty("支付宝费率")
-    private BigDecimal aliPayRate;
-
-    /** 微信费率 */
-    @Excel(name = "微信费率")
-    @ApiModelProperty("微信费率")
-    private BigDecimal wxPayRate;
-
-    /** 支付宝微信费率 */
-    @Excel(name = "支付宝微信费率")
-    @ApiModelProperty("支付宝微信费率")
-    private BigDecimal aliWxPayRate;
-
 
     private String remark;
 }

+ 2 - 2
yiqi-common/src/main/java/com/yiqi/order/domain/OrderClothItem.java

@@ -189,8 +189,8 @@ public class OrderClothItem extends BaseEntity
      *     refund("102","撤单"),
      *
      *     */
-    @Excel(name = "洗衣状态", readConverterExp = "0=待入厂,1=已入厂,2=已检查,3=已出厂,4=已上挂,5=已取衣,6=已到店、待送衣,7=送衣中,8=已送达、待评价,9=已完成,100=重洗,101=删除入厂,102=撤单")
-    @ApiModelProperty("洗衣状态(0=待入厂,1=已入厂,2=已检查,3=已出厂,4=已上挂,5=已取衣,6=已到店、待送衣,7=送衣中,8=已送达、待评价,9=已完成,100=重洗,101=删除入厂,102=撤单)")
+    @Excel(name = "洗衣状态", readConverterExp = "0=待入厂,1=已入厂,2=已检查,3=已出厂,4=已上挂,5=已取衣,6=已到店、待送衣,7=送衣中,8=已送达、待评价,9=已完成,100=重洗,11=删除入厂,-1=撤单")
+    @ApiModelProperty("洗衣状态(0=待入厂,1=已入厂,2=已检查,3=已出厂,4=已上挂,5=已取衣,6=已到店、待送衣,7=送衣中,8=已送达、待评价,9=已完成,100=重洗,11=删除入厂,-1=撤单)")
     private String flowStatus;
 
 

+ 10 - 3
yiqi-common/src/main/java/com/yiqi/order/domain/dto/RechargeCardPayDTO.java

@@ -1,5 +1,6 @@
 package com.yiqi.order.domain.dto;
 
+import com.yiqi.common.annotation.Excel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -16,8 +17,13 @@ public class RechargeCardPayDTO {
     @ApiModelProperty("客户ID")
     private Long appUserId;
 
+    /** 来源类型 */
+    @Excel(name = "来源类型")
+    @ApiModelProperty("来源类型")
+    private String sourceType;
+
     @ApiModelProperty("扣款门店ID")
-    private Long storeId;
+    private Long orgId;
 
     @ApiModelProperty("订单编号,预约单时需要")
     @NotNull(message = "订单编号必传")
@@ -39,8 +45,9 @@ public class RechargeCardPayDTO {
     @NotEmpty(message = "购买商品类型 1:洗衣 2:普通商品 3:生活服务 4:汽车美容")
     private String buyGoodsType;
 
-    public RechargeCardPayDTO(Long appUserId, Long storeId, String orderNo, BigDecimal payAmount, String buyGoodsType) {
-        this.storeId = storeId;
+    public RechargeCardPayDTO(Long appUserId, String sourceType, Long orgId, String orderNo, BigDecimal payAmount, String buyGoodsType) {
+        this.sourceType = sourceType;
+        this.orgId = orgId;
         this.appUserId = appUserId;
         this.orderNo = orderNo;
         this.payAmount = payAmount;

+ 9 - 2
yiqi-common/src/main/java/com/yiqi/recharge/domain/dto/BillMstrOrderDTO.java

@@ -76,9 +76,16 @@ public class BillMstrOrderDTO {
     private Long appUserId;
 
     /**
-     * 扣款门店
+     * 消费来源
      */
-    private Long storeId;
+    @Excel(name = "来源类型")
+    @ApiModelProperty("来源类型")
+    private String sourceType;
+
+    /**
+     * 消费来源门店
+     */
+    private Long orgId;
 
     /**
      * 会员卡绑定门店

+ 4 - 6
yiqi-core/src/main/java/com/yiqi/app/service/impl/AppUserBillMstrServiceImpl.java

@@ -8,8 +8,6 @@ import com.yiqi.common.core.domain.R;
 import com.yiqi.common.enums.*;
 import com.yiqi.common.utils.DateUtils;
 import com.yiqi.common.utils.EnumUtils;
-import com.yiqi.order.domain.dto.PayRefundDTO;
-import com.yiqi.order.domain.dto.RefundBaseDTO;
 import com.yiqi.order.service.IPayService;
 import com.yiqi.recharge.domain.dto.BillMstrOrderDTO;
 import com.yiqi.recharge.domain.dto.ConsumeOrderDTO;
@@ -62,9 +60,9 @@ public class AppUserBillMstrServiceImpl extends ServiceImpl<AppUserBillMstrMappe
         appUserBillMstr.setIsRefund(SysBoolType.NO.getCode());
         appUserBillMstr.setOrderNo(billMstrOrderDTO.getOrderNo());
         appUserBillMstr.setOrderType(billMstrOrderDTO.getOrderType());
-        appUserBillMstr.setOrgId(billMstrOrderDTO.getStoreId());
+        appUserBillMstr.setSourceType(billMstrOrderDTO.getSourceType());
+        appUserBillMstr.setOrgId(billMstrOrderDTO.getOrgId());
         appUserBillMstr.setCardStoreId(billMstrOrderDTO.getUseBindStoreId());
-        appUserBillMstr.setSourceType(SourceType.STORE.getCode());
         appUserBillMstr.setContent(billMstrOrderDTO.getRemark());
         appUserBillMstr.setRechargeCardNo(billMstrOrderDTO.getRechargeCardNo());
         switch (EnumUtils.getEnumByType(billMstrOrderDTO.getOrderType(), OrderType.class)) {
@@ -112,9 +110,9 @@ public class AppUserBillMstrServiceImpl extends ServiceImpl<AppUserBillMstrMappe
         appUserBillMstr.setIsRefund(SysBoolType.YES.getCode());
         appUserBillMstr.setOrderNo(billMstrOrderDTO.getOrderNo());
         appUserBillMstr.setOrderType(billMstrOrderDTO.getOrderType());
-        appUserBillMstr.setOrgId(billMstrOrderDTO.getStoreId());
+        appUserBillMstr.setOrgId(billMstrOrderDTO.getOrgId());
         appUserBillMstr.setCardStoreId(billMstrOrderDTO.getUseBindStoreId());
-        appUserBillMstr.setSourceType(SourceType.STORE.getCode());
+        appUserBillMstr.setSourceType(billMstrOrderDTO.getSourceType());
         appUserBillMstr.setContent(billMstrOrderDTO.getRemark());
         switch (EnumUtils.getEnumByType(billMstrOrderDTO.getOrderType(), OrderType.class)) {
             case cloth: {

+ 130 - 57
yiqi-core/src/main/java/com/yiqi/core/service/impl/SettlementManageBillServiceImpl.java

@@ -11,6 +11,7 @@ import com.wechat.pay.java.service.billdownload.model.BillType;
 import com.yiqi.app.domain.AppUserBillMstr;
 import com.yiqi.app.service.IAppUserBillMstrService;
 import com.yiqi.common.enums.*;
+import com.yiqi.common.exception.ServiceException;
 import com.yiqi.common.utils.CurrencyUtil;
 import com.yiqi.common.utils.DateUtils;
 import com.yiqi.core.domain.SettlementManageFactory;
@@ -111,7 +112,7 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         settlementManageBill.setEndTime(endTime);
         settlementManageBill.setTitle(settlementBillAddDTO.getTitle());
         settlementManageBill.buildCreateData();
-        settlementManageBill.setStatus(SettlementBillStatusType.COUNT.getCode());
+        settlementManageBill.setStatus(SettlementBillStatusType.WAITING.getCode());
         settlementManageBill.setDelFlag(StatusType.OK.getCode());
         this.save(settlementManageBill);
         return settlementManageBill;
@@ -132,14 +133,7 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         }
 
         for (ManageFactory factory : factoryList) {
-            //查询衣服订单,入场时间在上个月的,切没有撤销的衣服
-            List<OrderClothItem> orderClothItemList = orderClothItemService.list(new QueryWrapper<OrderClothItem>().lambda()
-                    .ne(OrderClothItem::getFlowStatus, ClothOrderFlowStatus.refund.getCode())
-                    .eq(OrderClothItem::getFactoryId, factory.getId())
-                    .ge(OrderClothItem::getCreateTime, settlementManageBill.getBeginTime())
-                    .ge(OrderClothItem::getInFactoryTime, settlementManageBill.getBeginTime())
-                    .lt(OrderClothItem::getInFactoryTime, DateUtils.addDays(settlementManageBill.getEndTime(), 1)));
-            this.buildFactorySettlement(settlementManageBill, factory, orderClothItemList);
+            this.buildFactorySettlement(settlementManageBill, factory);
         }
     }
 
@@ -511,6 +505,9 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         // 5. 计算运营相关金额
         calculateOperationalAmounts(settlement, data);
 
+        //计算跨店结算金
+        calculateCrossStoreAmount(settlement, data);
+
         // 6. 计算最终结算金额
         calculateFinalSettlement(settlement);
 
@@ -620,17 +617,18 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
                 .map(OrderClothItem::getPayPrice)
                 .reduce(BigDecimal.ZERO, BigDecimal::add);
         settlement.setWashClothAmount(washAmount);
-
-
-//        calculateCrossStoreAmount(data);
-
-
-//        BigDecimal crossStoreAmount = calculateCrossStoreAmount(data);
-//        settlement.setCrossStoreSettlementAmount(crossStoreAmount);
     }
 
     /**
      * 计算跨店结算金额
+     * *
+     * 1. 洗衣:线下门店,会员用余额支付的洗衣订单
+     * 2. 零售:线下门店,会员用余额支付的零售商品订单
+     * 3. app:线上app,会员用余额支付的零售商品订单(app洗衣订单不存在跨店结算)
+     * 4. 第三方:线下门店,会员用微信/支付宝等第三方支付渠道支付的所有订单(含洗衣和零售,实际情况下比较少)
+     * 5. 运费:暂时为0(目前平台和门店自有运费账户走预充值模式,字段保留)
+     * 根据会员余额所消费的门店费率计算分成,分成规则为:
+     * *      * 本店卡洗衣所得为本店卡在异店消费分给消费门店的费用,异店卡洗衣为异店卡在本店消费分给本店的费用**
      */
     private void calculateCrossStoreAmount(SettlementManageStore settlement, StoreSettlementData data) {
         // 4. 计算跨店结算金额(会员卡)
@@ -638,33 +636,109 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         // (本店卡:零售*费率-异店卡:零售*费率)+(本店卡:app*费率-异店卡:app*费率)+
         // (本店卡:第三方*费率-异店卡:第三方*费率)+(本店卡:运费*费率-异店卡:运费*费率)
         //消费的订单金额  洗衣 零售 app 第三方 运费
-        Map<String, BigDecimal> consoumeMaps = data.getCrossStoreBills().stream()
-                .filter(order -> OrderBillType.pay.getCode().equals(order.getBillType()))
-                .collect(Collectors.groupingBy(
-                        AppUserBillMstr::getOrderType,
-                        Collectors.reducing(
-                                BigDecimal.ZERO,
-                                AppUserBillMstr::getPayTotalAmount,
-                                BigDecimal::add
-                        )));
-        //退款的订单金额
-        Map<String, BigDecimal> refundMaps = data.getCrossStoreBills().stream()
-                .filter(order -> OrderBillType.recharge.getCode().equals(order.getBillType()))
-                .collect(Collectors.groupingBy(
-                        AppUserBillMstr::getOrderType,
-                        Collectors.reducing(
-                                BigDecimal.ZERO,
-                                AppUserBillMstr::getPayTotalAmount,
-                                BigDecimal::add
-                        )));
-
-
+        BigDecimal washAmount = BigDecimal.ZERO;
+        BigDecimal washOtherAmount = BigDecimal.ZERO; //洗衣异店
+        BigDecimal goodsAmount = BigDecimal.ZERO;
+        BigDecimal goodsOtherAmount = BigDecimal.ZERO;
+        BigDecimal appAmount = BigDecimal.ZERO;
+        BigDecimal appOtherAmount = BigDecimal.ZERO;
+        BigDecimal thirdAmount = BigDecimal.ZERO;
+        BigDecimal thirdOtherAmount = BigDecimal.ZERO;
+        BigDecimal freightAmount = BigDecimal.ZERO;
+
+        Long currentStoreId = settlement.getOrgId();
+
+        for (AppUserBillMstr appUserBillMstr : data.getCrossStoreBills()) {
+            if (appUserBillMstr.getIsRefund().equals(SysBoolType.NO.getCode())) {
+
+                if (appUserBillMstr.getSourceType().equals(SourceType.MANAGER.getCode())) {
+                    //线上三方使用门店卡支付的金额
+                    if (OrderType.goods.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.life.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.car.getCode().equals(appUserBillMstr.getOrderType())) {
+                        if (currentStoreId.equals(appUserBillMstr.getCardStoreId())) {
+                            appAmount = CurrencyUtil.add(appAmount, appUserBillMstr.getPayTotalAmount());
+                        }
+                    }
+                    continue;
+                }
+
+
+                if (OrderType.cloth.getCode().equals(appUserBillMstr.getOrderType())) {
+                    //本店的卡在其他店的消费
+                    if (currentStoreId.equals(appUserBillMstr.getCardStoreId()) && !currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        washAmount = CurrencyUtil.add(washAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                    //异店的卡在本店的消费
+                    if (!currentStoreId.equals(appUserBillMstr.getCardStoreId()) && currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        washOtherAmount = CurrencyUtil.add(washOtherAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                } else if (OrderType.goods.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.life.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.car.getCode().equals(appUserBillMstr.getOrderType())) {
+                    if (currentStoreId.equals(appUserBillMstr.getCardStoreId()) && !currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        goodsAmount = CurrencyUtil.add(goodsAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                    if (!currentStoreId.equals(appUserBillMstr.getCardStoreId()) && currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        goodsOtherAmount = CurrencyUtil.add(goodsOtherAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                }
+
+            } else {
+                //退款
+                if (appUserBillMstr.getSourceType().equals(SourceType.MANAGER.getCode())) {
+                    //线上三方使用门店卡支付的金额
+                    if (OrderType.goods.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.life.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.car.getCode().equals(appUserBillMstr.getOrderType())) {
+                        if (currentStoreId.equals(appUserBillMstr.getCardStoreId())) {
+                            appAmount = CurrencyUtil.sub(appAmount, appUserBillMstr.getPayTotalAmount());
+                        }
+                    }
+                    continue;
+                }
+
+
+                if (OrderType.cloth.getCode().equals(appUserBillMstr.getOrderType())) {
+                    //本店的卡在其他店的消费
+                    if (currentStoreId.equals(appUserBillMstr.getCardStoreId()) && !currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        washAmount = CurrencyUtil.sub(washAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                    //异店的卡在本店的消费
+                    if (!currentStoreId.equals(appUserBillMstr.getCardStoreId()) && currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        washOtherAmount = CurrencyUtil.sub(washOtherAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                } else if (OrderType.goods.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.life.getCode().equals(appUserBillMstr.getOrderType()) || OrderType.car.getCode().equals(appUserBillMstr.getOrderType())) {
+                    if (currentStoreId.equals(appUserBillMstr.getCardStoreId()) && !currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        goodsAmount = CurrencyUtil.sub(goodsAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                    if (!currentStoreId.equals(appUserBillMstr.getCardStoreId()) && currentStoreId.equals(appUserBillMstr.getOrgId())) {
+                        goodsOtherAmount = CurrencyUtil.sub(goodsOtherAmount, appUserBillMstr.getPayTotalAmount());
+                    }
+                }
+
+            }
+        }
+        SettlementStoreRate settlementRate = data.getSettlementRate();
+        BigDecimal allPayAmount = CurrencyUtil.add(washAmount, goodsAmount, appAmount, thirdAmount, freightAmount);
+        BigDecimal otherPayAmount = CurrencyUtil.add(washOtherAmount, goodsOtherAmount, appOtherAmount, thirdOtherAmount);
+        BigDecimal crossStoreAmount = CurrencyUtil.mul(CurrencyUtil.sub(allPayAmount, otherPayAmount), settlementRate.getOtherConsumeRate());
+        settlement.setOtherStoreAmount(allPayAmount);
+        settlement.setOtherCardAmount(otherPayAmount);
+        settlement.setRetailOtherStoreAmount(goodsAmount);
+        settlement.setRetailOtherCardAmount(goodsOtherAmount);
+        settlement.setAppOtherStoreAmount(appAmount);
+        settlement.setAppOtherCardAmount(appOtherAmount);
+        settlement.setThirdOtherStoreAmount(thirdAmount);
+        settlement.setThirdOtherCardAmount(thirdOtherAmount);
+
+
+        settlement.setCrossStoreSettlementAmount(crossStoreAmount);
     }
 
     /**
      * 计算最终结算金额
      */
     private void calculateFinalSettlement(SettlementManageStore settlement) {
+
+        /**
+         * 门店结算金额=(支付宝+微信实收金额)-(应付押金-已付押金)-(应付福利押金+卡密押金-已付福利押金-已付卡密押金)
+         *  -原材料备用金-系统维护费-洗衣费-跨店结算金*
+         */
         BigDecimal finalAmount = settlement.getAlipayAmount()
                 .add(settlement.getWechatAmount())
                 .subtract(settlement.getPayableDeposit().subtract(settlement.getPaidDeposit()))
@@ -737,24 +811,33 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
      * @param settlementManageBill
      * @return
      */
-    private void buildFactorySettlement(SettlementManageBill settlementManageBill, ManageFactory factory, List<OrderClothItem> orderClothItemList) {
+    private void buildFactorySettlement(SettlementManageBill settlementManageBill, ManageFactory factory) {
+        if (settlementManageBill.getStatus().equals(SettlementBillStatusType.FINISH.getCode())) {
+            throw new ServiceException("该账单已结算完成,请勿重复操作");
+        }
+        //删除工厂结算数据,重新结算
+        settlementManageFactoryService.remove(new QueryWrapper<SettlementManageFactory>().lambda().eq(SettlementManageFactory::getOrgId, factory.getId()).eq(SettlementManageFactory::getBillId, settlementManageBill.getId()));
         SettlementFactoryRate settlementFactoryRate = settlementFactoryRateService.getByFactoryId(factory.getId(), settlementManageBill.getBeginTime());
+        SettlementManageFactory settlementManageFactory = new SettlementManageFactory();
+        this.buildFactorySettlementInfo(settlementManageFactory, settlementManageBill, factory);
         if (settlementFactoryRate == null) {
-            SettlementManageFactory settlementManageFactory = new SettlementManageFactory();
-            this.buildFactorySettlementInfo(settlementManageFactory, settlementManageBill, factory);
             this.build0ClothFactory(settlementManageFactory);
+            settlementManageFactory.setRemark("工厂暂无可用费率");
             settlementManageFactoryService.save(settlementManageFactory);
         }
+        //查询衣服订单,入场时间在上个月的,切没有撤销或者推单的衣服
+        List<OrderClothItem> orderClothItemList = orderClothItemService.list(new QueryWrapper<OrderClothItem>().lambda()
+                .isNull(OrderClothItem::getRefundId)
+                .eq(OrderClothItem::getFactoryId, factory.getId())
+                .ge(OrderClothItem::getCreateTime, settlementManageBill.getBeginTime())
+                .ge(OrderClothItem::getInFactoryTime, settlementManageBill.getBeginTime())
+                .lt(OrderClothItem::getInFactoryTime, DateUtils.addDays(settlementManageBill.getEndTime(), 1)));
         if (CollUtil.isEmpty(orderClothItemList)) {
-            SettlementManageFactory settlementManageFactory = new SettlementManageFactory();
-            this.buildFactorySettlementInfo(settlementManageFactory, settlementManageBill, factory);
             this.build0ClothFactory(settlementManageFactory);
+            settlementManageFactory.setRemark("无入厂洗衣订单");
             settlementManageFactoryService.save(settlementManageFactory);
             return;
         }
-        SettlementManageFactory settlementManageFactory = new SettlementManageFactory();
-        this.buildFactorySettlementInfo(settlementManageFactory, settlementManageBill, factory);
-
         settlementManageFactory.setTotalTransactionNum(orderClothItemList.size());
         //计算衣服总价格
         BigDecimal orderClothItemTotalPrice = orderClothItemList.stream().map(OrderClothItem::getTotalPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
@@ -766,21 +849,13 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         //管理费
         BigDecimal managetAmount = CurrencyUtil.mul(settlementFactoryRate.getManagementRate(), orderClothItemTotalPrice);
         settlementManageFactory.setManageAmount(managetAmount);
-        //工厂结算金额总和
-//        BigDecimal factorySettlementAmount = orderClothItemList.stream().map(OrderClothItem::getFactorySettlementAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
-//        settlementManageFactory.setFactorySettlementAmount(factorySettlementAmount);
         // 工厂消费 = 材料费+ 管理费
         BigDecimal payMoney = settlementManageFactory.getManageAmount().add(settlementManageFactory.getMaterialAmount());
         // 工厂实际收入 = 工厂结算金额总和 - 工厂消费
         settlementManageFactory.setRealIncomeAmount(settlementManageFactory.getFactorySettlementAmount().subtract(payMoney));
         settlementManageFactoryService.save(settlementManageFactory);
-
-        // 设置账单洗衣费
-//        settlementManageBill.setWashClothAmount(
-//                orderClothItemList.stream().map(OrderClothItem::getFactorySettlementAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)
-//        );
-        settlementManageBill.setStatus(SettlementBillStatusType.WAITING.getCode());
-        this.updateById(settlementManageBill);
+//        settlementManageBill.setStatus(SettlementBillStatusType.WAITING.getCode());
+//        this.updateById(settlementManageBill);
     }
 
     /**
@@ -819,8 +894,6 @@ public class SettlementManageBillServiceImpl extends ServiceImpl<SettlementManag
         settlementManageFactory.setTotalTransactionNum(0);
         // 工厂实际收入
         settlementManageFactory.setRealIncomeAmount(BigDecimal.ZERO);
-        //
-        settlementManageFactory.setRemark("无入厂洗衣订单");
     }
 
     /**

+ 1 - 1
yiqi-core/src/main/java/com/yiqi/order/service/impl/OrderClothServiceImpl.java

@@ -626,7 +626,7 @@ public class OrderClothServiceImpl extends ServiceImpl<OrderClothMapper, OrderCl
         //会员余额支付
         if (orderClothPayDTO.getPayType().equals(PayType.BALANCE.getCode())) {
             orderCloth.setPayType(PayType.BALANCE.getCode());
-            RechargeCardPayDTO rechargeCardPayDTO = new RechargeCardPayDTO(orderCloth.getAppUserId(), orderCloth.getOrgId(), orderCloth.getOrderNo(), orderCloth.getPayAmount(), OrderType.cloth.getCode());
+            RechargeCardPayDTO rechargeCardPayDTO = new RechargeCardPayDTO(orderCloth.getAppUserId(), orderCloth.getSourceType(), orderCloth.getOrgId(), orderCloth.getOrderNo(), orderCloth.getPayAmount(), OrderType.cloth.getCode());
             rechargePasswordCardService.orderPayByBalance(rechargeCardPayDTO);
             paySuccess(orderCloth);
             return OrderPayResultVO.paySuccess(orderCloth.getOrderNo());

+ 1 - 1
yiqi-core/src/main/java/com/yiqi/order/service/impl/OrderGoodsServiceImpl.java

@@ -302,7 +302,7 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
         }
         //会员余额支付
         if (orderGoods.getPayType().equals(PayType.BALANCE.getCode())) {
-            RechargeCardPayDTO rechargeCardPayDTO = new RechargeCardPayDTO(orderGoods.getAppUserId(), orderGoods.getOrgId(), orderGoods.getOrderNo(), orderGoods.getPayAmount(), OrderType.goods.getCode());
+            RechargeCardPayDTO rechargeCardPayDTO = new RechargeCardPayDTO(orderGoods.getAppUserId(), orderGoods.getSourceType(), orderGoods.getOrgId(), orderGoods.getOrderNo(), orderGoods.getPayAmount(), OrderType.goods.getCode());
             rechargePasswordCardService.orderPayByBalance(rechargeCardPayDTO);
             this.handlePaySuccessUpdateOrderStatus(orderGoods.getOrderNo(), null);
             orderPayResultVO = OrderPayResultVO.paySuccess(orderGoods.getOrderNo());

+ 6 - 3
yiqi-core/src/main/java/com/yiqi/order/service/impl/OrderRechargeServiceImpl.java

@@ -705,7 +705,8 @@ public class OrderRechargeServiceImpl extends ServiceImpl<OrderRechargeMapper, O
 
         // 设置账单基本信息
         billDTO.setAppUserId(order.getAppUserId());
-        billDTO.setStoreId(order.getStoreId());
+        billDTO.setOrgId(order.getStoreId());
+        billDTO.setSourceType(order.getOrderSource());
         billDTO.setOrderNo(order.getOrderNo());
         billDTO.setOrderType(OrderType.recharge.getCode());
         billDTO.setUseBindStoreId(card.getUseBindStoreId());
@@ -779,7 +780,8 @@ public class OrderRechargeServiceImpl extends ServiceImpl<OrderRechargeMapper, O
     private void saveBillMstrOrder(OrderRecharge orderRecharge, RechargePasswordCard rechargePasswordCard, Date date) {
         BillMstrOrderDTO billMstrOrderDTO = new BillMstrOrderDTO();
         billMstrOrderDTO.setAppUserId(orderRecharge.getAppUserId());
-        billMstrOrderDTO.setStoreId(orderRecharge.getStoreId());
+        billMstrOrderDTO.setSourceType(orderRecharge.getSourceType());
+        billMstrOrderDTO.setOrgId(orderRecharge.getStoreId());
         billMstrOrderDTO.setOrderNo(orderRecharge.getOrderNo());
         billMstrOrderDTO.setOrderType(OrderType.recharge.getCode());
         billMstrOrderDTO.setRechargePayAmount(orderRecharge.getRechargeAmount());
@@ -1278,7 +1280,8 @@ public class OrderRechargeServiceImpl extends ServiceImpl<OrderRechargeMapper, O
 
         BillMstrOrderDTO billMstrOrderDTO = new BillMstrOrderDTO();
         billMstrOrderDTO.setAppUserId(orderRecharge.getAppUserId());
-        billMstrOrderDTO.setStoreId(orderRecharge.getStoreId());
+        billMstrOrderDTO.setOrgId(orderRecharge.getStoreId());
+        billMstrOrderDTO.setSourceType(orderRecharge.getSourceType());
         billMstrOrderDTO.setOrderNo(orderRecharge.getOrderNo());
         billMstrOrderDTO.setOrderType(OrderType.recharge.getCode());
         billMstrOrderDTO.setRechargePayAmount(orderRecharge.getRechargeAmount());

+ 4 - 5
yiqi-core/src/main/java/com/yiqi/recharge/service/impl/RechargePasswordCardServiceImpl.java

@@ -1,12 +1,9 @@
 package com.yiqi.recharge.service.impl;
 
-import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.yiqi.common.exception.ServiceException;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yiqi.app.domain.AppUser;
@@ -631,7 +628,8 @@ public class RechargePasswordCardServiceImpl extends ServiceImpl<RechargePasswor
             //保存日志
             BillMstrOrderDTO billMstrOrderDTO = new BillMstrOrderDTO();
             billMstrOrderDTO.setAppUserId(rechargeCardPayDTO.getAppUserId());
-            billMstrOrderDTO.setStoreId(rechargeCardPayDTO.getStoreId());
+            billMstrOrderDTO.setOrgId(rechargeCardPayDTO.getOrgId());
+            billMstrOrderDTO.setSourceType(rechargeCardPayDTO.getSourceType());
             billMstrOrderDTO.setUseBindStoreId(rechargePasswordCard.getUseBindStoreId());
             billMstrOrderDTO.setOrderNo(rechargeCardPayDTO.getOrderNo());
             billMstrOrderDTO.setOrderType(rechargeCardPayDTO.getBuyGoodsType());
@@ -704,7 +702,8 @@ public class RechargePasswordCardServiceImpl extends ServiceImpl<RechargePasswor
 
             BillMstrOrderDTO billMstrOrderDTO = new BillMstrOrderDTO();
             BeanUtils.copyProperties(consumeBillMstr, billMstrOrderDTO);
-            billMstrOrderDTO.setStoreId(consumeBillMstr.getOrgId());
+            billMstrOrderDTO.setOrgId(consumeBillMstr.getOrgId());
+            billMstrOrderDTO.setSourceType(consumeBillMstr.getSourceType());
             billMstrOrderDTO.setUseBindStoreId(rechargePasswordCard.getUseBindStoreId());
             billMstrOrderDTO.setRechargeCardNo(rechargePasswordCard.getCardNo());
             billMstrOrderDTO.setRemark("充值卡:" + rechargePasswordCard.getCardNo() + ",退款" + consumeBillMstr.getPayTotalAmount().negate() + "元");

+ 2 - 6
yiqi-core/src/main/resources/mapper/order/OrderClothItemMapper.xml

@@ -516,8 +516,8 @@
     </select>
     <select id="listFinancialStatisticsByFactoryWithToday"
             resultType="com.yiqi.order.domain.vo.FactoryFinancialClothDayVO">
-        select oci.org_id as orgId, ss.name as storeName , sum(oci.total_price) as totalPrice, count(1) as countCloth ,
-               sum(oci.factory_settlement_amount) as totalStatementPrice , oci.factory_settlement_rate as statementRate
+        select oci.org_id as orgId, ss.name as storeName , sum(oci.total_price) as totalPrice, count(1) as countCloth
+
         from order_cloth_item oci
         left join sys_store ss on oci.org_id = ss.id
         where  oci.factory_id = #{factoryId} and oci.flow_status != '102' and oci.source_type = '02' and oci.in_factory_time is not null
@@ -536,8 +536,6 @@
             resultType="com.yiqi.order.domain.vo.FactoryStatisticsListQueryVO">
         select oci.org_id as orgId, ss.name as storeName ,
                sum(oci.total_price) as totalPrice,
-                sum(oci.factory_settlement_amount) as totalStatementPrice ,
-                oci.factory_settlement_rate as statementRate,
                count(oci.wash_code) as countTotalCloth,
                count(ocif.wash_code) as countFinishCloth,
                count(ociw.wash_code) as countWashCloth,
@@ -566,8 +564,6 @@
                oci.cloth_item_name AS clothItemName, oci.cloth_speed_name as clothSpeedName ,
                oci.flow_status as flowStatus, oci.in_factory_time as inFactoryTime,
                oci.total_price as totalPrice ,
-                sum(oci.factory_settlement_amount) as totalStatementPrice ,
-                oci.factory_settlement_rate as statementRate,
                GROUP_CONCAT(occ.cloth_color_name) as clothColorName
         from order_cloth_item oci
                  LEFT JOIN order_cloth_color occ on oci.order_id = occ.order_id and oci.id = occ.order_cloth_id