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 8d2d6e84f..be1fd820b 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCouponController.java @@ -55,6 +55,8 @@ public class WxCouponController extends BaseController { @Autowired private WxMallService wxMallService; @Autowired + private WxCouponMallService wxCouponMallService; + @Autowired RedisLock redisLock; @Autowired @@ -573,5 +575,57 @@ public class WxCouponController extends BaseController { CouponCacheUtils.removeCouponCache(redisTemplate, wxCoupon.getId()); return result; } + + @ApiOperation("集团查询:查询平台券商场列表") + @GetMapping("/getPlatMallList") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) + public ResultData getPlatMallList(@RequestParam Long id) { + WxCouponMall wxCouponMall = new WxCouponMall(); + wxCouponMall.updateTenantInfo(getTenantInfo()); + wxCouponMall.setProductId(id); + return new ResultData(wxCouponMallService.list(wxCouponMall)); + } + + @ApiOperation("商场查询:平台券列表") + @GetMapping("/couponMalls") + @ApiImplicitParams({ + @ApiImplicitParam(name = "ids", value = "ids[]", dataType = "Long", paramType = "query", required = true)}) + public ResultData getMallList(Long[] ids) { + if (null == ids || ids.length <= 0 ) { + return new ResultData(ResultData.ERROR, "缺少参数ids"); + } + WxCouponMall wxCouponMall = new WxCouponMall(); + TenantEntity tenantEntity = getTenantInfo(); + if (null == tenantEntity.getParentTenantId()) { + wxCouponMall.updateTenantInfo(tenantEntity); + }else { + wxCouponMall.setTenantId(tenantEntity.getParentTenantId()); + } + //一个商场,每个平台券只有一条记录 + wxCouponMall.setMallTenantId(tenantEntity.getTenantId()); + wxCouponMall.setProductIds(Arrays.asList(ids)); + List mallList= wxCouponMallService.list(wxCouponMall); + if (null == mallList || mallList.size() <= 0 ) { + return new ResultData(); + } + Map productMallMap = new HashMap(); + for (int i = 0 ; i < mallList.size(); i ++) { + WxCouponMall cm = mallList.get(i); + productMallMap.put(cm.getProductId(), cm); + } + return new ResultData(productMallMap); + } + + @ApiOperation("商场设置平台券商户") + @PostMapping("/setMerchants") + public ResultData setMerchant(@RequestBody WxCoupon wxCoupon) { + wxCoupon.updateTenantInfo(getTenantInfo()); + try { + wxCouponService.setCouponMerchants(wxCoupon); + } catch (Exception e) { + return new ResultData(Result.ERROR,e.getMessage()); + } + return new ResultData(); + } } diff --git a/mallinkAdmin/src/main/resources/db/migration/V2022111500001__plat_coupon.sql b/mallinkAdmin/src/main/resources/db/migration/V2022111500001__plat_coupon.sql new file mode 100644 index 000000000..24fb769f7 --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V2022111500001__plat_coupon.sql @@ -0,0 +1,113 @@ +CREATE TABLE `wx_coupon_mall` ( + `id` bigint(20) NOT NULL, + `tenant_id` varchar(5) NOT NULL, + `parent_tenant_id` varchar(5) DEFAULT NULL, + `product_id` bigint(20) NOT NULL, + `mall_tenant_id` varchar(5) NOT NULL, + `create_date` datetime DEFAULT NULL, + `update_date` datetime DEFAULT NULL, + `status` int(1) NOT NULL DEFAULT '0' COMMENT '0-未就绪,1-已就绪', + PRIMARY KEY (`id`), + UNIQUE KEY `UNIQUE_P_M` (`product_id`,`mall_tenant_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +create table wx_coupon_mall_0 like wx_coupon_mall; +create table wx_coupon_mall_1 like wx_coupon_mall; +create table wx_coupon_mall_2 like wx_coupon_mall; +create table wx_coupon_mall_3 like wx_coupon_mall; +create table wx_coupon_mall_4 like wx_coupon_mall; +create table wx_coupon_mall_5 like wx_coupon_mall; +create table wx_coupon_mall_6 like wx_coupon_mall; +create table wx_coupon_mall_7 like wx_coupon_mall; +create table wx_coupon_mall_8 like wx_coupon_mall; +create table wx_coupon_mall_9 like wx_coupon_mall; +create table wx_coupon_mall_10 like wx_coupon_mall; +create table wx_coupon_mall_11 like wx_coupon_mall; +create table wx_coupon_mall_12 like wx_coupon_mall; +create table wx_coupon_mall_13 like wx_coupon_mall; +create table wx_coupon_mall_14 like wx_coupon_mall; +create table wx_coupon_mall_15 like wx_coupon_mall; +create table wx_coupon_mall_16 like wx_coupon_mall; +create table wx_coupon_mall_17 like wx_coupon_mall; +create table wx_coupon_mall_18 like wx_coupon_mall; +create table wx_coupon_mall_19 like wx_coupon_mall; +create table wx_coupon_mall_20 like wx_coupon_mall; +create table wx_coupon_mall_21 like wx_coupon_mall; +create table wx_coupon_mall_22 like wx_coupon_mall; +create table wx_coupon_mall_23 like wx_coupon_mall; +create table wx_coupon_mall_24 like wx_coupon_mall; +create table wx_coupon_mall_25 like wx_coupon_mall; +create table wx_coupon_mall_26 like wx_coupon_mall; +create table wx_coupon_mall_27 like wx_coupon_mall; +create table wx_coupon_mall_28 like wx_coupon_mall; +create table wx_coupon_mall_29 like wx_coupon_mall; +create table wx_coupon_mall_30 like wx_coupon_mall; +create table wx_coupon_mall_31 like wx_coupon_mall; +create table wx_coupon_mall_32 like wx_coupon_mall; +create table wx_coupon_mall_33 like wx_coupon_mall; +create table wx_coupon_mall_34 like wx_coupon_mall; +create table wx_coupon_mall_35 like wx_coupon_mall; +create table wx_coupon_mall_36 like wx_coupon_mall; +create table wx_coupon_mall_37 like wx_coupon_mall; +create table wx_coupon_mall_38 like wx_coupon_mall; +create table wx_coupon_mall_39 like wx_coupon_mall; +create table wx_coupon_mall_40 like wx_coupon_mall; +create table wx_coupon_mall_41 like wx_coupon_mall; +create table wx_coupon_mall_42 like wx_coupon_mall; +create table wx_coupon_mall_43 like wx_coupon_mall; +create table wx_coupon_mall_44 like wx_coupon_mall; +create table wx_coupon_mall_45 like wx_coupon_mall; +create table wx_coupon_mall_46 like wx_coupon_mall; +create table wx_coupon_mall_47 like wx_coupon_mall; +create table wx_coupon_mall_48 like wx_coupon_mall; +create table wx_coupon_mall_49 like wx_coupon_mall; +create table wx_coupon_mall_50 like wx_coupon_mall; +create table wx_coupon_mall_51 like wx_coupon_mall; +create table wx_coupon_mall_52 like wx_coupon_mall; +create table wx_coupon_mall_53 like wx_coupon_mall; +create table wx_coupon_mall_54 like wx_coupon_mall; +create table wx_coupon_mall_55 like wx_coupon_mall; +create table wx_coupon_mall_56 like wx_coupon_mall; +create table wx_coupon_mall_57 like wx_coupon_mall; +create table wx_coupon_mall_58 like wx_coupon_mall; +create table wx_coupon_mall_59 like wx_coupon_mall; +create table wx_coupon_mall_60 like wx_coupon_mall; +create table wx_coupon_mall_61 like wx_coupon_mall; +create table wx_coupon_mall_62 like wx_coupon_mall; +create table wx_coupon_mall_63 like wx_coupon_mall; +create table wx_coupon_mall_64 like wx_coupon_mall; +create table wx_coupon_mall_65 like wx_coupon_mall; +create table wx_coupon_mall_66 like wx_coupon_mall; +create table wx_coupon_mall_67 like wx_coupon_mall; +create table wx_coupon_mall_68 like wx_coupon_mall; +create table wx_coupon_mall_69 like wx_coupon_mall; +create table wx_coupon_mall_70 like wx_coupon_mall; +create table wx_coupon_mall_71 like wx_coupon_mall; +create table wx_coupon_mall_72 like wx_coupon_mall; +create table wx_coupon_mall_73 like wx_coupon_mall; +create table wx_coupon_mall_74 like wx_coupon_mall; +create table wx_coupon_mall_75 like wx_coupon_mall; +create table wx_coupon_mall_76 like wx_coupon_mall; +create table wx_coupon_mall_77 like wx_coupon_mall; +create table wx_coupon_mall_78 like wx_coupon_mall; +create table wx_coupon_mall_79 like wx_coupon_mall; +create table wx_coupon_mall_80 like wx_coupon_mall; +create table wx_coupon_mall_81 like wx_coupon_mall; +create table wx_coupon_mall_82 like wx_coupon_mall; +create table wx_coupon_mall_83 like wx_coupon_mall; +create table wx_coupon_mall_84 like wx_coupon_mall; +create table wx_coupon_mall_85 like wx_coupon_mall; +create table wx_coupon_mall_86 like wx_coupon_mall; +create table wx_coupon_mall_87 like wx_coupon_mall; +create table wx_coupon_mall_88 like wx_coupon_mall; +create table wx_coupon_mall_89 like wx_coupon_mall; +create table wx_coupon_mall_90 like wx_coupon_mall; +create table wx_coupon_mall_91 like wx_coupon_mall; +create table wx_coupon_mall_92 like wx_coupon_mall; +create table wx_coupon_mall_93 like wx_coupon_mall; +create table wx_coupon_mall_94 like wx_coupon_mall; +create table wx_coupon_mall_95 like wx_coupon_mall; +create table wx_coupon_mall_96 like wx_coupon_mall; +create table wx_coupon_mall_97 like wx_coupon_mall; +create table wx_coupon_mall_98 like wx_coupon_mall; +create table wx_coupon_mall_99 like wx_coupon_mall; \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java b/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java index edf813cbd..d9da5085b 100644 --- a/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java +++ b/mallinkService/src/main/java/com/iformall/config/BaseMyBatisConfiguration.java @@ -323,6 +323,13 @@ public class BaseMyBatisConfiguration { wxPressBatchItemSharding.setRule(EnumShardingRule.HASH.getCode()); shardingList.add(wxPressBatchItemSharding); + ShardingSphere wxCouponMallSharding = new ShardingSphere(); + wxCouponMallSharding.setColumn("tenant_id"); + wxCouponMallSharding.setTableName("wx_coupon_mall"); + wxCouponMallSharding.setCount(100); + wxCouponMallSharding.setRule(EnumShardingRule.HASH.getCode()); + shardingList.add(wxCouponMallSharding); + //初始化 shardingSpherePlugin.setShardingSpheres(shardingList); Properties properties = new Properties(); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponMall.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponMall.java new file mode 100644 index 000000000..22e8c9c18 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponMall.java @@ -0,0 +1,33 @@ +package com.iformall.domain.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.iformall.domain.po.base.TenantEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; +import java.util.List; + +@TableName(value = "wx_coupon_mall") +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCouponMall extends TenantEntity { + + private static final long serialVersionUID = -2285755324480617990L; + + protected Long id; + + @io.swagger.annotations.ApiModelProperty(value="",name="productId") + private Long productId; + @TableField(exist = false) + private List productIds; + @io.swagger.annotations.ApiModelProperty(value="",name="mallTenantId") + private String mallTenantId; + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + @io.swagger.annotations.ApiModelProperty(value="修改时间",name="updateDate") + private Date updateDate; + @io.swagger.annotations.ApiModelProperty(value="状态",name="status") + private Integer status; +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMallMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMallMapper.java new file mode 100644 index 000000000..8730942fd --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMallMapper.java @@ -0,0 +1,16 @@ +package com.iformall.mapper; + + +import com.iformall.common.CommonMapper; +import com.iformall.domain.po.WxCouponMall; + +import java.util.List; +import java.util.Map; + +import org.apache.ibatis.annotations.Param; + +public interface WxCouponMallMapper extends CommonMapper { + + List findList(WxCouponMall wxCouponMerchant); + List findMerchantListByProduct(@Param("productId")Long productId,@Param("tenantId")String tenantId); +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponMallService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponMallService.java new file mode 100644 index 000000000..97b23d0f0 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponMallService.java @@ -0,0 +1,27 @@ +package com.iformall.service; + +import java.util.*; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.ResultData; +import com.iformall.domain.po.TtCouponChannelPoi; +import com.iformall.domain.po.WxAppinfo; +import com.iformall.domain.po.WxCoupon; +import com.iformall.domain.po.WxCouponMall; +import com.iformall.domain.po.WxMerchant; +import com.iformall.domain.po.base.TenantEntity; +import com.iformall.domain.vo.TtCouponVo; +import com.iformall.domain.vo.WxCouponCVo; +import com.iformall.domain.vo.WxCouponStatisVo; +import com.iformall.domain.vo.WxMerchantVo; + +public interface WxCouponMallService { + + PageInfo listAsPage(WxCouponMall record, Integer pageIndex, Integer pageSize); + + List list(WxCouponMall wxCouponMall); + +} diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java index 6411ad043..266f2a9c4 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponService.java @@ -287,4 +287,6 @@ public interface WxCouponService { * @return */ ResultData disable(TenantEntity tenantInfo, Long couponId); + + void setCouponMerchants(WxCoupon wxCoupon) throws Exception; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponMallServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponMallServiceImpl.java new file mode 100644 index 000000000..82cc1f89e --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponMallServiceImpl.java @@ -0,0 +1,31 @@ +package com.iformall.service.impl; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.*; +import com.iformall.mapper.*; +import com.iformall.service.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.*; + +@Service +public class WxCouponMallServiceImpl implements WxCouponMallService { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + WxCouponMallMapper wxCouponMallMapper; + + @Override + public List list(WxCouponMall wxCouponMall){ + return wxCouponMallMapper.findList(wxCouponMall); + } + + @Override + public PageInfo listAsPage(WxCouponMall record, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponMallMapper.findList(record)); + } + +} 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 1bd98f61c..4ed45446c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -440,19 +440,13 @@ public class WxCouponServiceImpl implements WxCouponService { if(Result.SUCCESS != giftResult.code){ return giftResult; } - - ResultData receiverResult = checkCouponMerchantReceiver(record); - if(Result.SUCCESS != receiverResult.code){ - return receiverResult; - } - List merchantList = (List) receiverResult.data; - - if(merchantList.size() > 1){ - record.setBusiness(EnumBusiness.BUSINESS_ID6.getCode()); - }else{ - record.setBusiness(merchantList.get(0).getBusinessId()); - record.setSubBusiness(merchantList.get(0).getSubBusinessId()); - } + + try { + checkCouponMerchantReceiverAndUpdate(record); + }catch(Exception e) { + return new ResultData(Result.ERROR,e.getMessage()); + } + List merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); @@ -500,41 +494,7 @@ public class WxCouponServiceImpl implements WxCouponService { record.setInventory(oldCoupon.getInventory() + record.getRemainInventory() - oldCoupon.getRemainInventory()); } } - - WxCouponMerchant cmParam = new WxCouponMerchant(); - cmParam.updateTenantInfo(record); - cmParam.setProductId(record.getId()); - List oldList = wxCouponMerchantMapper.findList(cmParam); - merchantParamList.stream().forEach(merchantParam -> { - WxCouponMerchant cm = new WxCouponMerchant(); - WxCouponMerchantDto wxCouponMerchantDto = parseMerchantParam(merchantParam); - cm.updateTenantInfo(record); - cm.setMerchantId(wxCouponMerchantDto.getMerchantId()); - cm.setProductId(record.getId()); - WxCouponMerchant rcm = wxCouponMerchantMapper.selectOne(new QueryWrapper<>(cm)); - if (rcm != null) { - rcm.setParameter(wxCouponMerchantDto.getParameter()); - rcm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); - rcm.setUpdateDate(new Date()); - wxCouponMerchantMapper.updateById(rcm); - }else { - cm.setId(idWorker.nextId()); - cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); - cm.setParameter(wxCouponMerchantDto.getParameter()); - cm.setCreateDate(new Date()); - cm.setUpdateDate(new Date()); - wxCouponMerchantMapper.insert(cm); - } - oldList.removeIf( - old->old.getProductId().equals(record.getId()) && - old.getMerchantId().equals(wxCouponMerchantDto.getMerchantId())); - }); - - oldList.stream().forEach(old->{ - old.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_INVALID.getCode()); - old.setUpdateDate(new Date()); - wxCouponMerchantMapper.updateById(old); - }); + updateCouponMerchants(record,merchantParamList,idWorker); record.setUpdateDate(new Date()); wxCouponMapper.updateById(record); @@ -545,11 +505,62 @@ public class WxCouponServiceImpl implements WxCouponService { return new ResultData(record.getId()); } - private ResultData checkCouponMerchantReceiver(WxCoupon record){ + private void updateCouponMerchants(WxCoupon record,List merchantParamList,final IdWorker idWorker) { + WxCouponMerchant cmParam = new WxCouponMerchant(); + cmParam.updateTenantInfo(record); + cmParam.setProductId(record.getId()); + List oldList = wxCouponMerchantMapper.findList(cmParam); + merchantParamList.stream().forEach(merchantParam -> { + WxCouponMerchant cm = new WxCouponMerchant(); + WxCouponMerchantDto wxCouponMerchantDto = parseMerchantParam(merchantParam); + cm.updateTenantInfo(record); + cm.setMerchantId(wxCouponMerchantDto.getMerchantId()); + cm.setProductId(record.getId()); + WxCouponMerchant rcm = wxCouponMerchantMapper.selectOne(new QueryWrapper<>(cm)); + if (rcm != null) { + rcm.setParameter(wxCouponMerchantDto.getParameter()); + rcm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); + rcm.setUpdateDate(new Date()); + wxCouponMerchantMapper.updateById(rcm); + }else { + cm.setId(idWorker.nextId()); + cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); + cm.setParameter(wxCouponMerchantDto.getParameter()); + cm.setCreateDate(new Date()); + cm.setUpdateDate(new Date()); + wxCouponMerchantMapper.insert(cm); + } + oldList.removeIf( + old->old.getProductId().equals(record.getId()) && + old.getMerchantId().equals(wxCouponMerchantDto.getMerchantId())); + }); + + oldList.stream().forEach(old->{ + old.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_INVALID.getCode()); + old.setUpdateDate(new Date()); + wxCouponMerchantMapper.updateById(old); + }); + } + + private void checkCouponMerchantReceiverAndUpdate(WxCoupon wxCoupon) throws Exception{ + try { + List merchantList = checkCouponMerchantReceiver(wxCoupon); + if(merchantList.size() > 1){ + wxCoupon.setBusiness(EnumBusiness.BUSINESS_ID6.getCode()); + }else{ + wxCoupon.setBusiness(merchantList.get(0).getBusinessId()); + wxCoupon.setSubBusiness(merchantList.get(0).getSubBusinessId()); + } + }catch (Exception e) { + throw e; + } + } + + private List checkCouponMerchantReceiver(WxCoupon record) throws Exception{ List merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); if(merchantParamList == null || merchantParamList.isEmpty()){ - return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),"所属商户为空"); + throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND.getCode(),"所属商户为空"); } List merchantIds = new ArrayList<>(); for (JSONObject o:merchantParamList) { @@ -560,12 +571,12 @@ public class WxCouponServiceImpl implements WxCouponService { merchantQ.setIds(merchantIds); List merchantList = wxMerchantService.findList(merchantQ); if(merchantList.size() != merchantParamList.size()){ - return new ResultData(ErrorCode.MERCHANT_INFO_NOT_EQUAL.getCode(),"所属商户信息异常"); + throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_EQUAL.getCode(),"所属商户信息异常"); } List badMerchant = merchantList.stream().filter(m -> !EnumMerchantStatus.VALID.getCode().equals(m.getStatus())).collect(toList()); if(badMerchant != null && !badMerchant.isEmpty()){ List badNames = badMerchant.stream().map(WxMerchant::getName).collect(toList()); - return new ResultData(ErrorCode.MERCHANT_INFO_NOT_VALID.getCode(),JSONArray.toJSONString(badNames)+"被停用"); + throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_VALID.getCode(),JSONArray.toJSONString(badNames)+"被停用"); } if(record.getSalePrice() != null && record.getSalePrice() > 0) { @@ -573,11 +584,11 @@ public class WxCouponServiceImpl implements WxCouponService { EnumPayWay payWay = EnumAppPlat.getPayWay(plat); WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(record,plat); if (cAppInfo == null) { - return new ResultData(ErrorCode.APP_ID_NOT_FOUND); + throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); } WxPayAccount payAccount = payAccountMapper.selectById(cAppInfo.getPayId()); if (payAccount == null) { - return new ResultData(ErrorCode.APP_ID_NOT_FOUND); + throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); } //判断商户是否匹配poi @@ -590,7 +601,7 @@ public class WxCouponServiceImpl implements WxCouponService { } } if(!badPoiNames.isEmpty()){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), JSONArray.toJSONString(badPoiNames)+"未匹配poi"); + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), JSONArray.toJSONString(badPoiNames)+"未匹配poi"); } } @@ -607,9 +618,9 @@ public class WxCouponServiceImpl implements WxCouponService { }else{ List adminMerchant = merchantList.stream().filter(m -> EnumMerchantAdmin.PUBLIC_ADMIN.getCode().equals(m.getIsAdmin())).collect(toList()); if(adminMerchant == null || adminMerchant.isEmpty()){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "多门店券需包含一个商管商户"); + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "多门店券需包含一个商管商户"); }else if(adminMerchant.size() > 1){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "多门店券只能包含一个商管商户"); + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "多门店券只能包含一个商管商户"); } record.setMerchantType(EnumCouponMerchantType.MULTIPLE_MERCHANT.getCode()); makeMerchant = adminMerchant.get(0); @@ -619,13 +630,13 @@ public class WxCouponServiceImpl implements WxCouponService { WxProfitSharingReceiver receiver = payShareServie.getReceiver(payAccount, makeMerchant.getId(), null, payMchType.getCode()); if (receiver == null) { - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "[\""+makeMerchant.getName()+"\"]未配置收款账户"); + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "[\""+makeMerchant.getName()+"\"]未配置收款账户"); } if (EnumAppPlat.TOUTIAO.equals(plat)) { if (!MerchantImportStatus.improt_success.getCode().equals(receiver.getWxImportStatus()) && !MerchantImportStatus.improt_success.getCode().equals(receiver.getAlipayImportStatus()) && !MerchantImportStatus.improt_success.getCode().equals(receiver.getHzImportStatus())) { - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "[\""+makeMerchant.getName()+"\"]未配置收款账户"); + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "[\""+makeMerchant.getName()+"\"]未配置收款账户"); } } } else if (EnumPayShare.YES.equals(isShare)) { @@ -643,7 +654,7 @@ public class WxCouponServiceImpl implements WxCouponService { if(!EnumYesOrNo.YES.getCode().equals(openPayResult.getAlipay()) && !EnumYesOrNo.YES.getCode().equals(openPayResult.getWx()) && !EnumYesOrNo.YES.getCode().equals(openPayResult.getHz())){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "分账模式未设置开通支付渠道"); + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "分账模式未设置开通支付渠道"); } if(EnumYesOrNo.YES.getCode().equals(openPayResult.getAlipay()) && !MerchantImportStatus.improt_success.getCode().equals(receiver.getAlipayImportStatus())){ @@ -663,11 +674,11 @@ public class WxCouponServiceImpl implements WxCouponService { } } if(!badNames.isEmpty()){ - return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), JSONArray.toJSONString(badNames)+"未配置分账账户"); + throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), JSONArray.toJSONString(badNames)+"未配置分账账户"); } } } - return new ResultData(merchantList); + return merchantList; } @Override @@ -1320,4 +1331,17 @@ public class WxCouponServiceImpl implements WxCouponService { return new ResultData(); } + @Override + public void setCouponMerchants(WxCoupon wxCoupon) throws Exception { + try { + checkCouponMerchantReceiverAndUpdate(wxCoupon); + List merchantParamList = JSONObject.parseArray(wxCoupon.getMerchantParams(), JSONObject.class); + final IdWorker idWorker = IdWorker.get(); + updateCouponMerchants(wxCoupon,merchantParamList,idWorker); + }catch(Exception e) { + throw e; + } + } + + } diff --git a/mallinkService/src/main/resources/mapper/WxCouponMallMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMallMapper.xml new file mode 100644 index 000000000..7a5c012ce --- /dev/null +++ b/mallinkService/src/main/resources/mapper/WxCouponMallMapper.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + `id`,`tenant_id`,`parent_tenant_id`,`product_id`,`mall_tenant_id`,`create_date`,`update_date`,`status` + + + + where 1 = 1 + + + and `id` = #{id} + + + + and `tenant_id` = #{tenantId} + + + and `parent_tenant_id` = #{parentTenantId} + + + and `product_id` = #{productId} + + + + + and `mall_tenant_id` = #{mallTenantId} + + + + + and `create_date` = #{createDate} + + + + + and `update_date` = #{updateDate} + + + + + and `status` = #{status} + + + + + and id in + + #{idItem} + + + + and product_id in + + #{productIdItem} + + + + order by ${sortColumns} + + + + + + +