| @@ -1,7 +1,8 @@ | |||||
| package com.iformall.domain.vo; | package com.iformall.domain.vo; | ||||
| import javax.persistence.Id; | |||||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||||
| import javax.persistence.Id; | |||||
| public class WxMerchantVo { | public class WxMerchantVo { | ||||
| private static final long serialVersionUID = 6687964942922444531L; | private static final long serialVersionUID = 6687964942922444531L; | ||||
| @@ -28,7 +29,12 @@ public class WxMerchantVo { | |||||
| /**商户状态**/ | /**商户状态**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="商户状态1可用0停用",name="status") | @io.swagger.annotations.ApiModelProperty(value="商户状态1可用0停用",name="status") | ||||
| private Integer merchantStatus; | private Integer merchantStatus; | ||||
| /**商户业态**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户业态",name="businessId") | |||||
| private Integer businessId; | |||||
| /**商户业态**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="商户业态",name="parameter") | |||||
| private String parameter; | |||||
| /**地址**/ | /**地址**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="地址",name="addr") | @io.swagger.annotations.ApiModelProperty(value="地址",name="addr") | ||||
| @@ -85,13 +91,21 @@ public class WxMerchantVo { | |||||
| addr = _addr; | addr = _addr; | ||||
| } | } | ||||
| public Integer getBusinessId() { | |||||
| return businessId; | |||||
| } | |||||
| public String getMerChantImgUrl() { | |||||
| public void setBusinessId(Integer businessId) { | |||||
| this.businessId = businessId; | |||||
| } | |||||
| public String getMerchantImgUrl() { | |||||
| return merchantImgUrl; | return merchantImgUrl; | ||||
| } | } | ||||
| public void setMerChantImgUrl(String _imgUrl) { | |||||
| public void setMerchantImgUrl(String _imgUrl) { | |||||
| merchantImgUrl = _imgUrl; | merchantImgUrl = _imgUrl; | ||||
| } | } | ||||
| public String getMerchantName() { | public String getMerchantName() { | ||||
| return merchantName; | return merchantName; | ||||
| } | } | ||||
| @@ -111,6 +125,15 @@ public class WxMerchantVo { | |||||
| this.merchantStatus = status; | this.merchantStatus = status; | ||||
| } | } | ||||
| public String getParameter() { | |||||
| return parameter; | |||||
| } | |||||
| public void setParameter(String parameter) { | |||||
| this.parameter = parameter; | |||||
| } | |||||
| public Integer getVipDiscountRate1() { | public Integer getVipDiscountRate1() { | ||||
| return vipDiscountRate1; | return vipDiscountRate1; | ||||
| } | } | ||||
| @@ -134,4 +157,6 @@ public class WxMerchantVo { | |||||
| public void setVipDiscountRate3(Integer vipDiscountRate3) { | public void setVipDiscountRate3(Integer vipDiscountRate3) { | ||||
| this.vipDiscountRate3 = vipDiscountRate3; | this.vipDiscountRate3 = vipDiscountRate3; | ||||
| } | } | ||||
| } | } | ||||
| @@ -13,4 +13,5 @@ public interface WxCouponMerchantMapper extends CommonMapper<WxCouponMerchant, L | |||||
| List<WxCouponMerchant> findList(WxCouponMerchant wxCouponMerchant); | List<WxCouponMerchant> findList(WxCouponMerchant wxCouponMerchant); | ||||
| List<WxMerchantVo> findMerchantVoList(Map paramMap); | List<WxMerchantVo> findMerchantVoList(Map paramMap); | ||||
| List<WxMerchantVo> findMerchantNameList(Map paramMap); | List<WxMerchantVo> findMerchantNameList(Map paramMap); | ||||
| List<WxMerchantVo> findMerchantBaseList(Map paramMap); | |||||
| } | } | ||||
| @@ -67,6 +67,18 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| return wxCouponMapper.findVoDetail(id); | return wxCouponMapper.findVoDetail(id); | ||||
| } | } | ||||
| private Long parseMerchantId(JSONObject merchantParam){ | |||||
| return Long.valueOf(merchantParam.getString("id")); | |||||
| } | |||||
| private String parseParameter(JSONObject merchantParam){ | |||||
| return merchantParam.getString("parameter"); | |||||
| } | |||||
| private Integer parseBusiness(JSONObject merchantParam){ | |||||
| return Integer.valueOf(merchantParam.getString("businessId")); | |||||
| } | |||||
| @Override | @Override | ||||
| @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | @Transactional(isolation=Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | ||||
| public ResultData saveOrUpdate(WxCoupon record) { | public ResultData saveOrUpdate(WxCoupon record) { | ||||
| @@ -93,34 +105,34 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| record.setId(idWorker.nextId()); | |||||
| if (!record.getMerchantParams().isEmpty()) | if (!record.getMerchantParams().isEmpty()) | ||||
| { | { | ||||
| List<JSONObject> merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | List<JSONObject> merchantParamList = JSONObject.parseArray(record.getMerchantParams(), JSONObject.class); | ||||
| List<WxCouponMerchant> couponMerchantList = new ArrayList<>(); | |||||
| List<Integer> businessList= new ArrayList<>(); | List<Integer> businessList= new ArrayList<>(); | ||||
| merchantParamList.forEach(merchantParam -> { | merchantParamList.forEach(merchantParam -> { | ||||
| WxCouponMerchant cm = new WxCouponMerchant(); | WxCouponMerchant cm = new WxCouponMerchant(); | ||||
| cm.setId(idWorker.nextId()); | cm.setId(idWorker.nextId()); | ||||
| cm.setMerchantId(merchantParam.getLong("id")); | |||||
| cm.setParameter(merchantParam.getString("param")); | |||||
| cm.setMerchantId(parseMerchantId(merchantParam)); | |||||
| cm.setParameter(parseParameter(merchantParam)); | |||||
| cm.setProductId(record.getId()); | cm.setProductId(record.getId()); | ||||
| cm.setCreateDate(new Date()); | cm.setCreateDate(new Date()); | ||||
| cm.setUpdateDate(new Date()); | cm.setUpdateDate(new Date()); | ||||
| cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| couponMerchantList.add(cm); | |||||
| businessList.add(merchantParam.getInteger("business")); | |||||
| businessList.add(parseBusiness(merchantParam)); | |||||
| wxCouponMerchantMapper.insertSelective(cm); | |||||
| }); | }); | ||||
| if (businessList.stream().distinct().count() > 1) { | if (businessList.stream().distinct().count() > 1) { | ||||
| record.setBusiness(EnumBusiness.BUSINESS_NULL.getCode()); | record.setBusiness(EnumBusiness.BUSINESS_NULL.getCode()); | ||||
| } else { | } else { | ||||
| record.setBusiness(businessList.get(0)); | record.setBusiness(businessList.get(0)); | ||||
| } | } | ||||
| wxCouponMerchantMapper.insertList(couponMerchantList); | |||||
| } else{ | } else{ | ||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | ||||
| } | } | ||||
| record.setId(idWorker.nextId()); | |||||
| record.setCreateDate(new Date()); | record.setCreateDate(new Date()); | ||||
| record.setUpdateDate(new Date()); | record.setUpdateDate(new Date()); | ||||
| wxCouponMapper.insertSelective(record); | wxCouponMapper.insertSelective(record); | ||||
| @@ -135,27 +147,27 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| List<Integer> businessList= new ArrayList<>(); | List<Integer> businessList= new ArrayList<>(); | ||||
| merchantParamList.stream().forEach(merchantParam -> { | merchantParamList.stream().forEach(merchantParam -> { | ||||
| WxCouponMerchant cm = new WxCouponMerchant(); | WxCouponMerchant cm = new WxCouponMerchant(); | ||||
| cm.setMerchantId(merchantParam.getLong("id")); | |||||
| cm.setMerchantId(parseMerchantId(merchantParam)); | |||||
| cm.setProductId(record.getId()); | cm.setProductId(record.getId()); | ||||
| WxCouponMerchant rcm = wxCouponMerchantMapper.selectOne(cm); | WxCouponMerchant rcm = wxCouponMerchantMapper.selectOne(cm); | ||||
| if (rcm != null) { | if (rcm != null) { | ||||
| rcm.setMerchantId(merchantParam.getLong("id")); | |||||
| rcm.setParameter(merchantParam.getString("param")); | |||||
| rcm.setMerchantId(Long.valueOf(parseMerchantId(merchantParam))); | |||||
| rcm.setParameter(parseParameter(merchantParam)); | |||||
| rcm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | rcm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| rcm.setUpdateDate(new Date()); | rcm.setUpdateDate(new Date()); | ||||
| wxCouponMerchantMapper.updateByPrimaryKeySelective(rcm); | wxCouponMerchantMapper.updateByPrimaryKeySelective(rcm); | ||||
| }else { | }else { | ||||
| cm.setId(idWorker.nextId()); | cm.setId(idWorker.nextId()); | ||||
| cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | cm.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | ||||
| cm.setParameter(merchantParam.getString("param")); | |||||
| cm.setParameter(parseParameter(merchantParam)); | |||||
| cm.setCreateDate(new Date()); | cm.setCreateDate(new Date()); | ||||
| cm.setUpdateDate(new Date()); | cm.setUpdateDate(new Date()); | ||||
| wxCouponMerchantMapper.insertSelective(cm); | wxCouponMerchantMapper.insertSelective(cm); | ||||
| } | } | ||||
| businessList.add(merchantParam.getInteger("business")); | |||||
| businessList.add(Integer.valueOf(parseBusiness(merchantParam))); | |||||
| oldList.removeIf( | oldList.removeIf( | ||||
| old->old.getProductId().equals(record.getId()) && | old->old.getProductId().equals(record.getId()) && | ||||
| old.getMerchantId().equals(merchantParam.getLong("id"))); | |||||
| old.getMerchantId().equals(Long.valueOf(parseMerchantId(merchantParam)))); | |||||
| }); | }); | ||||
| oldList.stream().forEach(old->{ | oldList.stream().forEach(old->{ | ||||
| @@ -131,7 +131,7 @@ | |||||
| <collection column="{productId=coupon_id}" property="merchantVoList" | <collection column="{productId=coupon_id}" property="merchantVoList" | ||||
| ofType="com.iformall.domain.vo.WxMerchantVo" | ofType="com.iformall.domain.vo.WxMerchantVo" | ||||
| javaType="java.util.ArrayList" | |||||
| javaType="java.util.List" | |||||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" > | select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" > | ||||
| </collection> | </collection> | ||||
| </resultMap> | </resultMap> | ||||
| @@ -181,7 +181,7 @@ | |||||
| <collection column="{productId=coupon_id}" property="merchantVoList" | <collection column="{productId=coupon_id}" property="merchantVoList" | ||||
| ofType="com.iformall.domain.vo.WxMerchantVo" | ofType="com.iformall.domain.vo.WxMerchantVo" | ||||
| javaType="java.util.ArrayList" | |||||
| javaType="java.util.List" | |||||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | ||||
| </collection> | </collection> | ||||
| </resultMap> | </resultMap> | ||||
| @@ -80,8 +80,8 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != validStartDate "> | <if test=" null != validStartDate "> | ||||
| and `valid_start_date` = #{validStartDate} | |||||
| </if> | |||||
| and `valid_start_date` = #{validStartDate} | |||||
| </if> | |||||
| <if test=" null != validEndDate "> | <if test=" null != validEndDate "> | ||||
| and `valid_end_date` = #{validEndDate} | and `valid_end_date` = #{validEndDate} | ||||
| @@ -175,8 +175,8 @@ | |||||
| <collection column="{productId=id}" property="merchantVoList" | <collection column="{productId=id}" property="merchantVoList" | ||||
| ofType="com.iformall.domain.vo.WxMerchantVo" | ofType="com.iformall.domain.vo.WxMerchantVo" | ||||
| javaType="java.util.ArrayList" | |||||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | |||||
| javaType="java.util.List" | |||||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantBaseList" > | |||||
| </collection> | </collection> | ||||
| </resultMap> | </resultMap> | ||||
| @@ -64,9 +64,10 @@ | |||||
| <sql id="allMerchantVoColumns"> | <sql id="allMerchantVoColumns"> | ||||
| m.id, | m.id, | ||||
| m.img_url,m.name,m.link_phone,m.status, | |||||
| m.img_url,m.name,m.link_phone,m.status,m.business_id, | |||||
| s.addr,s.shop_number,s.baidu_poi, | s.addr,s.shop_number,s.baidu_poi, | ||||
| mb.building_name,mf.floor_name | |||||
| mb.building_name,mf.floor_name, | |||||
| cm.parameter | |||||
| </sql> | </sql> | ||||
| <resultMap id="MerchantVoResultMap" type="com.iformall.domain.vo.WxMerchantVo"> | <resultMap id="MerchantVoResultMap" type="com.iformall.domain.vo.WxMerchantVo"> | ||||
| @@ -75,6 +76,8 @@ | |||||
| <result column="name" jdbcType="VARCHAR" property="merchantName"/> | <result column="name" jdbcType="VARCHAR" property="merchantName"/> | ||||
| <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone"/> | <result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone"/> | ||||
| <result column="status" jdbcType="VARCHAR" property="merchantStatus"/> | <result column="status" jdbcType="VARCHAR" property="merchantStatus"/> | ||||
| <result column="business_id" jdbcType="INTEGER" property="businessId"/> | |||||
| <result column="parameter" jdbcType="VARCHAR" property="parameter"/> | |||||
| <result column="addr" jdbcType="VARCHAR" property="addr"/> | <result column="addr" jdbcType="VARCHAR" property="addr"/> | ||||
| <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/> | <result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/> | ||||
| @@ -95,11 +98,16 @@ | |||||
| where cm.product_id = #{productId} | where cm.product_id = #{productId} | ||||
| </select> | </select> | ||||
| <sql id="allMerchantNameColumns"> | <sql id="allMerchantNameColumns"> | ||||
| m.id,m.name,m.status | m.id,m.name,m.status | ||||
| </sql> | </sql> | ||||
| <sql id="allMerchantBaseColumns"> | |||||
| m.id, | |||||
| m.img_url,m.name,m.link_phone,m.status,m.business_id, | |||||
| cm.parameter | |||||
| </sql> | |||||
| <select id="findMerchantNameList" parameterType="java.util.Map" resultMap="MerchantVoResultMap"> | <select id="findMerchantNameList" parameterType="java.util.Map" resultMap="MerchantVoResultMap"> | ||||
| select | select | ||||
| <include refid="allMerchantNameColumns"/> | <include refid="allMerchantNameColumns"/> | ||||
| @@ -108,4 +116,13 @@ | |||||
| where cm.product_id = #{productId} | where cm.product_id = #{productId} | ||||
| </select> | </select> | ||||
| <select id="findMerchantBaseList" parameterType="java.util.Map" resultMap="MerchantVoResultMap"> | |||||
| select | |||||
| <include refid="allMerchantBaseColumns"/> | |||||
| from wx_coupon_merchant cm | |||||
| left join wx_merchant m on m.id = cm.merchant_id | |||||
| where cm.product_id = #{productId} | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -315,7 +315,7 @@ | |||||
| <collection column="{productId=coupon_id}" property="merchantVoList" | <collection column="{productId=coupon_id}" property="merchantVoList" | ||||
| ofType="com.iformall.domain.vo.WxMerchantVo" | ofType="com.iformall.domain.vo.WxMerchantVo" | ||||
| javaType="java.util.ArrayList" | |||||
| javaType="java.util.List" | |||||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" > | select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" > | ||||
| </collection> | </collection> | ||||
| </resultMap> | </resultMap> | ||||
| @@ -528,7 +528,7 @@ | |||||
| <collection column="{productId=coupon_id}" property="merchantVoList" | <collection column="{productId=coupon_id}" property="merchantVoList" | ||||
| ofType="com.iformall.domain.vo.WxMerchantVo" | ofType="com.iformall.domain.vo.WxMerchantVo" | ||||
| javaType="java.util.ArrayList" | |||||
| javaType="java.util.List" | |||||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | ||||
| </collection> | </collection> | ||||
| </resultMap> | </resultMap> | ||||
| @@ -173,7 +173,7 @@ | |||||
| <collection column="{productId=product_id}" property="merchantVoList" | <collection column="{productId=product_id}" property="merchantVoList" | ||||
| ofType="com.iformall.domain.vo.WxMerchantVo" | ofType="com.iformall.domain.vo.WxMerchantVo" | ||||
| javaType="java.util.ArrayList" | |||||
| javaType="java.util.List" | |||||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | ||||
| </collection> | </collection> | ||||
| </resultMap> | </resultMap> | ||||