| @@ -13,6 +13,7 @@ import com.iformall.domain.vo.TtCouponVo; | |||||
| import com.iformall.domain.vo.WxCouponStatisVo; | import com.iformall.domain.vo.WxCouponStatisVo; | ||||
| import com.iformall.douyin.web.bean.GoodsTemplateGet; | import com.iformall.douyin.web.bean.GoodsTemplateGet; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.WxCouponChannelMapper; | import com.iformall.mapper.WxCouponChannelMapper; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import com.iformall.service.util.CouponCacheUtils; | import com.iformall.service.util.CouponCacheUtils; | ||||
| @@ -279,6 +280,26 @@ public class WxCouponController extends BaseController { | |||||
| return result; | return result; | ||||
| } | } | ||||
| @ApiOperation("商场设置商户") | |||||
| @PostMapping("/setCouponMerchants") | |||||
| public ResultData setCouponMerchants(@RequestBody WxCoupon wxCoupon) { | |||||
| if(wxCoupon.getId() == null){ | |||||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||||
| } | |||||
| if(StringUtils.isBlank(wxCoupon.getMerchantParams())){ | |||||
| return new ResultData(ResultData.ERROR, "缺少商户信息"); | |||||
| } | |||||
| try { | |||||
| ResultData resultData = wxCouponService.setCouponMerchants(getTenantInfo(), wxCoupon); | |||||
| return resultData; | |||||
| } catch (MallinkException e) { | |||||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||||
| } | |||||
| catch (Exception e) { | |||||
| return new ResultData(Result.ERROR,e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("根据id更新库存及有效期接口") | @ApiOperation("根据id更新库存及有效期接口") | ||||
| @PostMapping("updateStokeAndValidDate") | @PostMapping("updateStokeAndValidDate") | ||||
| @SystemControllerLog(description = "券投放-库存/有效期更新") | @SystemControllerLog(description = "券投放-库存/有效期更新") | ||||
| @@ -301,4 +301,7 @@ public interface WxCouponService { | |||||
| boolean isCouponMerchantValid(Long couponId,Integer couponType,TenantEntity couponTenantEntity); | boolean isCouponMerchantValid(Long couponId,Integer couponType,TenantEntity couponTenantEntity); | ||||
| Integer getCategoryId(TenantEntity tenantEntity, Long couponId); | Integer getCategoryId(TenantEntity tenantEntity, Long couponId); | ||||
| ResultData setCouponMerchants(TenantEntity tenantInfo, WxCoupon wxCoupon); | |||||
| } | } | ||||
| @@ -1976,5 +1976,37 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| return wxCouponMapper.findCategoryIdById(couponId,tenantEntity.getTenantId()); | return wxCouponMapper.findCategoryIdById(couponId,tenantEntity.getTenantId()); | ||||
| } | } | ||||
| @Override | |||||
| public ResultData setCouponMerchants(TenantEntity tenantInfo, WxCoupon wxCoupon) { | |||||
| WxCoupon record = wxCouponMapper.selectById(wxCoupon.getId(), tenantInfo.getTenantId()); | |||||
| if (null == record) { | |||||
| throw new MallinkException(Result.ERROR,"未查询到券"); | |||||
| } | |||||
| record.setMerchantParams(wxCoupon.getMerchantParams()); | |||||
| //判断直连检查收款帐号(必须),总分模式直接收款到小程序的收款帐号 | |||||
| ResultData merchantResultData = checkCouponMakeMerchant(record); | |||||
| if(Result.SUCCESS != merchantResultData.code){ | |||||
| return merchantResultData; | |||||
| } | |||||
| try { | |||||
| Map<TenantEntity,String> tenantMerchantMap = checkCouponMerchantReceiver(record, true); | |||||
| }catch(MallinkException e){ | |||||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||||
| }catch(Exception e) { | |||||
| return new ResultData(Result.ERROR,e.getMessage()); | |||||
| } | |||||
| try { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| updateCouponMerchants(record,idWorker); | |||||
| } catch (Exception e) { | |||||
| logger.error("updateCouponMerchants error.",e); | |||||
| return new ResultData(Result.ERROR,"更新商户出错。"+e.getMessage()); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| } | } | ||||