ソースを参照

渠道分销商逻辑,schedule模块定时任务功能开发

hyq 6 年 前
コミット
d584114d84

+ 15 - 0
kmall-schedule/src/main/java/com/kmall/schedule/dao/MkDistSellStatisMapper.java

@@ -0,0 +1,15 @@
+package com.kmall.schedule.dao;
+
+import com.kmall.manager.dao.BaseDao;
+import com.kmall.schedule.entity.MkDistSellStatisEntity;
+
+/**
+ * 购买商品生成销售分配记录统计,渠道销售统计Dao
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2019-04-09 18:04:46
+ */
+public interface MkDistSellStatisMapper extends BaseDao<MkDistSellStatisEntity> {
+
+}

+ 9 - 0
kmall-schedule/src/main/java/com/kmall/schedule/dao/QzOrderMapper.java

@@ -2,6 +2,7 @@ package com.kmall.schedule.dao;
 
 import com.kmall.schedule.entity.MngChangeJobEntity;
 import com.kmall.schedule.entity.StoreMngChangeJobEntity;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
@@ -73,4 +74,12 @@ public interface QzOrderMapper {
     int updatePayOrderByOutNo(Map fromObject);
 
     List<Map> queryPinganPayingOrderList();
+
+    List<Map> queryReceiptOrderByDistList();
+
+    Map querySysConfigByKey(@Param("key") String key);
+
+    Map queryMkDistHierById(Map fromObject);
+
+    void updateOrderGoodsIsScan(Map fromObject);
 }

+ 402 - 0
kmall-schedule/src/main/java/com/kmall/schedule/entity/MkDistSellStatisEntity.java

