瀏覽代碼

Merge branch 'featrue/kmall向eccs推送订单明细数据' into feature/向eccs推送订单数据0621

qng 3 年之前
父節點
當前提交
db28811a30

+ 71 - 0
kmall-common/src/main/java/com/kmall/common/utils/DateUtils.java

@@ -253,4 +253,75 @@ public class DateUtils {
         System.out.println(new BigDecimal("11").compareTo(new BigDecimal("11")));
         System.out.println(BigDecimal.valueOf(Double.valueOf("0.112")));
     }
+
+    /**
+     * 获取date的日期和time的时间 组成的新的日期对象
+     *
+     * @return
+     */
+    public static Date getDateAddTime(String d1, String d2) {
+        Date allDate = parseToDate(d1 + " " + d2, "yyyy-MM-dd HH:mm:ss");
+        return allDate;
+    }
+    /**
+     * @desc:String转date
+     * @author Clyde
+     * @date:2014-3-16
+     * @param strDate
+     * @param format
+     * @return 若失败则返回当前时间
+     */
+    public static Date parseToDate(String strDate, String format) {
+        try {
+            if (strDate == null || strDate.trim().length() == 0) {
+                return new Date();
+            }
+            SimpleDateFormat sdf = new SimpleDateFormat(format);
+            return sdf.parse(strDate);
+        } catch (ParseException e) {
+            logger.error("[ERROR:时间转换失败;]", e);
+            return new Date();
+        }
+    }
+
+
+    /**
+     * @desc:格式化日期
+     * @author Clyde
+     * @date:2014-2-23
+     * @param date
+     * @param format
+     * @return
+     */
+    public static String formatDate(Date date, String format) {
+        String customDate = "";
+        if (date != null) {
+            SimpleDateFormat sdf = new SimpleDateFormat(format);
+            customDate = sdf.format(date);
+        }
+        return customDate;
+    }
+
+
+    public static Date add(int field, Date date, int value) {
+        if (value == 0) {
+            return date;
+        }
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        int fieldNewValue = c.get(field) + value;
+        c.set(field, fieldNewValue);
+        return c.getTime();
+    }
+
+    /**
+     * 加减日
+     * @param date
+     * @param value
+     * @return
+     */
+    public static Date addDate(Date date, int value){
+        return add(Calendar.DATE,date,value);
+    }
+
 }

+ 50 - 0
kmall-common/src/main/java/com/kmall/common/utils/HttpUtil.java

@@ -10,12 +10,21 @@ import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
 import org.apache.log4j.Logger;
 
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
 import java.net.URLEncoder;
+import java.nio.charset.Charset;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
@@ -482,4 +491,45 @@ public class HttpUtil {
         System.out.println(url.getHost());
         System.out.println(url.getPort());
     }
+
+
+    /**
+     * @method
+     * @description 发送post请求,json参数
+     * @date: 2019/9/10 13:58
+     * @author: 叶静
+     * @Param
+     * @return
+     */
+    public static String doPostJson(String url, String json) {
+        // 创建Httpclient对象
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        CloseableHttpResponse response = null;
+        String resultString = "";
+        try {
+            // 创建Http Post请求
+            HttpPost httpPost = new HttpPost(url);
+            RequestConfig config = RequestConfig.custom()
+                    .setConnectTimeout(10000)// 10秒 连接主机的超时时间(单位:毫秒)
+                    .setSocketTimeout(10000).build(); // 10秒 从主机读取数据的超时时间(单位:毫秒)
+            httpPost.setConfig(config);
+            httpPost.setEntity(new StringEntity(json, Charset.forName("UTF-8")));
+            // 创建请求内容
+            StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
+            httpPost.setEntity(entity);
+            // 执行http请求
+            response = httpClient.execute(httpPost);
+            resultString = EntityUtils.toString(response.getEntity(), "utf-8");
+        } catch (Exception e) {
+            logger.error("调用HttpClientUtil.doPostJson, url=" + url + ",param=" + json, e);
+        } finally {
+            try {
+                response.close();
+            } catch (IOException e) {
+                logger.error("调用HttpClientUtil.doPostJson, url=" + url + ",param=" + json, e);
+            }
+        }
+        return resultString;
+    }
+
 }

+ 25 - 0
kmall-schedule/src/main/java/com/kmall/schedule/dao/SalesDetailMapper.java

