Browse Source

二手商品上架费加入收款列表

zhijiezhao 3 years ago
parent
commit
252d22cde4

+ 1 - 1
src/main/java/com/caimei365/order/model/po/DiscernReceiptPo.java

@@ -27,7 +27,7 @@ public class DiscernReceiptPo implements Serializable {
      */
     private Integer payType;
     /**
-     * 收款款项类型:1订单款,2非订单款,3返佣款 , 5供应商退款,6超级会员款
+     * 收款款项类型:1订单款,2非订单款,3返佣款 , 5供应商退款,6超级会员款 ,7二手商品上架费
      */
     private Integer receiptType;
     /**

+ 5 - 1
src/main/java/com/caimei365/order/model/po/OrderReceiptRelationPo.java

@@ -18,7 +18,7 @@ public class OrderReceiptRelationPo implements Serializable {
      */
     private Integer id;
     /**
-     * 关系类型:1返佣订单(返佣款)、2非返佣订单(订单款或者非订单款)
+     * 关系类型:1返佣订单(返佣款)、2非返佣订单(订单款或者非订单款)、3超级会员款、4二手商品上架费
      */
     private Integer relationType;
     /**
@@ -59,4 +59,8 @@ public class OrderReceiptRelationPo implements Serializable {
      * 15小程序-微信支付、16余额抵扣
      */
     private Integer payType;
+    /**
+     * 二手商品上架费用对应的二手商品id
+     */
+    private Integer productId;
 }

+ 32 - 0
src/main/java/com/caimei365/order/service/impl/PayNonOrderServiceImpl.java

@@ -291,6 +291,38 @@ public class PayNonOrderServiceImpl implements PayNonOrderService {
         payOrderMapper.updateSeconHandDetail(productId, payType, amount, payFormData);
         //修改分账付款状态
         payOrderMapper.updateSplitAccountByPay(mbOrderId);
+        //存收款列表
+        Date date = new Date();
+        String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
+        // 保存收款记录
+        DiscernReceiptPo discernReceipt = new DiscernReceiptPo();
+        discernReceipt.setPayWay(1);
+        discernReceipt.setPayType(Integer.valueOf(payType));
+        discernReceipt.setReceiptType(7);
+        discernReceipt.setReceiptStatus(3);
+        discernReceipt.setReceiptAmount(amount);
+        discernReceipt.setConfirmType(4);
+        discernReceipt.setRePayFlag(1);
+        discernReceipt.setFormData(payFormData);
+        discernReceipt.setReceiptDate(curDateStr);
+        discernReceipt.setConfirmDate(curDateStr);
+        discernReceipt.setReviewDate(curDateStr);
+        discernReceipt.setUpdateDate(curDateStr);
+        discernReceipt.setDelFlag(0);
+        // 保存 收款记录
+        baseMapper.insertDiscernReceipt(discernReceipt);
+        // 收款项和订单关系表
+        OrderReceiptRelationPo relation = new OrderReceiptRelationPo();
+        relation.setReceiptId(discernReceipt.getId());
+        relation.setAssociateAmount(amount);
+        relation.setMbOrderId(mbOrderId);
+        relation.setSplitStatus(1);
+        relation.setRelationType(4);
+        relation.setDelFlag(0);
+        //二手商品id
+        relation.setProductId(productId);
+        // 保存 收款项和订单关系
+        baseMapper.insertOrderReceiptRelation(relation);
         return "SUCCESS";
     }
 

+ 193 - 133
src/main/resources/mapper/BaseMapper.xml

@@ -2,164 +2,198 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.order.mapper.BaseMapper">
     <select id="getShopNameById" resultType="java.lang.String">
-        SELECT `name` FROM shop WHERE shopID = #{shopId} LIMIT 1
+        SELECT `name`
+        FROM shop
+        WHERE shopID = #{shopId}
+        LIMIT 1
     </select>
     <select id="getClubNameById" resultType="java.lang.String">
