| @@ -302,6 +302,50 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * 没有做效验 | |||||
| * @param wxCoupon | |||||
| * @return | |||||
| */ | |||||
| @ApiOperation("商场批量设置商户") | |||||
| @PostMapping("/setManyCouponMerchants") | |||||
| public ResultData setManyCouponMerchants(@RequestBody WxCoupon wxCoupon) { | |||||
| if(wxCoupon.getIds() == null || wxCoupon.getIds().isEmpty()){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "未选择需要修改的券/卡"); | |||||
| } | |||||
| if(wxCoupon.getMerchantIds() == null || wxCoupon.getMerchantIds().length <= 0){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "未选择需要添加删除的门店"); | |||||
| } | |||||
| List<Long> couponIds = wxCoupon.getIds(); | |||||
| List<Long> merchantIds = Arrays.asList(wxCoupon.getMerchantIds()); | |||||
| wxCouponService.addManyCouponMerchants(getTenantInfo(),couponIds,merchantIds); | |||||
| return new ResultData(); | |||||
| } | |||||
| /** | |||||
| * 没有做效验 | |||||
| * @param wxCoupon | |||||
| * @return | |||||
| */ | |||||
| @ApiOperation("商场批量设置商户") | |||||
| @PostMapping("/delManyCouponMerchants") | |||||
| public ResultData delManyCouponMerchants(@RequestBody WxCoupon wxCoupon) { | |||||
| if(wxCoupon.getIds() == null || wxCoupon.getIds().isEmpty()){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "未选择需要修改的券/卡"); | |||||
| } | |||||
| if(wxCoupon.getMerchantIds() == null || wxCoupon.getMerchantIds().length <= 0){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "未选择需要添加删除的门店"); | |||||
| } | |||||
| List<Long> couponIds = wxCoupon.getIds(); | |||||
| List<Long> merchantIds = Arrays.asList(wxCoupon.getMerchantIds()); | |||||
| wxCouponService.delManyCouponMerchants(getTenantInfo(),couponIds,merchantIds); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据id更新库存及有效期接口") | @ApiOperation("根据id更新库存及有效期接口") | ||||
| @PostMapping("updateStokeAndValidDate") | @PostMapping("updateStokeAndValidDate") | ||||
| @SystemControllerLog(description = "券投放-库存/有效期更新") | @SystemControllerLog(description = "券投放-库存/有效期更新") | ||||
| @@ -878,4 +922,5 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| @@ -23,4 +23,10 @@ public interface WxCouponMerchantMapper extends CommonMapper<WxCouponMerchant, L | |||||
| List<Long> findMerchantProductIds(@Param("tenantId")String tenantId,@Param("merchantIdList")List<Long> merchantIdList,@Param("status")Integer status); | List<Long> findMerchantProductIds(@Param("tenantId")String tenantId,@Param("merchantIdList")List<Long> merchantIdList,@Param("status")Integer status); | ||||
| List<Long> findMerchantByProductIds(@Param("tenantId")String tenantId,@Param("productIds")List<Long> productIds); | List<Long> findMerchantByProductIds(@Param("tenantId")String tenantId,@Param("productIds")List<Long> productIds); | ||||
| List<Long> findOnlyMerchantByProductIds(@Param("tenantId")String tenantId,@Param("productIds")List<Long> productIds); | List<Long> findOnlyMerchantByProductIds(@Param("tenantId")String tenantId,@Param("productIds")List<Long> productIds); | ||||
| int updateStatus(@Param("tenantId")String tenantId, @Param("productId")Long couponId, @Param("merchantIdList")List<Long> merchantIds,@Param("status")Integer status); | |||||
| int insertList(List<WxCouponMerchant> addList); | |||||
| } | } | ||||
| @@ -304,4 +304,7 @@ public interface WxCouponService { | |||||
| ResultData setCouponMerchants(TenantEntity tenantInfo, WxCoupon wxCoupon); | ResultData setCouponMerchants(TenantEntity tenantInfo, WxCoupon wxCoupon); | ||||
| void addManyCouponMerchants(TenantEntity tenantInfo, List<Long> couponIds, List<Long> merchantIds); | |||||
| void delManyCouponMerchants(TenantEntity tenantInfo, List<Long> couponIds, List<Long> merchantIds); | |||||
| } | } | ||||
| @@ -2008,5 +2008,46 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @Override | |||||
| @Transactional(rollbackFor = Exception.class) | |||||
| public void addManyCouponMerchants(TenantEntity tenantInfo, List<Long> couponIds, List<Long> merchantIds) { | |||||
| List<WxCouponMerchant> add = new ArrayList<>(); | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| Date now = new Date(); | |||||
| for (Long couponId:couponIds) { | |||||
| wxCouponMerchantMapper.updateStatus(tenantInfo.getTenantId(),couponId,merchantIds,EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | |||||
| List<Long> couponOldMerchants = wxCouponMerchantMapper.findMerchantIdListByProduct(couponId, tenantInfo.getTenantId()); | |||||
| List<Long> couponAddMerchants = new ArrayList<>(); | |||||
| couponAddMerchants.addAll(merchantIds); | |||||
| couponAddMerchants.removeAll(couponOldMerchants); | |||||
| if(!couponAddMerchants.isEmpty()){ | |||||
| for (Long addMerchant:couponAddMerchants) { | |||||
| WxCouponMerchant couponMerchant = new WxCouponMerchant(); | |||||
| couponMerchant.setId(idWorker.nextId()); | |||||
| couponMerchant.updateTenantInfo(tenantInfo); | |||||
| couponMerchant.setProductId(couponId); | |||||
| couponMerchant.setMerchantId(addMerchant); | |||||
| couponMerchant.setCreateDate(now); | |||||
| couponMerchant.setUpdateDate(now); | |||||
| couponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | |||||
| add.add(couponMerchant); | |||||
| } | |||||
| } | |||||
| } | |||||
| if(!add.isEmpty()){ | |||||
| wxCouponMerchantMapper.insertList(add); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| @Transactional(rollbackFor = Exception.class) | |||||
| public void delManyCouponMerchants(TenantEntity tenantInfo, List<Long> couponIds, List<Long> merchantIds) { | |||||
| for (Long couponId:couponIds) { | |||||
| wxCouponMerchantMapper.updateStatus(tenantInfo.getTenantId(),couponId,merchantIds,EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_INVALID.getCode()); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -167,7 +167,7 @@ | |||||
| GROUP BY product_id | GROUP BY product_id | ||||
| HAVING mc = 1 | HAVING mc = 1 | ||||
| <if test=" null != merchantIdList"> | <if test=" null != merchantIdList"> | ||||
| and wcm.merchant_id in | |||||
| and wcm.merchant_id in | |||||
| <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")"> | <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")"> | ||||
| #{merchantIdItem} | #{merchantIdItem} | ||||
| </foreach> | </foreach> | ||||
| @@ -191,5 +191,35 @@ | |||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <update id="updateStatus" parameterType="java.util.Map" > | |||||
| update wx_coupon_merchant set `status` = #{status},`update_date`=now() | |||||
| where tenant_id = #{tenantId} | |||||
| and status != #{status} | |||||
| and product_id = #{productId} | |||||
| and merchant_id in | |||||
| <foreach collection="merchantIdList" index="index" item="merchantIdItem" open="(" separator="," close=")"> | |||||
| #{merchantIdItem} | |||||
| </foreach> | |||||
| </update> | |||||
| <insert id="insertList" parameterType="java.util.List"> | |||||
| insert into wx_coupon_merchant | |||||
| (`id`,`tenant_id`,`parent_tenant_id`,`product_id`,`merchant_id`,`parameter`,`create_date`,`update_date`,`status`) | |||||
| values | |||||
| <foreach collection="list" item="item" index="index" separator=","> | |||||
| (#{item.id,jdbcType=BIGINT}, | |||||
| #{item.tenantId,jdbcType=VARCHAR}, | |||||
| #{item.parentTenantId,jdbcType=VARCHAR}, | |||||
| #{item.productId,jdbcType=BIGINT}, | |||||
| #{item.merchantId,jdbcType=BIGINT}, | |||||
| #{item.parameter,jdbcType=VARCHAR}, | |||||
| #{item.createDate,jdbcType=TIMESTAMP}, | |||||
| #{item.updateDate,jdbcType=TIMESTAMP}, | |||||
| #{item.status,jdbcType=INTEGER}) | |||||
| </foreach> | |||||
| </insert> | |||||
| </mapper> | </mapper> | ||||