diff --git a/mallinkAdmin/src/main/resources/db/migration/V201906282030__COUPON_PRESS_DATA.sql b/mallinkAdmin/src/main/resources/db/migration/V201906282030__COUPON_PRESS_DATA.sql new file mode 100644 index 000000000..fb8319d17 --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V201906282030__COUPON_PRESS_DATA.sql @@ -0,0 +1,6 @@ +ALTER TABLE `wx_order_press` +ADD COLUMN `coupon_id` bigint(20) null default null AFTER `tenant_id`; + +UPDATE `wx_order_press` op, `wx_order` o +SET op.coupon_id = o.product_id +WHERE op.order_id = o.id and op.coupon_id is null; \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxOrderPress.java b/mallinkService/src/main/java/com/iformall/domain/po/WxOrderPress.java index 339af8d6c..d3395ab3b 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxOrderPress.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxOrderPress.java @@ -24,6 +24,8 @@ public class WxOrderPress implements Serializable { @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") private String tenantId; + @io.swagger.annotations.ApiModelProperty(value="券ID",name="couponId") + private Long couponId; @io.swagger.annotations.ApiModelProperty(value="订单ID",name="orderId") private Long orderId; @io.swagger.annotations.ApiModelProperty(value="砍价参与人ID",name="userId") @@ -41,6 +43,7 @@ public class WxOrderPress implements Serializable { { Id_ASC("`id` ASC"),Id_DESC("`id` DESC") ,TenantId_ASC("`tenant_id` ASC"),TenantId_DESC("`tenant_id` DESC") + ,CouponId_ASC("`coupon_id` ASC"),CouponId_DESC("`coupon_id` DESC") ,OrderId_ASC("`order_id` ASC"),OrderId_DESC("`order_id` DESC") ,UserId_ASC("`user_id` ASC"),UserId_DESC("`user_id` DESC") ,PressValue_ASC("`press_value` ASC"),PressValue_DESC("`press_value` DESC") diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index 6328432b3..2ee2a088d 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -21,6 +21,8 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; @@ -62,6 +64,10 @@ public class WxCouponServiceImpl implements WxCouponService { @Autowired WxCouponChannelMapper wxCouponChannelMapper; + @Autowired + @Qualifier("openRedisTemplate") + RedisTemplate openRedisTemplate; + @Override public ResultData list(WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { if (null == wxCoupon) wxCoupon = new WxCoupon(); @@ -480,15 +486,6 @@ public class WxCouponServiceImpl implements WxCouponService { @Override public PageInfo findPressData(WxCoupon record, Integer pageNum, Integer pageSize) { - if(pageNum == 0) { - wxCouponMapper.delPressData(record); - wxCouponMapper.insertPressData(record); - wxCouponMapper.updatePressData1(record); - wxCouponMapper.updatePressData2(record); - wxCouponMapper.updatePressData3(record); - wxCouponMapper.updatePressData4(record); - wxCouponMapper.updatePressData5(record); - } return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxCouponMapper.findPressData(record)); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderPressServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderPressServiceImpl.java index c7a735515..7ffd85a87 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderPressServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderPressServiceImpl.java @@ -82,6 +82,7 @@ public class WxOrderPressServiceImpl implements WxOrderPressService { WxOrderPress orderPress = new WxOrderPress(); orderPress.setId(idWorker.nextId()); orderPress.setTenantId(order.getTenantId()); + orderPress.setCouponId(order.getProductId()); orderPress.setOrderId(order.getId()); orderPress.setUserId(cUserId); orderPress.setCreateDate(curDate); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index f72ee4da6..f81d45b5d 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -1428,6 +1428,7 @@ public class WxOrderServiceImpl implements WxOrderService { int left_total = total; WxOrderPress orderPress = new WxOrderPress(); orderPress.setId(IdWorker.get().nextId()); + orderPress.setCouponId(record.getProductId()); orderPress.setOrderId(orderNumber); orderPress.setUserId(user.getId()); orderPress.setCreateDate(new Date()); diff --git a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml index 7b5351b83..7a892ef7a 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponMapper.xml @@ -274,9 +274,9 @@ where is_del = 0 and 0 = (select count(*) from wx_coupon_channel cc - where c.`id` = cc.coupon_id - and cc.status = 0 - and cc.target_ad = #{targetAd}) + where c.`id` = cc.coupon_id + and cc.status = 0 + and cc.target_ad = #{targetAd}) @@ -497,7 +497,7 @@ + select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantBaseList"> @@ -533,7 +533,8 @@ and m.status = 1) = 0 - select DATE_FORMAT(ci.create_date,'%Y-%m-%d') xtime,sum(round(ci.sale_amount/100,2)) xcount from wx_card_info ci left join wx_coupon c on c.id = ci.coupon_id where c.type = 100 @@ -541,7 +542,8 @@ group by xtime - select DATE_FORMAT(wcs.create_date,'%Y-%m-%d') xtime,sum(round(wcs.real_payment/100,2)) xcount from wx_card_info ci left join wx_coupon c on c.id = ci.coupon_id left join wx_card_spend wcs on wcs.card_id = ci.id @@ -612,17 +614,21 @@ and c.id = #{id} - order by ${sortColumns} - order by c.status asc,c.create_date desc + order by ${sortColumns} + order by c.status asc,c.create_date desc - - delete from `wx_coupon_press_data` where type = 8 and tenant_id = #{tenantId} + + delete from `wx_coupon_press_data` where tenant_id = #{tenantId} - + insert into `wx_coupon_press_data` (`id`, `tenant_id`, `cover_img`, `title`, `sale_price`, `price`) select `id`, `tenant_id`, `cover_img`, `title`, `sale_price`, `price` from wx_coupon where type = 8 and tenant_id = #{tenantId} - + update wx_coupon_press_data cpd set change_rate = IFNULL(round((select count(o.id) from wx_order o where o.tenant_id = #{tenantId} and o.order_status = 1 and o.product_id = cpd.id)/ @@ -698,12 +721,12 @@ where cpd.tenant_id=#{tenantId} - + update wx_coupon_press_data cpd set join_count = - (select count(wop.id) from wx_order o - left join wx_order_press wop on wop.order_id = o.id - where o.tenant_id = #{tenantId} and o.product_id = cpd.id and o.payment_type = 0) -where cpd.tenant_id=#{tenantId} + (select count(wop.id) from wx_order o + left join wx_order_press wop on wop.order_id = o.id + where o.tenant_id = #{tenantId} and o.product_id = cpd.id and o.payment_type = 0) + where cpd.tenant_id=#{tenantId} - select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c left join wx_coupon_order wco on c.id = wco.coupon_id where c.type not in(8,9,100) @@ -727,8 +751,8 @@ where cpd.tenant_id=#{tenantId} - - select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco where c.type not in(8,9,100) and wco.coupon_id = c.id and wco.coupon_order_status = 1 @@ -736,7 +760,8 @@ where cpd.tenant_id=#{tenantId} group by xtime - select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco where c.type not in(8,9,100) and wco.coupon_id = c.id and wco.coupon_price > 0 @@ -744,7 +769,8 @@ where cpd.tenant_id=#{tenantId} group by xtime - select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon c,wx_coupon_order wco where c.type not in(8,9,100) and wco.coupon_id = c.id and wco.coupon_order_status = 1 and wco.coupon_price > 0 @@ -774,7 +800,8 @@ where cpd.tenant_id=#{tenantId} - select DATE_FORMAT(wop.create_date,'%Y-%m-%d') xtime,count(wop.id) xcount from wx_coupon wc left join wx_order wo on wo.product_id = wc.id left join wx_order_press wop on wop.order_id = wo.id @@ -782,14 +809,16 @@ where cpd.tenant_id=#{tenantId} wop.create_date between #{startdate} and #{enddate} group by xtime - select DATE_FORMAT(wo.create_date,'%Y-%m-%d') xtime,count(wo.id) xcount from wx_coupon wc left join wx_order wo on wo.product_id = wc.id where wc.type = 8 and wo.order_status = 1 and wo.create_date between #{startdate} and #{enddate} group by xtime - select DATE_FORMAT(wco.create_date,'%Y-%m-%d') xtime,count(wco.id) xcount from wx_coupon wc left join wx_coupon_order wco on wco.coupon_id = wc.id where wc.type = 8 and wco.coupon_order_status = 1 @@ -823,7 +852,7 @@ where cpd.tenant_id=#{tenantId} and wop.create_date between #{startdate} and #{enddate} - select count(c.id) from wx_coupon c left join wx_coupon_order wco on c.id = wco.coupon_id where c.type not in(8,9,100) @@ -831,7 +860,8 @@ where cpd.tenant_id=#{tenantId} and wco.coupon_order_status = 3 - select DATE_FORMAT(co.create_date,'%Y-%m-%d') xtime,count(co.id) xcount from wx_card_info ci left join wx_coupon c on c.id = ci.coupon_id @@ -841,7 +871,8 @@ where cpd.tenant_id=#{tenantId} group by xtime - select ct.id as id,wc.id as couponId, wc.tenant_id,wc.`type`,wc.`cover_img`,wc.`cover_picture`,wc.`detail_picture`,wc.`title`,wc.`sub_title`,wc.`sale_price`,wc.`use_price`,wc.`use_limit_quantity`,wc.`send_type`, wc.`valid_type`,wc.`valid_start_date`,wc.`valid_end_date`,wc.`valid_days`,wc.`detail`,wc.`price`,wc.`unit`,wc.`remain_inventory`,wc.`inventory`,