From 729027dccfb797b26816fe8d57c77fe18620594f Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Sat, 08 Oct 2022 16:53:27 +0800
Subject: [PATCH] 20220902
---
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java | 161 +++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 136 insertions(+), 25 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
index 44f17a8..4f7d45f 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -14,6 +14,7 @@
import cc.mrbird.febs.mall.entity.*;
import cc.mrbird.febs.mall.mapper.*;
import cc.mrbird.febs.mall.service.*;
+import cc.mrbird.febs.mall.vo.ApiShopApplyVo;
import cc.mrbird.febs.mall.vo.OrderDetailVo;
import cc.mrbird.febs.mall.vo.OrderListVo;
import cc.mrbird.febs.mall.vo.OrderRefundVo;
@@ -26,6 +27,7 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONObject;
@@ -72,6 +74,10 @@
private final IMallAchieveService mallAchieveService;
private final UnipayService unipayService;
+ private final MallMemberBankSignMapper mallMemberBankSignMapper;
+ private final MallMemberBankMapper mallMemberBankMapper;
+ private final MallShopApplyMapper mallShopApplyMapper;
+
@Override
@Transactional(rollbackFor = Exception.class)
public Long createOrder(AddOrderDto addOrderDto) {
@@ -98,6 +104,22 @@
if (CollUtil.isEmpty(addOrderDto.getItems())) {
throw new FebsException("参数错误");
+ }
+
+ int deliverType = ObjectUtil.isEmpty(addOrderDto.getDeliverType()) ? 1 : addOrderDto.getDeliverType();
+ if(2 == deliverType){
+ if(ObjectUtil.isEmpty(addOrderDto.getShopId())){
+ throw new FebsException("请选择门店");
+ }
+ Long shopId = addOrderDto.getShopId();
+ MallShopApply mallShopApply = mallShopApplyMapper.selectById(shopId);
+ if(ObjectUtil.isEmpty(mallShopApply)){
+ throw new FebsException("请选择门店");
+ }
+ if(MallShopApply.APPLY_AGREE != mallShopApply.getStatus()){
+ throw new FebsException("请选择门店");
+ }
+ orderInfo.setShopId(shopId);
}
this.baseMapper.insert(orderInfo);
@@ -182,7 +204,13 @@
}
orderInfo.setAmount(total);
- orderInfo.setCarriage(carriage);
+ if(2 == deliverType){
+ orderInfo.setDeliverType(2);
+ orderInfo.setCarriage(BigDecimal.ZERO);
+ }else{
+ orderInfo.setDeliverType(1);
+ orderInfo.setCarriage(carriage);
+ }
this.baseMapper.updateById(orderInfo);
agentProducer.sendOrderCancelDelayMsg(orderInfo.getId(), 15 * 60 * 1000L);
@@ -208,12 +236,12 @@
this.baseMapper.updateById(orderInfo);
}
- public static void main(String[] args) {
- String unipayStr = "{\"r1_MerchantNo\":\"888118000001971\",\"rd_Pic\":\"\",\"r6_FrpCode\":\"ALIPAY_H5\",\"r7_TrxNo\":\"100222082332490699\",\"r0_Version\":\"1.0\",\"r3_Amount\":\"0.01\",\"r4_Cur\":\"1\",\"r2_OrderNo\":\"2022082212510288174\",\"rb_CodeMsg\":\"\",\"hmac\":\"1659BB77DEDDF9956EA4D6DF227C3B14\",\"ra_Code\":100,\"rc_Result\":\"<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><title></title></head><body><script type='text/javascript'>location.href='https://qr.alipay.com/bax019737vbdwoisxcdp00a2';</script></body></html>\"}";
- JSONObject jsonObject = JSONUtil.parseObj(unipayStr);
- String r7_trxNo = (String) jsonObject.get("r7_TrxNo");
- System.out.println(r7_trxNo);
- }
+// public static void main(String[] args) {
+// String unipayStr = "{\"r1_MerchantNo\":\"888118000001971\",\"rd_Pic\":\"\",\"r6_FrpCode\":\"ALIPAY_H5\",\"r7_TrxNo\":\"100222082332490699\",\"r0_Version\":\"1.0\",\"r3_Amount\":\"0.01\",\"r4_Cur\":\"1\",\"r2_OrderNo\":\"2022082212510288174\",\"rb_CodeMsg\":\"\",\"hmac\":\"1659BB77DEDDF9956EA4D6DF227C3B14\",\"ra_Code\":100,\"rc_Result\":\"<html><head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8'><title></title></head><body><script type='text/javascript'>location.href='https://qr.alipay.com/bax019737vbdwoisxcdp00a2';</script></body></html>\"}";
+// JSONObject jsonObject = JSONUtil.parseObj(unipayStr);
+// String r7_trxNo = (String) jsonObject.get("r7_TrxNo");
+// System.out.println(r7_trxNo);
+// }
@Override
@Transactional(rollbackFor = Exception.class)
@@ -232,10 +260,31 @@
String rcResult = "";
switch (payOrderDto.getType()) {
case "1":
+ UnipayDto unipayDtoWx = new UnipayDto();
+// unipayDto.setAmount(new BigDecimal("0.01"));
+ unipayDtoWx.setAmount(orderInfo.getAmount());
+ unipayDtoWx.setFrpCode("WEIXIN_APP3");
+ unipayDtoWx.setTradeMerchantNo("777180800385820");
+ unipayDtoWx.setOrderNo(orderInfo.getOrderNo());
+ List<MallOrderItem> itemsWx = orderInfo.getItems();
+ if(CollUtil.isEmpty(itemsWx)){
+ unipayDtoWx.setProductName("商品");
+ }else{
+ unipayDtoWx.setProductName(itemsWx.get(0).getGoodsName());
+ }
+ String unipayStrWx = unipayService.unipay(unipayDtoWx);
+ if("fail" == unipayStrWx){
+ throw new FebsException("支付失败");
+ }else{
+// JSONUtil.parseObj(unipayStr);
+ JSONObject jsonObject = JSONUtil.parseObj(unipayStrWx);
+ payResultStr = (String) jsonObject.get("r7_TrxNo");
+ rcResult = (String) jsonObject.get("rc_Result");
+ }
+ orderInfo.setPayOrderNo(payResultStr);
// orderInfo.setPayOrderNo(payOrderDto.getPayOrderNo());
// orderInfo.setPayImage(payOrderDto.getPayImage());
orderInfo.setPayMethod("微信支付");
- agentProducer.sendOrderReturn(orderInfo.getId());
break;
case "2":
// if (StrUtil.isNotBlank(orderInfo.getPayOrderNo())) {
@@ -247,7 +296,7 @@
// unipayDto.setAmount(new BigDecimal("0.01"));
unipayDto.setAmount(orderInfo.getAmount());
unipayDto.setFrpCode("ALIPAY_H5");
- unipayDto.setTradeMerchantNo("777180800385820");
+ unipayDto.setTradeMerchantNo("777184100385821");
unipayDto.setOrderNo(orderInfo.getOrderNo());
List<MallOrderItem> items = orderInfo.getItems();
if(CollUtil.isEmpty(items)){
@@ -333,19 +382,27 @@
mallMoneyFlowService.addMoneyFlow(member.getId(), orderInfo.getAmount().negate(), MoneyFlowTypeEnum.PAY.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.PRIZE_SCORE.getValue());
break;
case "5":
- AgreementSignDto agreementSignDto = new AgreementSignDto();
- agreementSignDto.setOrderNo(orderInfo.getOrderNo());
- agreementSignDto.setSmsCode(payOrderDto.getSmsCode());
- String agreementSignStr = unipayService.agreementSign(agreementSignDto);
- if("fail" == agreementSignStr){
- throw new FebsException("支付失败");
- }else{
- JSONObject jsonObject = JSONUtil.parseObj(agreementSignStr);
- payResultStr = (String) jsonObject.get("biz_code");
- if("JS000000" != payResultStr){
- throw new FebsException("支付失败");
- }
- }
+// AgreementSignDto agreementSignDto = new AgreementSignDto();
+// agreementSignDto.setOrderNo(orderInfo.getOrderNo());
+// agreementSignDto.setSmsCode(payOrderDto.getSmsCode());
+// String agreementSignStr = unipayService.agreementSign(agreementSignDto);
+// if("fail".equals(agreementSignStr)){
+// throw new FebsException("支付失败");
+// }else{
+// JSONObject jsonObject = JSONUtil.parseObj(agreementSignStr);
+// payResultStr = (String) jsonObject.get("biz_code");
+// String signData = (String) jsonObject.get("data");
+// String signBizMsg = (String) jsonObject.get("biz_msg");
+//
+// JSONObject signDatajsonObject = JSONUtil.parseObj(signData);
+// String err_msg = (String) signDatajsonObject.get("err_msg");
+// if(!"JS000000".equals(payResultStr)){
+// throw new FebsException(signBizMsg);
+// }
+// if(ObjectUtil.isNotNull(signDatajsonObject.get("err_code"))){
+// throw new FebsException(err_msg);
+// }
+// }
AgreementPayDto agreementPayDto = new AgreementPayDto();
agreementPayDto.setOrderNo(orderInfo.getOrderNo());
@@ -361,16 +418,27 @@
}else{
agreementPayDto.setOrderDesc(itemsGoods.get(0).getGoodsName());
}
- agreementPayDto.setBankNo(payOrderDto.getBankNo());
+ Long bankId = payOrderDto.getBankId() == null ? 0L : payOrderDto.getBankId();
+ MallMemberBank mallMemberBank = mallMemberBankMapper.selectById(bankId);
+ if(ObjectUtil.isEmpty(mallMemberBank)){
+ throw new FebsException("银行卡未添加");
+ }
+ String bankNo = mallMemberBank.getBankNo();
+ MallMemberBankSign mallMemberBankSign = mallMemberBankSignMapper.selectOneByMemberIdAndBankCardNo(member.getId(), bankNo);
+ if(ObjectUtil.isEmpty(mallMemberBankSign)){
+ throw new FebsException("银行卡未签约");
+ }
+ agreementPayDto.setBankNo(bankNo);
String agreementPayStr = unipayService.agreementPay(agreementPayDto);
- if("fail".equals(agreementSignStr)){
+ if("fail".equals(agreementPayStr)){
throw new FebsException("支付失败");
}else{
JSONObject jsonObject = JSONUtil.parseObj(agreementPayStr);
payResultStr = (String) jsonObject.get("biz_code");
+ String payBizMsg = (String) jsonObject.get("biz_msg");
if(!"JS000000".equals(payResultStr)){
- throw new FebsException("支付失败");
+ throw new FebsException(payBizMsg);
}
}
orderInfo.setPayMethod("快捷协议支付");
@@ -387,6 +455,21 @@
map.put("rcResult", rcResult);
return map;
+ }
+
+ public static void main(String[] args) {
+ String str = "{\"biz_code\":\"JS000000\",\"biz_msg\":\"成功\",\"data\":\"{\\\"order_status\\\":\\\"P2000\\\",\\\"jp_order_no\\\":\\\"100120220826446740396081496064\\\",\\\"err_msg\\\":\\\"短信验证码不符\\\",\\\"err_code\\\":\\\"CP110026\\\",\\\"sign_no\\\":\\\"\\\",\\\"mch_order_no\\\":\\\"NO_2022082618263952399\\\"}\",\"mch_no\":\"888118000001971\",\"rand_str\":\"an2w7ulf5ru6upkk5bdg441kdi3gnpvu\",\"resp_code\":\"SUCCESS\",\"sec_key\":\"\",\"sign\":\"NiJXRTSIZ9xZMUOwEHiEHdZXmgL2cHUU5WUa1NbMRRzui0DIiuZSW4e31LjnBxwVwmy3uuPMP+tqhY8VLyC8uCFOdGdZI7e72VuRvyvaiW7/sqCrsfgPOBEjiGE/CmSMRoEXv9HmqCyNBF6iHSEhQJql5Yge30dQdyB6xFfqjk0=\",\"sign_type\":\"2\"}";
+
+ JSONObject jsonObject = JSONUtil.parseObj(str);
+ String payResultStr = (String) jsonObject.get("biz_code");
+ String signBizMsg = (String) jsonObject.get("biz_msg");
+ String signData = (String) jsonObject.get("data");
+
+ JSONObject signDatajsonObject = JSONUtil.parseObj(signData);
+ String err_msg = (String) signDatajsonObject.get("err_msg");
+ if(ObjectUtil.isNotNull(signDatajsonObject.get("err_code"))){
+ System.out.println(err_msg);
+ }
}
private String balancePay(MallOrderInfo orderInfo, String tradePwd, String field) {
@@ -447,6 +530,21 @@
long remainTime = DateUtil.between(new Date(), endTime, DateUnit.SECOND, false);
orderDetailVo.setRemainTime(remainTime);
+ }
+ Integer deliverType = orderInfo.getDeliverType();
+ if(2 == deliverType){
+ MallShopApply mallShopApply = mallShopApplyMapper.selectById(orderInfo.getShopId());
+ if(ObjectUtil.isNotEmpty(mallShopApply)){
+ ApiShopApplyVo apiShopApplyVo = new ApiShopApplyVo();
+ apiShopApplyVo.setName(mallShopApply.getName());
+ apiShopApplyVo.setPhone(mallShopApply.getPhone());
+ apiShopApplyVo.setSaleArea(mallShopApply.getSaleArea());
+ apiShopApplyVo.setLatitude(mallShopApply.getLatitude());
+ apiShopApplyVo.setLongitude(mallShopApply.getLongitude());
+ apiShopApplyVo.setShopName(mallShopApply.getShopName());
+ apiShopApplyVo.setAddress(mallShopApply.getAddress());
+ orderDetailVo.setApiShopApplyVo(apiShopApplyVo);
+ }
}
return orderDetailVo;
}
@@ -620,4 +718,17 @@
}
}
+ @Override
+ public FebsResponse bangCardSign(BangCardSignDto bangCardSignDto) {
+ MallMember member = LoginUserUtil.getLoginUser();
+ Long memberId = member.getId();
+ String bankCard = bangCardSignDto.getBankCard();
+ MallMemberBankSign mallMemberBankSign = mallMemberBankSignMapper.selectOneByMemberIdAndBankCardNo(memberId,bankCard);
+ if(ObjectUtil.isNotEmpty(mallMemberBankSign)){
+ return new FebsResponse().success().data(mallMemberBankSign);
+ }else{
+ return new FebsResponse().success();
+ }
+ }
+
}
--
Gitblit v1.9.1