| @@ -625,5 +625,44 @@ public class WxCouponController extends BaseController { | |||||
| } | } | ||||
| } | } | ||||
| @ApiOperation("商场设置平台券已完成") | |||||
| @PostMapping("/setPlatCouponFinished") | |||||
| public ResultData setPlatCouponFinished(@RequestBody WxCoupon wxCoupon) { | |||||
| try { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| String mallTenantId = tenantEntity.getTenantId(); | |||||
| String tenantId = tenantEntity.getTenantId(); | |||||
| if (null != tenantEntity.getParentTenantId()) { | |||||
| tenantId = tenantEntity.getParentTenantId(); | |||||
| } | |||||
| wxCouponMallService.finised(tenantId, wxCoupon.getId(), mallTenantId); | |||||
| return new ResultData(); | |||||
| } catch (Exception e) { | |||||
| return new ResultData(Result.ERROR,e.getMessage()); | |||||
| } | |||||
| } | |||||
| @ApiOperation("商场设置平台券已完成") | |||||
| @PostMapping("/setPlatCouponUnFinished") | |||||
| public ResultData setPlatCouponUnFinished(@RequestBody WxCoupon wxCoupon) { | |||||
| try { | |||||
| if (null == wxCoupon.getType()) { | |||||
| return new ResultData(Result.ERROR,"缺少参数"); | |||||
| } | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| String mallTenantId = tenantEntity.getTenantId(); | |||||
| String tenantId = tenantEntity.getTenantId(); | |||||
| if (null != tenantEntity.getParentTenantId()) { | |||||
| tenantId = tenantEntity.getParentTenantId(); | |||||
| } | |||||
| wxCouponMallService.unfinised(tenantId, wxCoupon.getId(),wxCoupon.getType(), mallTenantId); | |||||
| return new ResultData(); | |||||
| } catch (Exception e) { | |||||
| return new ResultData(Result.ERROR,e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -32,7 +32,7 @@ public class TtCouponChannelPoi extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="描述",name="statusDesc") | @io.swagger.annotations.ApiModelProperty(value="描述",name="statusDesc") | ||||
| private String statusDesc; | private String statusDesc; | ||||
| @io.swagger.annotations.ApiModelProperty(value="状态:0-审核中,1-上架,2-下架,3-审核拒绝 4-审核通过",name="lastStatus") | |||||
| @io.swagger.annotations.ApiModelProperty(value="EnumSpuSyncStatus状态:0-审核中,1-上架,2-下架,3-审核拒绝 4-审核通过",name="lastStatus") | |||||
| private Integer lastStatus; | private Integer lastStatus; | ||||
| @io.swagger.annotations.ApiModelProperty(value="描述",name="lastStatusDesc") | @io.swagger.annotations.ApiModelProperty(value="描述",name="lastStatusDesc") | ||||
| @@ -0,0 +1,36 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumCouponMallStatus { | |||||
| UNFINISED(0, "未设置完成"), | |||||
| FINISED(1, "已设置完成") | |||||
| ; | |||||
| public static EnumCouponMallStatus getEnum(Integer code) { | |||||
| for (EnumCouponMallStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumCouponMallStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -38,4 +38,15 @@ public enum EnumSpuSyncStatus { | |||||
| public String getMessage() { | public String getMessage() { | ||||
| return message; | return message; | ||||
| } | } | ||||
| public static boolean isValid(Integer code) { | |||||
| if (code == sync_auditing.getCode()) { | |||||
| return true; | |||||
| }else if (code == sync_put_on.getCode()) { | |||||
| return true; | |||||
| }else if (code == sync_audit_pass.getCode()) { | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| } | } | ||||
| @@ -3,6 +3,7 @@ package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
| import com.iformall.domain.po.WxCouponMall; | import com.iformall.domain.po.WxCouponMall; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -11,6 +12,6 @@ import org.apache.ibatis.annotations.Param; | |||||
| public interface WxCouponMallMapper extends CommonMapper<WxCouponMall, Long> { | public interface WxCouponMallMapper extends CommonMapper<WxCouponMall, Long> { | ||||
| List<WxCouponMall> findList(WxCouponMall wxCouponMerchant); | |||||
| List<WxCouponMall> findMerchantListByProduct(@Param("productId")Long productId,@Param("tenantId")String tenantId); | |||||
| List<WxCouponMall> findList(WxCouponMall wxCouponMall); | |||||
| void updateStatus(WxCouponMall wxCouponMall); | |||||
| } | } | ||||
| @@ -24,4 +24,7 @@ public interface WxCouponMallService { | |||||
| List<WxCouponMall> list(WxCouponMall wxCouponMall); | List<WxCouponMall> list(WxCouponMall wxCouponMall); | ||||
| void finised(String tenantId,Long couponId,String mallTenantId); | |||||
| void unfinised(String tenantId, Long couponId,Integer couponType, String mallTenantId) throws Exception; | |||||
| } | } | ||||
| @@ -2,7 +2,15 @@ package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.enums.EnumAppPlat; | |||||
| import com.iformall.enums.EnumCouponChannelStatus; | |||||
| import com.iformall.enums.EnumCouponMallStatus; | |||||
| import com.iformall.enums.EnumCouponType; | |||||
| import com.iformall.enums.EnumSpuSyncStatus; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.*; | import com.iformall.service.*; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| @@ -17,6 +25,10 @@ public class WxCouponMallServiceImpl implements WxCouponMallService { | |||||
| @Autowired | @Autowired | ||||
| WxCouponMallMapper wxCouponMallMapper; | WxCouponMallMapper wxCouponMallMapper; | ||||
| @Autowired | |||||
| TtCouponChannelPoiMapper ttCouponChannelPoiMapper; | |||||
| @Autowired | |||||
| WxCouponChannelMapper wxCouponChannelMapper; | |||||
| @Override | @Override | ||||
| public List<WxCouponMall> list(WxCouponMall wxCouponMall){ | public List<WxCouponMall> list(WxCouponMall wxCouponMall){ | ||||
| @@ -28,4 +40,40 @@ public class WxCouponMallServiceImpl implements WxCouponMallService { | |||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponMallMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponMallMapper.findList(record)); | ||||
| } | } | ||||
| @Override | |||||
| public void finised(String tenantId, Long couponId, String mallTenantId) { | |||||
| WxCouponMall couponMall = new WxCouponMall(); | |||||
| couponMall.setTenantId(tenantId); | |||||
| couponMall.setMallTenantId(mallTenantId); | |||||
| couponMall.setProductId(couponId); | |||||
| couponMall.setStatus(EnumCouponMallStatus.FINISED.getCode()); | |||||
| wxCouponMallMapper.updateStatus(couponMall); | |||||
| } | |||||
| @Override | |||||
| public void unfinised(String tenantId, Long couponId,Integer couponType, String mallTenantId) throws Exception{ | |||||
| //抖音平台查询的是未提交抖音审核的,微信是未上架的 | |||||
| EnumAppPlat plat = EnumCouponType.getAppPlat(couponType); | |||||
| if (plat == EnumAppPlat.TOUTIAO) { | |||||
| TtCouponChannelPoi poi = ttCouponChannelPoiMapper.selectById(tenantId, couponId); | |||||
| if (null != poi &&( EnumSpuSyncStatus.isValid(poi.getLastStatus()))) { | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"券已在抖音审核流程中,无法修改。"); | |||||
| } | |||||
| }else if (plat == EnumAppPlat.WX) { | |||||
| WxCouponChannel couponChannel = new WxCouponChannel(); | |||||
| couponChannel.setTenantId(tenantId); | |||||
| couponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | |||||
| List<WxCouponChannel> clist = wxCouponChannelMapper.findList(couponChannel); | |||||
| if (null != clist && clist.size() > 0 ) { | |||||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"券已投放且上架,无法修改。"); | |||||
| } | |||||
| } | |||||
| WxCouponMall couponMall = new WxCouponMall(); | |||||
| couponMall.setTenantId(tenantId); | |||||
| couponMall.setMallTenantId(mallTenantId); | |||||
| couponMall.setProductId(couponId); | |||||
| couponMall.setStatus(EnumCouponMallStatus.UNFINISED.getCode()); | |||||
| wxCouponMallMapper.updateStatus(couponMall); | |||||
| } | |||||
| } | } | ||||
| @@ -76,12 +76,10 @@ | |||||
| from wx_coupon_mall | from wx_coupon_mall | ||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| <select id="findMerchantIdListByProduct" parameterType="java.util.Map" resultType="Long"> | |||||
| select distinct cm.merchant_id | |||||
| from wx_coupon_merchant cm | |||||
| where cm.status = 0 | |||||
| and cm.product_id = #{productId} and cm.tenant_id = #{tenantId} | |||||
| </select> | |||||
| <update id = "updateStatus" parameterType="com.iformall.domain.po.WxCouponMall"> | |||||
| update wx_coupon_mall set status = #{status} where `product_id` = #{productId} | |||||
| and `tenant_id` = #{tenantId} and `mall_tenant_id` = #{mallTenantId} | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||