| @@ -260,50 +260,10 @@ public class WxCouponController extends BaseController { | |||||
| return new ResultData(ResultData.ERROR, "缺少id"); | return new ResultData(ResultData.ERROR, "缺少id"); | ||||
| } | } | ||||
| wxCoupon.updateTenantInfo(getTenantInfo()); | 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; | return result; | ||||
| } | } | ||||
| @@ -103,7 +103,7 @@ public class SharingOrderRedoSchedule { | |||||
| + " MSG:" + e.getMessage()); | + " MSG:" + e.getMessage()); | ||||
| } | } | ||||
| //分账3天失败给通知 | //分账3天失败给通知 | ||||
| if(!isSuccess && i >= 1){ | |||||
| if(!isSuccess && i >= 5){ | |||||
| errorCount.getAndIncrement(); | errorCount.getAndIncrement(); | ||||
| } | } | ||||
| }); | }); | ||||
| @@ -128,4 +128,5 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> { | |||||
| WxCoupon selectDraftCoupon(@Param("couponId")Long id,@Param("tenantId")String tenantId); | WxCoupon selectDraftCoupon(@Param("couponId")Long id,@Param("tenantId")String tenantId); | ||||
| WxCoupon selectOnlineCoupon(@Param("id")Long id, @Param("tenantId")String tenantId); | |||||
| } | } | ||||
| @@ -311,4 +311,7 @@ public interface WxCouponService { | |||||
| void delManyCouponMerchants(TenantEntity tenantInfo, List<Long> couponIds, List<Long> merchantIds); | void delManyCouponMerchants(TenantEntity tenantInfo, List<Long> couponIds, List<Long> merchantIds); | ||||
| List<WxCoupon> getByIdListOrTitle(List<Long> couponIds, String tenantId, String title); | List<WxCoupon> getByIdListOrTitle(List<Long> couponIds, String tenantId, String title); | ||||
| void handleDraftCoupon(WxCoupon wxCoupon); | |||||
| } | } | ||||
| @@ -457,7 +457,7 @@ public class TtCouponGoodsServiceImpl implements TtCouponGoodsService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||||
| @Transactional(rollbackFor = Exception.class) | |||||
| public ResultData productDraftGet(TenantEntity tenantEntity,Long id,boolean isSaas) { | public ResultData productDraftGet(TenantEntity tenantEntity,Long id,boolean isSaas) { | ||||
| TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantEntity.getTenantId(),id); | TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(tenantEntity.getTenantId(),id); | ||||
| if(ttCouponChannelPoi == null){ | if(ttCouponChannelPoi == null){ | ||||
| @@ -36,6 +36,7 @@ import com.iformall.service.pay.PayServiceFactory; | |||||
| import com.iformall.service.pay.service.share.PayShareAdapterService; | import com.iformall.service.pay.service.share.PayShareAdapterService; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import org.apache.commons.beanutils.BeanUtils; | |||||
| import org.apache.commons.collections.CollectionUtils; | import org.apache.commons.collections.CollectionUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -2126,5 +2127,86 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| return wxCouponMapper.findList(coupon); | 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<WxCouponMall> 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<WxCouponMerchant> 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<WxCouponMerchant> 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); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -187,6 +187,7 @@ public class WxPayShareService extends PayShareBaseAdapterService{ | |||||
| try { | try { | ||||
| wxProfitSharingQueryP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingQueryP),payAccount.getApiKey())); | wxProfitSharingQueryP.setSign(WxPayment.createSignHMAC(BeanUtils.toStringMap(wxProfitSharingQueryP),payAccount.getApiKey())); | ||||
| response = WxProfitSharing.queryOrder(BeanUtils.toStringMap(wxProfitSharingQueryP), payAccount.getCertPath(), payAccount.getMchId()); | response = WxProfitSharing.queryOrder(BeanUtils.toStringMap(wxProfitSharingQueryP), payAccount.getCertPath(), payAccount.getMchId()); | ||||
| log.info("shareQuer:{}"+response); | |||||
| }catch (Exception e){ | }catch (Exception e){ | ||||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getCode(), ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getMessage()+e.getMessage()); | throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getCode(), ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getMessage()+e.getMessage()); | ||||
| } | } | ||||
| @@ -1607,4 +1607,11 @@ | |||||
| where c.`version` = 1 and coupon_id = #{couponId} and tenant_id = #{tenantId} | where c.`version` = 1 and coupon_id = #{couponId} and tenant_id = #{tenantId} | ||||
| </select> | </select> | ||||
| <select id="selectOnlineCoupon" parameterType="java.util.HashMap" resultMap="BaseResultMap"> | |||||
| select <include refid="allColumns"/> ,c.html,c.gift_list,c.product_attrs,c.sku_attrs | |||||
| from wx_coupon c | |||||
| where id = #{id} and tenant_id = #{tenantId} | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||