diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java index c0626f016..1e12aa436 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java @@ -260,50 +260,10 @@ public class WxCouponController extends BaseController { return new ResultData(ResultData.ERROR, "缺少id"); } wxCoupon.updateTenantInfo(getTenantInfo()); - WxCoupon coupon = wxCouponService.getById(wxCoupon.getId(),wxCoupon.getTenantId()); - if (null == coupon) { - return new ResultData(ResultData.ERROR, "券未查询到。"+wxCoupon.getId()); - } - - - if(EnumDelFlag.YES.getCode().equals(wxCoupon.getIsDel())){ - if(!EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(coupon.getStatus())){ - return new ResultData(ResultData.ERROR, "请先作废,再进行删除。"); - } - wxCouponService.deleteById(wxCoupon.getId(),wxCoupon.getTenantId()); - CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); - CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId(),null); - CouponCacheUtils.removeOnlyCouponCache(redisTemplate, wxCoupon.getId()); - return new ResultData(); - } - - //启动审批流 - if (wxCoupon.getFlowParams() != null && wxCoupon.getFlowParams().size() > 0) { - logger.info("------coupon.update().businessType:"+wxCoupon.getFlowParams().get("businessType")); - wxCoupon.getFlowParams().put("businessId",wxCoupon.getId()); - wxFlowService.start(wxCoupon.getFlowParams(), getUserId(), getUser().getName(), getTenantInfo()); - //作废审批 - if (EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())) { - wxCoupon.setCancleApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); - return new ResultData(wxCoupon); - } else { - //投放审批 - wxCoupon.setPutApplyStatus(EnumRentContractAppStatus.APPLYING.getCode()); - } - } - ResultData result = null; - if(EnumCouponStatus.COUPON_STATUS_TAKE_OFFF.getCode().equals(wxCoupon.getStatus())){ - result = wxCouponService.disable(wxCoupon, wxCoupon.getId(),getUser()); - }else{ - result = wxCouponService.saveOrUpdate(wxCoupon, null); - if(wxCoupon.getRemainInventory() != null){ - redisLock.setCouponStock(wxCoupon.getId(), wxCoupon.getRemainInventory()); - } - } + wxCouponService.handleDraftCoupon(wxCoupon); - CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); - CouponCacheUtils.removeCouponMerchantCache(redisTemplate, wxCoupon.getId(),null); + ResultData result = wxCouponService.saveOrUpdate(wxCoupon, null); return result; } diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java index 2e00ac2b1..7081c081e 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/SharingOrderRedoSchedule.java @@ -103,7 +103,7 @@ public class SharingOrderRedoSchedule { + " MSG:" + e.getMessage()); } //分账3天失败给通知 - if(!isSuccess && i >= 1){ + if(!isSuccess && i >= 5){ errorCount.getAndIncrement(); } }); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java index 05fd54fa1..23c0d19e1 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java @@ -128,4 +128,5 @@ public interface WxCouponMapper extends CommonMapper { WxCoupon selectDraftCoupon(@Param("couponId")Long id,@Param("tenantId")String tenantId); + WxCoupon selectOnlineCoupon(@Param("id")Long id, @Param("tenantId")String tenantId); } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java index 95c461461..29c254f86 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java @@ -311,4 +311,7 @@ public interface WxCouponService { void delManyCouponMerchants(TenantEntity tenantInfo, List couponIds, List merchantIds); List getByIdListOrTitle(List couponIds, String tenantId, String title); + + void handleDraftCoupon(WxCoupon wxCoupon); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java index 01f0307f7..f6c4f180c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/TtCouponGoodsServiceImpl.java @@ -457,7 +457,7 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { } @Override - @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) + @Transactional(rollbackFor = Exception.class) public ResultData productDraftGet(TenantEntity tenantEntity,Long id,boolean isSaas) { TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantEntity.getTenantId(),id); if(ttCouponChannelPoi == null){ diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index 2178831c8..772939c16 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -36,6 +36,7 @@ import com.iformall.service.pay.PayServiceFactory; import com.iformall.service.pay.service.share.PayShareAdapterService; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; +import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -2126,5 +2127,86 @@ public class WxCouponServiceImpl implements WxCouponService { return wxCouponMapper.findList(coupon); } + @Override + @Transactional(rollbackFor = Exception.class) + public void handleDraftCoupon(WxCoupon wxCoupon) { + WxCoupon onlineCoupon = wxCouponMapper.selectOnlineCoupon(wxCoupon.getId(),wxCoupon.getTenantId()); + if(onlineCoupon == null){ + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到券数据"); + } + TtCouponChannelPoi onlineCouponChannelPoi = ttCouponChannelPoiMapper.selectById(onlineCoupon.getTenantId(), onlineCoupon.getId()); + if(onlineCouponChannelPoi != null){ + if(EnumSpuSyncStatus.sync_auditing.getCode().equals(onlineCouponChannelPoi.getStatus())){ + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"商品数据流程中"); + } + if(EnumSpuSyncStatus.sync_put_on.getCode().equals(onlineCouponChannelPoi.getStatus()) + || EnumSpuSyncStatus.sync_pull_off.getCode().equals(onlineCouponChannelPoi.getStatus()) + || EnumSpuSyncStatus.sync_audit_pass.getCode().equals(onlineCouponChannelPoi.getStatus()) + || EnumSpuSyncStatus.sync_audit_disable.getCode().equals(onlineCouponChannelPoi.getStatus())){ + //复制草稿数据 + WxCoupon draftCoupon = wxCouponMapper.selectDraftCoupon(onlineCoupon.getId(),onlineCoupon.getTenantId()); + if(draftCoupon == null){ + try{ + final IdWorker idWorker = IdWorker.get(); + draftCoupon = new WxCoupon(); + BeanUtils.copyProperties(draftCoupon,onlineCoupon); + draftCoupon.setId(idWorker.nextId()); + draftCoupon.setVersion(EnumCouponVersion.draft.getCode()); + draftCoupon.setCreateDate(new Date()); + draftCoupon.setUpdateDate(new Date()); + wxCouponMapper.insert(draftCoupon); + + if (EnumCouponType.isParentCoupon(draftCoupon.getType())) { + WxCouponMall couponMall = new WxCouponMall(); + couponMall.updateTenantInfo(draftCoupon); + couponMall.setProductId(draftCoupon.getId()); + List couponMallList = wxCouponMallMapper.findList(couponMall); + + for (WxCouponMall cm : couponMallList) { + cm.setId(idWorker.nextId()); + cm.setProductId(draftCoupon.getCouponId()); + wxCouponMallMapper.insert(cm); + + WxCouponMerchant couponMerchant = new WxCouponMerchant(); + couponMerchant.setTenantId(cm.getMallTenantId()); + couponMerchant.setParentTenantId(cm.getTenantId()); + couponMerchant.setProductId(draftCoupon.getId()); + List couponMerchantList = wxCouponMerchantMapper.findList(couponMerchant); + + for (WxCouponMerchant cmt: couponMerchantList) { + cmt.setId(idWorker.nextId()); + cmt.setProductId(draftCoupon.getCouponId()); + wxCouponMerchantMapper.insert(cmt); + } + } + }else{ + WxCouponMerchant couponMerchant = new WxCouponMerchant(); + couponMerchant.updateTenantInfo(draftCoupon); + couponMerchant.setProductId(draftCoupon.getId()); + List couponMerchantList = wxCouponMerchantMapper.findList(couponMerchant); + for (WxCouponMerchant cmt: couponMerchantList) { + cmt.setId(idWorker.nextId()); + cmt.setProductId(draftCoupon.getCouponId()); + wxCouponMerchantMapper.insert(cmt); + } + } + }catch(Exception e){ + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"商品数据处理异常"); + } + + }else{ + TtCouponChannelPoi draftCouponChannelPoi = ttCouponChannelPoiMapper.selectById(draftCoupon.getTenantId(), draftCoupon.getId()); + if(draftCouponChannelPoi != null && EnumSpuSyncStatus.sync_auditing.getCode().equals(draftCouponChannelPoi.getStatus())){ + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"商品数据流程中"); + } + + } + wxCoupon.setId(draftCoupon.getId()); + wxCoupon.setVersion(null); + } + } + + } + } diff --git a/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java b/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java index dbf599113..5294533f2 100644 --- a/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java +++ b/mallinkService/src/main/java/com/iformall/service/pay/service/share/wx/v2/WxPayShareService.java @@ -187,6 +187,7 @@ public class WxPayShareService extends PayShareBaseAdapterService{ try { wxProfitSharingQueryP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingQueryP),payAccount.getApiKey())); response = WxProfitSharing.queryOrder(BeanUtils.toStringMap(wxProfitSharingQueryP), payAccount.getCertPath(), payAccount.getMchId()); + log.info("shareQuer:{}"+response); }catch (Exception e){ throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getCode(), ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getMessage()+e.getMessage()); } diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 9a791c002..0ee7913cc 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -1607,4 +1607,11 @@ where c.`version` = 1 and coupon_id = #{couponId} and tenant_id = #{tenantId} + + +