| @@ -568,37 +568,44 @@ public class WxCouponController extends BaseController { | |||||
| WxCouponMall wxCouponMall = new WxCouponMall(); | WxCouponMall wxCouponMall = new WxCouponMall(); | ||||
| wxCouponMall.updateTenantInfo(getTenantInfo()); | wxCouponMall.updateTenantInfo(getTenantInfo()); | ||||
| wxCouponMall.setProductId(id); | wxCouponMall.setProductId(id); | ||||
| return new ResultData(wxCouponMallService.list(wxCouponMall)); | |||||
| return new ResultData(wxCouponMallService.list(wxCouponMall,true)); | |||||
| } | } | ||||
| @ApiOperation("商场查询:平台券商场列表") | |||||
| @GetMapping("/couponMalls") | |||||
| @ApiOperation("平台券商场列表") | |||||
| @GetMapping("/getCouponMall") | |||||
| @ApiImplicitParams({ | @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"); | |||||
| } | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true)}) | |||||
| public ResultData getCouponMall(Long id) { | |||||
| //如果是集团查询,则查询所有的,如果是商场查询,则只查询商场的 | |||||
| WxCouponMall wxCouponMall = new WxCouponMall(); | WxCouponMall wxCouponMall = new WxCouponMall(); | ||||
| TenantEntity tenantEntity = getTenantInfo(); | TenantEntity tenantEntity = getTenantInfo(); | ||||
| if (null == tenantEntity.getParentTenantId()) { | if (null == tenantEntity.getParentTenantId()) { | ||||
| wxCouponMall.updateTenantInfo(tenantEntity); | wxCouponMall.updateTenantInfo(tenantEntity); | ||||
| wxCouponMall.setProductId(id); | |||||
| }else { | }else { | ||||
| wxCouponMall.setTenantId(tenantEntity.getParentTenantId()); | wxCouponMall.setTenantId(tenantEntity.getParentTenantId()); | ||||
| //一个商场,每个平台券只有一条记录 | |||||
| wxCouponMall.setMallTenantId(tenantEntity.getTenantId()); | |||||
| wxCouponMall.setProductId(id); | |||||
| } | } | ||||
| //一个商场,每个平台券只有一条记录 | |||||
| wxCouponMall.setMallTenantId(tenantEntity.getTenantId()); | |||||
| wxCouponMall.setProductIds(Arrays.asList(ids)); | |||||
| List<WxCouponMall> mallList= wxCouponMallService.list(wxCouponMall); | |||||
| if (null == mallList || mallList.size() <= 0 ) { | |||||
| return new ResultData(); | |||||
| List<WxCouponMall> mallList= wxCouponMallService.list(wxCouponMall,false); | |||||
| if (null != mallList && mallList.size() > 0 ) { | |||||
| boolean isComplete = true; | |||||
| for (int i = 0 ; i < mallList.size(); i ++) { | |||||
| WxCouponMall cm = mallList.get(i); | |||||
| if (EnumCouponMallStatus.UNFINISED.getCode() == cm.getStatus()) { | |||||
| isComplete = false; | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (isComplete) { | |||||
| return new ResultData("{\"isCompleted\":1}"); | |||||
| }else { | |||||
| return new ResultData("{\"isCompleted\":0}"); | |||||
| } | |||||
| }else { | |||||
| return new ResultData("{\"isCompleted\":0}"); | |||||
| } | } | ||||
| Map<Long,WxCouponMall> productMallMap = new HashMap<Long,WxCouponMall>(); | |||||
| for (int i = 0 ; i < mallList.size(); i ++) { | |||||
| WxCouponMall cm = mallList.get(i); | |||||
| productMallMap.put(cm.getProductId(), cm); | |||||
| } | |||||
| return new ResultData(productMallMap); | |||||
| } | } | ||||
| @ApiOperation("商场设置平台券商户") | @ApiOperation("商场设置平台券商户") | ||||
| @@ -110,4 +110,6 @@ 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_96 like wx_coupon_mall; | ||||
| create table wx_coupon_mall_97 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_98 like wx_coupon_mall; | ||||
| create table wx_coupon_mall_99 like wx_coupon_mall; | |||||
| create table wx_coupon_mall_99 like wx_coupon_mall; | |||||
| drop table wx_coupon_mall; | |||||
| @@ -394,6 +394,9 @@ public class WxCoupon extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Long[] merchantIds; | private Long[] merchantIds; | ||||
| @TableField(exist = false) | |||||
| private String[] mallTenantIds; | |||||
| public String getSalePriceStr() { | public String getSalePriceStr() { | ||||
| if(salePrice!=null) { | if(salePrice!=null) { | ||||
| @@ -496,6 +499,7 @@ public class WxCoupon extends TenantEntity { | |||||
| return valid_date; | return valid_date; | ||||
| } | } | ||||
| //是不是必须要有商户 | |||||
| public boolean checkCreateWithMerchants() { | public boolean checkCreateWithMerchants() { | ||||
| if(type == null) { | if(type == null) { | ||||
| return true; | return true; | ||||
| @@ -505,5 +509,16 @@ public class WxCoupon extends TenantEntity { | |||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| //是不是必须要有商场 | |||||
| public boolean checkCreateWithMalls() { | |||||
| if(type == null) { | |||||
| return false; | |||||
| } | |||||
| if(type == EnumCouponType.COUPON_DOUYIN_PLAT.getCode()) { | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| } | } | ||||
| @@ -30,4 +30,8 @@ public class WxCouponMall extends TenantEntity { | |||||
| private Date updateDate; | private Date updateDate; | ||||
| @io.swagger.annotations.ApiModelProperty(value="状态",name="status") | @io.swagger.annotations.ApiModelProperty(value="状态",name="status") | ||||
| private Integer status; | private Integer status; | ||||
| @io.swagger.annotations.ApiModelProperty(value="商场信息",name="mall") | |||||
| @TableField(exist = false) | |||||
| protected WxMall mall; | |||||
| } | } | ||||
| @@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | import com.fasterxml.jackson.annotation.JsonIgnore; | ||||
| import com.fasterxml.jackson.annotation.JsonProperty; | import com.fasterxml.jackson.annotation.JsonProperty; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import java.util.List; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| /** | /** | ||||
| @@ -27,6 +30,10 @@ public class TenantEntity extends BaseEntity { | |||||
| @JsonIgnore | @JsonIgnore | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| protected String shardTableSuffix; | protected String shardTableSuffix; | ||||
| @io.swagger.annotations.ApiModelProperty(value="租户编号列表,查询使用",name="tenantIdList") | |||||
| @TableField(exist = false) | |||||
| protected List<String> tenantIdList; | |||||
| public void updateTenantInfo(TenantEntity info) { | public void updateTenantInfo(TenantEntity info) { | ||||
| tenantId = info.getTenantId(); | tenantId = info.getTenantId(); | ||||
| @@ -82,4 +89,13 @@ public class TenantEntity extends BaseEntity { | |||||
| public void setFinalTenantId(String finalTenantId) { | public void setFinalTenantId(String finalTenantId) { | ||||
| this.finalTenantId = finalTenantId; | this.finalTenantId = finalTenantId; | ||||
| } | } | ||||
| public List<String> getTenantIdList() { | |||||
| return tenantIdList; | |||||
| } | |||||
| public void setTenantIdList(List<String> tenantIdList) { | |||||
| this.tenantIdList = tenantIdList; | |||||
| } | |||||
| } | } | ||||
| @@ -14,4 +14,5 @@ public interface WxCouponMallMapper extends CommonMapper<WxCouponMall, Long> { | |||||
| List<WxCouponMall> findList(WxCouponMall wxCouponMall); | List<WxCouponMall> findList(WxCouponMall wxCouponMall); | ||||
| void updateStatus(WxCouponMall wxCouponMall); | void updateStatus(WxCouponMall wxCouponMall); | ||||
| void delteAllByProductId(WxCouponMall wxCouponMall); | |||||
| } | } | ||||
| @@ -22,7 +22,7 @@ public interface WxCouponMallService { | |||||
| PageInfo<WxCouponMall> listAsPage(WxCouponMall record, Integer pageIndex, Integer pageSize); | PageInfo<WxCouponMall> listAsPage(WxCouponMall record, Integer pageIndex, Integer pageSize); | ||||
| List<WxCouponMall> list(WxCouponMall wxCouponMall); | |||||
| List<WxCouponMall> list(WxCouponMall wxCouponMall,boolean queryMall); | |||||
| void finised(String tenantId,Long couponId,String mallTenantId); | void finised(String tenantId,Long couponId,String mallTenantId); | ||||
| void unfinised(String tenantId, Long couponId,Integer couponType, String mallTenantId) throws Exception; | void unfinised(String tenantId, Long couponId,Integer couponType, String mallTenantId) throws Exception; | ||||
| @@ -29,10 +29,36 @@ public class WxCouponMallServiceImpl implements WxCouponMallService { | |||||
| TtCouponChannelPoiMapper ttCouponChannelPoiMapper; | TtCouponChannelPoiMapper ttCouponChannelPoiMapper; | ||||
| @Autowired | @Autowired | ||||
| WxCouponChannelMapper wxCouponChannelMapper; | WxCouponChannelMapper wxCouponChannelMapper; | ||||
| @Autowired | |||||
| WxMallMapper wxMallMapper; | |||||
| @Override | @Override | ||||
| public List<WxCouponMall> list(WxCouponMall wxCouponMall){ | |||||
| return wxCouponMallMapper.findList(wxCouponMall); | |||||
| public List<WxCouponMall> list(WxCouponMall wxCouponMall,boolean queryMall){ | |||||
| List<WxCouponMall> list = wxCouponMallMapper.findList(wxCouponMall); | |||||
| if (queryMall) { | |||||
| if (null != list && list.size() > 0 ) { | |||||
| List<String> mallTenantList = new ArrayList<String>();; | |||||
| for (int i = 0 ;i <list.size() ; i++) { | |||||
| String mt = list.get(i).getMallTenantId(); | |||||
| if (!mallTenantList.contains(mt)) { | |||||
| mallTenantList.add(mt); | |||||
| } | |||||
| } | |||||
| WxMall mallq = new WxMall(); | |||||
| mallq.setTenantIdList(mallTenantList); | |||||
| List<WxMall> mallList = wxMallMapper.findList(mallq); | |||||
| if (null != mallList && mallList.size() > 0) { | |||||
| Map<String,WxMall> mallMap = new HashMap<String,WxMall>(); | |||||
| for (WxMall m:mallList) { | |||||
| mallMap.put(m.getTenantId(), m); | |||||
| } | |||||
| for (WxCouponMall cm : list) { | |||||
| cm.setMall(mallMap.get(cm.getMallTenantId())); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| return list; | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -147,6 +147,9 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| @Autowired | @Autowired | ||||
| PayServiceFactory payServiceFactory; | PayServiceFactory payServiceFactory; | ||||
| @Autowired | |||||
| WxCouponMallMapper wxCouponMallMapper; | |||||
| @Override | @Override | ||||
| public ResultData list(TenantEntity tenantEntity,WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | public ResultData list(TenantEntity tenantEntity,WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { | ||||
| @@ -520,9 +523,12 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| return new ResultData(Result.ERROR,e.getMessage()); | return new ResultData(Result.ERROR,e.getMessage()); | ||||
| } | } | ||||
| merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | ||||
| }else if (record.checkCreateWithMalls()) { | |||||
| String[] mallTenantIds = record.getMallTenantIds(); | |||||
| if (null == mallTenantIds || mallTenantIds.length <= 0 ) { | |||||
| return new ResultData(Result.ERROR,"请选择商场"); | |||||
| } | |||||
| } | } | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| @@ -541,6 +547,17 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| wxCouponMerchantMapper.insert(cm); | wxCouponMerchantMapper.insert(cm); | ||||
| }); | }); | ||||
| }else if (record.checkCreateWithMalls()) { | |||||
| for (String mt : record.getMallTenantIds()) { | |||||
| WxCouponMall mall = new WxCouponMall(); | |||||
| mall.updateTenantInfo(record); | |||||
| mall.setMallTenantId(mt); | |||||
| mall.setProductId(record.getId()); | |||||
| mall.setCreateDate(new Date()); | |||||
| mall.setUpdateDate(new Date()); | |||||
| mall.setStatus(EnumCouponMallStatus.UNFINISED.getCode()); | |||||
| wxCouponMallMapper.insert(mall); | |||||
| } | |||||
| } | } | ||||
| if (record.getPasswordSupport() != null && record.getPasswordSupport().equals(EnumCouponPasswordSupport.SUPPORTED.getCode())) { | if (record.getPasswordSupport() != null && record.getPasswordSupport().equals(EnumCouponPasswordSupport.SUPPORTED.getCode())) { | ||||
| @@ -571,6 +588,21 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| } | } | ||||
| if (record.checkCreateWithMerchants()) { | if (record.checkCreateWithMerchants()) { | ||||
| updateCouponMerchants(record,merchantParamList,idWorker); | updateCouponMerchants(record,merchantParamList,idWorker); | ||||
| }else if (record.checkCreateWithMalls()) { | |||||
| WxCouponMall couponMall = new WxCouponMall(); | |||||
| couponMall.updateTenantInfo(record); | |||||
| couponMall.setProductId(record.getId()); | |||||
| wxCouponMallMapper.delteAllByProductId(couponMall); | |||||
| for (String mt : record.getMallTenantIds()) { | |||||
| WxCouponMall mall = new WxCouponMall(); | |||||
| mall.updateTenantInfo(record); | |||||
| mall.setMallTenantId(mt); | |||||
| mall.setProductId(record.getId()); | |||||
| mall.setCreateDate(new Date()); | |||||
| mall.setUpdateDate(new Date()); | |||||
| mall.setStatus(EnumCouponMallStatus.UNFINISED.getCode()); | |||||
| wxCouponMallMapper.insert(mall); | |||||
| } | |||||
| } | } | ||||
| record.setUpdateDate(new Date()); | record.setUpdateDate(new Date()); | ||||
| @@ -82,4 +82,7 @@ | |||||
| and `tenant_id` = #{tenantId} and `mall_tenant_id` = #{mallTenantId} | and `tenant_id` = #{tenantId} and `mall_tenant_id` = #{mallTenantId} | ||||
| </update> | </update> | ||||
| <update id = "delteAllByProductId" parameterType="com.iformall.domain.po.WxCouponMall"> | |||||
| delete from wx_coupon_mall where `product_id` = #{productId} and `tenant_id` = #{tenantId} | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||
| @@ -145,6 +145,13 @@ | |||||
| and `group_support` = #{groupSupport} | and `group_support` = #{groupSupport} | ||||
| </if> | </if> | ||||
| <if test=" null != tenantIdList "> | |||||
| and tenant_id in | |||||
| <foreach collection="tenantIdList" index="index" item="tIdItem" open="(" separator="," close=")"> | |||||
| #{tIdItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||