|
|
@@ -129,6 +129,8 @@ public class InquiryOrderController extends AppBaseController {
|
|
|
private ISysConfigService configService;
|
|
|
@Autowired
|
|
|
private IFsUserWxService userWxService;
|
|
|
+ @Autowired
|
|
|
+ private IFsUserService fsUserService;
|
|
|
@Login
|
|
|
@ApiOperation("确认订单")
|
|
|
@PostMapping("/confirm")
|
|
|
@@ -304,28 +306,34 @@ public class InquiryOrderController extends AppBaseController {
|
|
|
|
|
|
String openId = null;
|
|
|
String appId = param.getAppId();
|
|
|
- if (StringUtils.isNotBlank(appId)) {
|
|
|
- //查询fs_user_wx的openId
|
|
|
- Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
- .eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
- .eq(FsUserWx::getAppId, appId);
|
|
|
- FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
- if (fsUserWx != null) {
|
|
|
- openId = fsUserWx.getOpenId();
|
|
|
- }
|
|
|
+ if (request.getHeader("sourcetype") != null && "APP".equals(request.getHeader("sourcetype"))) {
|
|
|
+ FsUser fsUser = fsUserService.selectFsUserByUserId(param.getUserId().longValue());
|
|
|
+ openId = fsUser.getAppOpenId();
|
|
|
} else {
|
|
|
- appId = merchantAppConfig.getAppId();
|
|
|
- openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
|
- if (StringUtils.isBlank(openId)){
|
|
|
+ if (StringUtils.isNotBlank(appId)) {
|
|
|
+ //查询fs_user_wx的openId
|
|
|
Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
.eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
.eq(FsUserWx::getAppId, appId);
|
|
|
FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
- if (Objects.nonNull(fsUserWx)){
|
|
|
+ if (fsUserWx != null) {
|
|
|
openId = fsUserWx.getOpenId();
|
|
|
}
|
|
|
+ } else {
|
|
|
+ appId = merchantAppConfig.getAppId();
|
|
|
+ openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
|
+ if (StringUtils.isBlank(openId)){
|
|
|
+ Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
+ .eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
+ .eq(FsUserWx::getAppId, appId);
|
|
|
+ FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
+ if (Objects.nonNull(fsUserWx)){
|
|
|
+ openId = fsUserWx.getOpenId();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
//String json=configService.selectConfigByKey("his.pay");
|
|
|
//PayConfigDTO payConfigDTO= JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
|
|
|
@@ -344,7 +352,7 @@ public class InquiryOrderController extends AppBaseController {
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
- if ((!"appPay".equals(merchantAppConfig.getMerchantType()) && StringUtils.isBlank(openId))) {
|
|
|
+ if ((!"appPay".equals(merchantAppConfig.getMerchantType()) && (StringUtils.isBlank(openId) || ("hf".equals(merchantAppConfig.getMerchantType()) && "wx".equals(param.getPayType())) ))) {
|
|
|
return R.error("用户OPENID不存在");
|
|
|
}
|
|
|
|
|
|
@@ -359,7 +367,7 @@ public class InquiryOrderController extends AppBaseController {
|
|
|
}
|
|
|
FsStorePayment storePayment=new FsStorePayment();
|
|
|
storePayment.setStatus(0);
|
|
|
- storePayment.setPayMode(merchantAppConfig.getMerchantId());
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setCompanyId(order.getCompanyId());
|
|
|
storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
@@ -372,8 +380,9 @@ public class InquiryOrderController extends AppBaseController {
|
|
|
storePayment.setOpenId(openId);
|
|
|
storePayment.setUserId(user.getUserId());
|
|
|
storePayment.setBusinessId(order.getOrderId().toString());
|
|
|
+ storePayment.setMerchantId(merchantAppConfig.getId());
|
|
|
if(storePaymentService.insertFsStorePayment(storePayment)>0){
|
|
|
- if(merchantAppConfig.getMerchantId().equals("wx")){
|
|
|
+ if(merchantAppConfig.getMerchantType().equals("wx")){
|
|
|
//创建微信订单
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
payConfig.setAppId(appId);
|
|
|
@@ -401,7 +410,7 @@ public class InquiryOrderController extends AppBaseController {
|
|
|
throw new CustomException("支付失败"+e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
- else if(merchantAppConfig.getMerchantId().equals("yb")){
|
|
|
+ else if(merchantAppConfig.getMerchantType().equals("yb")){
|
|
|
WxJspayDTO p = new WxJspayDTO();
|
|
|
// 使用setter方法为对象赋值
|
|
|
p.setPayMoney(storePayment.getPayMoney().toString());
|
|
|
@@ -423,7 +432,7 @@ public class InquiryOrderController extends AppBaseController {
|
|
|
throw new CustomException("支付失败");
|
|
|
}
|
|
|
}
|
|
|
- else if(merchantAppConfig.getMerchantId().equals("tz")){
|
|
|
+ else if(merchantAppConfig.getMerchantType().equals("tz")){
|
|
|
PayCreateOrder o = new PayCreateOrder();
|
|
|
o.setOrderNo("inquiry"+storePayment.getPayCode()); // 业务系统订单号
|
|
|
o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
|
|
|
@@ -448,9 +457,9 @@ public class InquiryOrderController extends AppBaseController {
|
|
|
mt.setTradeNo(result.getBody().getOrderFlowNo());
|
|
|
storePaymentService.updateFsStorePayment(mt);
|
|
|
return R.ok().put("isPay",0).put("data",result).put("type","tz");
|
|
|
- }else if(merchantAppConfig.getMerchantId().equals("hf")){
|
|
|
+ }else if(merchantAppConfig.getMerchantType().equals("hf")){
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
- o.setTradeType("T_MINIAPP");
|
|
|
+ o.setTradeType(StringUtils.isEmpty(param.getPayType()) || param.getPayType().equals("wx") ? "T_MINIAPP" : "A_NATIVE");
|
|
|
o.setOpenid(openId);
|
|
|
o.setAppId(appId);
|
|
|
o.setReqSeqId("inquiry-"+storePayment.getPayCode());
|
|
|
@@ -498,7 +507,7 @@ public class InquiryOrderController extends AppBaseController {
|
|
|
AlipayTradeAppPayRequest aliRequest = new AlipayTradeAppPayRequest();
|
|
|
AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
|
|
|
// 商户订单号
|
|
|
- model.setOutTradeNo("package-" + storePayment.getPayCode());
|
|
|
+ model.setOutTradeNo("inquiry-" + storePayment.getPayCode());
|
|
|
// 订单总金额
|
|
|
model.setTotalAmount(storePayment.getPayMoney().toString());
|
|
|
// 订单标题r
|
|
|
@@ -605,6 +614,7 @@ public class InquiryOrderController extends AppBaseController {
|
|
|
storePayment.setOpenId(openId);
|
|
|
storePayment.setUserId(user.getUserId());
|
|
|
storePayment.setBusinessId(order.getOrderId().toString());
|
|
|
+ storePayment.setMerchantId(merchantAppConfig.getId());
|
|
|
if(storePaymentService.insertFsStorePayment(storePayment)>0){
|
|
|
if (merchantAppConfig.getMerchantType().equals("yb")) {
|
|
|
return R.error("支付暂不可用!");
|