|
|
|
|
@@ -24,6 +24,8 @@ import com.chaozhanggui.system.cashierservice.sign.Result;
|
|
|
|
|
import com.chaozhanggui.system.cashierservice.thirdpay.resp.*;
|
|
|
|
|
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
|
|
|
|
|
import com.chaozhanggui.system.cashierservice.util.*;
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
@@ -38,7 +40,6 @@ import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
|
|
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST;
|
|
|
|
|
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.SUCCESS;
|
|
|
|
|
@@ -48,43 +49,27 @@ import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.SUCCESS;
|
|
|
|
|
public class PayService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
@Autowired
|
|
|
|
|
TbOrderInfoMapper tbOrderInfoMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TbMerchantThirdApplyMapper tbMerchantThirdApplyMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TbOrderPaymentMapper tbOrderPaymentMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TbShopPayTypeMapper tbShopPayTypeMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TbCashierCartMapper tbCashierCartMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TbShopUserMapper tbShopUserMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TbShopUserFlowMapper tbShopUserFlowMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TbOrderDetailMapper tbOrderDetailMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
RestTemplate restTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
RabbitProducer producer;
|
|
|
|
|
@Resource
|
|
|
|
|
private TbGroupOrderInfoMapper tbGroupOrderInfoMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private TbGroupOrderCouponMapper couponMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TbUserInfoMapper tbUserInfoMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
@@ -93,22 +78,24 @@ public class PayService {
|
|
|
|
|
TbShopInfoMapper tbShopInfoMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
TbQuickPayMapper tbQuickPayMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TbmerchantAccountMapper tbmerchantAccountMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
TbPlussShopStaffMapper tbPlussShopStaffMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private TbGroupOrderInfoMapper tbGroupOrderInfoMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private TbGroupOrderCouponMapper couponMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private TbProductSkuMapper productSkuMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TbProductMapper productMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TbShopUnitMapper shopUnitMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private TbProductStockDetailMapper productStockDetailMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RedisUtils redisUtil;
|
|
|
|
|
|
|
|
|
|
@Value("${gateway.url}")
|
|
|
|
|
private String gateWayUrl;
|
|
|
|
|
@Value("${client.backUrl}")
|
|
|
|
|
@@ -119,14 +106,6 @@ public class PayService {
|
|
|
|
|
private String url;
|
|
|
|
|
@Value("${thirdPay.callBack}")
|
|
|
|
|
private String callBack;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TbmerchantAccountMapper tbmerchantAccountMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TbPlussShopStaffMapper tbPlussShopStaffMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private MpShopUserMapper mpShopUserMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
@@ -134,12 +113,13 @@ public class PayService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private MpShopTableMapper mpShopTableMapper;
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
|
|
|
|
public PayService(RedisTemplate<String, Object> redisTemplate) {
|
|
|
|
|
this.redisTemplate = redisTemplate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
System.out.println(MD5Util.encrypt("123456".concat("13718478323").concat("10")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Result queryPayType(String shopId) {
|
|
|
|
|
return Result.success(CodeEnum.SUCCESS, tbShopPayTypeMapper.selectByShopId(shopId));
|
|
|
|
|
@@ -303,7 +283,7 @@ public class PayService {
|
|
|
|
|
log.info("更新购物车:{}", cartCount);
|
|
|
|
|
|
|
|
|
|
//更新子单状态
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", orderInfo.getDiscountRatio());
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
jsonObject.put("token", token);
|
|
|
|
|
@@ -385,10 +365,10 @@ public class PayService {
|
|
|
|
|
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
|
|
|
|
|
log.info("更新购物车:{}", cartCount);
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
|
|
|
|
|
}else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
|
|
|
|
|
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", orderInfo.getDiscountRatio());
|
|
|
|
|
} else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
@@ -507,10 +487,10 @@ public class PayService {
|
|
|
|
|
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
|
|
|
|
|
log.info("更新购物车:{}", cartCount);
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
|
|
|
|
|
}else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
|
|
|
|
|
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", orderInfo.getDiscountRatio());
|
|
|
|
|
} else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", null);
|
|
|
|
|
}
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
jsonObject.put("token", token);
|
|
|
|
|
@@ -593,7 +573,7 @@ public class PayService {
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(memberAccount)) {
|
|
|
|
|
|
|
|
|
|
if (!memberAccount.substring(0, 2).equals("46")) {
|
|
|
|
|
if (!memberAccount.startsWith("46")) {
|
|
|
|
|
return Result.fail(CodeEnum.ERRORQR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -645,10 +625,10 @@ public class PayService {
|
|
|
|
|
//更新购物车状态
|
|
|
|
|
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
|
|
|
|
|
}else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
|
|
|
|
|
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", orderInfo.getDiscountRatio());
|
|
|
|
|
} else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("更新购物车:{}", cartCount);
|
|
|
|
|
@@ -669,14 +649,13 @@ public class PayService {
|
|
|
|
|
producer.sendStockSaleMsg(mqData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject baObj=new JSONObject();
|
|
|
|
|
baObj.put("userId",user.getUserId());
|
|
|
|
|
baObj.put("shopId",user.getShopId());
|
|
|
|
|
baObj.put("amount",orderInfo.getPayAmount());
|
|
|
|
|
baObj.put("balance",user.getAmount());
|
|
|
|
|
baObj.put("type","消费");
|
|
|
|
|
baObj.put("time",flow.getCreateTime());
|
|
|
|
|
JSONObject baObj = new JSONObject();
|
|
|
|
|
baObj.put("userId", user.getUserId());
|
|
|
|
|
baObj.put("shopId", user.getShopId());
|
|
|
|
|
baObj.put("amount", orderInfo.getPayAmount());
|
|
|
|
|
baObj.put("balance", user.getAmount());
|
|
|
|
|
baObj.put("type", "消费");
|
|
|
|
|
baObj.put("time", flow.getCreateTime());
|
|
|
|
|
producer.balance(baObj.toString());
|
|
|
|
|
|
|
|
|
|
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
|
|
|
|
|
@@ -736,7 +715,7 @@ public class PayService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TbShopUser user = tbShopUserMapper.selectByShopId(orderInfo.getShopId(), tbUserInfo.getId().toString(),"2").get(0);
|
|
|
|
|
TbShopUser user = tbShopUserMapper.selectByShopId(orderInfo.getShopId(), tbUserInfo.getId().toString(), "2").get(0);
|
|
|
|
|
if (ObjectUtil.isEmpty(user) || !"1".equals(user.getIsVip().toString())) {
|
|
|
|
|
return Result.fail(CodeEnum.MEMBERNOEXIST);
|
|
|
|
|
}
|
|
|
|
|
@@ -776,11 +755,10 @@ public class PayService {
|
|
|
|
|
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
|
|
|
|
|
}else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
|
|
|
|
|
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", orderInfo.getDiscountRatio());
|
|
|
|
|
} else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -802,14 +780,13 @@ public class PayService {
|
|
|
|
|
producer.sendStockSaleMsg(mqData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject baObj=new JSONObject();
|
|
|
|
|
baObj.put("userId",user.getUserId());
|
|
|
|
|
baObj.put("shopId",user.getShopId());
|
|
|
|
|
baObj.put("amount",orderInfo.getPayAmount());
|
|
|
|
|
baObj.put("balance",user.getAmount());
|
|
|
|
|
baObj.put("type","消费");
|
|
|
|
|
baObj.put("time",flow.getCreateTime());
|
|
|
|
|
JSONObject baObj = new JSONObject();
|
|
|
|
|
baObj.put("userId", user.getUserId());
|
|
|
|
|
baObj.put("shopId", user.getShopId());
|
|
|
|
|
baObj.put("amount", orderInfo.getPayAmount());
|
|
|
|
|
baObj.put("balance", user.getAmount());
|
|
|
|
|
baObj.put("type", "消费");
|
|
|
|
|
baObj.put("time", flow.getCreateTime());
|
|
|
|
|
producer.balance(baObj.toString());
|
|
|
|
|
clearTableInfoCache(orderInfo);
|
|
|
|
|
|
|
|
|
|
@@ -821,7 +798,7 @@ public class PayService {
|
|
|
|
|
return Result.fail(CodeEnum.PARAM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
|
|
|
|
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(orderInfo)) {
|
|
|
|
|
return Result.fail(CodeEnum.ORDERNOEXIST);
|
|
|
|
|
@@ -857,8 +834,6 @@ public class PayService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TbShopUserFlow userFlow = new TbShopUserFlow();
|
|
|
|
|
userFlow.setAmount((payAmount != null && discountAmount != null) ? payAmount : orderInfo.getOrderAmount());
|
|
|
|
|
userFlow.setBalance(shopUser.getAmount().subtract((payAmount != null && discountAmount != null) ? payAmount : orderInfo.getOrderAmount()));
|
|
|
|
|
@@ -888,10 +863,10 @@ public class PayService {
|
|
|
|
|
int cartCount = tbCashierCartMapper.updateByOrderId(String.valueOf(orderId), "final");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
|
|
|
|
|
}else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
|
|
|
|
|
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(orderId, "closed", orderInfo.getDiscountRatio());
|
|
|
|
|
} else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(orderId, "closed", null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("更新购物车:{}", cartCount);
|
|
|
|
|
@@ -978,10 +953,10 @@ public class PayService {
|
|
|
|
|
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
|
|
|
|
|
}else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
|
|
|
|
|
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", orderInfo.getDiscountRatio());
|
|
|
|
|
} else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", null);
|
|
|
|
|
}
|
|
|
|
|
log.info("更新购物车:{}", cartCount);
|
|
|
|
|
|
|
|
|
|
@@ -1072,10 +1047,10 @@ public class PayService {
|
|
|
|
|
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
|
|
|
|
|
log.info("更新购物车:{}", cartCount);
|
|
|
|
|
|
|
|
|
|
if(ObjectUtil.isNotNull(orderInfo.getDiscountRatio())&&ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())){
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",orderInfo.getDiscountRatio());
|
|
|
|
|
}else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed",null);
|
|
|
|
|
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", orderInfo.getDiscountRatio());
|
|
|
|
|
} else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
@@ -1214,7 +1189,7 @@ public class PayService {
|
|
|
|
|
detailPo.setStatus("closed");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
BigDecimal returnAmount = it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId())));;
|
|
|
|
|
BigDecimal returnAmount = it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId())));
|
|
|
|
|
|
|
|
|
|
detailPo.setReturnNum(map1.get(it.getId()));
|
|
|
|
|
detailPos.add(detailPo);
|
|
|
|
|
@@ -1264,7 +1239,7 @@ public class PayService {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId + "");
|
|
|
|
|
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(String.valueOf(orderId));
|
|
|
|
|
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(), newOrderInfo.getOrderNo(), payment.getTradeNumber(), null, "订单退款", newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
|
|
|
|
@@ -1316,13 +1291,13 @@ public class PayService {
|
|
|
|
|
tbShopUserFlowMapper.insert(flow);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject baObj=new JSONObject();
|
|
|
|
|
baObj.put("userId",user.getUserId());
|
|
|
|
|
baObj.put("shopId",user.getShopId());
|
|
|
|
|
baObj.put("amount",newOrderInfo.getPayAmount());
|
|
|
|
|
baObj.put("balance",user.getAmount());
|
|
|
|
|
baObj.put("type","退款");
|
|
|
|
|
baObj.put("time",flow.getCreateTime());
|
|
|
|
|
JSONObject baObj = new JSONObject();
|
|
|
|
|
baObj.put("userId", user.getUserId());
|
|
|
|
|
baObj.put("shopId", user.getShopId());
|
|
|
|
|
baObj.put("amount", newOrderInfo.getPayAmount());
|
|
|
|
|
baObj.put("balance", user.getAmount());
|
|
|
|
|
baObj.put("type", "退款");
|
|
|
|
|
baObj.put("time", flow.getCreateTime());
|
|
|
|
|
producer.balance(baObj.toString());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1363,13 +1338,9 @@ public class PayService {
|
|
|
|
|
producer.putOrderCollect(jsonObject.toJSONString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
producer.printMechine(newOrderInfo.getId().toString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//修改耗材数据
|
|
|
|
|
JSONObject jsonObject1 = new JSONObject();
|
|
|
|
|
jsonObject1.put("orderId", newOrderInfo.getId());
|
|
|
|
|
@@ -1690,7 +1661,6 @@ public class PayService {
|
|
|
|
|
return Result.success(CodeEnum.SUCCESS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Result getOrderDiscount(String staffId, String orderId, String token) {
|
|
|
|
|
if (ObjectUtil.isNull(staffId) || ObjectUtil.isNull(orderId) || ObjectUtil.isEmpty(staffId) || ObjectUtil.isEmpty(orderId)) {
|
|
|
|
|
return Result.fail(CodeEnum.PARAM);
|
|
|
|
|
@@ -1717,7 +1687,7 @@ public class PayService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ("master".equals(staff.getType())) {
|
|
|
|
|
return Result.success(SUCCESS, new BigDecimal(0.1));
|
|
|
|
|
return Result.success(SUCCESS, new BigDecimal("0.1"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(staff.getMaxDiscountAmount()) || ObjectUtil.isNull(staff.getMaxDiscountAmount())) {
|
|
|
|
|
@@ -1727,7 +1697,7 @@ public class PayService {
|
|
|
|
|
|
|
|
|
|
if ("0".equals(staff.getDiscountType())) {
|
|
|
|
|
if (staff.getMaxDiscountAmount().compareTo(tbOrderInfo.getOrderAmount()) >= 0) {
|
|
|
|
|
staff.setMaxDiscountAmount(new BigDecimal(0.1));
|
|
|
|
|
staff.setMaxDiscountAmount(new BigDecimal("0.1"));
|
|
|
|
|
} else {
|
|
|
|
|
staff.setMaxDiscountAmount(BigDecimal.ONE.subtract(staff.getMaxDiscountAmount().divide(tbOrderInfo.getOrderAmount(), 2, RoundingMode.HALF_DOWN).setScale(2, RoundingMode.HALF_DOWN)));
|
|
|
|
|
}
|
|
|
|
|
@@ -1737,9 +1707,372 @@ public class PayService {
|
|
|
|
|
return Result.success(SUCCESS, staff.getMaxDiscountAmount());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Result pcscanpay(String orderId, String ip, String userId, String payType) throws JsonProcessingException {
|
|
|
|
|
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(ip)) {
|
|
|
|
|
return Result.fail(CodeEnum.PARAM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(orderInfo)) {
|
|
|
|
|
return Result.fail(CodeEnum.ORDERNOEXIST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!"unpaid".equals(orderInfo.getStatus()) && !"paying".equals(orderInfo.getStatus())) {
|
|
|
|
|
return Result.fail(CodeEnum.ORDERSTATUSERROR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null);
|
|
|
|
|
if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) {
|
|
|
|
|
return Result.fail(CodeEnum.CARTEXIST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StringBuffer body = new StringBuffer();
|
|
|
|
|
for (TbCashierCart cashierCart : cashierCarts) {
|
|
|
|
|
body.append(cashierCart.getName());
|
|
|
|
|
}
|
|
|
|
|
if (ObjectUtil.isNull(orderInfo.getMerchantId()) || ObjectUtil.isEmpty(orderInfo.getMerchantId())) {
|
|
|
|
|
return Result.fail(CodeEnum.NOCUSTOMER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
|
|
|
|
|
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
|
|
|
|
return Result.fail(CodeEnum.NOCUSTOMER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId);
|
|
|
|
|
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
|
|
|
|
payment = new TbOrderPayment();
|
|
|
|
|
payment.setPayTypeId("ysk");
|
|
|
|
|
payment.setAmount(orderInfo.getOrderAmount());
|
|
|
|
|
payment.setPaidAmount(orderInfo.getPayAmount());
|
|
|
|
|
payment.setHasRefundAmount(BigDecimal.ZERO);
|
|
|
|
|
payment.setReceived(payment.getAmount());
|
|
|
|
|
payment.setChangeFee(BigDecimal.ZERO);
|
|
|
|
|
payment.setMemberId(orderInfo.getMemberId());
|
|
|
|
|
payment.setShopId(orderInfo.getShopId());
|
|
|
|
|
payment.setOrderId(orderInfo.getId().toString());
|
|
|
|
|
payment.setCreatedAt(System.currentTimeMillis());
|
|
|
|
|
payment.setAuthCode("");
|
|
|
|
|
tbOrderPaymentMapper.insert(payment);
|
|
|
|
|
} else {
|
|
|
|
|
payment.setAuthCode("");
|
|
|
|
|
payment.setUpdatedAt(System.currentTimeMillis());
|
|
|
|
|
tbOrderPaymentMapper.updateByPrimaryKey(payment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
|
|
|
|
orderInfo.setUpdatedAt(System.currentTimeMillis());
|
|
|
|
|
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String reqbody = "";
|
|
|
|
|
|
|
|
|
|
if (body.length() > 15) {
|
|
|
|
|
reqbody = body.substring(0, 6).concat("....").concat(body.substring(body.length() - 6, body.length()));
|
|
|
|
|
} else {
|
|
|
|
|
reqbody = body.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PublicResp<JspayResp> publicResp = thirdPayService.jspay(url, thirdApply.getAppId(), thirdApply.getAppToken(), reqbody, reqbody, orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(), payType, "WECHAT".equals(payType) ? thirdApply.getSmallAppid() : null, userId, ip, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), backUrl, backUrl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
|
|
|
|
if ("000000".equals(publicResp.getCode())) {
|
|
|
|
|
JspayResp scanpayResp = publicResp.getObjData();
|
|
|
|
|
if ("TRADE_SUCCESS".equals(scanpayResp.getState())) {
|
|
|
|
|
|
|
|
|
|
payment.setTradeNumber(scanpayResp.getPayOrderId());
|
|
|
|
|
payment.setUpdatedAt(System.currentTimeMillis());
|
|
|
|
|
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
|
|
|
|
|
|
|
|
|
//处理支付成功的订单
|
|
|
|
|
orderInfo.setStatus("closed");
|
|
|
|
|
orderInfo.setPayOrderNo(scanpayResp.getPayOrderId());
|
|
|
|
|
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
|
|
|
|
|
|
|
|
|
//更新购物车状态
|
|
|
|
|
int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
|
|
|
|
|
log.info("更新购物车:{}", cartCount);
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", orderInfo.getDiscountRatio());
|
|
|
|
|
} else {
|
|
|
|
|
tbOrderDetailMapper.updateStatusByOrderId(Integer.valueOf(orderId), "closed", null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// JSONObject jsonObject = new JSONObject();
|
|
|
|
|
// jsonObject.put("token", token);
|
|
|
|
|
// jsonObject.put("type", "create");
|
|
|
|
|
// jsonObject.put("orderId", orderId);
|
|
|
|
|
//
|
|
|
|
|
// producer.putOrderCollect(jsonObject.toJSONString());
|
|
|
|
|
//
|
|
|
|
|
// producer.printMechine(orderId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
return Result.success(CodeEnum.SUCCESS, mapper.readTree(scanpayResp.getPayInfo()));
|
|
|
|
|
|
|
|
|
|
} else if ("TRADE_AWAIT".equals(scanpayResp.getState())) {
|
|
|
|
|
orderInfo.setStatus("paying");
|
|
|
|
|
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
|
|
|
|
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
|
|
|
|
|
|
|
|
|
payment.setTradeNumber(scanpayResp.getPayOrderId());
|
|
|
|
|
payment.setUpdatedAt(System.currentTimeMillis());
|
|
|
|
|
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("WECHAT".equals(scanpayResp.getPayType())) {
|
|
|
|
|
orderInfo.setPayType("WECHAT");
|
|
|
|
|
} else if ("ALIPAY".equals(scanpayResp.getPayType())) {
|
|
|
|
|
orderInfo.setPayType("ALIPAY");
|
|
|
|
|
} else if ("UNIONPAY".equals(scanpayResp.getPayType())) {
|
|
|
|
|
orderInfo.setPayType("UNIONPAY");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tbOrderInfoMapper.updateByPrimaryKey(orderInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
return Result.success(CodeEnum.PAYING, mapper.readTree(scanpayResp.getPayInfo()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Result.fail(CodeEnum.FAIL);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String generateOrderNumber() {
|
|
|
|
|
String date = DateUtils.getSdfTimes();
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
int randomNum = random.nextInt(900) + 100;
|
|
|
|
|
return "QR" + date + randomNum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Result createOrder(String ip, String userId, String payType, String shopId, BigDecimal amount) throws JsonProcessingException {
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNull(userId) || ObjectUtil.isEmpty(userId) || ObjectUtil.isEmpty(payType) || ObjectUtil.isNull(payType)
|
|
|
|
|
|
|
|
|
|
|| ObjectUtil.isNull(shopId) || ObjectUtil.isEmpty(shopId) || ObjectUtil.isNull(shopId) || ObjectUtil.isNull(amount) || ObjectUtil.isEmpty(amount)
|
|
|
|
|
) {
|
|
|
|
|
return Result.fail(CodeEnum.PARAM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNull(shopInfo)) {
|
|
|
|
|
return Result.fail(CodeEnum.SHOPINFONOEXIST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TbOrderInfo orderInfo = new TbOrderInfo();
|
|
|
|
|
|
|
|
|
|
String orderNo = generateOrderNumber();
|
|
|
|
|
orderInfo.setOrderNo(orderNo);
|
|
|
|
|
orderInfo.setSettlementAmount(amount);
|
|
|
|
|
orderInfo.setPackFee(BigDecimal.ZERO);
|
|
|
|
|
orderInfo.setOriginAmount(amount);
|
|
|
|
|
orderInfo.setPayAmount(amount);
|
|
|
|
|
orderInfo.setAmount(amount);
|
|
|
|
|
orderInfo.setRefundAmount(BigDecimal.ZERO);
|
|
|
|
|
orderInfo.setPayType(payType);
|
|
|
|
|
orderInfo.setPayAmount(amount);
|
|
|
|
|
orderInfo.setOrderAmount(amount);
|
|
|
|
|
orderInfo.setSendType("QR");
|
|
|
|
|
orderInfo.setStatus("WAIT_PAY");
|
|
|
|
|
orderInfo.setMerchantId(shopInfo.getMerchantId());
|
|
|
|
|
orderInfo.setShopId(shopId);
|
|
|
|
|
orderInfo.setRefundAble(Byte.valueOf("1"));
|
|
|
|
|
orderInfo.setSystemTime(System.currentTimeMillis());
|
|
|
|
|
orderInfo.setCreatedAt(System.currentTimeMillis());
|
|
|
|
|
orderInfo.setIsAccepted(Byte.valueOf("1"));
|
|
|
|
|
orderInfo.setTradeDay(DateUtils.getDay());
|
|
|
|
|
|
|
|
|
|
tbOrderInfoMapper.insert(orderInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderInfo.getId().toString());
|
|
|
|
|
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
|
|
|
|
payment = new TbOrderPayment();
|
|
|
|
|
payment.setPayTypeId("ysk");
|
|
|
|
|
payment.setAmount(orderInfo.getOrderAmount());
|
|
|
|
|
payment.setPaidAmount(orderInfo.getPayAmount());
|
|
|
|
|
payment.setHasRefundAmount(BigDecimal.ZERO);
|
|
|
|
|
payment.setReceived(payment.getAmount());
|
|
|
|
|
payment.setChangeFee(BigDecimal.ZERO);
|
|
|
|
|
payment.setMemberId(orderInfo.getMemberId());
|
|
|
|
|
payment.setShopId(orderInfo.getShopId());
|
|
|
|
|
payment.setOrderId(orderInfo.getId().toString());
|
|
|
|
|
payment.setCreatedAt(System.currentTimeMillis());
|
|
|
|
|
payment.setAuthCode("");
|
|
|
|
|
tbOrderPaymentMapper.insert(payment);
|
|
|
|
|
} else {
|
|
|
|
|
payment.setAuthCode("");
|
|
|
|
|
payment.setUpdatedAt(System.currentTimeMillis());
|
|
|
|
|
tbOrderPaymentMapper.updateByPrimaryKey(payment);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
|
|
|
|
|
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
|
|
|
|
return Result.fail(CodeEnum.NOCUSTOMER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String reqbody = "店铺收款码";
|
|
|
|
|
|
|
|
|
|
if("WECHAT".equals(payType)){
|
|
|
|
|
PublicResp<JspayResp> publicResp = thirdPayService.jspay(url, thirdApply.getAppId(), thirdApply.getAppToken(), reqbody, reqbody, orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(), payType, "WECHAT".equals(payType) ? thirdApply.getSmallAppid() : null, userId, ip, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), backUrl, backUrl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
|
|
|
|
if ("000000".equals(publicResp.getCode())) {
|
|
|
|
|
JspayResp scanpayResp = publicResp.getObjData();
|
|
|
|
|
if ("TRADE_SUCCESS".equals(scanpayResp.getState())) {
|
|
|
|
|
|
|
|
|
|
payment.setTradeNumber(scanpayResp.getPayOrderId());
|
|
|
|
|
payment.setUpdatedAt(System.currentTimeMillis());
|
|
|
|
|
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
|
|
|
|
|
|
|
|
|
//处理支付成功的订单
|
|
|
|
|
orderInfo.setStatus("closed");
|
|
|
|
|
orderInfo.setPayOrderNo(scanpayResp.getPayOrderId());
|
|
|
|
|
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
return Result.success(CodeEnum.SUCCESS, mapper.readTree(scanpayResp.getPayInfo()));
|
|
|
|
|
|
|
|
|
|
} else if ("TRADE_AWAIT".equals(scanpayResp.getState())) {
|
|
|
|
|
orderInfo.setStatus("paying");
|
|
|
|
|
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
|
|
|
|
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
|
|
|
|
|
|
|
|
|
payment.setTradeNumber(scanpayResp.getPayOrderId());
|
|
|
|
|
payment.setUpdatedAt(System.currentTimeMillis());
|
|
|
|
|
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("WECHAT".equals(scanpayResp.getPayType())) {
|
|
|
|
|
orderInfo.setPayType("WECHAT");
|
|
|
|
|
} else if ("ALIPAY".equals(scanpayResp.getPayType())) {
|
|
|
|
|
orderInfo.setPayType("ALIPAY");
|
|
|
|
|
} else if ("UNIONPAY".equals(scanpayResp.getPayType())) {
|
|
|
|
|
orderInfo.setPayType("UNIONPAY");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
|
Map<String,Object> map=new HashMap<>();
|
|
|
|
|
|
|
|
|
|
map.put("orderInfo",orderInfo);
|
|
|
|
|
map.put("payInfo",mapper.readTree(scanpayResp.getPayInfo()));
|
|
|
|
|
return Result.success(CodeEnum.PAYING, map);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else if("ALIPAY".equals(payType)){
|
|
|
|
|
PublicResp<ApppayResp> publicResp= thirdPayService.apppay(url,thirdApply.getAppId(),thirdApply.getAppToken(),reqbody,reqbody,orderInfo.getOrderAmount().multiply(new BigDecimal(100)).longValue(),payType,ip,DateUtils.getSsdfTimes(),thirdApply.getStoreId(),backUrl,backUrl);
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
|
|
|
|
if ("000000".equals(publicResp.getCode())) {
|
|
|
|
|
ApppayResp scanpayResp = publicResp.getObjData();
|
|
|
|
|
if ("TRADE_SUCCESS".equals(scanpayResp.getState())) {
|
|
|
|
|
|
|
|
|
|
payment.setTradeNumber(scanpayResp.getPayOrderId());
|
|
|
|
|
payment.setUpdatedAt(System.currentTimeMillis());
|
|
|
|
|
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
|
|
|
|
|
|
|
|
|
//处理支付成功的订单
|
|
|
|
|
orderInfo.setStatus("closed");
|
|
|
|
|
orderInfo.setPayOrderNo(scanpayResp.getPayOrderId());
|
|
|
|
|
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
return Result.success(CodeEnum.SUCCESS, mapper.readTree(scanpayResp.getPayInfo()));
|
|
|
|
|
|
|
|
|
|
} else if ("TRADE_AWAIT".equals(scanpayResp.getState())) {
|
|
|
|
|
orderInfo.setStatus("paying");
|
|
|
|
|
orderInfo.setPayOrderNo(payment.getTradeNumber());
|
|
|
|
|
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
|
|
|
|
|
|
|
|
|
payment.setTradeNumber(scanpayResp.getPayOrderId());
|
|
|
|
|
payment.setUpdatedAt(System.currentTimeMillis());
|
|
|
|
|
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("WECHAT".equals(scanpayResp.getPayType())) {
|
|
|
|
|
orderInfo.setPayType("WECHAT");
|
|
|
|
|
} else if ("ALIPAY".equals(scanpayResp.getPayType())) {
|
|
|
|
|
orderInfo.setPayType("ALIPAY");
|
|
|
|
|
} else if ("UNIONPAY".equals(scanpayResp.getPayType())) {
|
|
|
|
|
orderInfo.setPayType("UNIONPAY");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
|
Map<String,Object> map=new HashMap<>();
|
|
|
|
|
|
|
|
|
|
map.put("orderInfo",orderInfo);
|
|
|
|
|
map.put("payInfo",mapper.readTree(scanpayResp.getPayInfo()));
|
|
|
|
|
return Result.success(CodeEnum.PAYING, map);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result.fail(CodeEnum.FAIL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Result queryOrderPay(String orderId) {
|
|
|
|
|
if (ObjectUtil.isEmpty(orderId)) {
|
|
|
|
|
return Result.fail(CodeEnum.PARAM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(orderInfo)) {
|
|
|
|
|
return Result.fail(CodeEnum.ORDERNOEXIST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ("unpaid".equals(orderInfo.getStatus()) || "paying".equals(orderInfo.getStatus())) {
|
|
|
|
|
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
|
|
|
|
|
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
|
|
|
|
return Result.fail(CodeEnum.NOCUSTOMER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TbOrderPayment tbOrderPayment = tbOrderPaymentMapper.selectByOrderId(orderId);
|
|
|
|
|
if (ObjectUtil.isNotEmpty(tbOrderPayment)) {
|
|
|
|
|
|
|
|
|
|
PublicResp<OrderStatusQueryResp> orderstatus = thirdPayService.queryOrder(url, thirdApply.getAppId(), tbOrderPayment.getTradeNumber(), null, thirdApply.getAppToken());
|
|
|
|
|
if (ObjectUtil.isNotNull(orderstatus) && ObjectUtil.isNotEmpty(orderstatus)) {
|
|
|
|
|
if ("000000".equals(orderstatus.getCode())) {
|
|
|
|
|
if ("TRADE_SUCCESS".equals(orderstatus.getObjData().getState())) {
|
|
|
|
|
orderInfo.setStatus("closed");
|
|
|
|
|
orderInfo.setPayOrderNo(tbOrderPayment.getTradeNumber());
|
|
|
|
|
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Result.success(CodeEnum.SUCCESS, orderInfo);
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
System.out.println(MD5Util.encrypt("123456".concat("13718478323").concat("10")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|