@@ -0,0 +1,25 @@
+package com.kmall.schedule.dao;
+
+import com.kmall.schedule.entity.NewSystemFormatEntiy;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Map;
+
+@Component
+public interface SalesDetailMapper {
+
+
+    List<NewSystemFormatEntiy> querySalesSystemFormatList(Map<String, Object> params);
+
+    void writebackSalesDet(NewSystemFormatEntiy bean);
+
+    /**
+     * 根据key,查询value
+     */
+    String querySalesByKey(String paramKey);
+
+    NewSystemFormatEntiy queryMerch(String merchSn);
+
+    List<NewSystemFormatEntiy> querySalesAgain(Map<String, Object> params);
+}

+ 419 - 0
kmall-schedule/src/main/java/com/kmall/schedule/entity/NewSystemFormatEntiy.java

@@ -0,0 +1,419 @@
+package com.kmall.schedule.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 线下订单实体类(新)
+ * 用于推送数据
+ */
+public class NewSystemFormatEntiy implements Serializable {
+
+    private String merchSn;//商户编号
+    private String merchSnName;//商户名称
+    private String thirdMerchSn;//第三方商户编号
+    private String thirdMerchSnName;//第三方商户名称
+    private String receiptNo;// 销售单号
+    private String cashRegisterNo;// 收银台
+    private String timeStampDetails;// 销售时间
+    private String staffID;// 收银员
+    private String staffName;// 收银员姓名
+    private String hsCode;// 品类编码
+    private String hsCodeName;// 品类名称
+    private String ematouCode;// 商品编码
+    private String plu;// PLU
+    private String mychemID;// MychemID
+    private String productNameEN;// 商品名称(英文)
+    private String productNameCN;// 商品名称(中文)
+    private String barcode;// 商品主条码
+    private String packSize;// 规格
+    private String productSpecification;// 单位
+    private String brand;// 品牌
+    private String edlp;// 日常价
+    private String currentPrice;// 实际销售价
+    private String costPrice;// 进货价
+    private String taxRate;// 综合税率
+    private String productCategory;// 商品类型
+    private String supplierName;// 主供应商名称
+    private String transactionType;// 销售类型
+    private String saleReturnType;// 退货类型
+    private String remark;// 备注
+    private Integer goodsId; // 商品id
+    private String orderStatus;//订单状态
+    private String taxPrice; // 税费
+    //private String outRefundNo;//退款订单号
+    //private String refundTime;//退款时间
+    //private String primeCost;//成本价=备案单价*货物数量(门店现有库存)
+    //private String goodsNumber;//可用库存数
+    private String storeName;//门店名称
+    private String payFlag;//支付方式
+    private String orderSnWx;//微信流水号
+    private String orderSnAli;//支付宝流水号
+
+    private String salesDetStatus;//数据状态
+    private String salesDetMsg;//eccs推送状态
+    private Date salesDetDate;//推送时间
+    private String storeNameSn;//门店名称编码
+    private String unitSold;// 销售数量
+    private String totalSalesInclTax;// 总销售额
+
+    public String getTotalSalesInclTax() {
+        return totalSalesInclTax;
+    }
+
+    public void setTotalSalesInclTax(String totalSalesInclTax) {
+        this.totalSalesInclTax = totalSalesInclTax;
+    }
+
+    public String getUnitSold() {
+        return unitSold;
+    }
+
+    public void setUnitSold(String unitSold) {
+        this.unitSold = unitSold;
+    }
+
+    public String getStoreNameSn() {
+        return storeNameSn;
+    }
+
+    public void setStoreNameSn(String storeNameSn) {
+        this.storeNameSn = storeNameSn;
+    }
+
+    public String getSalesDetStatus() {
+        return salesDetStatus;
+    }
+
+    public void setSalesDetStatus(String salesDetStatus) {
+        this.salesDetStatus = salesDetStatus;
+    }
+
+    public String getSalesDetMsg() {
+        return salesDetMsg;
+    }
+
+    public void setSalesDetMsg(String salesDetMsg) {
+        this.salesDetMsg = salesDetMsg;
+    }
+
+    public Date getSalesDetDate() {
+        return salesDetDate;
+    }
+
+    public void setSalesDetDate(Date salesDetDate) {
+        this.salesDetDate = salesDetDate;
+    }
+
+    public String getMerchSn() {
+        return merchSn;
+    }
+
+    public void setMerchSn(String merchSn) {
+        this.merchSn = merchSn;
+    }
+
+    public String getMerchSnName() {
+        return merchSnName;
+    }
+
+    public void setMerchSnName(String merchSnName) {
+        this.merchSnName = merchSnName;
+    }
+
+    public String getThirdMerchSn() {
+        return thirdMerchSn;
+    }
+
+    public void setThirdMerchSn(String thirdMerchSn) {
+        this.thirdMerchSn = thirdMerchSn;
+    }
+
+    public String getThirdMerchSnName() {
+        return thirdMerchSnName;
+    }
+
+    public void setThirdMerchSnName(String thirdMerchSnName) {
+        this.thirdMerchSnName = thirdMerchSnName;
+    }
+
+    public String getReceiptNo() {
+        return receiptNo;
+    }
+
+    public void setReceiptNo(String receiptNo) {
+        this.receiptNo = receiptNo;
+    }
+
+    public String getCashRegisterNo() {
+        return cashRegisterNo;
+    }
+
+    public void setCashRegisterNo(String cashRegisterNo) {
+        this.cashRegisterNo = cashRegisterNo;
+    }
+
+    public String getTimeStampDetails() {
+        return timeStampDetails;
+    }
+
+    public void setTimeStampDetails(String timeStampDetails) {
+        this.timeStampDetails = timeStampDetails;
+    }
+
+    public String getStaffID() {
+        return staffID;
+    }
+
+    public void setStaffID(String staffID) {
+        this.staffID = staffID;
+    }
+
+    public String getStaffName() {
+        return staffName;
+    }
+
+    public void setStaffName(String staffName) {
+        this.staffName = staffName;
+    }
+
+    public String getHsCode() {
+        return hsCode;
+    }
+
+    public void setHsCode(String hsCode) {
+        this.hsCode = hsCode;
+    }
+
+    public String getHsCodeName() {
+        return hsCodeName;
+    }
+
+    public void setHsCodeName(String hsCodeName) {
+        this.hsCodeName = hsCodeName;
+    }
+
+    public String getEmatouCode() {
+        return ematouCode;
+    }
+
+    public void setEmatouCode(String ematouCode) {
+        this.ematouCode = ematouCode;
+    }
+
+    public String getPlu() {
+        return plu;
+    }
+
+    public void setPlu(String plu) {
+        this.plu = plu;
+    }
+
+    public String getMychemID() {
+        return mychemID;
+    }
+
+    public void setMychemID(String mychemID) {
+        this.mychemID = mychemID;
+    }
+
+    public String getProductNameEN() {
+        return productNameEN;
+    }
+
+    public void setProductNameEN(String productNameEN) {
+        this.productNameEN = productNameEN;
+    }
+
+    public String getProductNameCN() {
+        return productNameCN;
+    }
+
+    public void setProductNameCN(String productNameCN) {
+        this.productNameCN = productNameCN;
+    }
+
+    public String getBarcode() {
+        return barcode;
+    }
+
+    public void setBarcode(String barcode) {
+        this.barcode = barcode;
+    }
+
+    public String getPackSize() {
+        return packSize;
+    }
+
+    public void setPackSize(String packSize) {
+        this.packSize = packSize;
+    }
+
+    public String getProductSpecification() {
+        return productSpecification;
+    }
+
+    public void setProductSpecification(String productSpecification) {
+        this.productSpecification = productSpecification;
+    }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    public String getEdlp() {
+        return edlp;
+    }
+
+    public void setEdlp(String edlp) {
+        this.edlp = edlp;
+    }
+
+    public String getCurrentPrice() {
+        return currentPrice;
+    }
+
+    public void setCurrentPrice(String currentPrice) {
+        this.currentPrice = currentPrice;
+    }
+
+    public String getCostPrice() {
+        return costPrice;
+    }
+
+    public void setCostPrice(String costPrice) {
+        this.costPrice = costPrice;
+    }
+
+    public String getTaxRate() {
+        return taxRate;
+    }
+
+    public void setTaxRate(String taxRate) {
+        this.taxRate = taxRate;
+    }
+
+    public String getProductCategory() {
+        return productCategory;
+    }
+
+    public void setProductCategory(String productCategory) {
+        this.productCategory = productCategory;
+    }
+
+    public String getSupplierName() {
+        return supplierName;
+    }
+
+    public void setSupplierName(String supplierName) {
+        this.supplierName = supplierName;
+    }
+
+    public String getTransactionType() {
+        return transactionType;
+    }
+
+    public void setTransactionType(String transactionType) {
+        this.transactionType = transactionType;
+    }
+
+    public String getSaleReturnType() {
+        return saleReturnType;
+    }
+
+    public void setSaleReturnType(String saleReturnType) {
+        this.saleReturnType = saleReturnType;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public Integer getGoodsId() {
+        return goodsId;
+    }
+
+    public void setGoodsId(Integer goodsId) {
+        this.goodsId = goodsId;
+    }
+
+    public String getOrderStatus() {
+        return orderStatus;
+    }
+
+    public void setOrderStatus(String orderStatus) {
+        this.orderStatus = orderStatus;
+    }
+
+    public String getTaxPrice() {
+        return taxPrice;
+    }
+
+    public void setTaxPrice(String taxPrice) {
+        this.taxPrice = taxPrice;
+    }
+
+//    public String getOutRefundNo() {
+//        return outRefundNo;
+//    }
+//
+//    public void setOutRefundNo(String outRefundNo) {
+//        this.outRefundNo = outRefundNo;
+//    }
+
+//    public String getRefundTime() {
+//        return refundTime;
+//    }
+//
+//    public void setRefundTime(String refundTime) {
+//        this.refundTime = refundTime;
+//    }
+
+//    public String getGoodsNumber() {
+//        return goodsNumber;
+//    }
+//
+//    public void setGoodsNumber(String goodsNumber) {
+//        this.goodsNumber = goodsNumber;
+//    }
+
+    public String getStoreName() {
+        return storeName;
+    }
+
+    public void setStoreName(String storeName) {
+        this.storeName = storeName;
+    }
+
+    public String getPayFlag() {
+        return payFlag;
+    }
+
+    public void setPayFlag(String payFlag) {
+        this.payFlag = payFlag;
+    }
+
+    public String getOrderSnWx() {
+        return orderSnWx;
+    }
+
+    public void setOrderSnWx(String orderSnWx) {
+        this.orderSnWx = orderSnWx;
+    }
+
+    public String getOrderSnAli() {
+        return orderSnAli;
+    }
+
+    public void setOrderSnAli(String orderSnAli) {
+        this.orderSnAli = orderSnAli;
+    }
+}

+ 22 - 0
kmall-schedule/src/main/java/com/kmall/schedule/quartz/OrderTask.java

@@ -251,4 +251,26 @@ public class OrderTask {
         qzOrderService.updateProductStoreByGoodsShareStock();
         logger.info(">>>>>>>>>>>>>>>>>>>>updateProductStoreByGoodsShareStock is end ");
     }
+
+    /**
+     * 每天向eccs推送销售明细数据
+     */
+    //@Scheduled(cron = "0/10 * * * * ?")
+    public void pushSalesDetailData() {
+        logger.info(">>>>>>>>>>>>>>>>>>>>pushSalesDetailData is start ");
+        qzOrderService.pushSalesDetailData();
+        logger.info(">>>>>>>>>>>>>>>>>>>>pushSalesDetailData is end ");
+    }
+
+    /**
+     * 每天向eccs重推销售明细数据
+     */
+    //@Scheduled(cron = "0/10 * * * * ?")
+    public void pushSalesDetailDataAgain() {
+        logger.info(">>>>>>>>>>>>>>>>>>>>pushSalesDetailDataAgain is start ");
+        qzOrderService.pushSalesDetailDataAgain();
+        logger.info(">>>>>>>>>>>>>>>>>>>>pushSalesDetailDataAgain is end ");
+    }
+
+
 }

