liaoyongfei hace 4 años
padre
commit
f989d53c56

+ 1 - 0
ymall/src/main/java/com/liangjian11/ymall/mapper/CalculationProfitMapper.java

@@ -91,4 +91,5 @@ public interface CalculationProfitMapper extends BaseMapper<CalculationProfit> {
 
   List<CalculationProfit> getListOfCashOutId(@Param("cashOutId")Integer cashOutId);
 
+  Integer editCashOutState(@Param("cashOutId")Integer cashOutId,@Param("updateTime")Date updateTime,@Param("status")Integer status);
 }

+ 4 - 0
ymall/src/main/java/com/liangjian11/ymall/mapper/UserAccountProfitMapper.java

@@ -14,6 +14,10 @@ public interface UserAccountProfitMapper extends BaseMapper<UserAccountProfit> {
 
   Integer cashOutById(@Param("cashOutAmount")Integer cashOutAmount, @Param("editTime")Date editTime,@Param("id")Integer id);
 
+  Integer cashOutDisagreeById(@Param("cashOutAmount")Integer cashOutAmount, @Param("editTime")Date editTime,@Param("id")Integer id);
+
+  Integer cashOutAgreeById(@Param("cashOutAmount")Integer cashOutAmount, @Param("editTime")Date editTime,@Param("id")Integer id);
+
   Integer accountProfitOfEntry(@Param("amount")Integer amount,@Param("editTime")Date editTime,@Param("id")Integer id);
 
 

+ 1 - 1
ymall/src/main/java/com/liangjian11/ymall/service/impl/CashOutRecordServiceImpl.java

@@ -63,7 +63,7 @@ public class CashOutRecordServiceImpl extends ServiceImpl<CashOutRecordMapper, C
           auidtIngCount+=item.getCount();
           continue;
         }
-        if(item.getState().equals(1)){
+        if(item.getState().equals(3)){
           alreadyAuidtCount+=item.getCount();
           continue;
         }

+ 38 - 20
ymall/src/main/java/com/liangjian11/ymall/service/impl/UserAccountProfitServiceImpl.java

@@ -123,31 +123,49 @@ public class UserAccountProfitServiceImpl extends ServiceImpl<UserAccountProfitM
   }
 
   @Override
