plf 4 rokov pred
rodič
commit
b22b2bdea0

+ 8 - 1
base-module/src/main/java/com/caimei/module/base/entity/po/CmOrder.java

@@ -255,6 +255,11 @@ public class CmOrder implements Serializable {
      */
     private BigDecimal freight;
 
+    /**
+     * 采美豆抵扣运费数量(100:1)
+     */
+    private Integer userBeans;
+
     /**
      * 订单状态 0 有效  其它无效
      */
@@ -302,6 +307,8 @@ public class CmOrder implements Serializable {
      */
     private String rebateFlag;
 
-    /** 订单0成本标识*/
+    /**
+     * 订单0成本标识
+     */
     private Integer zeroCostFlag;
 }

+ 1 - 1
base-module/src/main/java/com/caimei/module/base/entity/po/Product.java

@@ -495,7 +495,7 @@ public class Product implements Serializable {
     private Date downlineTime;
 
     /**
-     * 是否包邮 0包邮 1到付
+     * 是否包邮 0包邮 1到付 2默认(遵循运费规则)
      */
     private String freePostFlag;
 

+ 54 - 0
base-module/src/main/java/com/caimei/module/base/entity/po/UserBeansHistoryPo.java

@@ -0,0 +1,54 @@
+package com.caimei.module.base.entity.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * user_beans_history
+ *
+ * @author
+ */
+@Data
+public class UserBeansHistoryPo implements Serializable {
+    private Integer id;
+
+    /**
+     * 用户id
+     */
+    private Integer userId;
+
+    /**
+     * 收支类型:1收入,2支出
+     */
+    private Integer type;
+
+    /**
+     * 采美豆类型:1注册机构,2升级会员机构,3普通机构完善资料,4会员机构完善资料,5下单,
+     * 6线上支付订单,7确认收货,8系统发放,9抵用退回,10抵用运费,11退款回收
+     */
+    private Integer beansType;
+
+    /**
+     * 主订单id
+     */
+    private Integer orderId;
+
+    /**
+     * 采美豆数量
+     */
+    private Integer num;
+
+    /**
+     * 推送状态:0未推送,1已推送
+     */
+    private Integer pushStatus;
+
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+
+    private static final long serialVersionUID = 1L;
+}

+ 22 - 0
pay/src/main/java/com/caimei/module/pay/dao/PayDao.java

@@ -1,6 +1,7 @@
 package com.caimei.module.pay.dao;
 
 import com.caimei.module.base.entity.po.SeconHandProduct;
+import com.caimei.module.base.entity.po.UserBeansHistoryPo;
 import com.caimei.module.base.entity.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -159,4 +160,25 @@ public interface PayDao {
      * @param payStatus
      */
     void updateOrderByPayStatus(@Param("orderId") Integer orderId, @Param("payStatus") String payStatus);
+
+    /**
+     * 保存采美豆记录
+     *
+     * @param beansHistory
+     */
+    void insertBeansHistory(UserBeansHistoryPo beansHistory);
+
+    /**
+     * @param orderId
+     * @return
+     */
+    Integer findPromotionsOrder(Long orderId);
+
+    /**
+     * 修改采美豆数量
+     *
+     * @param userId
+     * @param userBeans
+     */
+    void updateUserBeans(@Param("userId") Long userId, @Param("userBeans") int userBeans);
 }

+ 48 - 3
pay/src/main/java/com/caimei/module/pay/service/impl/PayServiceImpl.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.caimei.module.base.entity.bo.JsonModel;
 import com.caimei.module.base.entity.bo.Payment;
 import com.caimei.module.base.entity.po.SeconHandProduct;
+import com.caimei.module.base.entity.po.UserBeansHistoryPo;
 import com.caimei.module.base.entity.vo.*;
 import com.caimei.module.pay.dao.PayDao;
 import com.caimei.module.pay.service.PayService;
@@ -490,7 +491,8 @@ public class PayServiceImpl implements PayService {
             payDao.updateOrderPayLink(orderPayLink);
         }
         //保存收款记录
-        String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date());
+        Date date = new Date();
+        String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
         DiscernReceiptVo discernReceipt = new DiscernReceiptVo();
         discernReceipt.setPayWay("1");
         discernReceipt.setPayType(payType);
@@ -517,10 +519,53 @@ public class PayServiceImpl implements PayService {
         relation.setSplitStatus("0");
         payDao.insertOrderRelation(relation);
         log.info(">>>>>>>>>>>>>>>>>>>>>>>保存付款金额到收款记录," + amount);
-        //修改分账付款状态
-        //payDao.updateSplitAccountByPay(mbOrderId);
         //判断是否是充值商品
         getRechargeGoods(order, amount);
+        //线上支付与自主下单送豆
+        UserVo user = payDao.findUser(order.getUserID());
+        if (user != null && "3".equals(order.getReceiptStatus()) && "0".equals(order.getSecondHandOrderFlag())) {
+            int userBeans = user.getUserBeans() == null ? 0 : user.getUserBeans();
+            //线上支付送100采美豆
+            UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
+            beansHistory.setUserId(order.getUserID().intValue());
+            beansHistory.setOrderId(order.getOrderID().intValue());
+            beansHistory.setBeansType(6);
+            beansHistory.setType(1);
+            beansHistory.setNum(100);
+            beansHistory.setPushStatus(0);
+            beansHistory.setAddTime(date);
+            payDao.insertBeansHistory(beansHistory);
+            userBeans = userBeans + 100;
+
+            //自主下单且没有促销活动送豆
+            Integer id = payDao.findPromotionsOrder(order.getOrderID());
+            if (1 == order.getOrderType() && id == null) {
+                BigDecimal payTotalFee = order.getPayTotalFee();
+                int num = 0;
+                if (MathUtil.compare(1000, payTotalFee) > -1) {
+                    num = 10;
+                } else if (MathUtil.compare(5000, payTotalFee) > -1) {
+                    num = 20;
+                } else if (MathUtil.compare(10000, payTotalFee) > -1) {
+                    num = 50;
+                } else if (MathUtil.compare(25000, payTotalFee) > -1) {
+                    num = 100;
+                } else if (MathUtil.compare(100000, payTotalFee) > -1) {
+                    num = 150;
+                } else if (MathUtil.compare(250000, payTotalFee) > -1) {
+                    num = 200;
+                } else if (MathUtil.compare(500000, payTotalFee) > -1) {
+                    num = 250;
+                } else {
+                    num = 400;
+                }
+                beansHistory.setBeansType(5);
+                beansHistory.setNum(num);
+                payDao.insertBeansHistory(beansHistory);
+                userBeans = userBeans + num;
+            }
+            payDao.updateUserBeans(order.getUserID(), userBeans);
+        }
         return "SUCCESS";
     }
 

+ 20 - 0
pay/src/main/resources/com-caimei-module-pay/PayMapper.xml

@@ -584,4 +584,24 @@
         WHERE
           orderID = #{orderId}
     </update>
+
+    <insert id="insertBeansHistory">
+        INSERT INTO `user_beans_history` (
+          `userId`, `type`, `beansType`, `orderId`,
+          `num`, `pushStatus`, `addTime`
+        )
+        VALUES
+          (
+            #{userId}, #{type}, #{beansType}, #{orderId},
+            #{num}, #{pushStatus}, #{addTime}
+          )
+    </insert>
+
+    <select id="findPromotionsOrder" resultType="integer">
+        SELECT id FROM cm_organize_promotions_order WHERE orderId = #{orderId} LIMIT 1
+    </select>
+
+    <update id="updateUserBeans">
+        UPDATE USER SET userBeans = #{userBeans} WHERE userID = #{userId}
+    </update>
 </mapper>