+ 90 - 4
kmall-schedule/src/main/java/com/kmall/schedule/service/QzOrderService.java

@@ -1,5 +1,6 @@
 package com.kmall.schedule.service;
 
+import com.alibaba.fastjson.JSON;
 import com.google.common.collect.Maps;
 import com.kmall.common.constant.Dict;
 import com.kmall.common.utils.*;
@@ -20,11 +21,8 @@ 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.entity.ScheduleJobLogEntity;
+import com.kmall.schedule.entity.*;
 import com.kmall.schedule.quartz.OrderTask;
-import com.kmall.schedule.entity.MngChangeJobEntity;
-import com.kmall.schedule.entity.StoreMngChangeJobEntity;
 import com.kmall.schedule.utils.ScheduleJob;
 import net.sf.json.JSONObject;
 import org.apache.commons.logging.Log;
@@ -59,6 +57,8 @@ public class QzOrderService {
     private MkDistSellStatisMapper mkDistSellStatisMapper;
     @Autowired
     private ScheduleJobLogDao scheduleJobLogDao;
+    @Autowired
+    private SalesDetailMapper salesDetailMapper;
 
     /**
      * todo 一期暂时不实现团购
@@ -1619,4 +1619,90 @@ public class QzOrderService {
         Date successTime = DateUtils.strToDate("2018-11-02 14:57:12.0");
         System.out.println(successTime);
     }
+
+
+
+
+    /**
+     *向eccs推送销售明细数据
+     */
+    public void pushSalesDetailData() {
+        logger.info(">>>>>>>>>>>>>>>>>>>>pushSalesDetailData is start ");
+        Map<String, Object> params  = new HashMap<>();
+        String date = DateUtils.formatDate(DateUtils.addDate(new Date(),-1),"yyyy-MM-dd");
+        params.put("startTime", DateUtils.getDateAddTime(date,"00:00:00"));
+        params.put("endTime",DateUtils.getDateAddTime(date,"23:59:59"));
+
+//        params.put("startTime", "2021-03-07 00:00:00");
+//        params.put("endTime","2021-03-11 23:59:59");
+        params.put("isOnfiilineOrder","1");
+        List<NewSystemFormatEntiy> dtoList = salesDetailMapper.querySalesSystemFormatList(params);
+        pushDateEccs(dtoList);
+    }
+
+
+    public void pushDateEccs(List<NewSystemFormatEntiy> dtoList) {
+        String valueUrl = salesDetailMapper.querySalesByKey("SALES_DETAIL_DATA_URL");
+
+        if (dtoList.size() > 0) {
+
+            dtoList.forEach(bean ->{
+                BigDecimal unitSold = new BigDecimal(bean.getUnitSold());
+                // 如果是退货
+                String orderStatus = bean.getOrderStatus();
+                if (Dict.orderStatus.item_401.getItem().equals(orderStatus)){
+                    bean.setSaleReturnType("整单退货");
+                    bean.setTransactionType("退货");
+                }else{
+                    bean.setTransactionType("销售");
+                }
+                // 设置综合税额
+                BigDecimal totalSalesIncTax = new BigDecimal(bean.getTotalSalesInclTax());
+                // 设置实际销售额
+                bean.setCurrentPrice(totalSalesIncTax.divide(unitSold,2,BigDecimal.ROUND_HALF_UP).setScale(2,BigDecimal.ROUND_HALF_UP).toEngineeringString());
+                NewSystemFormatEntiy merchMsg = salesDetailMapper.queryMerch(bean.getMerchSn());
+                if(merchMsg!=null){
+                    bean.setThirdMerchSn(merchMsg.getThirdMerchSn());
+                    bean.setThirdMerchSnName(merchMsg.getThirdMerchSnName());
+                    bean.setMerchSnName(merchMsg.getMerchSnName());
+                }
+                String msg = HttpUtil.doPostJson(valueUrl, JSON.toJSONString(bean));
+                if(msg!=null&&!msg.equals("")){
+                    Map<String, Object> kmallMsg = com.alibaba.fastjson.JSONObject.toJavaObject(JSON.parseObject(msg), Map.class);
+                    if (kmallMsg.get("code").equals(200)) {
+                        bean.setSalesDetStatus("1");
+                    } else {
+                        bean.setSalesDetStatus("2");
+                    }
+                    bean.setSalesDetMsg(msg);
+                    salesDetailMapper.writebackSalesDet(bean);
+                }
+            });
+        }
+
+    }
+
+
+    /**
+     * 重推接口
+     */
+    public void pushSalesDetailDataAgain() {
+        logger.info(">>>>>>>>>>>>>>>>>>>>pushSalesDetailDataAgain is start ");
+        Map<String, Object> params  = new HashMap<>();
+        String date = DateUtils.formatDate(DateUtils.addDate(new Date(),-1),"yyyy-MM-dd");
+        params.put("startTime", DateUtils.getDateAddTime(date,"00:00:00"));
+        params.put("endTime",DateUtils.getDateAddTime(date,"23:59:59"));
+        List<NewSystemFormatEntiy> dtoList = salesDetailMapper.querySalesAgain(params);
+        pushDateEccs(dtoList);
+
+
+    }
+
+
+
+
+
+
+
+
 }

