|
@@ -1,7 +1,9 @@
|
|
|
package com.fs.hisStore.service.impl;
|
|
|
|
|
|
+import cn.binarywang.wx.miniapp.api.WxMaOrderShippingService;
|
|
|
import cn.binarywang.wx.miniapp.bean.shop.request.shipping.*;
|
|
|
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetListResponse;
|
|
|
+import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetResponse;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.hutool.core.net.URLDecoder;
|
|
@@ -91,6 +93,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
import lombok.Synchronized;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.aop.framework.AopContext;
|
|
@@ -3701,70 +3704,64 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class, propagation = Propagation.REQUIRED)
|
|
|
- public void refreshOrderSettlementStatus(){
|
|
|
+ public void refreshOrderSettlementStatus() {
|
|
|
try {
|
|
|
- //判断是否对接微信发货
|
|
|
- String json = configService.selectConfigByKey("store.config");
|
|
|
- StoreConfig config = JSONUtil.toBean(json, StoreConfig.class);
|
|
|
- if(config != null && config.getIsWeChatShipping() != null && config.getIsWeChatShipping()){
|
|
|
- //获取未结算订单
|
|
|
- List<FsStoreOrderScrm> orderScrmList=fsStoreOrderMapper.getUnsettledOrder();
|
|
|
- String payConfig=configService.selectConfigByKey("store.pay");
|
|
|
- JSONObject js=JSON.parseObject(payConfig);
|
|
|
- String appId=js.getString("hf");
|
|
|
- if(ObjectUtil.isNotNull(appId) && !appId.equals("")){
|
|
|
- //请求微信批量查询订单
|
|
|
- final WxMaService wxService = WxMaConfiguration.getMaService(appId);
|
|
|
- WxMaOrderShippingInfoGetListRequest request=new WxMaOrderShippingInfoGetListRequest();
|
|
|
-
|
|
|
-
|
|
|
- WxMaOrderShippingInfoGetListResponse response=wxService.getWxMaOrderShippingService().getList(request);
|
|
|
-
|
|
|
- logger.info("请求信息------------------------》{}",response);
|
|
|
-// if(!orderScrmList.isEmpty()){
|
|
|
-// orderScrmList.forEach(order->{
|
|
|
-// if (order.getStatus() == OrderInfoEnum.STATUS_2.getValue()) {
|
|
|
-// order.setFinishTime(new Date());
|
|
|
-// order.setStatus(3);
|
|
|
-// fsStoreOrderMapper.updateFsStoreOrder(order);
|
|
|
-// orderStatusService.create(order.getId(), OrderLogEnum.FINISH_ORDER.getValue(),
|
|
|
-// OrderLogEnum.FINISH_ORDER.getDesc());
|
|
|
-// //写入公司余额 条件是只有全款订单才分,非全款后台导入
|
|
|
-// if (order.getCompanyId() != null && order.getCompanyId() > 0 && order.getPayDelivery().compareTo(new BigDecimal(0)) == 0) {
|
|
|
-// if (order.getTuiMoneyStatus() == null || order.getTuiMoneyStatus() != 1) {
|
|
|
-// companyService.addCompanyMoney(order);
|
|
|
-// }
|
|
|
-// }
|
|
|
-//
|
|
|
-// FsErpConfig erpConfig = configUtil.getErpConfig();
|
|
|
-// Integer erpType = erpConfig.getErpType();
|
|
|
-// Integer erpOpen = erpConfig.getErpOpen();
|
|
|
-// if (erpOpen != null && erpOpen == 1) {
|
|
|
-// if (erpType != null && erpType == 2) {
|
|
|
-// // 如果是物流代收 或者 货到付款
|
|
|
-// if ("2".equals(order.getPayType()) || "3".equals(order.getPayType())) {
|
|
|
-// // 已结算
|
|
|
-// if ("1".equals(order.getDeliveryPayStatus())) {
|
|
|
-// FsErpFinishPush fsErpFinishPush = new FsErpFinishPush();
|
|
|
-// fsErpFinishPush.setOrderId(order.getId());
|
|
|
-// fsErpFinishPush.setTaskStatus(0);
|
|
|
-// fsErpFinishPush.setRetryCount(0);
|
|
|
-// fsErpFinishPush.setCreateTime(new Date());
|
|
|
-// fsErpFinishPushMapper.insert(fsErpFinishPush);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
+ // 判断是否对接微信发货
|
|
|
+ String json = configService.selectConfigByKey("store.config");
|
|
|
+ StoreConfig config = JSONUtil.toBean(json, StoreConfig.class);
|
|
|
+ logger.info("进入微信结算订单定时任务--------------->{}","start");
|
|
|
+ if (config != null && config.getIsWeChatShipping() != null && config.getIsWeChatShipping()) {
|
|
|
+ // 获取未结算订单
|
|
|
+ List<FsStoreOrderScrm> orderScrmList = fsStoreOrderMapper.getUnsettledOrder();
|
|
|
+
|
|
|
+ String payConfig = configService.selectConfigByKey("store.pay");
|
|
|
+ JSONObject js = JSON.parseObject(payConfig);
|
|
|
+ String appId = js.getString("appId");
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotNull(appId) && !appId.isEmpty()) {
|
|
|
+ final WxMaService wxService = WxMaConfiguration.getMaService(appId);
|
|
|
+
|
|
|
+ if (!orderScrmList.isEmpty()) {
|
|
|
+ for (FsStoreOrderScrm order : orderScrmList) {
|
|
|
+ WxMaOrderShippingInfoGetRequest request = new WxMaOrderShippingInfoGetRequest();
|
|
|
+ request.setTransactionId(order.getBankTransactionId());
|
|
|
+ WxMaOrderShippingInfoGetResponse response;
|
|
|
+
|
|
|
+ try {
|
|
|
+ response = wxService.getWxMaOrderShippingService().get(request);
|
|
|
+
|
|
|
+ if (response.getErrCode().equals(0)) {
|
|
|
+ // 订单状态枚举:(1) 待发货;(2) 已发货;(3) 确认收货;(4) 交易完成;(5) 已退款
|
|
|
+ if (response.getOrder().getOrderState().equals(3) || response.getOrder().getOrderState().equals(4)) {
|
|
|
+ if (order.getStatus() == OrderInfoEnum.STATUS_2.getValue()) {
|
|
|
+ this.finishOrder(order.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("请求信息------------------------》{}", response);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (WxErrorException e) {
|
|
|
+ logger.info("异常信息------------------------》{}", e.getMessage());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.getStackTrace();
|
|
|
+ }finally {
|
|
|
+ logger.info("进入微信结算订单定时任务--------------->{}","end");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void calculateAgentPayment(FsStoreOrderScrm order) {
|
|
|
+ //通过订单获取关联商品信息
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private boolean uploadShippingInfoToWechat(WxMaService wxService,
|
|
|
OrderOpenIdTransDTO orderInfo,
|
|
|
List<FsStoreOrderCodeOpenIdVo> orderDetails,
|