Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
2024-09-13 15:32:21 +08:00
8 changed files with 252 additions and 150 deletions

View File

@@ -1,8 +1,10 @@
package com.chaozhanggui.system.cashierservice.controller;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipaySystemOauthTokenRequest;
import com.alipay.api.request.AlipayUserInfoShareRequest;
@@ -17,6 +19,7 @@ import com.chaozhanggui.system.cashierservice.service.PayService;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.IpUtil;
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
import com.chaozhanggui.system.cashierservice.util.RedisCst;
import com.chaozhanggui.system.cashierservice.util.WechatUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -28,6 +31,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
@@ -304,6 +308,10 @@ public class PayController {
}
@RequestMapping("createOrder")
public Result createOrder(HttpServletRequest request,@RequestBody PaymentReq paymentReq){
try {
@@ -315,8 +323,10 @@ public class PayController {
}
@GetMapping("queryOrderPay")
public Result queryOrderPay(String orderId){
return payService.queryOrderPay(orderId);
}
@@ -365,15 +375,32 @@ public class PayController {
return Result.success(CodeEnum.SUCCESS,openid);
}else if("ALIPAY".equals(payType)){
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",aliAppId,privateKey,"json","GBK",publicKey,"RSA2");
AlipayUserInfoShareRequest request = new AlipayUserInfoShareRequest();
AlipayUserInfoShareResponse response = alipayClient.execute(request,code);
log.info("AlipayUserInfoShareResponse:{}",JSONObject.toJSONString(response));
if(!response.isSuccess()){
// 初始化SDK
AlipayClient alipayClient = new DefaultAlipayClient(getAlipayConfig());
// 构造请求参数以调用接口
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
// 设置刷新令牌
// request.setRefreshToken("201208134b203fe6c11548bcabd8da5bb087a83b");
// 设置授权码
request.setCode(code);
// 设置授权方式
request.setGrantType("authorization_code");
AlipaySystemOauthTokenResponse response = alipayClient.execute(request);
log.info("AlipaySystemOauthTokenResponse:{}", JSONUtil.toJSONString(response));
response.setAccessToken(response.getRefreshToken());
if (!response.isSuccess()) {
return Result.fail("获取支付宝userId失败");
}
return Result.success(CodeEnum.SUCCESS,response.getUserId());
return Result.success(CodeEnum.SUCCESS, ObjectUtil.isNull(response.getUserId())?response.getOpenId():response.getUserId());
}
return Result.fail(CodeEnum.FAIL);
@@ -381,6 +408,28 @@ public class PayController {
private AlipayConfig getAlipayConfig() {
AlipayConfig alipayConfig = new AlipayConfig();
alipayConfig.setServerUrl("https://openapi.alipay.com/gateway.do");
alipayConfig.setAppId(aliAppId);
alipayConfig.setPrivateKey(privateKey);
alipayConfig.setFormat("json");
alipayConfig.setAlipayPublicKey(publicKey);
alipayConfig.setCharset("UTF-8");
alipayConfig.setSignType("RSA2");
return alipayConfig;
}
public static void main(String[] args){
LocalDate date=LocalDate.now();
if(date.isLeapYear()){
System.out.println();
}
}

View File

@@ -17,6 +17,11 @@ public class ShopInfoController {
@Autowired
ShopInfoService shopInfoService;
@GetMapping("/queryShopInfo")
public Result queryShopInfo(@RequestParam Integer shopId){
return shopInfoService.queryShopInfo(shopId);
}
@GetMapping("queryShopArea")
public Result queryShopArea(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName,

View File

@@ -105,9 +105,16 @@ public class TbShopInfo implements Serializable {
private String isMemberReturn;
//是否开启桌位费 0否1是
private Integer isTableFee;
//桌位费
private BigDecimal tableFee;
//就餐模式 堂食 dine-in 外带 take-out
private String eatModel;
//程序码(零点八零首页)
private String smallQrcode;
//店铺收款码
private String paymentQrcode;
private static final long serialVersionUID = 1L;
@@ -495,4 +502,44 @@ public class TbShopInfo implements Serializable {
public void setIsMemberReturn(String isMemberReturn) {
this.isMemberReturn = isMemberReturn;
}
public Integer getIsTableFee() {
return isTableFee;
}
public void setIsTableFee(Integer isTableFee) {
this.isTableFee = isTableFee;
}
public BigDecimal getTableFee() {
return tableFee;
}
public void setTableFee(BigDecimal tableFee) {
this.tableFee = tableFee;
}
public String getEatModel() {
return eatModel;
}
public void setEatModel(String eatModel) {
this.eatModel = eatModel;
}
public String getSmallQrcode() {
return smallQrcode;
}
public void setSmallQrcode(String smallQrcode) {
this.smallQrcode = smallQrcode;
}
public String getPaymentQrcode() {
return paymentQrcode;
}
public void setPaymentQrcode(String paymentQrcode) {
this.paymentQrcode = paymentQrcode;
}
}

View File

@@ -31,6 +31,7 @@ public class WebAppConfigurer implements WebMvcConfigurer {
.excludePathPatterns("/pay/pcscanpay")
.excludePathPatterns("/pay/openId")
.excludePathPatterns("/pay/createOrder")
.excludePathPatterns("/pay/queryOrderPay")
;

View File

@@ -40,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;
@@ -50,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
@@ -95,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}")
@@ -121,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
@@ -136,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));
@@ -305,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);
@@ -387,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();
@@ -509,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);
@@ -595,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);
}
@@ -647,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);
@@ -671,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(),
@@ -738,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);
}
@@ -778,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);
}
@@ -804,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);
@@ -823,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);
@@ -859,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()));
@@ -890,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);
@@ -980,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);
@@ -1074,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();
@@ -1216,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);
@@ -1266,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)) {
@@ -1318,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());
}
@@ -1365,13 +1338,9 @@ public class PayService {
producer.putOrderCollect(jsonObject.toJSONString());
producer.printMechine(newOrderInfo.getId().toString());
//修改耗材数据
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("orderId", newOrderInfo.getId());
@@ -1692,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);
@@ -1719,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())) {
@@ -1729,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)));
}
@@ -1739,9 +1707,8 @@ 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)) {
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);
}
@@ -1757,7 +1724,6 @@ public class PayService {
}
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null);
if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) {
return Result.fail(CodeEnum.CARTEXIST);
@@ -1778,7 +1744,6 @@ public class PayService {
}
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId);
if (ObjectUtil.isEmpty(payment) || payment == null) {
payment = new TbOrderPayment();
@@ -1814,10 +1779,10 @@ public class PayService {
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);
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 (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
JspayResp scanpayResp = publicResp.getObjData();
if ("TRADE_SUCCESS".equals(scanpayResp.getState())) {
@@ -1835,10 +1800,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();
@@ -1854,7 +1819,7 @@ public class PayService {
ObjectMapper mapper = new ObjectMapper();
return Result.success(CodeEnum.SUCCESS, mapper.readTree(scanpayResp.getPayInfo()));
}else if("TRADE_AWAIT".equals(scanpayResp.getState())){
} else if ("TRADE_AWAIT".equals(scanpayResp.getState())) {
orderInfo.setStatus("paying");
orderInfo.setPayOrderNo(payment.getTradeNumber());
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
@@ -1864,11 +1829,11 @@ public class PayService {
tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
if("WECHAT".equals(scanpayResp.getPayType())){
if ("WECHAT".equals(scanpayResp.getPayType())) {
orderInfo.setPayType("WECHAT");
}else if("ALIPAY".equals(scanpayResp.getPayType())){
} else if ("ALIPAY".equals(scanpayResp.getPayType())) {
orderInfo.setPayType("ALIPAY");
}else if("UNIONPAY".equals(scanpayResp.getPayType())){
} else if ("UNIONPAY".equals(scanpayResp.getPayType())) {
orderInfo.setPayType("UNIONPAY");
}
@@ -1877,7 +1842,7 @@ public class PayService {
ObjectMapper mapper = new ObjectMapper();
return Result.success(CodeEnum.PAYING,mapper.readTree(scanpayResp.getPayInfo()));
return Result.success(CodeEnum.PAYING, mapper.readTree(scanpayResp.getPayInfo()));
}
}
}
@@ -1886,7 +1851,6 @@ public class PayService {
}
public String generateOrderNumber() {
String date = DateUtils.getSdfTimes();
Random random = new Random();
@@ -1894,28 +1858,23 @@ public class PayService {
return "QR" + date + randomNum;
}
public Result createOrder(String ip, String userId, String payType, String shopId, BigDecimal amount) throws JsonProcessingException {
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)
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)
){
|| ObjectUtil.isNull(shopId) || ObjectUtil.isEmpty(shopId) || ObjectUtil.isNull(shopId) || ObjectUtil.isNull(amount) || ObjectUtil.isEmpty(amount)
) {
return Result.fail(CodeEnum.PARAM);
}
if(!"WECHAT".equals(payType)||!"ALIPAY".equals(payType)){
return Result.fail(CodeEnum.PARAM);
}
TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
if(ObjectUtil.isNull(shopInfo)){
if (ObjectUtil.isNull(shopInfo)) {
return Result.fail(CodeEnum.SHOPINFONOEXIST);
}
TbOrderInfo orderInfo=new TbOrderInfo();
TbOrderInfo orderInfo = new TbOrderInfo();
String orderNo = generateOrderNumber();
orderInfo.setOrderNo(orderNo);
@@ -1963,8 +1922,6 @@ public class PayService {
}
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
return Result.fail(CodeEnum.NOCUSTOMER);
@@ -1973,7 +1930,7 @@ public class PayService {
String reqbody = "店铺收款码";
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);
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)) {
@@ -2014,22 +1971,55 @@ public class PayService {
ObjectMapper mapper = new ObjectMapper();
return Result.success(CodeEnum.PAYING, mapper.readTree(scanpayResp.getPayInfo()));
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")));
}
}

View File

@@ -53,6 +53,10 @@ public class ShopInfoService {
this.orderInfoMapper = orderInfoMapper;
}
public Result queryShopInfo(Integer shopId) {
return new Result(CodeEnum.SUCCESS,tbShopInfoMapper.selectByPrimaryKey(shopId));
}
public Result queryShopArea(String shopId){
List<TbShopArea> list= tbShopAreaMapper.selectByShopId(shopId);
return Result.success(CodeEnum.SUCCESS,list);

View File

@@ -61,8 +61,8 @@ wx:
secrete: a34a61adc0602118b49400baa8812454
warnMsgTmpId: AV-KybUHaK3KtFVLqpy6PHccHBS7XeX__mOM4RbufnQ
ali:
appId: 2021003175619219
privateKey: MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCInywsrhhiSNj7jjOB4/zL79pAaLzoYOuOqHeQELxgXrVFmpqJ7y76wniu4nrHKfp4jQVIHw4+IkBsTNwABTPiryVzAQ4ydb/opzn4zblWRB4S7mAgnc2wqO4FMcwSOiHh7uPFAqvB8oZmEizlbXIJSiDFd3rqG2l8ZADjwuwM0nue1fUJLu65d2B6NDFgBIa11enkrNyX9uPiaeIFW62lvTN1W2AUqTJLvfko5ejExGUDkie6g5W5MIvUSKfq7sDkpt5IoQCooBzjJJ/Ckfw/rJlqoPDFzUSiANBABwu0jAJ42MGYdJ8+dyDDUNla20xmMjXbRtUe5roVzJrrgMjFAgMBAAECggEAPKPx9o77sbxF2zod8JxiW57Fj+stVjOWuoZaM27KPjgr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,11 @@
<result column="is_member_in" jdbcType="VARCHAR" property="isMemberIn" />
<result column="is_member_return" jdbcType="VARCHAR" property="isMemberReturn" />
<result column="is_table_fee" jdbcType="TINYINT" property="isTableFee" />
<result column="table_fee" jdbcType="DECIMAL" property="tableFee" />
<result column="eat_model" jdbcType="VARCHAR" property="eatModel" />
<result column="small_qrcode" jdbcType="VARCHAR" property="smallQrcode" />
<result column="payment_qrcode" jdbcType="VARCHAR" property="paymentQrcode" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.chaozhanggui.system.cashierservice.entity.TbShopInfo">
<result column="view" jdbcType="LONGVARCHAR" property="view" />
@@ -61,7 +66,8 @@
detail, lat, lng, mch_id, register_type, is_wx_ma_independent, address, city, type,
industry, industry_name, business_time, post_time, post_amount_line, on_sale, settle_type,
settle_time, enter_at, expire_at, status, average, order_wait_pay_minute, support_device_number,
distribute_level, created_at, updated_at, proxy_id,is_custom,is_return,is_member_in,is_member_return
distribute_level, created_at, updated_at, proxy_id,is_custom,is_return,is_member_in,is_member_return,
is_table_fee,table_fee,eat_model,small_qrcode,payment_qrcode
</sql>
<sql id="Blob_Column_List">
view