|
@@ -5,32 +5,30 @@ import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.fs.app.annotation.Login;
|
|
|
-import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.annotation.RepeatSubmit;
|
|
|
|
|
|
import com.fs.common.config.FSSysConfig;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
-import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
-import com.fs.common.utils.IPUtils;
|
|
|
-import com.fs.common.utils.IpUtil;
|
|
|
-import com.fs.common.utils.ParseUtils;
|
|
|
-import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.common.utils.*;
|
|
|
import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
|
import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
|
+import com.fs.huifuPay.dto.*;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
|
-import com.fs.pay.pay.config.PayConfig;
|
|
|
+import com.fs.tzBank.TzBankService;
|
|
|
import com.fs.pay.pay.domain.CreateWxOrderResult;
|
|
|
-import com.fs.pay.pay.domain.OrderResult;
|
|
|
import com.fs.pay.pay.dto.OrderQueryDTO;
|
|
|
import com.fs.pay.pay.dto.WxJspayDTO;
|
|
|
import com.fs.pay.pay.service.PayService;
|
|
|
-import com.fs.pay.pay.service.impl.PayApiServiceImpl;
|
|
|
-import com.fs.pay.service.dto.PayQueryDTO;
|
|
|
+import com.fs.store.constants.StoreConstants;
|
|
|
import com.fs.store.domain.*;
|
|
|
+import com.fs.system.domain.SysConfig;
|
|
|
+import com.fs.system.mapper.SysConfigMapper;
|
|
|
+import com.fs.tzBank.utils.TzConfigUtils;
|
|
|
import com.fs.wx.miniapp.config.WxMaConfiguration;
|
|
|
import com.fs.wx.miniapp.config.WxMaProperties;
|
|
|
import com.fs.wx.pay.config.WxPayProperties;
|
|
@@ -45,24 +43,14 @@ import com.fs.store.service.*;
|
|
|
import com.fs.store.vo.FsMyStoreOrderListQueryVO;
|
|
|
import com.fs.store.vo.FsStoreOrderItemVO;
|
|
|
import com.fs.pay.service.IPayService;
|
|
|
-import com.fs.pay.service.dto.CreatePayDTO;
|
|
|
-import com.fs.pay.service.dto.PayDTO;
|
|
|
-import com.fs.pay.service.dto.TradeOrder;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
-import com.github.binarywang.wxpay.bean.entpay.EntPayResult;
|
|
|
-import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
|
|
-import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
|
-import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
|
-import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
-import com.github.binarywang.wxpay.service.EntPayService;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import com.google.gson.Gson;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
-import lombok.Synchronized;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
-import org.apache.catalina.servlets.DefaultServlet;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -119,6 +107,10 @@ public class StoreOrderController extends AppBaseController {
|
|
|
private IFsStoreProductPackageService productPackageService;
|
|
|
@Autowired
|
|
|
PayService ybPayService;
|
|
|
+ @Autowired
|
|
|
+ TzBankService tzBankService;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Login
|
|
|
@ApiOperation("获取我的订单列表")
|
|
@@ -294,8 +286,7 @@ public class StoreOrderController extends AppBaseController {
|
|
|
String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
// order.setOrderCode(orderCode);
|
|
|
|
|
|
-
|
|
|
- //汇付支付
|
|
|
+ // 台州银行支付
|
|
|
if(order.getPayType().equals("1")||order.getPayType().equals("2")){
|
|
|
String json = configService.selectConfigByKey("store.pay");
|
|
|
FsPayConfig fsPayConfig = JSON.parseObject(json, FsPayConfig.class);
|
|
@@ -335,8 +326,70 @@ public class StoreOrderController extends AppBaseController {
|
|
|
else{
|
|
|
return R.error(result.getResp_desc());
|
|
|
}
|
|
|
- }
|
|
|
- if (fsPayConfig.getType().equals("yb")){
|
|
|
+ } else if(fsPayConfig.getType().equals("tzbk")){
|
|
|
+ TzConfigInfoDTO tzConfigInfoDTO = JSON.parseObject(json, TzConfigInfoDTO.class);
|
|
|
+
|
|
|
+ TzPayCreateOrderReqBodyDTO reqBodyDTO = new TzPayCreateOrderReqBodyDTO();
|
|
|
+ RequestDTO<TzPayCreateOrderReqBodyDTO> requestDTO = new RequestDTO<>();
|
|
|
+ reqBodyDTO.setOrderNo(order.getOrderCode());
|
|
|
+ reqBodyDTO.setOrderSource("02");
|
|
|
+ reqBodyDTO.setTrxAmt(storePayment.getPayMoney());
|
|
|
+ reqBodyDTO.setCurrency("CNY");
|
|
|
+ reqBodyDTO.setTransType("2001");
|
|
|
+ reqBodyDTO.setTradeMerCstNo(tzConfigInfoDTO.getPlatMerCstNo());
|
|
|
+ reqBodyDTO.setPlatMerCstNo(tzConfigInfoDTO.getPlatMerCstNo());
|
|
|
+ reqBodyDTO.setBusinessCstNo(user.getUserId().toString());
|
|
|
+ reqBodyDTO.setPayNotifyUrl(tzConfigInfoDTO.getPayNotifyUrl());
|
|
|
+ reqBodyDTO.setPayerName(user.getUsername());
|
|
|
+ reqBodyDTO.setPayerMobileNo(user.getPhone());
|
|
|
+ //TODO 商品信息必须获取
|
|
|
+ reqBodyDTO.setGoodsInfo("测试");
|
|
|
+ // 不需要分账
|
|
|
+ reqBodyDTO.setNeedLedger("00");
|
|
|
+ reqBodyDTO.setClientIp(IPUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
+ // 获取订单到期时间
|
|
|
+ String redisKey = String.valueOf(StrUtil.format("{}{}",
|
|
|
+ StoreConstants.REDIS_ORDER_OUTTIME_UNPAY, order.getId()));
|
|
|
+ Long expire = redisCache.getExpire(redisKey);
|
|
|
+ Long currentTimeMillis = System.currentTimeMillis();
|
|
|
+
|
|
|
+ reqBodyDTO.setExpiredTime(String.valueOf(currentTimeMillis+expire));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ requestDTO.setReqHeader(TzReqHeaderDTO.getInstance(payCode));
|
|
|
+ requestDTO.setReqBody(reqBodyDTO);
|
|
|
+ try {
|
|
|
+ // 创建订单
|
|
|
+ TzReqResultDTO<TzPayCreateOrderRspDTO> payCreateOrder = tzBankService.payCreateOrder(requestDTO);
|
|
|
+ // 获得小程序请求码
|
|
|
+ if("00000000".equals(payCreateOrder.getRetCode())){
|
|
|
+ TzPayCreateOrderRspDTO body = payCreateOrder.getBody();
|
|
|
+
|
|
|
+ RequestDTO<TzMiniProgramCodeReqDTO> reqDTORequestDTO = new RequestDTO<>();
|
|
|
+ TzMiniProgramCodeReqDTO tzMiniProgramCodeReqDTO = new TzMiniProgramCodeReqDTO();
|
|
|
+ tzMiniProgramCodeReqDTO.setOrderNo(body.getOrderFlowNo());
|
|
|
+ tzMiniProgramCodeReqDTO.setPlatMerCstNo(tzConfigInfoDTO.getPlatMerCstNo());
|
|
|
+ tzMiniProgramCodeReqDTO.setBusinessCstNo(user.getUserId().toString());
|
|
|
+ reqDTORequestDTO.setReqHeader(TzReqHeaderDTO.getInstance(payCode));
|
|
|
+ reqDTORequestDTO.setReqBody(tzMiniProgramCodeReqDTO);
|
|
|
+ TzReqResultDTO<TzMiniProgramCodeRespDTO> miniProgramCode = tzBankService.miniProgramCode(reqDTORequestDTO);
|
|
|
+ if("00000000".equals(miniProgramCode.getRetCode())){
|
|
|
+ FsStorePayment mt=new FsStorePayment();
|
|
|
+ mt.setPaymentId(storePayment.getPaymentId());
|
|
|
+ mt.setTradeNo(miniProgramCode.getBody().getOrderNo());
|
|
|
+ fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
|
+ redisCache.setCacheObject("isPaying:"+order.getId(),order.getId().toString(),1, TimeUnit.MINUTES);
|
|
|
+ return R.ok().put("payType",param.getPayType()).put("result",miniProgramCode.getBody());
|
|
|
+ } else {
|
|
|
+ return R.error(miniProgramCode.getRetMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("系统异常",e);
|
|
|
+ return R.error("系统异常,请联系管理员!");
|
|
|
+ }
|
|
|
+ } else if (fsPayConfig.getType().equals("yb")){
|
|
|
WxJspayDTO p = new WxJspayDTO();
|
|
|
p.setPayMoney(order.getPayMoney().toString());
|
|
|
p.setLowOrderId("store-"+payCode);
|
|
@@ -506,12 +559,29 @@ public class StoreOrderController extends AppBaseController {
|
|
|
for(FsStorePayment payment : payments){
|
|
|
OrderQueryDTO orderQueryDTO = new OrderQueryDTO();
|
|
|
orderQueryDTO.setLowOrderId("store-"+payment.getPayCode());
|
|
|
- OrderResult orderResult = ybPayService.getOrder(orderQueryDTO);
|
|
|
- if(orderResult.getStatus()!= null&&orderResult.getStatus().equals("100")){
|
|
|
- if(orderResult.getState()!=null&&orderResult.getState().equals("0")){
|
|
|
- return R.error("订单已支付");
|
|
|
- }
|
|
|
+ RequestDTO<QueryOrderRestDTO> requestDTO = new RequestDTO<>();
|
|
|
|
|
|
+ QueryOrderRestDTO queryOrderRestDTO = new QueryOrderRestDTO();
|
|
|
+
|
|
|
+ queryOrderRestDTO.setOrderFlowNo(payment.getTradeNo());
|
|
|
+ TzConfigInfoDTO tzConfigInfoDTO = TzConfigUtils.getConfig();
|
|
|
+
|
|
|
+ queryOrderRestDTO.setPlatMerCstNo(tzConfigInfoDTO.getPlatMerCstNo());
|
|
|
+
|
|
|
+ requestDTO.setReqBody(queryOrderRestDTO);
|
|
|
+ requestDTO.setReqHeader(TzReqHeaderDTO.getInstance(payment.getPayCode()));
|
|
|
+ try {
|
|
|
+ TzReqResultDTO<QueryOrderInfoDTO> resultDTO = tzBankService.payQueryOrder(requestDTO);
|
|
|
+ if(ObjectUtil.isNotNull(resultDTO)){
|
|
|
+ QueryOrderInfoDTO body = resultDTO.getBody();
|
|
|
+ if(ObjectUtil.isNotNull(body)){
|
|
|
+ if("80".equals(body.getStatus()) || "90".equals(body.getStatus())){
|
|
|
+ return R.error("订单已支付");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
}
|
|
|
}
|