|
@@ -10,6 +10,7 @@ import com.liangjian11.ymall.service.UserAccountProfitService;
|
|
|
import com.liangjian11.ymall.service.thirdapi.MQMessageService;
|
|
|
import com.liangjian11.ymall.utils.DataChangeUtil;
|
|
|
import com.liangjian11.ymall.utils.ResultData;
|
|
|
+import com.liangjian11.ymall.view.CashOutRecordStateReq;
|
|
|
import com.liangjian11.ymall.view.CashOutReq;
|
|
|
import com.liangjian11.ymall.view.PrepareCashOutRsp;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
@@ -70,6 +71,7 @@ public class UserAccountProfitServiceImpl extends ServiceImpl<UserAccountProfitM
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
public synchronized ResultData cashOut(CashOutReq cashOutReq) {
|
|
|
//QueryWrapper<UserAccountProfit> profitQuery = new QueryWrapper<>();
|
|
|
UserAccountProfit accountProfit = userAccountProfitMapper.selectById(cashOutReq.getAccountProfitId());
|
|
@@ -77,6 +79,8 @@ public class UserAccountProfitServiceImpl extends ServiceImpl<UserAccountProfitM
|
|
|
return ResultData.getFailResult("未找到用户账户");
|
|
|
if (!cashOutReq.getUnionid().equals(accountProfit.getUnionid()))
|
|
|
return ResultData.getFailResult("用户账户与提交信息不匹配");
|
|
|
+ if(cashOutReq.getCashOutAmount()==null || cashOutReq.getCashOutAmount()<=0)
|
|
|
+ return ResultData.getFailResult("提现金额要大于0");
|
|
|
if (!cashOutReq.getCashOutAmount().equals(accountProfit.getCurrentAmount()))
|
|
|
return ResultData.getFailResult("提现金额与账户剩余金额不匹配");
|
|
|
QueryWrapper<UserAccountBank> bankQuery = new QueryWrapper<>();
|
|
@@ -114,9 +118,46 @@ public class UserAccountProfitServiceImpl extends ServiceImpl<UserAccountProfitM
|
|
|
}
|
|
|
count= calculationProfitMapper.askForCashOut(cashOutRecord.getId(),actionTime,userId);
|
|
|
//发送提现的消息队列
|
|
|
+ this.sendCashOutMQ(cashOutRecord,actionTime,profitList);
|
|
|
+ return ResultData.getSuccessResult("申请成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ return ResultData.getSuccessResult("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void sendCashOutMQ(CashOutRecord cashOutRecord,Date cashOutTime,List<CalculationProfit> profitList){
|
|
|
+ if(cashOutRecord==null ||profitList==null || profitList.size()==0)
|
|
|
+ return;
|
|
|
JSONObject mqJo=new JSONObject();
|
|
|
mqJo.put("cashOutId",cashOutRecord.getId().toString());
|
|
|
- mqJo.put("createTime",df.format(actionTime));
|
|
|
+ mqJo.put("createTime",df.format(cashOutTime));
|
|
|
mqJo.put("userName",cashOutRecord.getUserName());
|
|
|
mqJo.put("userPhone", DataChangeUtil.ljDecode(cashOutRecord.getUserPhone()));
|
|
|
mqJo.put("amount",decimalFormat.format(cashOutRecord.getAmount()/100D));
|
|
@@ -134,7 +175,6 @@ public class UserAccountProfitServiceImpl extends ServiceImpl<UserAccountProfitM
|
|
|
}
|
|
|
mqJo.put("orderNews",jsonArray.toString());
|
|
|
mqMessageService.sendCashOut(mqJo);
|
|
|
- return ResultData.getSuccessResult("申请成功");
|
|
|
}
|
|
|
|
|
|
|