1
0
Bläddra i källkod

Merge branch 'feature/eccs-upgrade' of lvjian/eccs into feature/eccs-upgrade

吕健 2 år sedan
förälder
incheckning
15e76a7726

+ 0 - 1
eccs-biz/src/main/java/com/emato/biz/controller/mall/SalesDetailController.java

@@ -44,7 +44,6 @@ public class SalesDetailController {
     @PostMapping("/salesdetail/eccspushsales")
     public ResultNew pushSalesDetailServicel(@RequestBody NewSystemFormatEntiy newSystemFormatEntiy)
     {
-        logger.debug("---------- 接收销售明细推送::开始 ----------");
         return ResultNew.success(salesDetaiServicel.pushSalesDetaiServicel(newSystemFormatEntiy));
     }
 

+ 45 - 7
eccs-biz/src/main/java/com/emato/biz/domain/mall/NewSystemFormatEntiy.java

@@ -1,6 +1,7 @@
 package com.emato.biz.domain.mall;
 
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * 线下订单实体类(新)
@@ -8,16 +9,21 @@ import java.io.Serializable;
  */
 public class NewSystemFormatEntiy implements Serializable {
 
-    private String storeNameSn;//门店名称
     private String merchSn;//商户编号
     private String merchSnName;//商户名称
     private String thirdMerchSn;//第三方商户编号
     private String thirdMerchSnName;//第三方商户名称
     private String receiptNo;// 销售单号
+    private String storeName;//门店名称
+    private String storeNameSn;//门店名称
     private String cashRegisterNo;// 收银台
     private String timeStampDetails;// 销售时间
     private String staffID;// 收银员
     private String staffName;// 收银员姓名
+    private String payFlag;//支付方式
+    private String orderStatus;//订单状态
+    private String orderSnWx;//微信流水号
+    private String orderSnAli;//支付宝流水号
     private String hsCode;// 品类编码
     private String hsCodeName;// 品类名称
     private String ematouCode;// 商品编码
@@ -32,24 +38,24 @@ public class NewSystemFormatEntiy implements Serializable {
     private String edlp;// 日常价
     private String currentPrice;// 实际销售价
     private String costPrice;// 进货价
+    private String taxPrice; // 税费
     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 createSn;
+    private Date createTime;
+    private String moderSn;
+    private Date modTime;
 
     public String getMerchSn() {
         return merchSn;
@@ -370,4 +376,36 @@ public class NewSystemFormatEntiy implements Serializable {
     public void setStoreNameSn(String storeNameSn) {
         this.storeNameSn = storeNameSn;
     }
+
+    public String getCreateSn() {
+        return createSn;
+    }
+
+    public void setCreateSn(String createSn) {
+        this.createSn = createSn;
+    }
+
+    public String getModerSn() {
+        return moderSn;
+    }
+
+    public void setModerSn(String moderSn) {
+        this.moderSn = moderSn;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getModTime() {
+        return modTime;
+    }
+
+    public void setModTime(Date modTime) {
+        this.modTime = modTime;
+    }
 }

+ 103 - 0
eccs-biz/src/main/java/com/emato/biz/domain/mall/SalesDataReqVO.java

@@ -0,0 +1,103 @@
+package com.emato.biz.domain.mall;
+
+import com.emato.common.annotation.DataSource;
+
+/**
+ * 销售数据请求 VO
+ *
+ * @author frankeleyn
+ * @email lvjian@qhdswl.com
+ * @date 2023/4/7 16:37
+ */
+public class SalesDataReqVO {
+
+    /**
+     * 订单编号
+     */
+    private String orderSn;
+
+    /**
+     * 订单状态
+     */
+    private String orderStatus;
+
+    /**
+     * 开始时间
+     */
+    private String starTime;
+
+    /**
+     * 结束时间
+     */
+    private String endTime;
+
+    /**
+     * 分页页码
+     */
+    private String pageIndex;
+
+    /**
+     * 分页大小
+     */
+    private String pageSize;
+
+    @Override
+    public String toString() {
+        return "SalesDataReqVO{" +
+                "orderSn='" + orderSn + '\'' +
+                ", orderStatus='" + orderStatus + '\'' +
+                ", starTime='" + starTime + '\'' +
+                ", endTime='" + endTime + '\'' +
+                ", pageIndex='" + pageIndex + '\'' +
+                ", pageSize='" + pageSize + '\'' +
+                '}';
+    }
+
+    public String getOrderSn() {
+        return orderSn;
+    }
+
+    public void setOrderSn(String orderSn) {
+        this.orderSn = orderSn;
+    }
+
+    public String getOrderStatus() {
+        return orderStatus;
+    }
+
+    public void setOrderStatus(String orderStatus) {
+        this.orderStatus = orderStatus;
+    }
+
+    public String getStarTime() {
+        return starTime;
+    }
+
+    public void setStarTime(String starTime) {
+        this.starTime = starTime;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+
+    public String getPageIndex() {
+        return pageIndex;
+    }
+
+    public void setPageIndex(String pageIndex) {
+        this.pageIndex = pageIndex;
+    }
+
+    public String getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(String pageSize) {
+        this.pageSize = pageSize;
+    }
+}

+ 18 - 1
eccs-biz/src/main/java/com/emato/biz/mapper/mall/SalesDetailMapper.java

@@ -1,6 +1,7 @@
 package com.emato.biz.mapper.mall;
 
 import com.emato.biz.domain.mall.NewSystemFormatEntiy;
+import com.emato.biz.domain.mall.SalesDataReqVO;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
@@ -13,5 +14,21 @@ public interface SalesDetailMapper {
 
     public void pullQueryData(Map map);
 
-    public int pushSalesDetaiDate(NewSystemFormatEntiy newSystemFormatEntiy);
+    public int insertSalesDetaiDate(NewSystemFormatEntiy newSystemFormatEntiy);
+
+    /**
+     * 查询销售数据
+     *
+     * @param reqVO
+     * @return
+     */
+    List<NewSystemFormatEntiy> selectSalesDetailData(SalesDataReqVO reqVO);
+
+    /**
+     * 修改销售数据
+     *
+     * @param newSystemFormatEntiy
+     * @return
+     */
+    int updateSalesDetailData(NewSystemFormatEntiy newSystemFormatEntiy);
 }

+ 40 - 5
eccs-biz/src/main/java/com/emato/biz/service/impl/SalesDetaiServicelImpl.java

@@ -6,12 +6,16 @@ import com.emato.biz.domain.OmsUtils;
 import com.emato.biz.domain.mall.InventoryDataPushVo;
 import com.emato.biz.domain.mall.InventoryDataVo;
 import com.emato.biz.domain.mall.NewSystemFormatEntiy;
+import com.emato.biz.domain.mall.SalesDataReqVO;
 import com.emato.biz.domain.merchant.MerchantSecret;
+import com.emato.biz.exception.Assert;
 import com.emato.biz.mapper.mall.InventoryDataMapper;
 import com.emato.biz.mapper.mall.MallMngChangeMapper;
+import com.emato.biz.mapper.mall.SalesDetailMapper;
 import com.emato.biz.mapper.merchant.MerchantSecretMapper;
 import com.emato.biz.service.mall.ISalesDetaiServicel;
 import com.emato.common.core.Result;
+import com.emato.common.exception.ServiceException;
 import com.emato.common.utils.DateUtils;
 import com.emato.common.utils.StringUtils;
 import com.emato.common.utils.sign.Md5Utils;
@@ -21,6 +25,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.sql.*;
 import java.util.ArrayList;
@@ -38,17 +43,20 @@ public class SalesDetaiServicelImpl implements ISalesDetaiServicel {
 
     private final Logger logger = LoggerFactory.getLogger(SalesDetaiServicelImpl.class);
 
-    @Autowired
+    @Resource
     private InventoryDataMapper inventoryDataMapper;
-    @Autowired
+    @Resource
     private MallMngChangeMapper mallMngChangeMapper;
     @Autowired
     private SysConfigMapper configMapper;
-    @Autowired
+    @Resource
     private MerchantSecretMapper merchantSecretMapper;
     @Autowired
     private OmsUtils omsUtils;
 
+    @Resource
+    private SalesDetailMapper salesDetailMapper;
+
     /**
      * kmall向eccs系统推送数据
      * @param newSystemFormatEntiy
@@ -56,8 +64,35 @@ public class SalesDetaiServicelImpl implements ISalesDetaiServicel {
      */
     @Override
     public int pushSalesDetaiServicel(NewSystemFormatEntiy newSystemFormatEntiy) {
-        logger.debug("---------- 处理销售明细推送::开始写库 ----------");
-        return mallMngChangeMapper.pushSalesDetaiDate(newSystemFormatEntiy);
+        logger.debug("---------- Eccs 接收 Kmall 销售数据开始 ----------");
+        int rows = 0;
+        try {
+            // 查询订单查看是否存在
+            SalesDataReqVO reqVO = new SalesDataReqVO();
+            reqVO.setOrderSn(newSystemFormatEntiy.getReceiptNo());
+            List<NewSystemFormatEntiy> salesDataList = salesDetailMapper.selectSalesDetailData(reqVO);
+
+            if (salesDataList.isEmpty()) {
+                // 如果不存在, 新增
+                // 设置创建人和创建时间
+                newSystemFormatEntiy.setCreateSn("admin");
+                newSystemFormatEntiy.setCreateTime(new Date());
+
+                rows = salesDetailMapper.insertSalesDetaiDate(newSystemFormatEntiy);
+            }else {
+                // 如果存在则修改
+                // 设置修改人和修改时间
+                newSystemFormatEntiy.setModerSn("admin");
+                newSystemFormatEntiy.setModTime(new Date());
+                rows = salesDetailMapper.updateSalesDetailData(newSystemFormatEntiy);
+            }
+        } catch (Exception e) {
+            logger.error("Eccs 接收 Kmall 销售数据异常 => ", e);
+            throw new ServiceException("Eccs 接收 Kmall 销售数据异常!");
+        }
+
+        logger.debug("---------- Eccs 接收 Kmall 销售数据结束 ----------");
+        return rows;
     }
 
     /**

+ 1 - 1
eccs-biz/src/main/resources/mapper/biz/mall/MallMngChangeMapper.xml

@@ -201,7 +201,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <!--    外部接口查询订单信息-->
-    <select id="getSalesDetaiData"  parameterType="java.util.Map" resultType="com.emato.biz.domain.mall.PushSystemOdOderVo">
+    <select id="getSalesDetaiData"  parameterType="java.util.Map" resultType="com.emato.biz.domain.mall.NewSystemFormatEntiy">
         SELECT
         merch_sn_name as merchSnName,
         third_merch_sn_name as thirdMerchSnName,

+ 103 - 12
eccs-biz/src/main/resources/mapper/biz/mall/SalesDetailMapper.xml.xml → eccs-biz/src/main/resources/mapper/biz/mall/SalesDetailMapper.xml

@@ -5,8 +5,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 <mapper namespace="com.emato.biz.mapper.mall.SalesDetailMapper">
 
 
+    <!-- 查询销售数据 -->
+    <select id="selectSalesDetailData" resultType="com.emato.biz.domain.mall.NewSystemFormatEntiy" parameterType="com.emato.biz.domain.mall.SalesDataReqVO">
+        SELECT
+            merch_sn,
+            merch_sn_name,
+            third_merch_sn,
+            third_merch_sn_name,
+            receipt_no,
+            store_name,
+            store_name_sn,
+            cash_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
+        <where>
+            <if test="orderSn != null and orderSn != '' ">
+                AND receipt_no = #{orderSn}
+            </if>
+        </where>
+        <if test="pageIndex != null and pageSize != null">
+            limit #{pageIndex}, #{pageSize}
+        </if>
+    </select>
+
 <!--    接收kmall数据-->
-    <insert id="pushSalesDetaiDate" parameterType="NewSystemFormatEntiy">
+    <insert id="insertSalesDetaiDate" parameterType="com.emato.biz.domain.mall.NewSystemFormatEntiy">
         insert into mall_sales_detail_data(
             <if test="merchSn != null">merch_sn,</if>
             <if test="merchSnName != null">merch_sn_name,</if>
@@ -15,15 +65,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <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="cashRegisterNo != null">cash_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>
@@ -44,7 +92,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="supplierName != null">supplier_name,</if>
             <if test="transactionType != null">transaction_type,</if>
             <if test="saleReturnType != null">sale_return_type,</if>
-            <if test="remark != null">remark</if>
+            <if test="remark != null">remark,</if>
+            <if test="createSn != null">creater_sn,</if>
+            <if test="createTime != null">create_time</if>
         )values(
         <if test="merchSn != null">#{merchSn},</if>
         <if test="merchSnName != null">#{merchSnName},</if>
@@ -54,14 +104,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <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>
@@ -82,7 +130,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="supplierName != null">#{supplierName},</if>
         <if test="transactionType != null">#{transactionType},</if>
         <if test="saleReturnType != null">#{saleReturnType},</if>
-        <if test="remark != null">#{remark}</if>
+        <if test="remark != null">#{remark},</if>
+        <if test="createSn != null">#{createSn},</if>
+        <if test="createTime != null">#{createTime}</if>
         )
     </insert>
 
@@ -97,7 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         receipt_no,
         store_name,
         store_name_sn,
-        ash_register_no,
+        cash_register_no,
         time_stamp,
         staff_id,
         staff_name,
@@ -158,6 +208,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         )
     </insert>
 
-
-
-</mapper>
+    <update id="updateSalesDetailData" parameterType="com.emato.biz.domain.mall.NewSystemFormatEntiy">
+        update mall_sales_detail_data
+        <set>
+            <if test="merchSn != null">`merch_sn` = #{merchSn},</if>
+            <if test="merchSnName != null">`merch_sn_name` = #{merchSnName},</if>
+            <if test="thirdMerchSn != null">`third_merch_sn` = #{thirdMerchSn},</if>
+            <if test="thirdMerchSnName != null">`third_merch_sn_name` = #{thirdMerchSnName},</if>
+            <if test="storeName != null">`store_name` = #{storeName},</if>
+            <if test="storeNameSn != null">`store_name_sn` = #{storeNameSn},</if>
+            <if test="cashRegisterNo != null">`cash_register_no` = #{cashRegisterNo},</if>
+            <if test="timeStampDetails != null">`time_stamp` = #{timeStampDetails},</if>
+            <if test="staffID != null">`staff_id` = #{staffID},</if>
+            <if test="staffName != null">`staff_name` = #{staffName},</if>
+            <if test="payFlag != null">`pay_flag` = #{payFlag},</if>
+            <if test="orderStatus != null">`order_status` = #{orderStatus},</if>
+            <if test="orderSnWx != null">`order_sn_wx` = #{orderSnWx},</if>
+            <if test="orderSnAli != null">`order_sn_ali` = #{orderSnAli},</if>
+            <if test="hsCode != null">`hs_code` = #{hsCode},</if>
+            <if test="hsCodeName != null">`hs_code_name` = #{hsCodeName},</if>
+            <if test="ematouCode != null">`ematou_code` = #{ematouCode},</if>
+            <if test="plu != null">`plu` = #{plu},</if>
+            <if test="mychemID != null">`mychem_id` = #{mychemID},</if>
+            <if test="productNameEN != null">`product_name_en` = #{productNameEN},</if>
+            <if test="productNameCN != null">`product_name_cn` = #{productNameCN},</if>
+            <if test="barcode != null">`barcode` = #{barcode},</if>
+            <if test="packSize != null">`pack_size` = #{packSize},</if>
+            <if test="productSpecification != null">`product_spec` = #{productSpecification},</if>
+            <if test="brand != null">`brand` = #{brand},</if>
+            <if test="edlp != null">`edlp` = #{edlp},</if>
+            <if test="currentPrice != null">`current_price` = #{currentPrice},</if>
+            <if test="costPrice != null">`cost_price` = #{costPrice},</if>
+            <if test="taxPrice != null">`tax_price` = #{taxPrice},</if>
+            <if test="taxRate != null">`tax_rate` = #{taxRate},</if>
+            <if test="productCategory != null">`product_category` = #{productCategory},</if>
+            <if test="supplierName != null">`supplier_name` = #{supplierName},</if>
+            <if test="transactionType != null">`transaction_type` = #{transactionType},</if>
+            <if test="saleReturnType != null">`sale_return_type` = #{saleReturnType},</if>
+            <if test="remark != null">`remark` = #{remark},</if>
+            <if test="moderSn != null">`moder_sn` = #{moderSn},</if>
+            <if test="modTime != null">`mod_time` = #{modTime},</if>
+        </set>
+        where receipt_no = #{receiptNo}
+    </update>
+</mapper>