From e961b6a4a7a792cce8a847cf466ece5a02cc93a4 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Fri, 16 Oct 2020 21:06:37 +0800 Subject: [PATCH] =?UTF-8?q?wx=5Fprofit=5Fsharing=5Forder=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WxProfitSharingOrderController.java | 2 +- .../schedule/SharingOrderRedoSchedule.java | 92 +++++++++++-------- ...edoScheduletttttttttttttttttttttttttt.java | 19 +++- .../mapper/WxProfitSharingOrderMapper.java | 4 +- .../service/WxProfitSharingOrderService.java | 4 +- .../impl/WxProfitSharingOrderServiceImpl.java | 8 +- .../mapper/WxProfitSharingOrderMapper.xml | 4 +- 7 files changed, 82 insertions(+), 51 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxProfitSharingOrderController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxProfitSharingOrderController.java index bc0006d19..66ac30426 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxProfitSharingOrderController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxProfitSharingOrderController.java @@ -64,7 +64,7 @@ public class WxProfitSharingOrderController extends BaseController { @SystemControllerLog(description = "分账订单-分账详情") public ResultData findOrderDetails(Long id) { logger.debug("[" + getIpAddr() + "] WxProfitSharingOrderController::findOrderDetails"); - return wxProfitSharingOrderService.findOrderDetails(id); + return wxProfitSharingOrderService.findOrderDetails(id,getTenantInfo().getTenantId()); } diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java index d7b296e97..2d233c2a2 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java @@ -3,10 +3,12 @@ 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.WxMall; 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.WxMallMapper; import com.iformall.mapper.WxPayOrderMapper; import com.iformall.mapper.WxProfitSharingOrderMapper; import com.iformall.service.WxProfitSharingOrderService; @@ -30,49 +32,59 @@ public class SharingOrderRedoSchedule { private WxProfitSharingOrderMapper wxProfitSharingOrderMapper; + @Autowired + WxMallMapper wxMallMapper; + + private List getMalls() { + WxMall wxMall =new WxMall(); + return wxMallMapper.findList(wxMall); + } + @Scheduled(cron = "0 0 2 * * ?") // 每天凌晨02:00分账重试 //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 public void sharingOrderResultSchedule() { - - 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->{ - try { - ResultData result = wxProfitSharingOrderService.redoSharingOrder(sharingOrder); - if (result.code != ResultData.SUCCESS) { - logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getMessage() - + " ID:" +sharingOrder.getId() - + " RES:" + result.message); - } - - } catch (Exception e){ - logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getMessage() - + " ID:" +sharingOrder.getId() - + " MSG:" + e.getMessage()); - } - }); - - - wxProfitSharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode()); - wxProfitSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); - list = wxProfitSharingOrderMapper.findList(wxProfitSharingOrder); - list.stream().forEach(sharingOrder->{ - try { - ResultData result = wxProfitSharingOrderService.redoSharingOrder(sharingOrder); - if (result.code != ResultData.SUCCESS) { - logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getMessage() - + " ID:" +sharingOrder.getId() - + " RES:" + result.message); - } - } catch (Exception e){ - logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getMessage() - + " ID:" +sharingOrder.getId() - + " MSG:" + e.getMessage()); - } - }); + List malls = getMalls(); + for (WxMall mall: malls) { + WxProfitSharingOrder wxProfitSharingOrder = new WxProfitSharingOrder(); + wxProfitSharingOrder.setTenantId(mall.getTenantId()); + wxProfitSharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()); + wxProfitSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); + List list = wxProfitSharingOrderMapper.findList(wxProfitSharingOrder); + list.stream().forEach(sharingOrder->{ + try { + ResultData result = wxProfitSharingOrderService.redoSharingOrder(sharingOrder); + if (result.code != ResultData.SUCCESS) { + logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getMessage() + + " ID:" +sharingOrder.getId() + + " RES:" + result.message); + } + + } catch (Exception e){ + logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getMessage() + + " ID:" +sharingOrder.getId() + + " MSG:" + e.getMessage()); + } + }); + + + wxProfitSharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getCode()); + wxProfitSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); + list = wxProfitSharingOrderMapper.findList(wxProfitSharingOrder); + list.stream().forEach(sharingOrder->{ + try { + ResultData result = wxProfitSharingOrderService.redoSharingOrder(sharingOrder); + if (result.code != ResultData.SUCCESS) { + logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getMessage() + + " ID:" +sharingOrder.getId() + + " RES:" + result.message); + } + } catch (Exception e){ + logger.error("分账重试失败:" + EnumProfitSharingOrderType.PROFIT_SHARING_MULTI.getMessage() + + " ID:" +sharingOrder.getId() + + " MSG:" + e.getMessage()); + } + }); + } } } \ No newline at end of file diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoScheduletttttttttttttttttttttttttt.java b/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoScheduletttttttttttttttttttttttttt.java index e683fd2c3..31f0f508e 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoScheduletttttttttttttttttttttttttt.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoScheduletttttttttttttttttttttttttt.java @@ -3,10 +3,12 @@ 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.WxMall; 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.WxMallMapper; import com.iformall.mapper.WxPayOrderMapper; import com.iformall.mapper.WxProfitSharingOrderMapper; import com.iformall.service.WxProfitSharingOrderService; @@ -28,13 +30,26 @@ public class SharingOrderRedoScheduletttttttttttttttttttttttttt { @Autowired private WxProfitSharingOrderMapper wxProfitSharingOrderMapper; + + @Autowired + WxMallMapper wxMallMapper; + private List getMalls() { + WxMall wxMall =new WxMall(); + return wxMallMapper.findList(wxMall); + } @Scheduled(cron = "0 5 0 * * ?") // 每天凌晨02:00分账重试 //@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 public void sharingOrderResultSchedule() { - - wxProfitSharingOrderService.updatetttttttttttttt(); + List malls = getMalls(); + for (WxMall mall: malls) { + try { + wxProfitSharingOrderService.updatetttttttttttttt(mall.getTenantId()); + }catch(Exception e) { + logger.error("sharingOrderResultScheduletttttttt error",e); + } + } } } \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingOrderMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingOrderMapper.java index 07466463a..535cd4cd6 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingOrderMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingOrderMapper.java @@ -9,6 +9,8 @@ import com.iformall.domain.vo.WxProfitSharingOrderVo; import java.util.List; import java.util.Map; +import org.apache.ibatis.annotations.Param; + public interface WxProfitSharingOrderMapper extends CommonMapper { List findList(WxProfitSharingOrder wxProfitSharingOrder); @@ -19,6 +21,6 @@ public interface WxProfitSharingOrderMapper extends CommonMapper params); - List findOrderDetails(Long id); + List findOrderDetails(@Param("id")Long id,@Param("tenantId")String tenantId); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java index dd40f7c0e..f60892ad5 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java @@ -39,9 +39,9 @@ public interface WxProfitSharingOrderService { Map queryOrderSummary(TenantEntity tenantEntity); - ResultData findOrderDetails(Long id); + ResultData findOrderDetails(Long id,String tenantId); - void updatetttttttttttttt(); + void updatetttttttttttttt(String tenantId); } 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 1cd06b082..0991dbc99 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java @@ -509,12 +509,13 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ } @Override - public ResultData findOrderDetails(Long id) { + public ResultData findOrderDetails(Long id,String tenantId) { Map result=new HashMap<>(2); WxProfitSharingOrderQueryVo wxProfitSharingOrderQueryVo = new WxProfitSharingOrderQueryVo(); wxProfitSharingOrderQueryVo.setId(id); + wxProfitSharingOrderQueryVo.setTenantId(tenantId); WxProfitSharingOrderVo wxProfitSharingOrderVo = wxProfitSharingOrderMapper.findOrderList(wxProfitSharingOrderQueryVo).get(0); - List orderDetails = wxProfitSharingOrderMapper.findOrderDetails(id); + List orderDetails = wxProfitSharingOrderMapper.findOrderDetails(id,tenantId); result.put("order",wxProfitSharingOrderVo); result.put("details",orderDetails); return new ResultData(result); @@ -619,8 +620,9 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ //更新以前分账用户绑定微信号的分账数据,微信已经停止了微信号分账 @Override @Deprecated - public void updatetttttttttttttt() { + public void updatetttttttttttttt(String tenantId) { WxProfitSharingOrder wxProfitSharingOrder = new WxProfitSharingOrder(); + wxProfitSharingOrder.setTenantId(tenantId); wxProfitSharingOrder.setType(EnumProfitSharingOrderType.PROFIT_SHARING_SINGLE.getCode()); wxProfitSharingOrder.setSharingStatus(EnumProfitSharingOrderStatus.PROFIT_SHARING_APPLY_FAILED.getCode()); List list = wxProfitSharingOrderMapper.findList(wxProfitSharingOrder); diff --git a/mallinkService/src/main/resources/mapper/WxProfitSharingOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxProfitSharingOrderMapper.xml index 7aa17e9be..3dbc14d4f 100644 --- a/mallinkService/src/main/resources/mapper/WxProfitSharingOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxProfitSharingOrderMapper.xml @@ -219,11 +219,11 @@ - select psr.id,psr.tenant_id,psr.parent_tenant_id,psr.pay_amount,psr.create_time,sharing_status,finish_time,failed_reason,description, psre.receiver_type,psre.receiver_account,psre.receiver_comments,psre.sharing_type,psre.`status` from wx_profit_sharing_result psr left join wx_profit_sharing_receiver psre on psr.sharing_receiver_id=psre.id - where psr.sharing_order_id=#{value} and psr.sharing_receiver_id!=0 + where psr.sharing_order_id=#{id} and psr.tenant_id=#{tenantId} and psr.sharing_receiver_id!=0