添加会员支付
This commit is contained in:
@@ -50,6 +50,28 @@ public class PayController {
|
|||||||
return Result.fail("支付失败");
|
return Result.fail("支付失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 储值卡支付
|
||||||
|
* @param token
|
||||||
|
* @param loginName
|
||||||
|
* @param clientType
|
||||||
|
* @param orderId
|
||||||
|
* @param memberId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("accountPay")
|
||||||
|
public Result accountPay(@RequestHeader("token") String token,
|
||||||
|
@RequestHeader("loginName") String loginName,
|
||||||
|
@RequestHeader("clientType") String clientType,
|
||||||
|
@RequestParam("orderId") String orderId,
|
||||||
|
@RequestParam("memberId") String memberId
|
||||||
|
){
|
||||||
|
return payService.accountPay(orderId,memberId,token);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("groupOrderPay")
|
@RequestMapping("groupOrderPay")
|
||||||
public Result groupOrderPay(HttpServletRequest request, @RequestHeader String environment,@RequestHeader String token, @RequestBody Map<String, String> map) {
|
public Result groupOrderPay(HttpServletRequest request, @RequestHeader String environment,@RequestHeader String token, @RequestBody Map<String, String> map) {
|
||||||
if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("orderId") || ObjectUtil.isEmpty(map.get("orderId"))) {
|
if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("orderId") || ObjectUtil.isEmpty(map.get("orderId"))) {
|
||||||
|
|||||||
@@ -277,6 +277,91 @@ public class PayService {
|
|||||||
return Result.fail("失败");
|
return Result.fail("失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Result accountPay(String orderId, String memberId, String token) {
|
||||||
|
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(memberId)) {
|
||||||
|
return Result.fail("参数错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||||
|
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||||
|
return Result.fail("订单信息不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||||
|
return Result.fail("订单出状态异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "deposit");
|
||||||
|
if (count < 1) {
|
||||||
|
return Result.fail("店铺未开通此支付方式");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbShopUser user = tbShopUserMapper.selectByPrimaryKey(memberId);
|
||||||
|
if (ObjectUtil.isEmpty(user) || !"1".equals(user.getIsVip().toString())) {
|
||||||
|
return Result.fail("用户非会员");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (N.gt(orderInfo.getPayAmount(), user.getAmount())) {
|
||||||
|
return Result.fail("会员卡余额不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
user.setAmount(user.getAmount().subtract(orderInfo.getOrderAmount()));
|
||||||
|
user.setConsumeAmount(user.getConsumeAmount().add(orderInfo.getPayAmount()));
|
||||||
|
user.setConsumeNumber(user.getConsumeNumber() + 1);
|
||||||
|
user.setUpdatedAt(System.currentTimeMillis());
|
||||||
|
tbShopUserMapper.updateByPrimaryKeySelective(user);
|
||||||
|
|
||||||
|
|
||||||
|
TbShopUserFlow flow = new TbShopUserFlow();
|
||||||
|
flow.setShopUserId(Integer.valueOf(user.getId()));
|
||||||
|
flow.setBizCode("accountPay");
|
||||||
|
flow.setBizName("会员储值卡支付");
|
||||||
|
flow.setAmount(orderInfo.getOrderAmount());
|
||||||
|
flow.setBalance(user.getAmount());
|
||||||
|
flow.setCreateTime(new Date());
|
||||||
|
tbShopUserFlowMapper.insert(flow);
|
||||||
|
|
||||||
|
|
||||||
|
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||||
|
orderInfo.setMemberId(memberId);
|
||||||
|
orderInfo.setPayType("deposit");
|
||||||
|
orderInfo.setStatus("closed");
|
||||||
|
orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo()));
|
||||||
|
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||||
|
//更新购物车状态
|
||||||
|
int cartCount = tbCashierCartMapper.updateStatusByOrderId(orderId, "final");
|
||||||
|
|
||||||
|
|
||||||
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed");
|
||||||
|
|
||||||
|
tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
|
||||||
|
|
||||||
|
log.info("更新购物车:{}", cartCount);
|
||||||
|
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("token", token);
|
||||||
|
jsonObject.put("type", "create");
|
||||||
|
jsonObject.put("orderId", orderId);
|
||||||
|
|
||||||
|
producer.putOrderCollect(jsonObject.toJSONString());
|
||||||
|
|
||||||
|
producer.printMechine(orderId);
|
||||||
|
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result groupOrderPay(String orderId, String payType, String userId, String ip) throws JsonProcessingException {
|
public Result groupOrderPay(String orderId, String payType, String userId, String ip) throws JsonProcessingException {
|
||||||
TbGroupOrderInfo orderInfo = tbGroupOrderInfoMapper.queryById(Integer.valueOf(orderId));
|
TbGroupOrderInfo orderInfo = tbGroupOrderInfoMapper.queryById(Integer.valueOf(orderId));
|
||||||
|
|||||||
Reference in New Issue
Block a user