@@ -0,0 +1,402 @@
+package com.kmall.schedule.entity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 购买商品生成销售分配记录统计,渠道销售统计实体
+ * 表名 mk_dist_sell_statis
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2019-04-09 18:04:46
+ */
+public class MkDistSellStatisEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    private Integer id;
+    /**
+     * 分销渠道名称
+     */
+    private String distFlag;
+    /**
+     * 所属三方商户
+     */
+    private Integer thirdMerchSn;
+    /**
+     * 所属供应商
+     */
+    private Integer supplierId;
+    /**
+     * 商品所属分销商id
+     */
+    private Integer distId;
+    /**
+     * 商品id
+     */
+    private String goodsId;
+    /**
+     * 商品价格
+     */
+    private BigDecimal goodsPrice;
+//    /**
+//     * 分配方式,【alloc_type,00:比例,10:金额】
+//     */
+//    private String allocType;
+    /**
+     * 支出分销商id
+     */
+    private Integer expendDistId;
+    /**
+     * 支出分销商金额【点数/金额】,公式:商品价格*设置点数/金额
+     */
+    private BigDecimal expendDistPrice;
+    /**
+     * 支出分销商等级 1 一级,2 二级,3 三级
+     */
+    private String expendDistLevel;
+    /**
+     * 来源
+     */
+    private String expendSource;
+    /**
+     * 是否有效,0:有效,1:无效
+     */
+    private String isValid;
+    /**
+     * 备注
+     */
+    private String note;
+    /**
+     * 创建人编号
+     */
+    private String createrSn;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 修改人编号
+     */
+    private String moderSn;
+    /**
+     * 修改时间
+     */
+    private Date modTime;
+    /**
+     * 时间戳
+     */
+    private Date tstm;
+
+    private String orderSn;
+
+    private String distChnlId;
+
+    private Integer userId;
+
+    private Integer orderGoodsId;
+
+    private Integer storeId;
+
+    private Integer sellAllocHistoryId;
+
+    public Integer getSellAllocHistoryId() {
+        return sellAllocHistoryId;
+    }
+
+    public void setSellAllocHistoryId(Integer sellAllocHistoryId) {
+        this.sellAllocHistoryId = sellAllocHistoryId;
+    }
+
+    public Integer getStoreId() {
+        return storeId;
+    }
+
+    public void setStoreId(Integer storeId) {
+        this.storeId = storeId;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Integer getOrderGoodsId() {
+        return orderGoodsId;
+    }
+
+    public void setOrderGoodsId(Integer orderGoodsId) {
+        this.orderGoodsId = orderGoodsId;
+    }
+
+    public String getDistChnlId() {
+        return distChnlId;
+    }
+
+    public void setDistChnlId(String distChnlId) {
+        this.distChnlId = distChnlId;
+    }
+
+    public String getOrderSn() {
+        return orderSn;
+    }
+
+    public void setOrderSn(String orderSn) {
+        this.orderSn = orderSn;
+    }
+
+    /**
+     * 设置:编号
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * 获取:编号
+     */
+    public Integer getId() {
+        return id;
+    }
+    /**
+     * 设置:分销渠道名称
+     */
+    public void setDistFlag(String distFlag) {
+        this.distFlag = distFlag;
+    }
+
+    /**
+     * 获取:分销渠道名称
+     */
+    public String getDistFlag() {
+        return distFlag;
+    }
+    /**
+     * 设置:所属三方商户
+     */
+    public void setThirdMerchSn(Integer thirdMerchSn) {
+        this.thirdMerchSn = thirdMerchSn;
+    }
+
+    /**
+     * 获取:所属三方商户
+     */
+    public Integer getThirdMerchSn() {
+        return thirdMerchSn;
+    }
+    /**
+     * 设置:所属供应商
+     */
+    public void setSupplierId(Integer supplierId) {
+        this.supplierId = supplierId;
+    }
+
+    /**
+     * 获取:所属供应商
+     */
+    public Integer getSupplierId() {
+        return supplierId;
+    }
+    /**
+     * 设置:商品所属分销商id
+     */
+    public void setDistId(Integer distId) {
+        this.distId = distId;
+    }
+
+    /**
+     * 获取:商品所属分销商id
+     */
+    public Integer getDistId() {
+        return distId;
+    }
+    /**
+     * 设置:商品id
+     */
+    public void setGoodsId(String goodsId) {
+        this.goodsId = goodsId;
+    }
+
+    /**
+     * 获取:商品id
+     */
+    public String getGoodsId() {
+        return goodsId;
+    }
+    /**
+     * 设置:商品价格
+     */
+    public void setGoodsPrice(BigDecimal goodsPrice) {
+        this.goodsPrice = goodsPrice;
+    }
+
+    /**
+     * 获取:商品价格
+     */
+    public BigDecimal getGoodsPrice() {
+        return goodsPrice;
+    }
+//    /**
+//     * 设置:分配方式,【alloc_type,00:比例,10:金额】
+//     */
+//    public void setAllocType(String allocType) {
+//        this.allocType = allocType;
+//    }
+//
+//    /**
+//     * 获取:分配方式,【alloc_type,00:比例,10:金额】
+//     */
+//    public String getAllocType() {
+//        return allocType;
+//    }
+    /**
+     * 设置:支出分销商id
+     */
+    public void setExpendDistId(Integer expendDistId) {
+        this.expendDistId = expendDistId;
+    }
+
+    /**
+     * 获取:支出分销商id
+     */
+    public Integer getExpendDistId() {
+        return expendDistId;
+    }
+    /**
+     * 设置:支出分销商金额【点数/金额】,公式:商品价格*设置点数/金额
+     */
+    public void setExpendDistPrice(BigDecimal expendDistPrice) {
+        this.expendDistPrice = expendDistPrice;
+    }
+
+    /**
+     * 获取:支出分销商金额【点数/金额】,公式:商品价格*设置点数/金额
+     */
+    public BigDecimal getExpendDistPrice() {
+        return expendDistPrice;
+    }
+    /**
+     * 设置:支出分销商等级 1 一级,2 二级,3 三级
+     */
+    public void setExpendDistLevel(String expendDistLevel) {
+        this.expendDistLevel = expendDistLevel;
+    }
+
+    /**
+     * 获取:支出分销商等级 1 一级,2 二级,3 三级
+     */
+    public String getExpendDistLevel() {
+        return expendDistLevel;
+    }
+    /**
+     * 设置:来源
+     */
+    public void setExpendSource(String expendSource) {
+        this.expendSource = expendSource;
+    }
+
+    /**
+     * 获取:来源
+     */
+    public String getExpendSource() {
+        return expendSource;
+    }
+    /**
+     * 设置:是否有效,0:有效,1:无效
+     */
+    public void setIsValid(String isValid) {
+        this.isValid = isValid;
+    }
+
+    /**
+     * 获取:是否有效,0:有效,1:无效
+     */
+    public String getIsValid() {
+        return isValid;
+    }
+    /**
+     * 设置:备注
+     */
+    public void setNote(String note) {
+        this.note = note;
+    }
+
+    /**
+     * 获取:备注
+     */
+    public String getNote() {
+        return note;
+    }
+    /**
+     * 设置:创建人编号
+     */
+    public void setCreaterSn(String createrSn) {
+        this.createrSn = createrSn;
+    }
+
+    /**
+     * 获取:创建人编号
+     */
+    public String getCreaterSn() {
+        return createrSn;
+    }
+    /**
+     * 设置:创建时间
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    /**
+     * 获取:创建时间
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+    /**
+     * 设置:修改人编号
+     */
+    public void setModerSn(String moderSn) {
+        this.moderSn = moderSn;
+    }
+
+    /**
+     * 获取:修改人编号
+     */
+    public String getModerSn() {
+        return moderSn;
+    }
+    /**
+     * 设置:修改时间
+     */
+    public void setModTime(Date modTime) {
+        this.modTime = modTime;
+    }
+
+    /**
+     * 获取:修改时间
+     */
+    public Date getModTime() {
+        return modTime;
+    }
+    /**
+     * 设置:时间戳
+     */
+    public void setTstm(Date tstm) {
+        this.tstm = tstm;
+    }
+
+    /**
+     * 获取:时间戳
+     */
+    public Date getTstm() {
+        return tstm;
+    }
+}

