|
|
|
@@ -59,6 +59,10 @@ public class FmInsideOrderPushDeliveryMsgServiceImpl implements MsgSendService { |
|
|
|
@Autowired |
|
|
|
private MaUtil maUtil; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TtOrderPushErrorMapper ttOrderPushErrorMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void send(BaseMsg baseMsg) throws Exception{ |
|
|
|
@@ -72,39 +76,65 @@ public class FmInsideOrderPushDeliveryMsgServiceImpl implements MsgSendService { |
|
|
|
tenantEntity.setTenantId(msg.getTenantId()); |
|
|
|
tenantEntity.setParentTenantId(msg.getParentTenantId()); |
|
|
|
|
|
|
|
WxCouponOrder couponOrder = wxCouponOrderService.getById(msg.getCouponOrderId(), tenantEntity.getTenantId()); |
|
|
|
if(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode().equals(couponOrder.getCouponOrderStatus()) |
|
|
|
&& EnumPayWay.PAY_WAY_TT.getCode().equals(couponOrder.getPayVendor())){ |
|
|
|
WxOrder order = wxOrderService.getById(couponOrder.getOrderId(), tenantEntity.getTenantId()); |
|
|
|
String itemOrderId = (String) order.getExpParamValue("itemOrderId"); |
|
|
|
WxMerchant merchant = wxMerchantService.getById(couponOrder.getBMerchantId()); |
|
|
|
String shop_name = merchant.getName(); |
|
|
|
String ext_valid_shop_id = couponOrder.getBMerchantId().toString(); |
|
|
|
TtMerchantPoi poi = ttMerchantPoiService.getById(couponOrder.getBMerchantId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantEntity,EnumPayWay.PAY_WAY_TT.getPlat()); |
|
|
|
WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); |
|
|
|
TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); |
|
|
|
|
|
|
|
TtOrderPushDeliveryRequest request = new TtOrderPushDeliveryRequest(); |
|
|
|
List<TtOrderPushDeliveryRequest.ItemOrder> itemOrderList = new ArrayList<>(); |
|
|
|
TtOrderPushDeliveryRequest.ItemOrder itemOrder = new TtOrderPushDeliveryRequest.ItemOrder(); |
|
|
|
itemOrder.setItemOrderId(itemOrderId); |
|
|
|
itemOrderList.add(itemOrder); |
|
|
|
request.setItemOrderList(itemOrderList); |
|
|
|
JSONObject poiInfo = new JSONObject(); |
|
|
|
poiInfo.put("shop_name",shop_name); |
|
|
|
poiInfo.put("ext_valid_shop_id",ext_valid_shop_id); |
|
|
|
if(poi != null){ |
|
|
|
poiInfo.put("valid_poi_id_str",poi.getPoiId()); |
|
|
|
try{ |
|
|
|
WxCouponOrder couponOrder = wxCouponOrderService.getById(msg.getCouponOrderId(), tenantEntity.getTenantId()); |
|
|
|
if(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode().equals(couponOrder.getCouponOrderStatus()) |
|
|
|
&& EnumPayWay.PAY_WAY_TT.getCode().equals(couponOrder.getPayVendor())){ |
|
|
|
WxOrder order = wxOrderService.getById(couponOrder.getOrderId(), tenantEntity.getTenantId()); |
|
|
|
String itemOrderId = (String) order.getExpParamValue("itemOrderId"); |
|
|
|
WxMerchant merchant = wxMerchantService.getById(couponOrder.getBMerchantId()); |
|
|
|
String shop_name = merchant.getName(); |
|
|
|
String ext_valid_shop_id = couponOrder.getBMerchantId().toString(); |
|
|
|
TtMerchantPoi poi = ttMerchantPoiService.getById(couponOrder.getBMerchantId()); |
|
|
|
|
|
|
|
|
|
|
|
WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantEntity,EnumPayWay.PAY_WAY_TT.getPlat()); |
|
|
|
WxPayAccount payAccount = wxPayAccountService.getById(appinfo.getPayId()); |
|
|
|
TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); |
|
|
|
|
|
|
|
TtOrderPushDeliveryRequest request = new TtOrderPushDeliveryRequest(); |
|
|
|
List<TtOrderPushDeliveryRequest.ItemOrder> itemOrderList = new ArrayList<>(); |
|
|
|
TtOrderPushDeliveryRequest.ItemOrder itemOrder = new TtOrderPushDeliveryRequest.ItemOrder(); |
|
|
|
itemOrder.setItemOrderId(itemOrderId); |
|
|
|
itemOrderList.add(itemOrder); |
|
|
|
request.setItemOrderList(itemOrderList); |
|
|
|
JSONObject poiInfo = new JSONObject(); |
|
|
|
poiInfo.put("shop_name",shop_name); |
|
|
|
poiInfo.put("ext_valid_shop_id",ext_valid_shop_id); |
|
|
|
if(poi != null){ |
|
|
|
poiInfo.put("valid_poi_id_str",poi.getPoiId()); |
|
|
|
} |
|
|
|
request.setPoiInfo(poiInfo.toJSONString()); |
|
|
|
boolean b = ttPayService.pushDelivery(request); |
|
|
|
if(b){ |
|
|
|
ttOrderPushErrorMapper.deleteById(msg.getCouponOrderId()); |
|
|
|
} |
|
|
|
} |
|
|
|
request.setPoiInfo(poiInfo.toJSONString()); |
|
|
|
ttPayService.pushDelivery(request); |
|
|
|
}catch(Exception e){ |
|
|
|
TtOrderPushError pushError = new TtOrderPushError(); |
|
|
|
pushError.setId(msg.getCouponOrderId()); |
|
|
|
pushError.updateTenantInfo(tenantEntity); |
|
|
|
pushError.setErrMsg(e.getMessage()); |
|
|
|
saveOrUpdate(pushError); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void saveOrUpdate(TtOrderPushError pushError){ |
|
|
|
Date now = new Date(); |
|
|
|
TtOrderPushError pushError1 = ttOrderPushErrorMapper.selectById(pushError.getId()); |
|
|
|
if(pushError1 != null){ |
|
|
|
pushError1.setErrMsg(pushError.getErrMsg()); |
|
|
|
pushError1.setUpdateDate(now); |
|
|
|
ttOrderPushErrorMapper.updateById(pushError1); |
|
|
|
}else{ |
|
|
|
pushError.setCreateDate(now); |
|
|
|
pushError.setUpdateDate(now); |
|
|
|
ttOrderPushErrorMapper.insert(pushError); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |