| @@ -568,37 +568,44 @@ public class WxCouponController extends BaseController { | |||
| WxCouponMall wxCouponMall = new WxCouponMall(); | |||
| wxCouponMall.updateTenantInfo(getTenantInfo()); | |||
| wxCouponMall.setProductId(id); | |||
| return new ResultData(wxCouponMallService.list(wxCouponMall)); | |||
| return new ResultData(wxCouponMallService.list(wxCouponMall,true)); | |||
| } | |||
| @ApiOperation("商场查询:平台券商场列表") | |||
| @GetMapping("/couponMalls") | |||
| @ApiOperation("平台券商场列表") | |||
| @GetMapping("/getCouponMall") | |||
| @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(); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| if (null == tenantEntity.getParentTenantId()) { | |||
| wxCouponMall.updateTenantInfo(tenantEntity); | |||
| wxCouponMall.setProductId(id); | |||
| }else { | |||
| 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("商场设置平台券商户") | |||
| @@ -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_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; | |||
| 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) | |||
| private Long[] merchantIds; | |||
| @TableField(exist = false) | |||
| private String[] mallTenantIds; | |||
| public String getSalePriceStr() { | |||
| if(salePrice!=null) { | |||
| @@ -496,6 +499,7 @@ public class WxCoupon extends TenantEntity { | |||
| return valid_date; | |||
| } | |||
| //是不是必须要有商户 | |||
| public boolean checkCreateWithMerchants() { | |||
| if(type == null) { | |||
| return true; | |||
| @@ -505,5 +509,16 @@ public class WxCoupon extends TenantEntity { | |||
| } | |||
| 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; | |||
| @io.swagger.annotations.ApiModelProperty(value="状态",name="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.JsonProperty; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.util.List; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| /** | |||
| @@ -27,6 +30,10 @@ public class TenantEntity extends BaseEntity { | |||
| @JsonIgnore | |||
| @TableField(exist = false) | |||
| protected String shardTableSuffix; | |||
| @io.swagger.annotations.ApiModelProperty(value="租户编号列表,查询使用",name="tenantIdList") | |||
| @TableField(exist = false) | |||
| protected List<String> tenantIdList; | |||
| public void updateTenantInfo(TenantEntity info) { | |||
| tenantId = info.getTenantId(); | |||
| @@ -82,4 +89,13 @@ public class TenantEntity extends BaseEntity { | |||
| public void setFinalTenantId(String 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); | |||
| void updateStatus(WxCouponMall wxCouponMall); | |||
| void delteAllByProductId(WxCouponMall wxCouponMall); | |||
| } | |||
| @@ -22,7 +22,7 @@ public interface WxCouponMallService { | |||
| 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 unfinised(String tenantId, Long couponId,Integer couponType, String mallTenantId) throws Exception; | |||
| @@ -29,10 +29,36 @@ public class WxCouponMallServiceImpl implements WxCouponMallService { | |||
| TtCouponChannelPoiMapper ttCouponChannelPoiMapper; | |||
| @Autowired | |||
| WxCouponChannelMapper wxCouponChannelMapper; | |||
| @Autowired | |||
| WxMallMapper wxMallMapper; | |||
| @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 | |||
| @@ -147,6 +147,9 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| @Autowired | |||
| PayServiceFactory payServiceFactory; | |||
| @Autowired | |||
| WxCouponMallMapper wxCouponMallMapper; | |||
| @Override | |||
| 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()); | |||
| } | |||
| 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(); | |||
| if (record.getId() == null) { | |||
| @@ -541,6 +547,17 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | |||
| 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())) { | |||
| @@ -571,6 +588,21 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| } | |||
| if (record.checkCreateWithMerchants()) { | |||
| 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()); | |||
| @@ -82,4 +82,7 @@ | |||
| and `tenant_id` = #{tenantId} and `mall_tenant_id` = #{mallTenantId} | |||
| </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> | |||
| @@ -145,6 +145,13 @@ | |||
| and `group_support` = #{groupSupport} | |||
| </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 "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||