+ 13 - 2
kmall-schedule/src/main/java/com/kmall/schedule/quartz/OrderTask.java

@@ -83,7 +83,7 @@ public class OrderTask {
     /**
      * 方法描述:商品发货后7天自动确认收货
      */
-    @Scheduled(cron = "0 0 2 * * ?")
+    @Scheduled(fixedRate = 1000 * 60 * 1)
     public void shipmentOrderAutoTakeGoods() {
         logger.info(">>>>>>>>>>>>>>>>>>>>shipmentOrderAutoTakeGoods is start ");
         qzOrderService.shipmentOrderAutoTakeGoods();
@@ -93,7 +93,7 @@ public class OrderTask {
     /**
      * 方法描述:确认收货后30天自动确认好评
      */
-    @Scheduled(cron = "0 0 2 * * ?")
+    @Scheduled(fixedRate = 1000 * 60 * 1)
     public void receiptOrderAutoComment() {
         logger.info(">>>>>>>>>>>>>>>>>>>>receiptOrderAutoComment is start ");
         qzOrderService.receiptOrderAutoComment();
@@ -110,6 +110,17 @@ public class OrderTask {
         qzOrderService.realTimeDataUp();
         logger.info(">>>>>>>>>>>>>>>>>>>>realTimeDataUp is end ");
     }
+
+    /**
+     * 方法描述:用户确认收货后,记录商品分销购买记录
+     * 1分钟更新
+     */
+    @Scheduled(fixedRate = 1000 * 60 * 1)
+    public void receiptOrderSaveDistSellStatis() {
+        logger.info(">>>>>>>>>>>>>>>>>>>>receiptOrderAutoComment is start ");
+        qzOrderService.receiptOrderSaveDistSellStatis();
+        logger.info(">>>>>>>>>>>>>>>>>>>>receiptOrderAutoComment is end ");
+    }
 }
 
 

+ 62 - 0
kmall-schedule/src/main/java/com/kmall/schedule/service/QzMkDistSellStatisService.java

@@ -0,0 +1,62 @@
+package com.kmall.schedule.service;
+
+import com.kmall.schedule.dao.MkDistSellStatisMapper;
+import com.kmall.schedule.entity.MkDistSellStatisEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 购买商品生成销售分配记录统计,渠道销售统计Service实现类
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2019-04-09 18:04:46
+ */
+@Service
+public class QzMkDistSellStatisService {
+    @Autowired
+    private MkDistSellStatisMapper mkDistSellStatisMapper;
+
+    
+    public MkDistSellStatisEntity queryObject(Integer id) {
+        return mkDistSellStatisMapper.queryObject(id);
+    }
+
+
+    public List<MkDistSellStatisEntity> queryList(Map<String, Object> map) {
+        return mkDistSellStatisMapper.queryList(map);
+    }
+
+
+    public int queryTotal(Map<String, Object> map) {
+        return mkDistSellStatisMapper.queryTotal(map);
+    }
+
+
+    public int save(MkDistSellStatisEntity mkDistSellStatis) {
+//        mkDistSellStatis.setCreaterSn(ShiroUtils.getUserEntity().getUsername());
+        mkDistSellStatis.setCreateTime(new Date());
+        return mkDistSellStatisMapper.save(mkDistSellStatis);
+    }
+
+
+    public int update(MkDistSellStatisEntity mkDistSellStatis) {
+//        mkDistSellStatis.setModerSn(ShiroUtils.getUserEntity().getUsername());
+        mkDistSellStatis.setModTime(new Date());
+        return mkDistSellStatisMapper.update(mkDistSellStatis);
+    }
+
+
+    public int delete(Integer id) {
+        return mkDistSellStatisMapper.delete(id);
+    }
+
+
+    public int deleteBatch(Integer[]ids) {
+        return mkDistSellStatisMapper.deleteBatch(ids);
+    }
+}

+ 112 - 0
kmall-schedule/src/main/java/com/kmall/schedule/service/QzOrderService.java

@@ -14,6 +14,7 @@ import com.kmall.manager.manager.wechat.wxglobal.WechatGlobalUtil;
 import com.kmall.manager.manager.wechat.wxglobal.dto.WechatGlobalQueryApiResult;
 import com.kmall.manager.manager.wechat.wxglobal.dto.WechatGlobalRefundQueryResult;
 import com.kmall.manager.manager.wechat.wxtemplate.WxTemplate;
+import com.kmall.schedule.dao.MkDistSellStatisMapper;
 import com.kmall.schedule.dao.OrderWXPayRecordMapper;
 import com.kmall.schedule.dao.QzGroupMapper;
 import com.kmall.schedule.dao.QzOrderMapper;
@@ -22,6 +23,7 @@ import com.kmall.common.utils.wechat.WechatRefundApiResult;
 import com.kmall.common.utils.wechat.WechatRefundQueryResult;
 import com.kmall.manager.manager.wechat.wxtemplate.TemplateData;
 import com.kmall.manager.manager.wechat.wxtemplate.WxTemplateUtil;
+import com.kmall.schedule.entity.MkDistSellStatisEntity;
 import com.kmall.schedule.quartz.OrderTask;
 import com.kmall.schedule.entity.MngChangeJobEntity;
 import com.kmall.schedule.entity.StoreMngChangeJobEntity;
@@ -54,6 +56,8 @@ public class QzOrderService {
     private QzOrderMapper qzOrderMapper;
     @Autowired
     private OrderWXPayRecordMapper orderWXPayRecordMapper;
+    @Autowired
+    private MkDistSellStatisMapper mkDistSellStatisMapper;
 
     /**
      * todo 一期暂时不实现团购
@@ -1238,6 +1242,114 @@ public class QzOrderService {
         logger.info(">>>>>>>>>>>>>>>>>>>>receiptOrderAutoComment is end ");
     }
 
+    /**
+     * 方法描述:用户确认收货后,记录商品分销购买记录
+     * 1分钟更新
+     */
+    @Transactional
+    public void receiptOrderSaveDistSellStatis(){
+        logger.info(">>>>>>>>>>>>>>>>>>>>receiptOrderSaveDistSellStatis is start ");
+        logger.info(">>>>>>>>>>>>>>>>>>>>用户确认收货后,记录商品分销购买记录 ");
+        Map configMap = qzOrderMapper.querySysConfigByKey("IS_DIST_SELL");
+        String status = MapUtils.getString("status", configMap);
+        if(Dict.status.item_1.getItem().equalsIgnoreCase(status)) {//1为启用渠道销售功能
+            // 获取收货后的订单
+            List<Map> receiptOrderList = qzOrderMapper.queryReceiptOrderByDistList();
+            if (null != receiptOrderList && receiptOrderList.size() > 0) {
+                for (Map map : receiptOrderList) {
+                    String orderSn = MapUtils.getString("orderSn", map);
+                    Integer orderGoodsId = MapUtils.getInteger("orderGoodsId", map);
+                    Integer storeId = MapUtils.getInteger("storeId", map);
+                    Integer userId = MapUtils.getInteger("userId", map);
+                    Long goodsId = MapUtils.getLong("goodsId", map);
+                    BigDecimal goodsPrice = MapUtils.getBigDecimal("goodsPrice", map);
+                    Integer thirdMerchSn = MapUtils.getInteger("thirdMerchSn", map);
+                    Integer supplierId = MapUtils.getInteger("supplierId", map);
+                    Integer distId = MapUtils.getInteger("distId", map);
+                    String distFlag = MapUtils.getString("distFlag", map);
+                    String distChnlId = MapUtils.getString("distChnlId", map);
+
+                    String allocType = MapUtils.getString("allocType", map);
+                    Integer sell_alloc_history_id = MapUtils.getInteger("sell_alloc_history_id", map);
+
+                    String expendDistIds = MapUtils.getString("expendDistIds", map);
+                    String expendDistLines = MapUtils.getString("expendDistLines", map);
+
+                    MkDistSellStatisEntity mkDistSellStatisEntity = new MkDistSellStatisEntity();
+                    mkDistSellStatisEntity.setUserId(userId);
+                    mkDistSellStatisEntity.setOrderGoodsId(orderGoodsId);
+                    mkDistSellStatisEntity.setOrderSn(orderSn);
+                    mkDistSellStatisEntity.setGoodsId(String.valueOf(goodsId));
+                    mkDistSellStatisEntity.setGoodsPrice(goodsPrice);
+                    mkDistSellStatisEntity.setThirdMerchSn(thirdMerchSn);
+                    mkDistSellStatisEntity.setSupplierId(supplierId);
+                    mkDistSellStatisEntity.setDistId(distId);
+                    mkDistSellStatisEntity.setDistChnlId(distChnlId);
+                    mkDistSellStatisEntity.setDistFlag(distFlag);
+//                    mkDistSellStatisEntity.setAllocType(allocType);
+                    mkDistSellStatisEntity.setSellAllocHistoryId(sell_alloc_history_id);
+                    mkDistSellStatisEntity.setIsValid("0");
+                    mkDistSellStatisEntity.setCreateTime(new Date());
+                    mkDistSellStatisEntity.setModTime(new Date());
+                    mkDistSellStatisEntity.setStoreId(storeId);
+
+                    List<Integer> expendDistIdList = getExpendDistId(expendDistIds);//支出对应分销商
+                    List<Double> expendDistLinesList = getExpendDistLines(expendDistLines);//商品支出对应佣金额度
+
+                    for (int i = 0; i < expendDistIdList.size(); i++) {
+                        Map hierMap = new HashMap();
+                        hierMap.put("distId", expendDistIdList.get(i));
+//                        hierMap.put("pdistId", distId);
+                        hierMap.put("distChnlId", distChnlId);
+                        Map distHierMap = qzOrderMapper.queryMkDistHierById(hierMap);
+                        if (!StringUtils.isNullOrEmpty(distHierMap)) {
+                            String level = MapUtils.getString("hierLvl", distHierMap);
+                            BigDecimal price = new BigDecimal(0);
+                            Double expendDistPrice = expendDistLinesList.get(i);
+                            if (allocType.equalsIgnoreCase(Dict.allocType.item_00.getItem())) {//比例,公式:商品购买价格*设置比例
+                                price = goodsPrice.multiply(BigDecimal.valueOf(expendDistPrice));
+                            } else if (allocType.equalsIgnoreCase(Dict.allocType.item_10.getItem())) {//金额
+                                //// TODO: 2019/4/12 金额
+                                price = BigDecimal.valueOf(expendDistPrice);
+                            }
+
+                            mkDistSellStatisEntity.setExpendDistId(expendDistIdList.get(i));
+                            mkDistSellStatisEntity.setExpendDistLevel(level);
+                            mkDistSellStatisEntity.setExpendDistPrice(price);
+                            mkDistSellStatisEntity.setExpendSource("");
+                            mkDistSellStatisMapper.save(mkDistSellStatisEntity);
+                        }
+                    }
+
+                    Map isScanMap = new HashMap();
+                    isScanMap.put("orderGoodsId", orderGoodsId);
+                    isScanMap.put("isDistSellScan", Dict.isDistSellScan.item_1.getItem());
+                    qzOrderMapper.updateOrderGoodsIsScan(isScanMap);
+                }
+            }else{
+                logger.info(">>>>>>>>>>>>>>>>>>>>确认收货订单没有数据 ");
+            }
+        }
+        logger.info(">>>>>>>>>>>>>>>>>>>>receiptOrderSaveDistSellStatis is end ");
+
+    }
+    private List<Integer> getExpendDistId(String expendDistIds){
+        List<Integer> expendDistIdList = new ArrayList<>();
+        String[] expendIds = expendDistIds.split(",");
+        for (int i=0;i<expendIds.length;i++){
+            expendDistIdList.add(Integer.parseInt(expendIds[i]));
+        }
+        return expendDistIdList;
+    }
+    private List<Double> getExpendDistLines(String expendDistLines){
+        List<Double> expendDistLinesList = new ArrayList<>();
+        String[] expendLines = expendDistLines.split(",");
+        for (int i=0;i<expendLines.length;i++){
+            expendDistLinesList.add(Double.parseDouble(expendLines[i]));
+        }
+        return expendDistLinesList;
+    }
+
     public long getDateBetween(Date begin, Date end) {
         SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 

+ 200 - 0
kmall-schedule/src/main/resources/mybatis/mapper/QzMkDistSellStatisMapper.xml

@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.kmall.schedule.dao.MkDistSellStatisMapper">
+
+    <resultMap type="com.kmall.schedule.entity.MkDistSellStatisEntity" id="mkDistSellStatisMap">
+        <result property="id" column="id"/>
+        <result property="distFlag" column="dist_flag"/>
+        <result property="thirdMerchSn" column="third_merch_sn"/>
+        <result property="supplierId" column="supplier_id"/>
+        <result property="distId" column="dist_id"/>
+        <result property="goodsId" column="goods_id"/>
+        <result property="goodsPrice" column="goods_price"/>
+        <!--<result property="allocType" column="alloc_type"/>-->
+		<result property="sellAllocHistoryId" column="sell_alloc_history_id"/>
+        <result property="expendDistId" column="expend_dist_id"/>
+        <result property="expendDistPrice" column="expend_dist_price"/>
+        <result property="expendDistLevel" column="expend_dist_level"/>
+        <result property="expendSource" column="expend_source"/>
+        <result property="isValid" column="is_valid"/>
+        <result property="note" column="note"/>
+        <result property="createrSn" column="creater_sn"/>
+        <result property="createTime" column="create_time"/>
+        <result property="moderSn" column="moder_sn"/>
+        <result property="modTime" column="mod_time"/>
+        <result property="tstm" column="tstm"/>
+		<result property="orderSn" column="order_sn"/>
+		<result property="distChnlId" column="dist_chnl_id"/>
+		<result property="userId" column="user_id"/>
+		<result property="orderGoodsId" column="order_goods_id"/>
+		<result property="storeId" column="store_id"/>
+    </resultMap>
+
+	<select id="queryObject" resultType="com.kmall.schedule.entity.MkDistSellStatisEntity">
+		select
+			`id`,
+			dist_chnl_id,
+			`dist_flag`,
+			`third_merch_sn`,
+			`supplier_id`,
+			`dist_id`,
+			`goods_id`,
+			`goods_price`,
+			`alloc_type`,
+			`expend_dist_id`,
+			`expend_dist_price`,
+			`expend_dist_level`,
+			`expend_source`,
+			`is_valid`,
+			`note`,
+			`creater_sn`,
+			`create_time`,
+			`moder_sn`,
+			`mod_time`,
+			`tstm`,order_sn,user_id,order_goods_id,store_id
+		from mk_dist_sell_statis
+		where id = #{id}
+	</select>
+
+	<select id="queryList" resultType="com.kmall.schedule.entity.MkDistSellStatisEntity">
+		select
+    		`id`,
+			dist_chnl_id,
+    		`dist_flag`,
+    		`third_merch_sn`,
+    		`supplier_id`,
+    		`dist_id`,
+    		`goods_id`,
+    		`goods_price`,
+    		`alloc_type`,
+    		`expend_dist_id`,
+    		`expend_dist_price`,
+    		`expend_dist_level`,
+    		`expend_source`,
+    		`is_valid`,
+    		`note`,
+    		`creater_sn`,
+    		`create_time`,
+    		`moder_sn`,
+    		`mod_time`,
+    		`tstm`,order_sn,user_id,order_goods_id,store_id
+		from mk_dist_sell_statis
+		WHERE 1=1
+		<if test="name != null and name.trim() != ''">
+			AND name LIKE concat('%',#{name},'%')
+		</if>
+        <choose>
+            <when test="sidx != null and sidx.trim() != ''">
+                order by ${sidx} ${order}
+            </when>
+			<otherwise>
+                order by id desc
+			</otherwise>
+        </choose>
+		<if test="offset != null and limit != null">
+			limit #{offset}, #{limit}
+		</if>
+	</select>
+	
+ 	<select id="queryTotal" resultType="int">
+		select count(*) from mk_dist_sell_statis
+		WHERE 1=1
+        <if test="name != null and name.trim() != ''">
+            AND name LIKE concat('%',#{name},'%')
+        </if>
+	</select>
+
+	<insert id="save" parameterType="com.kmall.schedule.entity.MkDistSellStatisEntity" useGeneratedKeys="true" keyProperty="id">
+		insert into mk_dist_sell_statis(
+			`dist_flag`,
+			dist_chnl_id,
+			`third_merch_sn`,
+			`supplier_id`,
+			`dist_id`,
+			user_id,
+			order_goods_id,
+			order_sn,
+			store_id,
+			`goods_id`,
+			`goods_price`,
+			`sell_alloc_history_id`,
+			`expend_dist_id`,
+			`expend_dist_price`,
+			`expend_dist_level`,
+			`expend_source`,
+			`is_valid`,
+			`note`,
+			`creater_sn`,
+			`create_time`,
+			`moder_sn`,
+			`mod_time`,
+			`tstm`)
+		values(
+			#{distFlag},
+			#{distChnlId},
+			#{thirdMerchSn},
+			#{supplierId},
+			#{distId},
+			#{userId},
+			#{orderGoodsId},
+			#{orderSn},
+			#{storeId},
+			#{goodsId},
+			#{goodsPrice},
+			#{sellAllocHistoryId},
+			#{expendDistId},
+			#{expendDistPrice},
+			#{expendDistLevel},
+			#{expendSource},
+			#{isValid},
+			#{note},
+			#{createrSn},
+			#{createTime},
+			#{moderSn},
+			#{modTime},
+			#{tstm})
+	</insert>
+
+	<update id="update" parameterType="com.kmall.schedule.entity.MkDistSellStatisEntity">
+		update mk_dist_sell_statis 
+		<set>
+			<if test="distFlag != null">`dist_flag` = #{distFlag}, </if>
+			<if test="thirdMerchSn != null">`third_merch_sn` = #{thirdMerchSn}, </if>
+			<if test="distChnlId != null">`dist_chnl_id` = #{distChnlId}, </if>
+			<if test="supplierId != null">`supplier_id` = #{supplierId}, </if>
+			<if test="distId != null">`dist_id` = #{distId}, </if>
+			<if test="userId != null">`user_id` = #{userId}, </if>
+			<if test="orderGoodsId != null">`order_goods_id` = #{orderGoodsId}, </if>
+			<if test="storeId != null">`store_id` = #{storeId}, </if>
+			<if test="orderSn != null">`order_sn` = #{orderSn}, </if>
+			<if test="goodsId != null">`goods_id` = #{goodsId}, </if>
+			<if test="goodsPrice != null">`goods_price` = #{goodsPrice}, </if>
+			<if test="sellAllocHistoryId != null">`sell_alloc_history_id` = #{sellAllocHistoryId}, </if>
+			<if test="expendDistId != null">`expend_dist_id` = #{expendDistId}, </if>
+			<if test="expendDistPrice != null">`expend_dist_price` = #{expendDistPrice}, </if>
+			<if test="expendDistLevel != null">`expend_dist_level` = #{expendDistLevel}, </if>
+			<if test="expendSource != null">`expend_source` = #{expendSource}, </if>
+			<if test="isValid != null">`is_valid` = #{isValid}, </if>
+			<if test="note != null">`note` = #{note}, </if>
+			<if test="createrSn != null">`creater_sn` = #{createrSn}, </if>
+			<if test="createTime != null">`create_time` = #{createTime}, </if>
+			<if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
+			<if test="modTime != null">`mod_time` = #{modTime}, </if>
+			<if test="tstm != null">`tstm` = #{tstm}</if>
+		</set>
+		where id = #{id}
+	</update>
+	
+	<delete id="delete">
+		delete from mk_dist_sell_statis where id = #{value}
+	</delete>
+	
+	<delete id="deleteBatch">
+		delete from mk_dist_sell_statis where id in 
+		<foreach item="id" collection="array" open="(" separator="," close=")">
+			#{id}
+		</foreach>
+	</delete>
+
+</mapper>

+ 45 - 0
kmall-schedule/src/main/resources/mybatis/mapper/QzOrderMapper.xml

@@ -350,4 +350,49 @@
         </set>
         where `out_no` = #{outNo}
     </update>
+
+    <select id="queryReceiptOrderByDistList" resultType="map">
+        SELECT
+        o.user_id 'userId',
+        o.id 'orderId',
+        o.order_sn 'orderSn',
+        g.goods_id 'goodsId',
+        g.goods_name 'goodsName',
+        o.store_id,
+        g.retail_price 'goodsPrice' ,
+        a.third_merch_sn 'thirdMerchSn',
+        a.supplier_id 'supplierId',
+        a.dist_id 'distId',
+        a.dist_flag 'distFlag',
+        a.dist_chnl_id 'distChnlId',
+        a.alloc_type 'allocType',
+        a.expend_dist_ids 'expendDistIds',
+        a.expend_dist_lines 'expendDistLines',
+        g.is_dist_sell_scan 'isDistSellScan',
+        g.id 'orderGoodsId',
+        o.store_id 'storeId',
+		a.sell_alloc_history_id sell_alloc_history_id
+        FROM
+        `mall_order` o
+        left JOIN mall_order_goods g ON o.id = g.order_id
+		inner join mk_dist_sell_allocation sa on g.goods_id = sa.goods_id and o.store_id = sa.store_id
+        inner join mk_dist_sell_allocation_history a on a.sell_alloc_history_id = sa.sell_alloc_history_id
+        WHERE
+        order_status = '301'
+        AND shipping_status = '2'
+        AND o.is_onffline_order = 0 AND g.is_dist_sell_scan = 0 order by sell_alloc_history_id
+    </select>
+
+    <select id="querySysConfigByKey" resultType="map">
+        select s.status from sys_config s where s.key = #{key}
+    </select>
+
+    <select id="queryMkDistHierById" resultType="map" parameterType="map">
+        select s.dist_id 'distId',s.dist_hier_name 'distHierName',s.hier_lvl 'hierLvl' from mk_dist_hier s
+        where s.dist_id = #{distId} and s.dist_chnl_id = #{distChnlId}
+    </select>
+    <update id="updateOrderGoodsIsScan" parameterType="map">
+        update mall_order_goods set is_dist_sell_scan = #{isDistSellScan} where id=#{orderGoodsId}
+    </update>
+
 </mapper>