|
|
|
@@ -160,6 +160,7 @@ public class WxOrderController extends BaseController { |
|
|
|
@ApiOperation(value = "抖音支付2.0与下单回调推送订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\",\"orderGroupId\":\"String\",\"formId\":\"String\"}") |
|
|
|
@PostMapping("douyinPushOrder") |
|
|
|
public Map<String,Object> douyinPushOrder(HttpServletRequest request) { |
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap(); |
|
|
|
|
|
|
|
SignatureHeader header = new SignatureHeader(); |
|
|
|
@@ -171,60 +172,60 @@ public class WxOrderController extends BaseController { |
|
|
|
|
|
|
|
String body = ((BodyReaderHttpServletRequestWrapper) request).getBody(); |
|
|
|
logger.info("支付2.0预下单回调---body{}"+body); |
|
|
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(body); |
|
|
|
String msg = jsonObject.getString("msg"); |
|
|
|
|
|
|
|
JSONObject msgObject = JSONObject.parseObject(msg); |
|
|
|
String app_id = msgObject.getString("app_id"); |
|
|
|
String open_id = msgObject.getString("open_id"); |
|
|
|
//透传字段 |
|
|
|
Map<String,String> couponMap = new HashMap<>(); |
|
|
|
try{ |
|
|
|
String cp_extra = msgObject.getString("cp_extra"); |
|
|
|
if(StringUtils.isBlank(cp_extra)){ |
|
|
|
try { |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(body); |
|
|
|
String msg = jsonObject.getString("msg"); |
|
|
|
|
|
|
|
JSONObject msgObject = JSONObject.parseObject(msg); |
|
|
|
String app_id = msgObject.getString("app_id"); |
|
|
|
String open_id = msgObject.getString("open_id"); |
|
|
|
//透传字段 |
|
|
|
Map<String,String> couponMap = new HashMap<>(); |
|
|
|
try{ |
|
|
|
String cp_extra = msgObject.getString("cp_extra"); |
|
|
|
if(StringUtils.isBlank(cp_extra)){ |
|
|
|
map.put("err_no",ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); |
|
|
|
map.put("err_tips","缺少透传字段"); |
|
|
|
return map; |
|
|
|
} |
|
|
|
couponMap = JSONObject.parseObject(cp_extra, Map.class); |
|
|
|
}catch(Exception e){ |
|
|
|
} |
|
|
|
if(couponMap.isEmpty()){ |
|
|
|
map.put("err_no",ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); |
|
|
|
map.put("err_tips","缺少透传字段"); |
|
|
|
map.put("err_tips","透传字段格式不正确"); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
//验证app |
|
|
|
WxAppinfo appinfo = wxAppinfoService.getByAppId(app_id); |
|
|
|
if(appinfo == null || !EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) |
|
|
|
|| !EnumAppType.C.getCode().equals(appinfo.getType())){ |
|
|
|
map.put("err_no",ErrorCode.APP_ID_NOT_FOUND.getCode()); |
|
|
|
map.put("err_tips",ErrorCode.APP_ID_NOT_FOUND.getMessage()); |
|
|
|
return map; |
|
|
|
} |
|
|
|
WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); |
|
|
|
if(payAccount == null){ |
|
|
|
map.put("err_no",ErrorCode.API_KEY_NOT_FOUND.getCode()); |
|
|
|
map.put("err_tips","未找到支付配置"); |
|
|
|
return map; |
|
|
|
} |
|
|
|
TenantEntity tenantEntity = new TenantEntity(); |
|
|
|
tenantEntity.updateTenantInfo(appinfo); |
|
|
|
//验证用户 |
|
|
|
Long memberId = null; |
|
|
|
TtCUser cuser = (TtCUser) cuserFactory.getCUserService(EnumAppPlat.TOUTIAO).getByOpenId(open_id, tenantEntity.getTenantId()); |
|
|
|
if(cuser != null && cuser.getUserId() != null){ |
|
|
|
memberId = cuser.getUserId(); |
|
|
|
} |
|
|
|
if(memberId == null){ |
|
|
|
map.put("err_no",ErrorCode.USER_NOT_MEMBER.getCode()); |
|
|
|
map.put("err_tips",ErrorCode.USER_NOT_MEMBER.getMessage()); |
|
|
|
return map; |
|
|
|
} |
|
|
|
couponMap = JSONObject.parseObject(cp_extra, Map.class); |
|
|
|
}catch(Exception e){ |
|
|
|
} |
|
|
|
if(couponMap.isEmpty()){ |
|
|
|
map.put("err_no",ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); |
|
|
|
map.put("err_tips","透传字段格式不正确"); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
//验证app |
|
|
|
WxAppinfo appinfo = wxAppinfoService.getByAppId(app_id); |
|
|
|
if(appinfo == null || !EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) |
|
|
|
|| !EnumAppType.C.getCode().equals(appinfo.getType())){ |
|
|
|
map.put("err_no",ErrorCode.APP_ID_NOT_FOUND.getCode()); |
|
|
|
map.put("err_tips",ErrorCode.APP_ID_NOT_FOUND.getMessage()); |
|
|
|
return map; |
|
|
|
} |
|
|
|
WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); |
|
|
|
if(payAccount == null){ |
|
|
|
map.put("err_no",ErrorCode.API_KEY_NOT_FOUND.getCode()); |
|
|
|
map.put("err_tips","未找到支付配置"); |
|
|
|
return map; |
|
|
|
} |
|
|
|
TenantEntity tenantEntity = new TenantEntity(); |
|
|
|
tenantEntity.updateTenantInfo(appinfo); |
|
|
|
//验证用户 |
|
|
|
Long memberId = null; |
|
|
|
TtCUser cuser = (TtCUser) cuserFactory.getCUserService(EnumAppPlat.TOUTIAO).getByOpenId(open_id, tenantEntity.getTenantId()); |
|
|
|
if(cuser != null && cuser.getUserId() != null){ |
|
|
|
memberId = cuser.getUserId(); |
|
|
|
} |
|
|
|
if(memberId == null){ |
|
|
|
map.put("err_no",ErrorCode.USER_NOT_MEMBER.getCode()); |
|
|
|
map.put("err_tips",ErrorCode.USER_NOT_MEMBER.getMessage()); |
|
|
|
return map; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); |
|
|
|
CreateOrderCallback createOrderCallback = ttPayService.parseOrderNotifyV2Result(body, header); |
|
|
|
JSONObject allExtParam = new JSONObject(); |
|
|
|
@@ -383,7 +384,6 @@ public class WxOrderController extends BaseController { |
|
|
|
if (null != payOrder) { |
|
|
|
WxComposeOrder composeOrder = orderFactory.getOrderAdapterService(payOrder.getComposeOrder()).getComposeOrder(payOrder.getOrderId(), payOrder.getTenantId()); |
|
|
|
//查询微信订单状态并更新 |
|
|
|
|
|
|
|
boolean hasCompleted = wxPayOrderService.hasCompleted(composeOrder,payOrder); |
|
|
|
if (!hasCompleted) { |
|
|
|
WxAppinfo appInfo = wxAppinfoService.getCAppInfo(payOrder, EnumPayWay.getEnum(payOrder.getPayVendor()).getPlat()); |
|
|
|
|