修改
This commit is contained in:
@@ -3,8 +3,6 @@ package com.chaozhanggui.system.cashierservice.service;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
import com.chaozhanggui.system.cashierservice.bean.TableStateEnum;
|
|
||||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
@@ -20,8 +18,6 @@ import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderStatusQueryResp
|
|||||||
import com.chaozhanggui.system.cashierservice.thirdpay.resp.PublicResp;
|
import com.chaozhanggui.system.cashierservice.thirdpay.resp.PublicResp;
|
||||||
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
|
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
|
||||||
import com.chaozhanggui.system.cashierservice.util.*;
|
import com.chaozhanggui.system.cashierservice.util.*;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import com.github.pagehelper.PageHelper;
|
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -87,6 +83,7 @@ public class MemberService {
|
|||||||
@Qualifier("tbOrderInfoMapper")
|
@Qualifier("tbOrderInfoMapper")
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbOrderInfoMapper tbOrderInfoMapper;
|
private TbOrderInfoMapper tbOrderInfoMapper;
|
||||||
|
private MpShopTableMapper mpShopTableMapper;
|
||||||
|
|
||||||
public Result queryMember(String shopId, String phone, int page, int pageSize) {
|
public Result queryMember(String shopId, String phone, int page, int pageSize) {
|
||||||
|
|
||||||
@@ -316,7 +313,6 @@ public class MemberService {
|
|||||||
producer.putOrderCollect(jsonObject.toJSONString());
|
producer.putOrderCollect(jsonObject.toJSONString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS, memberIn);
|
return Result.success(CodeEnum.SUCCESS, memberIn);
|
||||||
} else {
|
} else {
|
||||||
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
|
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
|
||||||
@@ -399,7 +395,6 @@ public class MemberService {
|
|||||||
producer.putOrderCollect(jsonObject.toJSONString());
|
producer.putOrderCollect(jsonObject.toJSONString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JSONObject baObj = new JSONObject();
|
JSONObject baObj = new JSONObject();
|
||||||
baObj.put("userId", shopUser.getUserId());
|
baObj.put("userId", shopUser.getUserId());
|
||||||
baObj.put("shopId", shopInfo.getId());
|
baObj.put("shopId", shopInfo.getId());
|
||||||
@@ -410,8 +405,6 @@ public class MemberService {
|
|||||||
producer.balance(baObj.toString());
|
producer.balance(baObj.toString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS, memberIn);
|
return Result.success(CodeEnum.SUCCESS, memberIn);
|
||||||
|
|
||||||
} else if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
|
} else if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
|
||||||
@@ -432,7 +425,6 @@ public class MemberService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Result queryScanPay(String flowId, String token) {
|
public Result queryScanPay(String flowId, String token) {
|
||||||
if (ObjectUtil.isEmpty(flowId)) {
|
if (ObjectUtil.isEmpty(flowId)) {
|
||||||
return Result.fail(CodeEnum.PARAM);
|
return Result.fail(CodeEnum.PARAM);
|
||||||
@@ -579,7 +571,6 @@ public class MemberService {
|
|||||||
return Result.success(CodeEnum.SUCCESS, memberIn);
|
return Result.success(CodeEnum.SUCCESS, memberIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result memberAccountPay(Map<String, Object> map, String token) throws Exception {
|
public Result memberAccountPay(Map<String, Object> map, String token) throws Exception {
|
||||||
if (ObjectUtil.isEmpty(map) || map.size() <= 0
|
if (ObjectUtil.isEmpty(map) || map.size() <= 0
|
||||||
@@ -592,7 +583,6 @@ public class MemberService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String memberId = String.valueOf(map.get("memberId"));
|
String memberId = String.valueOf(map.get("memberId"));
|
||||||
|
|
||||||
String shopId = String.valueOf(map.get("shopId"));
|
String shopId = String.valueOf(map.get("shopId"));
|
||||||
@@ -709,7 +699,6 @@ public class MemberService {
|
|||||||
producer.putOrderCollect(jsonObject.toJSONString());
|
producer.putOrderCollect(jsonObject.toJSONString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JSONObject baObj = new JSONObject();
|
JSONObject baObj = new JSONObject();
|
||||||
baObj.put("userId", shopUser.getUserId());
|
baObj.put("userId", shopUser.getUserId());
|
||||||
baObj.put("shopId", shopInfo.getId());
|
baObj.put("shopId", shopInfo.getId());
|
||||||
@@ -720,14 +709,9 @@ public class MemberService {
|
|||||||
producer.balance(baObj.toString());
|
producer.balance(baObj.toString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MpShopTableMapper mpShopTableMapper;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Result queryMemberAccount(String memberId, int page, int pageSize) {
|
public Result queryMemberAccount(String memberId, int page, int pageSize) {
|
||||||
if (ObjectUtil.isEmpty(memberId)) {
|
if (ObjectUtil.isEmpty(memberId)) {
|
||||||
return Result.fail(CodeEnum.PARAM);
|
return Result.fail(CodeEnum.PARAM);
|
||||||
@@ -760,27 +744,39 @@ public class MemberService {
|
|||||||
return Result.fail(CodeEnum.ACCOUNTEIXST);
|
return Result.fail(CodeEnum.ACCOUNTEIXST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BigDecimal amount=BigDecimal.ZERO;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
if(N.gt(flow.getAmount(),user.getAmount())){
|
if(N.gt(flow.getAmount(),user.getAmount())){
|
||||||
return Result.fail(CodeEnum.ACCOUNTAMOUNT);
|
amount=user.getAmount();
|
||||||
|
}else {
|
||||||
|
amount=flow.getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(user.getShopId()));
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(user.getShopId()));
|
||||||
if (ObjectUtil.isEmpty(shopInfo) || ObjectUtil.isNull(shopInfo)) {
|
if (ObjectUtil.isEmpty(shopInfo) || ObjectUtil.isNull(shopInfo)) {
|
||||||
return Result.fail(CodeEnum.MERCHANTEIXST);
|
return Result.fail(CodeEnum.MERCHANTEIXST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ("scanMemberIn".equals(flow.getBizCode())) {
|
||||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(shopInfo.getMerchantId()));
|
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(shopInfo.getMerchantId()));
|
||||||
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
||||||
return Result.fail(CodeEnum.NOCUSTOMER);
|
return Result.fail(CodeEnum.NOCUSTOMER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if("scanMemberIn".equals(flow.getBizCode())) {
|
|
||||||
|
|
||||||
String no = DateUtils.getSsdfTimes();
|
String no = DateUtils.getSsdfTimes();
|
||||||
|
|
||||||
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(),no , null, flow.getRemark(), "充值退款", flow.getAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
|
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(), no, null, flow.getRemark(), "充值退款",amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
|
||||||
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||||
if ("000000".equals(publicResp.getCode())) {
|
if ("000000".equals(publicResp.getCode())) {
|
||||||
if (!"SUCCESS".equals(publicResp.getObjData().getState()) && !publicResp.getObjData().getState().equals("ING")) {
|
if (!"SUCCESS".equals(publicResp.getObjData().getState()) && !publicResp.getObjData().getState().equals("ING")) {
|
||||||
@@ -797,7 +793,7 @@ public class MemberService {
|
|||||||
} else {
|
} else {
|
||||||
return Result.fail(CodeEnum.OPARETIONERROR);
|
return Result.fail(CodeEnum.OPARETIONERROR);
|
||||||
}
|
}
|
||||||
user.setAmount(user.getAmount().subtract(flow.getAmount()));
|
user.setAmount(user.getAmount().subtract(amount));
|
||||||
user.setUpdatedAt(System.currentTimeMillis());
|
user.setUpdatedAt(System.currentTimeMillis());
|
||||||
tbShopUserMapper.updateByPrimaryKey(user);
|
tbShopUserMapper.updateByPrimaryKey(user);
|
||||||
|
|
||||||
@@ -806,11 +802,10 @@ public class MemberService {
|
|||||||
tbShopUserFlowMapper.updateByPrimaryKey(flow);
|
tbShopUserFlowMapper.updateByPrimaryKey(flow);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JSONObject baObj = new JSONObject();
|
JSONObject baObj = new JSONObject();
|
||||||
baObj.put("userId", user.getUserId());
|
baObj.put("userId", user.getUserId());
|
||||||
baObj.put("shopId", user.getId());
|
baObj.put("shopId", user.getId());
|
||||||
baObj.put("amount",flow.getAmount());
|
baObj.put("amount", amount);
|
||||||
baObj.put("balance", user.getAmount());
|
baObj.put("balance", user.getAmount());
|
||||||
baObj.put("type", "退款");
|
baObj.put("type", "退款");
|
||||||
baObj.put("time", new Date());
|
baObj.put("time", new Date());
|
||||||
@@ -821,17 +816,4 @@ public class MemberService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user