-        SELECT `name` FROM club WHERE clubID = #{clubId} LIMIT 1
+        SELECT `name`
+        FROM club
+        WHERE clubID = #{clubId}
+        LIMIT 1
     </select>
     <insert id="insertUserInvoiceByUserId" parameterType="com.caimei365.order.model.vo.InvoiceVo">
-        INSERT INTO cm_user_invoiceinfo (userId, invoiceTitle, corporationTaxNum, registeredAddress, registeredPhone, bankAccountNo, openBank)
-        VALUES(#{userId}, #{invoiceTitle}, #{corporationTaxNum},#{registeredAddress}, #{registeredPhone},#{bankAccountNo}, #{openBank})
+        INSERT INTO cm_user_invoiceinfo (userId, invoiceTitle, corporationTaxNum, registeredAddress, registeredPhone,
+                                         bankAccountNo, openBank)
+        VALUES (#{userId}, #{invoiceTitle}, #{corporationTaxNum}, #{registeredAddress}, #{registeredPhone},
+                #{bankAccountNo}, #{openBank})
     </insert>
-    <insert id="insertPurchasePrice" keyColumn="id" keyProperty="id" parameterType="com.caimei365.order.model.po.PurchasePricePo" useGeneratedKeys="true">
+    <insert id="insertPurchasePrice" keyColumn="id" keyProperty="id"
+            parameterType="com.caimei365.order.model.po.PurchasePricePo" useGeneratedKeys="true">
         INSERT INTO repeat_purchase_price (userId, clubId, orderId, productId, shopId, shopName,
-        taxRate, currentPrice, createTime, updateTime, delFlag)
+                                           taxRate, currentPrice, createTime, updateTime, delFlag)
         VALUES (#{userId}, #{clubId}, #{orderId}, #{productId}, #{shopId}, #{shopName},
-        #{taxRate}, #{currentPrice}, #{createTime}, #{updateTime}, #{delFlag})
+                #{taxRate}, #{currentPrice}, #{createTime}, #{updateTime}, #{delFlag})
     </insert>
-    <insert id="insertPurchaseHistory" keyColumn="id" keyProperty="id" parameterType="com.caimei365.order.model.po.PurchaseHistoryPo" useGeneratedKeys="true">
-        INSERT INTO repeat_purchase_price_history (userId, clubId, orderId, productId, price, currentCostPrice, createTime, delFlag)
-        VALUES (#{userId}, #{clubId}, #{orderId}, #{productId}, #{price}, #{currentCostPrice}, #{createTime}, #{delFlag})
+    <insert id="insertPurchaseHistory" keyColumn="id" keyProperty="id"
+            parameterType="com.caimei365.order.model.po.PurchaseHistoryPo" useGeneratedKeys="true">
+        INSERT INTO repeat_purchase_price_history (userId, clubId, orderId, productId, price, currentCostPrice,
+                                                   createTime, delFlag)
+        VALUES (#{userId}, #{clubId}, #{orderId}, #{productId}, #{price}, #{currentCostPrice}, #{createTime},
+                #{delFlag})
     </insert>
     <update id="updateUserInvoiceByUserId" parameterType="com.caimei365.order.model.vo.InvoiceVo">
         UPDATE cm_user_invoiceinfo
-        SET
-            invoiceTitle = #{invoiceTitle},
+        SET invoiceTitle      = #{invoiceTitle},
             corporationTaxNum = #{corporationTaxNum},
             registeredAddress = #{registeredAddress},
-            registeredPhone = #{registeredPhone},
-            bankAccountNo = #{bankAccountNo},
-            openBank = #{openBank}
+            registeredPhone   = #{registeredPhone},
+            bankAccountNo     = #{bankAccountNo},
+            openBank          = #{openBank}
         WHERE userId = #{userId}
     </update>
     <update id="updatePurchasePrice">
-        UPDATE repeat_purchase_price SET
-        currentPrice = #{currentPrice}, taxRate = #{taxRate}, updateTime = #{updateTime}
+        UPDATE repeat_purchase_price
+        SET currentPrice = #{currentPrice},
+            taxRate      = #{taxRate},
+            updateTime   = #{updateTime}
         WHERE id = #{id}
     </update>
     <select id="getUserIdByClubId" resultType="java.lang.Integer">
-        select userID from user where clubID = #{clubId} LIMIT 1
+        select userID
+        from user
+        where clubID = #{clubId}
+        LIMIT 1
     </select>
     <select id="getIdentityByUserId" resultType="java.lang.Integer">
-        select userIdentity from user where userID = #{userId} LIMIT 1
+        select userIdentity
+        from user
+        where userID = #{userId}
+        LIMIT 1
     </select>
     <select id="getUserNameByUserId" resultType="java.lang.String">
-        select userName from user where userID = #{userId} LIMIT 1
+        select userName
+        from user
+        where userID = #{userId}
+        LIMIT 1
     </select>
     <select id="getLadderPriceList" resultType="com.caimei365.order.model.vo.LadderPriceVo">
-        select
-        id, productId, ladderNum, buyNum, buyPrice
+        select id,
+               productId,
+               ladderNum,
+               buyNum,
+               buyPrice
         from product_ladder_price
-        where productId = #{productId} and userType = 3 and delFlag = 0
+        where productId = #{productId}
+          and userType = 3
+          and delFlag = 0
         order by ladderNum asc
     </select>
     <select id="getRepurchasePrice" resultType="java.lang.Double">
-        select
-        r.currentPrice
+        select r.currentPrice
         from repeat_purchase_price r
-        left join product p on p.productID = r.productId
-        where r.productId = #{productId} and r.userId = #{userId}
-        and ((p.costCheckFlag=1 and r.currentPrice <![CDATA[ >= ]]> p.costPrice) or p.costCheckFlag=2)
-        and p.price1 <![CDATA[ >= ]]> r.currentPrice
-        and r.delFlag = 0
+                 left join product p on p.productID = r.productId
+        where r.productId = #{productId}
+          and r.userId = #{userId}
+          and ((p.costCheckFlag = 1 and r.currentPrice <![CDATA[ >= ]]> p.costPrice) or p.costCheckFlag = 2)
+          and p.price1 <![CDATA[ >= ]]> r.currentPrice
+          and r.delFlag = 0
     </select>
     <select id="getPromotionByShopId" resultType="com.caimei365.order.model.vo.PromotionsVo">
-        SELECT
-        pr.id,
-        pr.name,
-        pr.description,
-        pr.type,
-        pr.mode,
-        pr.touchPrice,
-        pr.reducedPrice,
-        pr.beginTime,
-        pr.endTime,
-        pr.status,
-        prp.productId,
-        prp.supplierId AS shopId
+        SELECT pr.id,
+               pr.name,
+               pr.description,
+               pr.type,
+               pr.mode,
+               pr.touchPrice,
+               pr.reducedPrice,
+               pr.beginTime,
+               pr.endTime,
+               pr.status,
+               prp.productId,
+               prp.supplierId AS shopId
         FROM cm_promotions pr
-        LEFT JOIN cm_promotions_product prp ON pr.id = prp.promotionsId
-        WHERE prp.supplierId = #{shopId} and pr.delFlag=0 and pr.type=3
-        AND (pr.status = 1 OR ( pr.status = 2 AND (NOW() BETWEEN pr.beginTime AND pr.endTime)))
-        ORDER BY pr.type DESC LIMIT 1
+                 LEFT JOIN cm_promotions_product prp ON pr.id = prp.promotionsId
+        WHERE prp.supplierId = #{shopId}
+          and pr.delFlag = 0
+          and pr.type = 3
+          AND (pr.status = 1 OR (pr.status = 2 AND (NOW() BETWEEN pr.beginTime AND pr.endTime)))
+        ORDER BY pr.type DESC
+        LIMIT 1
     </select>
     <select id="getPromotionByProductId" resultType="com.caimei365.order.model.vo.PromotionsVo">
-        SELECT
-        pr.id,
-        pr.name,
-        pr.description,
-        pr.type,
-        pr.mode,
-        pr.touchPrice,
-        pr.reducedPrice,
-        pr.beginTime,
-        pr.endTime,
-        pr.status,
-        prp.productId,
-        prp.supplierId AS shopId
+        SELECT pr.id,
+               pr.name,
+               pr.description,
+               pr.type,
+               pr.mode,
+               pr.touchPrice,
+               pr.reducedPrice,
+               pr.beginTime,
+               pr.endTime,
+               pr.status,
+               prp.productId,
+               prp.supplierId AS shopId
         FROM cm_promotions pr
-        LEFT JOIN cm_promotions_product prp ON pr.id = prp.promotionsId
-        WHERE prp.productId = #{productId} and pr.delFlag=0 and pr.type in (1,2)
-        AND (pr.status = 1 OR ( pr.status = 2 AND (NOW() BETWEEN pr.beginTime AND pr.endTime)))
-        ORDER BY pr.type DESC LIMIT 1
+                 LEFT JOIN cm_promotions_product prp ON pr.id = prp.promotionsId
+        WHERE prp.productId = #{productId}
+          and pr.delFlag = 0
+          and pr.type in (1, 2)
+          AND (pr.status = 1 OR (pr.status = 2 AND (NOW() BETWEEN pr.beginTime AND pr.endTime)))
+        ORDER BY pr.type DESC
+        LIMIT 1
     </select>
     <select id="getPromotionGifts" resultType="com.caimei365.order.model.vo.CartItemVo">
-        SELECT
-        cpg.id AS id,
-        p.productID AS productId,
-        p.shopID AS shopId,
-        p.`name` AS `name`,
-        p.mainImage AS image,
-        cpg.number AS number,
-        0 AS price,
-        2 as productType,
-        p.price1 AS originalPrice,
-        p.unit AS unit,
-        p.stock AS stock,
-        p.validFlag AS validFlag
+        SELECT cpg.id      AS id,
+               p.productID AS productId,
+               p.shopID    AS shopId,
+               p.`name`    AS `name`,
+               p.mainImage AS image,
+               cpg.number  AS number,
+               0           AS price,
+               2           as productType,
+               p.price1    AS originalPrice,
+               p.unit      AS unit,
+               p.stock     AS stock,
+               p.validFlag AS validFlag
         FROM cm_promotions_gift cpg
-        LEFT JOIN product p ON cpg.productId = p.productID
+                 LEFT JOIN product p ON cpg.productId = p.productID
         WHERE cpg.promotionsId = #{promotionsId}
         ORDER BY cpg.id DESC
     </select>
     <select id="getShopByProductId" resultType="com.caimei365.order.model.vo.CartShopVo">
-        SELECT
-        s.shopID AS shopId,
-        s.name AS shopName,
-        s.logo AS shopLogo
+        SELECT s.shopID AS shopId,
+               s.name   AS shopName,
+               s.logo   AS shopLogo
         FROM shop s
-        LEFT JOIN product p ON p.shopID = s.shopID
+                 LEFT JOIN product p ON p.shopID = s.shopID
         WHERE p.productId = #{productId}
         LIMIT 1
     </select>
     <select id="getUserInvoice" resultType="com.caimei365.order.model.vo.InvoiceVo">
-        SELECT
-            id,
-            userId,
-            invoiceTitle,
-            corporationTaxNum,
-            registeredAddress,
-            registeredPhone,
-            bankAccountNo,
-            openBank
+        SELECT id,
+               userId,
+               invoiceTitle,
+               corporationTaxNum,
+               registeredAddress,
+               registeredPhone,
+               bankAccountNo,
+               openBank
         FROM cm_user_invoiceinfo
         WHERE userId = #{userId}
         LIMIT 1
     </select>
     <select id="getUserMoney" resultType="java.lang.Double">
-        SELECT userMoney FROM user WHERE userID = #{userId}
+        SELECT userMoney
+        FROM user
+        WHERE userID = #{userId}
     </select>
     <select id="getAbleUserMoney" resultType="java.lang.Double">
-        SELECT ableUserMoney FROM user WHERE userID = #{userId}
+        SELECT ableUserMoney
+        FROM user
+        WHERE userID = #{userId}
     </select>
     <select id="getUserBeans" resultType="java.lang.Integer">
-        SELECT userBeans FROM user WHERE userID = #{userId}
+        SELECT userBeans
+        FROM user
+        WHERE userID = #{userId}
     </select>
     <select id="getPostageFlagList" resultType="com.caimei365.order.model.vo.ProductPostageVo">
         SELECT
-            productID AS productId,
-            freePostFlag AS postageFlag,
-            commodityType
+        productID AS productId,
+        freePostFlag AS postageFlag,
+        commodityType
         FROM product
         WHERE validFlag='2' AND productID in
         <foreach collection="productIds" open="(" separator="," close=")" item="productId">
@@ -167,75 +201,99 @@
         </foreach>
     </select>
     <select id="countUserOrder" resultType="java.lang.Integer">
-        SELECT COUNT(*) FROM cm_order WHERE userID = #{userId} AND delFlag=0 AND STATUS != 6
+        SELECT COUNT(*)
+        FROM cm_order
+        WHERE userID = #{userId}
+          AND delFlag = 0
+          AND STATUS != 6
     </select>
     <select id="getProvinceIdAndCityId" resultType="com.caimei365.order.model.vo.AddressVo">
-        SELECT provinceID AS provinceId, cityID AS cityId FROM city
-        WHERE cityID =(SELECT cityID from town where townID = #{townId})
+        SELECT provinceID AS provinceId, cityID AS cityId
+        FROM city
+        WHERE cityID = (SELECT cityID from town where townID = #{townId})
     </select>
     <select id="getTownIdByAddressId" resultType="java.lang.Integer">
-        SELECT townID FROM address WHERE addressID = #{addressId}
+        SELECT townID
+        FROM address
+        WHERE addressID = #{addressId}
     </select>
     <select id="getPurchasePricePo" resultType="com.caimei365.order.model.po.PurchasePricePo">
-        SELECT
-        id,
-        userId,
-        clubId,
-        orderId,
-        productId,
-        shopId,
-        shopName,
-        taxRate,
-        currentPrice,
-        createTime
+        SELECT id,
+               userId,
+               clubId,
+               orderId,
+               productId,
+               shopId,
+               shopName,
+               taxRate,
+               currentPrice,
+               createTime
         FROM repeat_purchase_price
-        WHERE userId = #{userId} AND productId = #{productId} AND delFlag='0'
+        WHERE userId = #{userId}
+          AND productId = #{productId}
+          AND delFlag = '0'
     </select>
     <select id="getBindMobileByUserId" resultType="java.lang.String">
-        SELECT bindMobile FROM user WHERE userID = #{userId}
+        SELECT bindMobile
+        FROM user
+        WHERE userID = #{userId}
     </select>
     <select id="getShopIdByproductId" resultType="java.lang.Integer">
-        SELECT shopID FROM product WHERE productID = #{productId}
+        SELECT shopID
+        FROM product
+        WHERE productID = #{productId}
     </select>
     <select id="getClauseList" resultType="com.caimei365.order.model.vo.ClauseVo">
-        SELECT
-            id,
-            name,
-            content,
-            clauseType,
-            enabledStatus
+        SELECT id,
+               name,
+               content,
+               clauseType,
+               enabledStatus
         FROM bp_clause
     </select>
-    <insert id="insertDiscernReceipt" keyColumn="id" keyProperty="id" parameterType="com.caimei365.order.model.po.DiscernReceiptPo" useGeneratedKeys="true">
+    <insert id="insertDiscernReceipt" keyColumn="id" keyProperty="id"
+            parameterType="com.caimei365.order.model.po.DiscernReceiptPo" useGeneratedKeys="true">
         INSERT INTO cm_discern_receipt (payWay, payType, receiptType, receiptStatus, receiptAmount, confirmType,
-        receiptDate, confirmDate, reviewDate, updateDate, delFlag, rePayFlag, formData)
+                                        receiptDate, confirmDate, reviewDate, updateDate, delFlag, rePayFlag, formData)
         VALUES (#{payWay}, #{payType}, #{receiptType}, #{receiptStatus}, #{receiptAmount}, #{confirmType},
-        #{receiptDate}, #{confirmDate}, #{reviewDate}, #{updateDate}, #{delFlag}, #{rePayFlag}, #{formData})
+                #{receiptDate}, #{confirmDate}, #{reviewDate}, #{updateDate}, #{delFlag}, #{rePayFlag}, #{formData})
     </insert>
-    <insert id="insertOrderReceiptRelation" keyColumn="id" keyProperty="id" parameterType="com.caimei365.order.model.po.OrderReceiptRelationPo" useGeneratedKeys="true">
-        INSERT INTO cm_receipt_order_relation (relationType, receiptId, associateAmount, orderId, vipRecordId, delFlag, mbOrderId, orderRequestNo, splitStatus)
-        VALUES (#{relationType}, #{receiptId}, #{associateAmount}, #{orderId}, #{vipRecordId}, #{delFlag}, #{mbOrderId}, #{orderRequestNo}, #{splitStatus})
+    <insert id="insertOrderReceiptRelation" keyColumn="id" keyProperty="id"
+            parameterType="com.caimei365.order.model.po.OrderReceiptRelationPo" useGeneratedKeys="true">
+        INSERT INTO cm_receipt_order_relation (relationType, receiptId, associateAmount, orderId, vipRecordId, delFlag,
+                                               mbOrderId, orderRequestNo, splitStatus, productId)
+        VALUES (#{relationType}, #{receiptId}, #{associateAmount}, #{orderId}, #{vipRecordId}, #{delFlag}, #{mbOrderId},
+                #{orderRequestNo}, #{splitStatus}, #{productId})
     </insert>
     <insert id="insertBeansHistory" parameterType="com.caimei365.order.model.po.UserBeansHistoryPo">
         INSERT INTO user_beans_history (userId, type, beansType, orderId, num, pushStatus, addTime, delFlag)
         VALUES (#{userId}, #{type}, #{beansType}, #{orderId}, #{num}, #{pushStatus}, #{addTime}, #{delFlag})
     </insert>
     <update id="updateUserBeans">
-        UPDATE USER SET userBeans = #{userBeans}
+        UPDATE USER
+        SET userBeans = #{userBeans}
         WHERE userID = #{userId}
     </update>
     <update id="updateUserClubStatus">
-        UPDATE user SET clubStatus = #{clubStatus} WHERE userID = #{userId}
+        UPDATE user
+        SET clubStatus = #{clubStatus}
+        WHERE userID = #{userId}
     </update>
     <update id="updateClubStatus">
-        UPDATE club SET status = #{clubStatus} WHERE userID = #{userId}
+        UPDATE club
+        SET status = #{clubStatus}
+        WHERE userID = #{userId}
     </update>
     <insert id="insertBalanceRecord" parameterType="com.caimei365.order.model.po.BalanceRecordPo">
         INSERT INTO cm_user_balance_record (userId, type, balanceType, addDate, amount, orderId, remark, delFlag)
         VALUES (#{userId}, #{type}, #{balanceType}, #{addDate}, #{amount}, #{orderId}, #{remark}, #{delFlag})
     </insert>
     <select id="getSvipUserIdByUserId" resultType="java.lang.Integer">
-        select userId from cm_svip_user where userId = #{userId} and delFlag = '0' and now() <![CDATA[ < ]]> endTime
+        select userId
+        from cm_svip_user
+        where userId = #{userId}
+          and delFlag = '0'
+          and now() <![CDATA[ < ]]> endTime
     </select>
     <select id="getSvipUserIdByClubId" resultType="java.lang.Integer">
         select svu.userId
@@ -246,7 +304,9 @@
           and now() <![CDATA[ < ]]> endTime;
     </select>
     <select id="getClubStatus" resultType="java.lang.Integer">
-        select clubStatus from user where userID = #{userId}
+        select clubStatus
+        from user
+        where userID = #{userId}
     </select>
     <select id="getClubConfirmTime" resultType="java.util.Date">
         SELECT confirmTime