liaoyongfei 4 年 前
コミット
17c58d3831

+ 7 - 1
ymall/src/main/java/com/liangjian11/ymall/handle/SynProfitHandle.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.liangjian11.ymall.mapper.PartnerMapper;
+import com.liangjian11.ymall.mapper.UserAccountMapper;
 import com.liangjian11.ymall.model.*;
 import com.liangjian11.ymall.model.common.HospitalDomain;
 import com.liangjian11.ymall.service.*;
@@ -37,10 +38,12 @@ public class SynProfitHandle {
   private final UserRoleService userRoleService;
   private final DailyProfitService dailyProfitService;
   private final PartnerMapper partnerMapper;
+  private final UserAccountMapper userAccountMapper;
 
   public SynProfitHandle(HospitalDomain hospitalDomain, InterrogationOrdersService interrogationOrdersService, PrescriptionOrdersService prescriptionOrdersService,
                          DoctorService doctorService, ProfitRuleDetailService profitRuleDetailService, CalculationProfitService calculationProfitService,
-                         PartnerRecommendService partnerRecommendService, UserRoleService userRoleService, DailyProfitService dailyProfitService,PartnerMapper partnerMapper) {
+                         PartnerRecommendService partnerRecommendService, UserRoleService userRoleService, DailyProfitService dailyProfitService,PartnerMapper partnerMapper
+  ,UserAccountMapper userAccountMapper) {
     this.hospitalDomain = hospitalDomain;
     this.interrogationOrdersService = interrogationOrdersService;
     this.prescriptionOrdersService = prescriptionOrdersService;
@@ -51,6 +54,7 @@ public class SynProfitHandle {
     this.userRoleService = userRoleService;
     this.dailyProfitService = dailyProfitService;
     this.partnerMapper=partnerMapper;
+    this.userAccountMapper=userAccountMapper;
   }
 
   /**
@@ -529,6 +533,8 @@ public class SynProfitHandle {
           profit.setStatus(1);
           profit.setUpdateTime(now);
           profit.setEntryTime(now);
+          UserAccount userAccount=userAccountMapper.selectById(profit.getAccountId());
+
         } else {
           //退款
           profit.setStatus(3);

+ 10 - 6
ymall/src/main/java/com/liangjian11/ymall/service/impl/UserAccountProfitServiceImpl.java

@@ -45,10 +45,13 @@ public class UserAccountProfitServiceImpl extends ServiceImpl<UserAccountProfitM
     QueryWrapper<UserAccountProfit> profitQUery = new QueryWrapper<>();
     profitQUery.eq("unionid", unionId);
     List<UserAccountProfit> profitList = userAccountProfitMapper.selectList(profitQUery);
-    if (profitList == null || profitList.size() == 0)
-      return prepareCashOutRes;
-    prepareCashOutRes.setCurrentAmount(profitList.get(0).getCurrentAmount());
-    prepareCashOutRes.setAccountProfitId(profitList.get(0).getId());
+    if (profitList == null || profitList.size() == 0){
+      prepareCashOutRes.setCurrentAmount(0);
+      prepareCashOutRes.setAccountProfitId(0);
+    }else {
+      prepareCashOutRes.setCurrentAmount(profitList.get(0).getCurrentAmount());
+      prepareCashOutRes.setAccountProfitId(profitList.get(0).getId());
+    }
     List<UserAccountBank> bankList = userAccountBankMapper.getListByUser(unionId);
     prepareCashOutRes.setBankList(bankList);
     if (bankList != null && bankList.size() > 0)
@@ -63,12 +66,12 @@ public class UserAccountProfitServiceImpl extends ServiceImpl<UserAccountProfitM
     UserAccountProfit accountProfit = userAccountProfitMapper.selectById(cashOutReq.getAccountProfitId());
     if (accountProfit == null)
       return ResultData.getFailResult("未找到用户账户");
-    if (!cashOutReq.getUnionid().equals(accountProfit.getUnifiedId()))
+    if (!cashOutReq.getUnionid().equals(accountProfit.getUnionid()))
       return ResultData.getFailResult("用户账户与提交信息不匹配");
     if (!cashOutReq.getCashOutAmount().equals(accountProfit.getCurrentAmount()))
       return ResultData.getFailResult("提现金额与账户剩余金额不匹配");
     QueryWrapper<UserAccountBank> bankQuery = new QueryWrapper<>();
-    bankQuery.eq("delete",false);
+    bankQuery.eq("is_delete",false);
     bankQuery.eq("id",cashOutReq.getDefaultBank().getId());
     List<UserAccountBank> bankList=userAccountBankMapper.selectList(bankQuery);
     if(bankList==null||bankList.size()==0)
@@ -80,6 +83,7 @@ public class UserAccountProfitServiceImpl extends ServiceImpl<UserAccountProfitM
       throw new RuntimeException("账户扣款失败");
     CashOutRecord cashOutRecord=new CashOutRecord(accountProfit.getUserId(),cashOutReq.getCashOutAmount(),(short)1,bank.getAccountId(),bank.getSubbranchName()
       ,bank.getAccountArea(),bank.getAccountName(),bank.getBankName(),accountProfit.getUnionid(),accountProfit.getUserPhone(),accountProfit.getUnifiedId(),accountProfit.getPraiseId());
+    cashOutRecord.setCreateTime(actionTime);
     count=cashOutRecordMapper.addItem(cashOutRecord);
     if(count<1 || cashOutRecord.getId()==null || cashOutRecord.getId()==0)
       throw new RuntimeException("生成提现记录失败");

+ 5 - 5
ymall/src/main/resources/mapper/CashOutRecordMapper.xml

@@ -58,21 +58,21 @@
     VALUES
     <trim prefix="(" suffix=")" suffixOverrides=",">
       <if test="userId!=null and userId !=''">
-        user_id=#{userId},
+        #{userId},
       </if>
       #{amount} , #{state} , #{accountId} , #{subbranchName} , #{accountArea} , #{accountName} ,
       <if test="userRemarks!=null and userRemarks !=''">
-        user_remarks=#{userRemarks},
+        #{userRemarks},
       </if>
       #{bankName} , #{type} , #{createTime} , #{createTime} , #{unionid},
       <if test="userPhone!=null and userPhone !=''">
-        user_phone=#{userPhone},
+        #{userPhone},
       </if>
       <if test="unifiedId!=null and unifiedId !=''">
-        unified_id=#{unifiedId},
+        #{unifiedId},
       </if>
       <if test="praiseId!=null and praiseId !=''">
-        praise_id=#{praiseId},
+        #{praiseId},
       </if>
     </trim>
   </insert>