diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoScheduletttttttttttttttttttttttttt.java b/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoScheduletttttttttttttttttttttttttt.java new file mode 100644 index 000000000..e683fd2c3 --- /dev/null +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoScheduletttttttttttttttttttttttttt.java @@ -0,0 +1,40 @@ +package com.iformall.schedule; + +import com.iformall.common.ErrorCode; +import com.iformall.common.ResultData; +import com.iformall.domain.dto.WxSharingOrderDto; +import com.iformall.domain.po.WxProfitSharingOrder; +import com.iformall.enums.EnumPayWay; +import com.iformall.enums.EnumProfitSharingOrderStatus; +import com.iformall.enums.EnumProfitSharingOrderType; +import com.iformall.mapper.WxPayOrderMapper; +import com.iformall.mapper.WxProfitSharingOrderMapper; +import com.iformall.service.WxProfitSharingOrderService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class SharingOrderRedoScheduletttttttttttttttttttttttttt { + + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private WxProfitSharingOrderService wxProfitSharingOrderService; + + @Autowired + private WxProfitSharingOrderMapper wxProfitSharingOrderMapper; + + + @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨02:00分账重试 + //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 + public void sharingOrderResultSchedule() { + + wxProfitSharingOrderService.updatetttttttttttttt(); + + } +} \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java index 4df58d67b..dd40f7c0e 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java @@ -40,5 +40,8 @@ public interface WxProfitSharingOrderService { Map queryOrderSummary(TenantEntity tenantEntity); ResultData findOrderDetails(Long id); + + void updatetttttttttttttt(); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java index 20b7cd99b..0e2f3fb6e 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java @@ -616,5 +616,61 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ } } + //更新以前分账用户绑定微信号的分账数据,微信已经停止了微信号分账 + @Override + @Deprecated + public void updatetttttttttttttt() { + WxProfitSharingOrder wxProfitSharingOrder = new WxProfitSharingOrder(); + wxProfitSharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()); + wxProfitSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); + List list = wxProfitSharingOrderMapper.findList(wxProfitSharingOrder); + list.stream().forEach(sharingOrder->{ + if (!sharingOrder.getType().equals(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode())) { + return; + } + + WxProfitShareAppInoDto dto = getAppinfo(sharingOrder); + WxAppinfo appInfo = dto.getAppinfo(); + WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); + + List receivers; + + receivers = JSONArray.parseArray(sharingOrder.getReceivers(), JSONObject.class); + if (receivers.size() != 1 ) + return; + + Integer amount = receivers.get(0).getInteger("amount"); + if (!EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_PERSONAL_WECHATID.getMessage().equals(receivers.get(0).getString("type"))) { + return; + } + + //准备分账列表 + WxProfitSharingReceiver psReceiverQ = new WxProfitSharingReceiver(); + psReceiverQ.updateTenantInfo(payAccount); + psReceiverQ.setMerchantId(sharingOrder.getMerchantId()); + psReceiverQ.setSharingType(payServiceFactory.getPayShareAdapterService(dto.getPayWay()).getProfitSharingType()); + psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); + List psReceiverList = wxProfitSharingReceiverMapper.findList(psReceiverQ); + if (null == psReceiverList || psReceiverList.size() !=1 ) { + return ; + } + + JSONArray realReceivers = new JSONArray(); + psReceiverList.stream().forEach(receiver->{ + JSONObject jo = new JSONObject(); + jo.put("type",payServiceFactory.getPayShareAdapterService(dto.getPayWay()).getShareAccount(receiver.getReceiverType()).getMessage()); + jo.put("account",receiver.getReceiverAccount()); + jo.put("amount", amount); + //jo.put("description",receiver.getReceiverComments()); //改为存ID, + jo.put("description",receiver.getId().toString()); //为重试做准备 + realReceivers.add(jo); + }); + + + sharingOrder.setReceivers(JSON.toJSONString(realReceivers)); + wxProfitSharingOrderMapper.updateById(sharingOrder); + }); + } + }