FengChaoYu il y a 1 semaine
Parent
commit
1fe3d7b237

+ 20 - 1
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/user/UserCompanyCreditLogic.java

@@ -1,13 +1,17 @@
 package com.gree.mall.miniapp.logic.user;
 
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.gree.mall.miniapp.commonmapper.LockQueryMapper;
 import com.gree.mall.miniapp.constant.Constant;
+import com.gree.mall.miniapp.enums.TransactionTypeEnum;
 import com.gree.mall.miniapp.exception.RemoteServiceException;
 import com.gree.mall.miniapp.helper.ResponseHelper;
 import com.gree.mall.miniapp.plus.entity.OrderInfo;
 import com.gree.mall.miniapp.plus.entity.User;
 import com.gree.mall.miniapp.plus.entity.UserCompanyCredit;
+import com.gree.mall.miniapp.plus.entity.UserCompanyCreditBillItem;
 import com.gree.mall.miniapp.plus.service.UserCompanyCreditService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -55,12 +59,27 @@ public class UserCompanyCreditLogic {
                 throw new RemoteServiceException("商户授信额度不足");
             }
 
+            final DateTime curDate = DateUtil.date();
+            // 更新用户商户授信记录
             userCompanyCreditService.lambdaUpdate()
                     .set(UserCompanyCredit::getAvailableCredit, userCompanyCredit.getAvailableCredit().subtract(payAmount))
-                    .set(UserCompanyCredit::getUpdateTime, DateUtil.date())
+                    .set(UserCompanyCredit::getUpdateTime, curDate)
                     .eq(UserCompanyCredit::getId, userCompanyCredit.getId())
                     .update();
 
+            // 生成授信消费三级账明细
+            UserCompanyCreditBillItem item = new UserCompanyCreditBillItem();
+            item.setId(IdWorker.getIdStr())
+                    .setOrderId(orderInfo.getOrderId())
+                    .setTransactionType(TransactionTypeEnum.CONSUMPTION.getKey())
+                    .setDescription(TransactionTypeEnum.CONSUMPTION.getRemark())
+                    .setCompanyWechatId(userCompanyCredit.getCompanyWechatId())
+                    .setCompanyWechatName(userCompanyCredit.getCompanyWechatName())
+                    .setUserId(userCompanyCredit.getUserId())
+                    .setAmount(payAmount)
+                    .setCreateTime(curDate)
+                    .insert();
+
         } finally {
             this.txCallUnlock(obtain);
         }

+ 2 - 2
mall-miniapp-service/src/main/resources/mapper/AppMapper.xml

@@ -36,12 +36,12 @@
     <select id="queryNewGoods" resultType="com.gree.mall.miniapp.bean.goods.GoodsNewBean">
         select
             a.*,
-            b.img_url
+            c.img_url
         <if test="objId != null and objId != ''">
             ,b.obj_id
         </if>
         from goods a
-            LEFT JOIN goods_detail b ON a.goods_id = b.goods_id
+            LEFT JOIN goods_detail c ON a.goods_id = c.goods_id
         <if test="objId != null and objId != ''">
             join goods_news_category_goods b on a.goods_id = b.goods_id
         </if>

+ 3 - 2
mall-miniapp-service/src/main/resources/mapper/GoodsSpecDetailMapper.xml

@@ -81,8 +81,9 @@
 
     <select id="queryGoodsList" resultType="com.gree.mall.miniapp.bean.goods.GoodsNewBean">
         select
-            a.*
-        from goods a
+            a.*,
+            b.img_url
+        from goods a LEFT JOIN goods_detail b ON a.goods_id = b.goods_id
         where a.del=0 and a.status=true
                 and a.company_wechat_id= #{companyWechatId}
                 <if test="minPrice != null and maxPrice != null">