+  @Transactional
   public ResultData editCashOutState(CashOutRecordStateReq req){
     if(req.getId()==null|| req.getId()<=0)
       return ResultData.getFailResult("id不能为空");
     if(req.getState()==null)
       return ResultData.getFailResult("state不能为空");
-    CashOutRecord cashOutRecord=new CashOutRecord();
-    cashOutRecord.setId(req.getId());
-    if(req.getState().equals(Short.valueOf("5"))){//拒绝提现
-      cashOutRecord.setState(req.getState());
-      cashOutRecord.setReviewRemarks(req.getReviewRemarks());
-      cashOutRecordMapper.updateById(cashOutRecord);
-    }else if(req.getState().equals(Short.valueOf("1"))){//从新发起钉钉审批
-      cashOutRecord.setState((short)2);
-      cashOutRecord.setProcessInstanceId("");
-      cashOutRecordMapper.updateById(cashOutRecord);
-      CashOutRecord existCashOutRecord=cashOutRecordMapper.selectById(req.getId());
-      List<CalculationProfit> profitList=calculationProfitMapper.getListOfCashOutId(req.getId());
-      this.sendCashOutMQ(existCashOutRecord,new Date(),profitList);
-    }else if(req.getState().equals(Short.valueOf("2"))){//审批中
-      cashOutRecord.setState(req.getState());
-      cashOutRecord.setProcessInstanceId(req.getProcessInstanceId());
-      cashOutRecordMapper.updateById(cashOutRecord);
-    }else {
-      cashOutRecord.setState(req.getState());
-      cashOutRecordMapper.updateById(cashOutRecord);
+    CashOutRecord existCashOutRecord=cashOutRecordMapper.selectById(req.getId());
+    if(existCashOutRecord!=null){
+      Date actionTme=new Date();
+      CashOutRecord cashOutRecord=new CashOutRecord();
+      cashOutRecord.setId(req.getId());
+      cashOutRecord.setEditTime(actionTme);
+      if(req.getState().equals(Short.valueOf("5"))){//拒绝提现
+        cashOutRecord.setState(req.getState());
+        cashOutRecord.setReviewRemarks(req.getReviewRemarks());
+        cashOutRecordMapper.updateById(cashOutRecord);
+        calculationProfitMapper.editCashOutState(req.getId(),actionTme,1);
+        QueryWrapper<UserAccountProfit> profitQuery = new QueryWrapper<>();
+        profitQuery.eq("unionid", existCashOutRecord.getUnionid());
+        List<UserAccountProfit>accountProfitList=userAccountProfitMapper.selectList(profitQuery);
+        userAccountProfitMapper.cashOutDisagreeById(existCashOutRecord.getAmount(),actionTme,accountProfitList.get(0).getId());
+      }else if(req.getState().equals(Short.valueOf("1"))){//从新发起钉钉审批
+        cashOutRecord.setState((short)2);
+        cashOutRecord.setProcessInstanceId("");
+        cashOutRecordMapper.updateById(cashOutRecord);
+        List<CalculationProfit> profitList=calculationProfitMapper.getListOfCashOutId(req.getId());
+        this.sendCashOutMQ(existCashOutRecord,new Date(),profitList);
+      }else if(req.getState().equals(Short.valueOf("2"))){//审批中
+        cashOutRecord.setState(req.getState());
+        cashOutRecord.setProcessInstanceId(req.getProcessInstanceId());
+        cashOutRecordMapper.updateById(cashOutRecord);
+      }else if(req.getState().equals(Short.valueOf("4"))){//已完成
+        cashOutRecord.setState(req.getState());
+        cashOutRecordMapper.updateById(cashOutRecord);
+        calculationProfitMapper.editCashOutState(req.getId(),actionTme,4);
+        QueryWrapper<UserAccountProfit> profitQuery = new QueryWrapper<>();
+        profitQuery.eq("unionid", existCashOutRecord.getUnionid());
+        List<UserAccountProfit>accountProfitList=userAccountProfitMapper.selectList(profitQuery);
+        userAccountProfitMapper.cashOutAgreeById(existCashOutRecord.getAmount(),actionTme,accountProfitList.get(0).getId());
+      }else {
+        cashOutRecord.setState(req.getState());
+        cashOutRecordMapper.updateById(cashOutRecord);
+      }
     }
     return ResultData.getSuccessResult("操作成功");
   }

+ 5 - 0
ymall/src/main/resources/mapper/CalculationProfitMapper.xml

@@ -255,6 +255,11 @@
     where account_id = #{userId} and status =1
   </update>
 
+  <update id="editCashOutState">
+     update calculation_profit set status=#{status} ,update_time=#{updateTime}
+     where cash_out_id= #{cashOutId}
+  </update>
+
   <resultMap id="cashOutOrdersMap" type="com.liangjian11.ymall.view.CashOutOrdersRsp">
     <id column="id" property="id"  jdbcType="VARCHAR"></id>
     <result column="entry_time" property="entryTime"></result>

+ 10 - 0
ymall/src/main/resources/mapper/UserAccountProfitMapper.xml

@@ -31,6 +31,16 @@
     edit_time=#{editTime} where state=1 and id=#{id}
   </update>
 
+  <update id="cashOutDisagreeById">
+    update user_account_profit set current_amount=current_amount+ #{cashOutAmount} , withdrawal_amount = withdrawal_amount - #{cashOutAmount} ,
+    edit_time=#{editTime} where  id=#{id}
+  </update>
+
+  <update id="cashOutAgreeById">
+    update user_account_profit set  withdrawal_amount = withdrawal_amount - #{cashOutAmount} ,cashout_amount + #{cashOutAmount}
+    edit_time=#{editTime} where  id=#{id}
+  </update>
+
   <update id="accountProfitOfEntry">
     update user_account_profit set current_amount=current_amount + #{amount} , total_amount = total_amount + #{amount} ,
     edit_time=#{editTime} where id=#{id}