+ 313 - 0
kmall-schedule/src/main/resources/mybatis/mapper/SalesDetailMapper.xml

@@ -0,0 +1,313 @@
+<?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.SalesDetailMapper">
+
+<!--    抓取订单销售明细数据-->
+    <select id="querySalesSystemFormatList" resultType="com.kmall.schedule.entity.NewSystemFormatEntiy">
+
+        SELECT distinct
+        o.id,
+        g.goods_id,
+        o.order_sn as receiptNo,
+        u.username as cashRegisterNo,
+
+        o.create_time as timeStampDetails,
+        u.username as staffID,
+        u.username as staffName,
+        gs.hs_code as hsCode,
+        gs.hs_code_name as hsCodeName,
+        gs.goods_sn as ematouCode,
+        gs.plu as plu,
+        gs.mychem_id as mychemID,
+        gs.english_name as productNameEN,
+        gs.name as productNameCN,
+        gs.prod_barcode as barcode,
+        gs.ciq_prod_model as packSize,
+        gs.goods_number as goodsNumber,
+        uc.name as productSpecification,
+        b.name as brand,
+        gs.daily_price as edlp,
+        sr.bottom_line_price as costPrice,
+        sr.bottom_line_price*gs.goods_number as primeCost,
+        g.number as unitSold,
+        g.actual_payment_amount as totalSalesInclTax,
+        gs.goods_rate as taxRate,
+        '专柜单品' as productCategory,
+        sup.child_supplier_name as supplierName,
+        '300' as orderStatus,
+        g.tax_price as taxPrice,
+        s.store_name as storeName,
+        s.store_number as storeNameSn,
+        o.pay_flag as payFlag,
+        o.pay_transaction_id as orderSnWx,
+        o.ali_trade_no as orderSnAli
+        FROM
+        mall_order o
+        LEFT JOIN mall_order_goods g ON o.id = g.order_id
+        left join mall_store s on o.store_id = s.id
+        LEFT JOIN mall_goods gs ON g.goods_id = gs.id
+        left join mall_sale_record record on record.order_sn = o.order_sn
+        LEFT JOIN sys_user u ON record.saller_id = u.user_id
+        left join sys_cus_unit_code uc on uc.code = gs.unit_code
+        left join mall_product_store_rela sr on sr.goods_id=gs.id and sr.store_id = o.store_id
+        left join mall_brand b on b.id=sr.brand_id
+        left join mall_supplier sup on gs.supplier_id = sup.id
+        WHERE 1=1
+        <if test="orderSn != null and orderSn.trim() != ''">
+            AND o.order_sn LIKE concat('%',#{orderSn},'%')
+        </if>
+        <choose>
+            <when test="orderStatus != null and orderStatus.trim() != ''">
+                AND o.order_status = #{orderStatus}
+            </when>
+            <otherwise>
+                AND o.order_status in ('401','300')
+            </otherwise>
+        </choose>
+        <if test="isOnfiilineOrder != null">
+            AND o.is_onffline_order = #{isOnfiilineOrder}
+        </if>
+        <if test="startTime != null and startTime != ''">
+            AND o.add_time <![CDATA[ >  ]]> STR_TO_DATE(#{startTime}, '%Y-%m-%d %H:%i:%s')
+        </if>
+        <if test="endTime != null and endTime != ''">
+            AND o.add_time <![CDATA[ <  ]]>  STR_TO_DATE(#{endTime}, '%Y-%m-%d %H:%i:%s')
+        </if>
+        <if test="storeName != null and storeName != ''">
+            AND s.store_name LIKE concat('%',#{storeName},'%')
+        </if>
+
+        union
+
+        SELECT distinct
+        o.id,
+        g.goods_id,
+        o.order_sn as receiptNo,
+        u.username as cashRegisterNo,
+        mor.create_time as timeStampDetails,
+        u.username as staffID,
+        u.username as staffName,
+        gs.hs_code as hsCode,
+        gs.hs_code_name as hsCodeName,
+        gs.goods_sn as ematouCode,
+        gs.plu as plu,
+        gs.mychem_id as mychemID,
+        gs.english_name as productNameEN,
+        gs.name as productNameCN,
+        gs.prod_barcode as barcode,
+        gs.ciq_prod_model as packSize,
+        gs.goods_number as goodsNumber,
+        uc.name as productSpecification,
+        b.name as brand,
+        gs.daily_price as edlp,
+        sr.bottom_line_price as costPrice,
+        sr.bottom_line_price*gs.goods_number as primeCost,
+        g.number as unitSold,
+        g.actual_payment_amount as totalSalesInclTax,
+        gs.goods_rate as taxRate,
+        '专柜单品' as productCategory,
+        sup.child_supplier_name as supplierName,
+        o.order_status as orderStatus,
+        g.tax_price as taxPrice,
+
+        s.store_name as storeName,
+        s.store_number as storeNameSn,
+        o.pay_flag as payFlag,
+        o.pay_transaction_id as orderSnWx,
+        o.ali_trade_no as orderSnAli
+        FROM
+        mall_order o
+        LEFT JOIN mall_order_goods g ON o.id = g.order_id
+        left join mall_store s on o.store_id = s.id
+        LEFT JOIN mall_goods gs ON g.goods_id = gs.id
+        left join mall_sale_record record on record.order_sn = o.order_sn
+        LEFT JOIN sys_user u ON record.saller_id = u.user_id
+        left join sys_cus_unit_code uc on uc.code = gs.unit_code
+        left join mall_product_store_rela sr on sr.goods_id=gs.id and sr.store_id = o.store_id
+        left join mall_brand b on b.id=sr.brand_id
+        left join mall_supplier sup on gs.supplier_id = sup.id
+        left join mall_order_refund mor on mor.out_refund_no = o.order_sn
+        WHERE 1=1
+        <if test="orderSn != null and orderSn.trim() != ''">
+            AND o.order_sn LIKE concat('%',#{orderSn},'%')
+        </if>
+        <choose>
+            <when test="orderStatus != null and orderStatus.trim() != ''">
+                AND o.order_status = #{orderStatus}
+            </when>
+            <otherwise>
+                AND o.order_status = '401'
+            </otherwise>
+        </choose>
+        <if test="isOnfiilineOrder != null">
+            AND o.is_onffline_order = #{isOnfiilineOrder}
+        </if>
+        <if test="startTime != null and startTime != ''">
+            AND mor.create_time <![CDATA[ >  ]]> STR_TO_DATE(#{startTime}, '%Y-%m-%d %H:%i:%s')
+        </if>
+        <if test="endTime != null and endTime != ''">
+            AND mor.create_time <![CDATA[ <  ]]> STR_TO_DATE(#{endTime}, '%Y-%m-%d %H:%i:%s')
+        </if>
+        <if test="storeName != null and storeName != ''">
+            AND s.store_name LIKE concat('%',#{storeName},'%')
+        </if>
+
+    </select>
+
+    <!--记录推送数据-->
+    <insert id="writebackSalesDet" parameterType="com.kmall.schedule.entity.NewSystemFormatEntiy">
+        insert into mall_sales_detail_data_log
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="merchSn != null">merch_sn,</if>
+            <if test="merchSnName != null">merch_sn_name,</if>
+            <if test="thirdMerchSn != null">third_merch_sn,</if>
+            <if test="thirdMerchSnName != null">third_merch_sn_name,</if>
+            <if test="receiptNo != null">receipt_no,</if>
+            <if test="storeName != null">store_name,</if>
+            <if test="storeNameSn != null">store_name_sn,</if>
+            <if test="cashRegisterNo != null">ash_register_no,</if>
+            <if test="timeStampDetails != null">time_stamp,</if>
+            <if test="staffID != null">staff_id,</if>
+            <if test="staffName != null">staff_name,</if>
+            <if test="payFlag != null">pay_flag,</if>
+            <if test="orderStatus != null">order_status,</if>
+            <if test="orderSnWx != null">order_sn_wx,</if>
+
+            <if test="orderSnAli != null">order_sn_ali,</if>
+            <if test="hsCode != null">hs_code,</if>
+            <if test="hsCodeName != null">hs_code_name,</if>
+            <if test="ematouCode != null">ematou_code,</if>
+            <if test="plu != null">plu,</if>
+            <if test="mychemID != null">mychem_id,</if>
+            <if test="productNameEN != null">product_name_en,</if>
+            <if test="productNameCN != null">product_name_cn,</if>
+            <if test="barcode != null">barcode,</if>
+            <if test="packSize != null">pack_size,</if>
+            <if test="productSpecification != null">product_spec,</if>
+            <if test="brand != null">brand,</if>
+            <if test="edlp != null">edlp,</if>
+            <if test="currentPrice != null">current_price,</if>
+            <if test="costPrice != null">cost_price,</if>
+            <if test="taxRate != null">tax_rate,</if>
+            <if test="productCategory != null">product_category,</if>
+            <if test="supplierName != null">supplier_name,</if>
+            <if test="transactionType != null">transaction_type,</if>
+            <if test="saleReturnType != null">sale_return_type,</if>
+            <if test="salesDetStatus != null">det_status,</if>
+            <if test="salesDetMsg != null">det_msg,</if>
+            det_date
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="merchSn != null">#{merchSn},</if>
+            <if test="merchSnName != null">#{merchSnName},</if>
+            <if test="thirdMerchSn != null">#{thirdMerchSn},</if>
+            <if test="thirdMerchSnName != null">#{thirdMerchSnName},</if>
+            <if test="receiptNo != null">#{receiptNo},</if>
+            <if test="storeName != null">#{storeName},</if>
+            <if test="storeNameSn != null">#{storeNameSn},</if>
+            <if test="cashRegisterNo != null">#{cashRegisterNo},</if>
+            <if test="timeStampDetails != null">#{timeStampDetails},</if>
+            <if test="staffID != null">#{staffID},</if>
+            <if test="staffName != null">#{staffName},</if>
+            <if test="payFlag != null">#{payFlag},</if>
+            <if test="orderStatus != null">#{orderStatus},</if>
+            <if test="orderSnWx != null">#{orderSnWx},</if>
+
+            <if test="orderSnAli != null">#{orderSnAli},</if>
+            <if test="hsCode != null">#{hsCode},</if>
+            <if test="hsCodeName != null">#{hsCodeName},</if>
+            <if test="ematouCode != null">#{ematouCode},</if>
+            <if test="plu != null">#{plu},</if>
+            <if test="mychemID != null">#{mychemID},</if>
+            <if test="productNameEN != null">#{productNameEN},</if>
+            <if test="productNameCN != null">#{productNameCN},</if>
+            <if test="barcode != null">#{barcode},</if>
+            <if test="packSize != null">#{packSize},</if>
+            <if test="productSpecification != null">#{productSpecification},</if>
+            <if test="brand != null">#{brand},</if>
+            <if test="edlp != null">#{edlp},</if>
+            <if test="currentPrice != null">#{currentPrice},</if>
+            <if test="costPrice != null">#{costPrice},</if>
+            <if test="taxRate != null">#{taxRate},</if>
+            <if test="productCategory != null">#{productCategory},</if>
+            <if test="supplierName != null">#{supplierName},</if>
+            <if test="transactionType != null">#{transactionType},</if>
+            <if test="saleReturnType != null">#{saleReturnType},</if>
+            <if test="salesDetStatus != null">#{salesDetStatus},</if>
+            <if test="salesDetMsg != null">#{salesDetMsg},</if>
+            sysdate()
+        </trim>
+    </insert>
+
+    <!-- 根据key,查询value -->
+    <select id="querySalesByKey" parameterType="string" resultType="string">
+		select value from sys_config where `key` = #{key}
+	</select>
+
+<!--    查询商户名称和第三方商户信息-->
+    <select id="queryMerch" parameterType="java.lang.String" resultType="com.kmall.schedule.entity.NewSystemFormatEntiy">
+        SELECT
+            mall.merch_name as merchSnName,
+            biz.third_party_merch_code as thirdMerchSn,
+            biz.third_party_merch_name as thirdMerchSnName
+        FROM
+            mall_merch mall
+        LEFT JOIN third_merchant_biz biz ON mall.merch_sn = biz.merch_sn
+        WHERE
+            mall.merch_sn = #{merchSn}
+    </select>
+
+
+    <!--数据重推-->
+    <select id="querySalesAgain"  parameterType="java.util.Map" resultType="com.kmall.schedule.entity.NewSystemFormatEntiy">
+        SELECT
+        merch_sn,
+        merch_sn_name,
+        third_merch_sn,
+        third_merch_sn_name,
+        receipt_no,
+        store_name,
+        store_name_sn,
+        ash_register_no,
+        time_stamp,
+        staff_id,
+        staff_name,
+        pay_flag,
+        order_status,
+        order_sn_wx,
+        order_sn_ali,
+        hs_code,
+        hs_code_name,
+        ematou_code,
+        plu,
+        mychem_id,
+        product_name_en,
+        product_name_cn,
+        barcode,
+        pack_size,
+        product_spec,
+        brand,
+        edlp,
+        current_price,
+        cost_price,
+        tax_rate,
+        product_category,
+        supplier_name,
+        transaction_type,
+        sale_return_type,
+        remark
+        FROM
+        mall_sales_detail_data_log
+        WHERE
+        <if test="startTime != null and startTime != ''">
+            det_date &gt; STR_TO_DATE(#{startTime}, '%Y-%m-%d %H:%i:%s')
+        </if>
+        <if test="endTime != null and endTime != ''">
+            AND time_stamp &lt;= STR_TO_DATE(#{endTime}, '%Y-%m-%d %H:%i:%s')
+        </if>
+            AND det_status = 2
+    </select>
+
+
+</mapper>