|
@@ -1657,6 +1657,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
throw new CustomException("小程序没有配置商户信息");
|
|
throw new CustomException("小程序没有配置商户信息");
|
|
|
}
|
|
}
|
|
|
MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
String openId = null;
|
|
String openId = null;
|
|
|
String appId = param.getAppId();
|
|
String appId = param.getAppId();
|
|
|
if (StringUtils.isNotBlank(appId)) {
|
|
if (StringUtils.isNotBlank(appId)) {
|
|
@@ -1714,40 +1715,76 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
storePayment.setRemark("商城收款订单支付");
|
|
storePayment.setRemark("商城收款订单支付");
|
|
|
storePayment.setOpenId(openId);
|
|
storePayment.setOpenId(openId);
|
|
|
storePayment.setUserId(user.getUserId());
|
|
storePayment.setUserId(user.getUserId());
|
|
|
- storePayment.setPayMode("hf");//目前微信收款仅支持汇付
|
|
|
|
|
- fsStorePaymentMapper.insertFsStorePayment(storePayment);
|
|
|
|
|
-
|
|
|
|
|
- //汇付支付
|
|
|
|
|
- HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
|
|
- o.setTradeType("T_MINIAPP");
|
|
|
|
|
- o.setOpenid(openId);
|
|
|
|
|
- o.setReqSeqId("payment-"+storePayment.getPayCode());
|
|
|
|
|
- o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
|
|
- o.setGoodsDesc("商城订单支付");
|
|
|
|
|
- o.setAppId(appId);
|
|
|
|
|
- //公司分账
|
|
|
|
|
- try {
|
|
|
|
|
- HuiFuUtils.doDiv(o,company.getCompanyId());
|
|
|
|
|
- //存储分账明细
|
|
|
|
|
- HuiFuUtils.saveDivItem(o, storePayment.getPayCode(), storePayment.getPayCode());
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- logger.error("-------------微信收款分账出错:{}", e.getMessage());
|
|
|
|
|
- }
|
|
|
|
|
- HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
|
|
- if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
|
|
|
|
|
- FsStorePayment mt=new FsStorePayment();
|
|
|
|
|
- mt.setPaymentId(storePayment.getPaymentId());
|
|
|
|
|
- mt.setTradeNo(result.getHf_seq_id());
|
|
|
|
|
- mt.setAppId(appId);
|
|
|
|
|
- fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
|
|
|
- Map<String, Object> resultMap = com.alibaba.fastjson.JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
|
|
|
|
|
- String s = (String) resultMap.get("package");
|
|
|
|
|
- resultMap.put("packageValue",s);
|
|
|
|
|
- return R.ok().put("result",resultMap);
|
|
|
|
|
- }
|
|
|
|
|
- else{
|
|
|
|
|
- return R.error(result.getResp_desc());
|
|
|
|
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
|
|
+
|
|
|
|
|
+ if (fsStorePaymentMapper.insertFsStorePayment(storePayment) > 0) {
|
|
|
|
|
+ if (merchantAppConfig.getMerchantType().equals("wx")) {
|
|
|
|
|
+ //创建微信订单
|
|
|
|
|
+ WxPayConfig payConfig = new WxPayConfig();
|
|
|
|
|
+ payConfig.setAppId(appId);
|
|
|
|
|
+ payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
|
|
+ payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
|
|
+ payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
|
|
+ payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
|
|
+ payConfig.setKeyPath(null);
|
|
|
|
|
+ payConfig.setNotifyUrl(wxPayProperties.getNotifyUrl());
|
|
|
|
|
+ wxPayService.setConfig(payConfig);
|
|
|
|
|
+ WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
|
|
|
+ orderRequest.setOpenid(openId);//公众号支付提供用户openid
|
|
|
|
|
+ orderRequest.setBody("拍商品订单支付");
|
|
|
|
|
+ orderRequest.setOutTradeNo("product-" + storePayment.getPayCode());
|
|
|
|
|
+ orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
|
|
|
|
|
+ //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
|
|
|
|
|
+ orderRequest.setTradeType("JSAPI");
|
|
|
|
|
+ orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
|
|
+ //调用统一下单接口,获取"预支付交易会话标识"
|
|
|
|
|
+ try {
|
|
|
|
|
+ WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
|
|
|
|
|
+ return R.ok().put("data", orderResult).put("type", "wx").put("isPay", 0);
|
|
|
|
|
+ } catch (WxPayException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ throw new CustomException("支付失败" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (merchantAppConfig.getMerchantType().equals("hf")) {
|
|
|
|
|
+
|
|
|
|
|
+ //汇付支付
|
|
|
|
|
+ HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
|
|
+ o.setTradeType("T_MINIAPP");
|
|
|
|
|
+ o.setOpenid(openId);
|
|
|
|
|
+ o.setReqSeqId("payment-"+storePayment.getPayCode());
|
|
|
|
|
+ o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
|
|
+ o.setGoodsDesc("商城订单支付");
|
|
|
|
|
+ o.setAppId(appId);
|
|
|
|
|
+ //公司分账
|
|
|
|
|
+ try {
|
|
|
|
|
+ HuiFuUtils.doDiv(o,company.getCompanyId());
|
|
|
|
|
+ //存储分账明细
|
|
|
|
|
+ HuiFuUtils.saveDivItem(o, storePayment.getPayCode(), storePayment.getPayCode());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("-------------微信收款分账出错:{}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
|
|
+
|
|
|
|
|
+ if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
|
|
|
|
|
+ FsStorePayment mt=new FsStorePayment();
|
|
|
|
|
+ mt.setPaymentId(storePayment.getPaymentId());
|
|
|
|
|
+ mt.setTradeNo(result.getHf_seq_id());
|
|
|
|
|
+ mt.setAppId(appId);
|
|
|
|
|
+ fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
|
|
|
+ Map<String, Object> resultMap = com.alibaba.fastjson.JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
|
|
|
|
|
+ String s = (String) resultMap.get("package");
|
|
|
|
|
+ resultMap.put("packageValue",s);
|
|
|
|
|
+ return R.ok().put("result",resultMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ return R.error(result.getResp_desc());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else {
|
|
|
|
|
+ return R.error("新增订单失败!");
|
|
|
}
|
|
}
|
|
|
|
|
+ return R.error("支付失败!");
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|