Просмотр исходного кода

[A端][需求]:整理couponordermapper的接口,支持多商户

release_toaliyun_real
hupeng 7 лет назад
Родитель
Сommit
eb45bb194a
10 измененных файлов: 297 добавлений и 408 удалений
  1. +3
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/WxCouponOrderController.java
  2. +11
    -91
      mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderBVo.java
  3. +1
    -1
      mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java
  4. +3
    -3
      mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java
  5. +5
    -5
      mallinkService/src/main/java/com/iformall/service/impl/WxCUserTagsServiceImpl.java
  6. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java
  7. +2
    -11
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
  8. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java
  9. +2
    -2
      mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java
  10. +266
    -291
      mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml

+ 3
- 0
mallinkAdmin/src/main/java/com/iformall/controller/WxCouponOrderController.java Просмотреть файл

@@ -55,6 +55,9 @@ public class WxCouponOrderController extends BaseController {
logger.debug("[" + getIpAddr() + "] WxCouponOrderController::list");
if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrderBVo();
wxCouponOrder.setTenantId(getTenantId());
if (wxCouponOrder.getMerchantName().isEmpty()) {
wxCouponOrder.setMerchantName(null);
}
wxCouponOrder.setSortColumns(WxCouponOrder.Field.Id_DESC);
return wxCouponOrderService.listAdminAsPage(wxCouponOrder, pageNum, pageSize);
}


+ 11
- 91
mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderBVo.java Просмотреть файл

@@ -1,6 +1,7 @@
package com.iformall.domain.vo;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.iformall.domain.po.WxCouponOrder;

import javax.persistence.Id;
@@ -8,22 +9,14 @@ import javax.persistence.Transient;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;
@JsonIgnoreProperties(value = {"handler"})
public class WxCouponOrderBVo extends WxCouponOrder{

/**
*
*/
private static final long serialVersionUID = 6687954932922444531L;
@Id
@Excel(name="券码",width = 20)
protected Long id;

@Transient
protected List<Long> ids;
@Transient
protected String sortColumns;

public Long getId() {
return id;
}
@@ -32,18 +25,6 @@ public class WxCouponOrderBVo extends WxCouponOrder{
this.id = id;
}

public String getSortColumns() {
return sortColumns;
}

public List<Long> getIds() {
return ids;
}

public void setIds(List<Long> ids) {
this.ids = ids;
}


/* 基础购买到的券信息 */
/***/
@@ -66,10 +47,7 @@ public class WxCouponOrderBVo extends WxCouponOrder{
@io.swagger.annotations.ApiModelProperty(value = "该订单对应券的实际过期时间 ", name = "expiredTime")
private Date expiredTime;

/**商户名**/
@Excel(name="商户名",width = 50)
@io.swagger.annotations.ApiModelProperty(value="商户名",name="merchantName")
private String merchantName;


/*券名称**/
@Excel(name="券名称",width = 50)
@@ -132,7 +110,15 @@ public class WxCouponOrderBVo extends WxCouponOrder{
@Excel(name="商户管理员手机",width = 20)
@io.swagger.annotations.ApiModelProperty(value="b端用户手机号",name="bUserPhone")
private String bUserPhone;
/**使用券商户名**/
@Excel(name="使用券商户名",width = 50)
@io.swagger.annotations.ApiModelProperty(value="使用券商户名",name="merchantName")
private String merchantName;


/*发券商户信息*/
@io.swagger.annotations.ApiModelProperty(value="商户列表",name="merchantVoList")
private List<WxMerchantVo> merchantVoList;

@Transient
private Date startDate;
@@ -308,70 +294,4 @@ public class WxCouponOrderBVo extends WxCouponOrder{
this.priceStr = priceStr;
}

public static enum Field {
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")
,CUserId_ASC("`c_user_id` ASC"), CUserId_DESC("`c_user_id` DESC")
,BUserId_ASC("`b_user_id` ASC"), BUserId_DESC("`b_user_id` DESC")
,OrderId_ASC("`order_id` ASC"), OrderId_DESC("`order_id` DESC")
,ExpiredTime_ASC("`expired_time` ASC"), ExpiredTime_DESC("`expired_time` DESC")
,CouponOrderStatus_ASC("`coupon_order_status` ASC"), CouponOrderStatus_DESC("`coupon_order_status` DESC")
,CreateDate_ASC("`create_date` ASC"), CreateDate_DESC("`create_date` DESC")
,UpdateDate_ASC("`update_date` ASC"), UpdateDate_DESC("`update_date` DESC")
,CouponPrice_ASC("`coupon_price` ASC"), CouponPrice_DESC("`coupon_price` DESC")
;
private String value;

Field(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public void setCol(String value) {
this.value = value;
}

@Override
public String toString() {
return this.getValue();
}
}

public void setSortColumns(WxCouponOrder.Field... fields) {
if (fields == null || fields.length == 0) {
return;
}
for (int k = 0; k < fields.length; k++) {
if (fields[k] == null) {
return;
}
}
StringBuilder sb = new StringBuilder(fields[0].toString());
for (int k = 1; k < fields.length; k++) {
sb.append(",");
sb.append(fields[k].toString());
}

this.sortColumns = sb.toString();
}

public void setSortColumns(String sortColumns) {
if (sortColumns == null || "".equals(sortColumns.trim())) {
return;
}
if (sortColumns.contains(",")) {
String[] cols = sortColumns.split(",");
java.util.List<WxCouponOrder.Field> fList = new java.util.ArrayList();
for (int k = 0; k < cols.length; k++) {
fList.add(WxCouponOrder.Field.valueOf(cols[k]));
}
this.setSortColumns(fList.toArray(new WxCouponOrder.Field[fList.size()]));
} else {
this.setSortColumns(WxCouponOrder.Field.valueOf(sortColumns));
}
}
}

+ 1
- 1
mallinkService/src/main/java/com/iformall/mapper/WxCouponMerchantMapper.java Просмотреть файл

@@ -12,5 +12,5 @@ public interface WxCouponMerchantMapper extends CommonMapper<WxCouponMerchant, L

List<WxCouponMerchant> findList(WxCouponMerchant wxCouponMerchant);
List<WxMerchantVo> findMerchantVoList(Map paramMap);
List<WxMerchantVo> findMerchantNameList(Map paramMap);
}

+ 3
- 3
mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java Просмотреть файл

@@ -26,7 +26,7 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> {
List<WxCouponOrderBVo> findListOfOrderedByDateForBUser(Map dateMap);
List<WxCouponOrderBVo> findListOfVerifiedByDateForBUser(Map dateMap);

WxCouponOrderCVo selectDetailOfUser(Map paramMap);
WxCouponOrderCVo findDetail(@Param("id")Long id);

List<WxCouponOrderCVo> findListOfCUser(WxCouponOrderCVo wxCouponOrder);
List<WxCouponOrderBVo> findListOfAdmin(WxCouponOrderBVo wxCouponOrder);
@@ -38,8 +38,8 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> {
* @param endTime
* @return
*/
int findOrderedCountForCUser(@Param("cUserId")Long cUserId,@Param("startTime") Date startTime,@Param("endTime")Date endTime);
int findVerifiedCountForCUser(@Param("cUserId")Long cUserId,@Param("startTime") Date startTime,@Param("endTime")Date endTime);
int findOrderedCountByCUser(@Param("cUserId")Long cUserId,@Param("startTime") Date startTime,@Param("endTime")Date endTime);
int findVerifiedCountByCUser(@Param("cUserId")Long cUserId,@Param("startTime") Date startTime,@Param("endTime")Date endTime);





+ 5
- 5
mallinkService/src/main/java/com/iformall/service/impl/WxCUserTagsServiceImpl.java Просмотреть файл

@@ -421,18 +421,18 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService {
for (int ago = 0; ago > -30 ; ago-- ) {
if (endC.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY
&& endC.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
workDayCount += wxCouponOrderMapper.findVerifiedCountForCUser(param.getId(),startTime,endTime);
workDayCount += wxCouponOrderMapper.findVerifiedCountByCUser(param.getId(),startTime,endTime);
} else {
WeekendDayCount += wxCouponOrderMapper.findVerifiedCountForCUser(param.getId(),startTime,endTime);
WeekendDayCount += wxCouponOrderMapper.findVerifiedCountByCUser(param.getId(),startTime,endTime);
}

endC.add(Calendar.DAY_OF_YEAR, -1);

if (endC.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY
&& endC.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
workNightCount += wxCouponOrderMapper.findVerifiedCountForCUser(param.getId(),startTime,endTime);
workNightCount += wxCouponOrderMapper.findVerifiedCountByCUser(param.getId(),startTime,endTime);
} else {
WeekendNightCount += wxCouponOrderMapper.findVerifiedCountForCUser(param.getId(),startTime,endTime);
WeekendNightCount += wxCouponOrderMapper.findVerifiedCountByCUser(param.getId(),startTime,endTime);
}

startC.add(Calendar.DAY_OF_YEAR, -1);
@@ -464,7 +464,7 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService {
c.setTime(endTime);
c.add(Calendar.DAY_OF_YEAR, -30);
Date startTime = c.getTime();
int count = wxCouponOrderMapper.findVerifiedCountForCUser(param.getId(),startTime,endTime);
int count = wxCouponOrderMapper.findVerifiedCountByCUser(param.getId(),startTime,endTime);

float verifiedRate = (float)count/30;
if (verifiedRate > 1F/4)


+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java Просмотреть файл

@@ -108,8 +108,8 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
private boolean isCouponMerchantValid(Long couponId) {
Map paramMap = new HashMap<>();
paramMap.put("productId",couponId);
List<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantVoList(paramMap);
if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID)))){
List<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantNameList(paramMap);
if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))){
return true;
}
return false;


+ 2
- 11
mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java Просмотреть файл

@@ -192,12 +192,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
throw new MallinkException(ErrorCode.USER_IS_EMPTY);
}

Map paramMap = new HashMap();
paramMap.put("cUserId", cUserId);
paramMap.put("tenantId", wxCuser.getTenantId());
paramMap.put("couponOrderId", couponOrderId);

WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.selectDetailOfUser(paramMap);
WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.findDetail(Long.valueOf(couponOrderId));
if (wxCouponOrderCVo == null)
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL);
return new ResultData(wxCouponOrderCVo);
@@ -228,11 +223,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND);
}

Map paramMap = new HashMap();
paramMap.put("merchantId", wxMerchant.getId());
paramMap.put("tenantId", wxMerchant.getTenantId());
paramMap.put("couponOrderId", couponOrderId);
WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.selectDetailOfUser(paramMap);
WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.findDetail(Long.valueOf(couponOrderId));
if (wxCouponOrderCVo == null)
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL);
return new ResultData(wxCouponOrderCVo);


+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java Просмотреть файл

@@ -176,8 +176,8 @@ public class WxMerchantServiceImpl implements WxMerchantService {
private boolean isCouponMerchantValid(Long couponId) {
Map paramMap = new HashMap<>();
paramMap.put("productId",couponId);
List<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantVoList(paramMap);
if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID)))){
List<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantNameList(paramMap);
if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))){
return true;
}
return false;


+ 2
- 2
mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java Просмотреть файл

@@ -290,8 +290,8 @@ public class WxOrderServiceImpl implements WxOrderService {
private boolean isCouponMerchantValid(Long couponId) {
Map paramMap = new HashMap<>();
paramMap.put("productId",couponId);
List<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantVoList(paramMap);
if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID)))){
List<WxMerchantVo> merchantVoList = wxCouponMerchantMapper.findMerchantNameList(paramMap);
if (merchantVoList.stream().anyMatch((cm->cm.getMerchantStatus().equals(EnumMerchantStatus.VALID.getCode())))){
return true;
}
return false;


+ 266
- 291
mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml Просмотреть файл

@@ -102,6 +102,190 @@
</where>
</select>

<select id="findCountByDateLimit" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_order
where tenant_id = #{tenantId}
and create_date &gt;= #{startTime}
and create_date &lt;= #{endTime}
</select>

<select id="couponDataMap" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
SELECT DATE_FORMAT(create_date,'%m/%d') as createTime,
COUNT(DISTINCT c_user_id) as couponUserCount,
count(*) as couponCount,
(select Count(*)
from wx_coupon_order c
where coupon_order_status=1
AND DATE_FORMAT(create_date,'%m/%d')=createTime
AND tenant_id=#{tenantId}
AND c.update_date &gt;= #{startTime}
AND c.update_date &lt;= #{endTime}) as verifyCount,
(select Count(DISTINCT c_user_id)
from wx_coupon_order d
where coupon_order_status=1
AND DATE_FORMAT(create_date,'%m/%d')=createTime
AND tenant_id=#{tenantId}
AND d.update_date &gt;= #{startTime}
AND d.update_date &lt;= #{endTime}) as verifyUserCount
from wx_coupon_order
where tenant_id=#{tenantId}
AND create_date &gt;= #{startTime}
AND create_date &lt;= #{endTime}
GROUP BY createTime
</select>

<select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
SELECT DATE_FORMAT(wx_coupon_order.create_date,'%Y-%m-%d') as createTime,wx_coupon_order.coupon_id as couponId
,COUNT(DISTINCT c_user_id) as couponUserCount,count(*) as couponCount
,(select Count(coupon_id) from wx_coupon_order c
where coupon_order_status=1
and DATE_FORMAT(create_date,'%Y-%m-%d')=createTime
and tenant_id=#{tenantId}
and c.coupon_id=couponId
<if test="startTime != null">
and c.update_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and c.update_date &lt;= #{endTime}
</if>
) as verifyCount
,(select Count(DISTINCT c_user_id) from wx_coupon_order d
where coupon_order_status=1
and d.coupon_id=couponId
and DATE_FORMAT(create_date,'%Y-%m-%d')=createTime
and tenant_id=#{tenantId}
and d.coupon_id=couponId
<if test="startTime != null">
and d.update_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and d.update_date &lt;= #{endTime}
</if>
) as verifyUserCount
from wx_coupon_order
join wx_coupon on wx_coupon_order.coupon_id=wx_coupon.id
where wx_coupon_order.tenant_id=#{tenantId}
<if test="startTime != null">
and wx_coupon_order.create_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and wx_coupon_order.create_date &lt;= #{endTime}
</if>
<if test="couponType != null">
and wx_coupon.type = #{couponType}
</if>
<if test="couponTitle != null">
and wx_coupon.title like concat('%', #{couponTitle},'%')
</if>
GROUP BY createTime,couponId
order by createTime desc
</select>

<select id="touchUsersReportList" resultType="com.iformall.domain.vo.TouchUsersReportVo" parameterType="hashmap">
SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime
,COUNT(DISTINCT c_user_id) as userCount,count(*) as couponCount
,(select Count(*) from wx_coupon_order c
where coupon_order_status=1
and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime
and tenant_id=#{tenantId}
<if test="startTime != null">
and c.update_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and c.update_date &lt;= #{endTime}
</if>
)
as verifyCount
,(select Count(DISTINCT c_user_id) from wx_coupon_order d
where coupon_order_status=1
and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime
and tenant_id=#{tenantId}
<if test="startTime != null">
and d.update_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and d.update_date &lt;= #{endTime}
</if>
)
as verifyUserCount
from wx_coupon_order
where tenant_id=#{tenantId}
<if test="startTime != null">
AND create_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and create_date &lt;= #{endTime}
</if>
GROUP BY xTime
order by xTime desc
</select>


<select id="queryForSceneRepotyHistoryVerified" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
from wx_coupon_order c
where c.tenant_id = #{tenantId}
and c.coupon_order_status = 1
<if test=" null != startTime and null != endTime">
and c.update_date BETWEEN #{startTime} and #{endTime}
</if>
group by xTime
</select>

<select id="findVerifiedCountByCUser" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_order
where c_user_id = #{cUserId}
and update_date &gt;= #{startTime}
and update_date &lt;= #{endTime}
and coupon_order_status = 1
</select>

<select id="findOrderedCountByCUser" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_order
where c_user_id = #{cUserId}
and create_date &gt;= #{startTime}
and create_date &lt;= #{endTime}
</select>

<select id="findVerifiedCount" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_order
where tenant_id = #{tenantId}
and update_date &gt;= #{startTime}
and update_date &lt;= #{endTime}
and coupon_order_status = 1
</select>

<select id="findOrderedCount" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_order
where tenant_id = #{tenantId}
and create_date &gt;= #{startTime}
and create_date &lt;= #{endTime}
</select>

<select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" >
SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,IFNULL(SUM(coupon_price),0) as price from wx_coupon_order
where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt; #{endTime} GROUP BY xTime
</select>

<select id="queryPriceTotal" resultType="java.lang.Integer" >
SELECT IFNULL(SUM(coupon_price),0) from wx_coupon_order
where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt; #{endTime}
</select>

<update id="offExpiredCouponOrderByValidDate">
update wx_coupon_order SET coupon_order_status = 2, update_date = now()
where expired_time &lt; now() and coupon_price = 0 and coupon_order_status = 0
</update>

<select id="findExpiredCouponOrderByValidDate" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_coupon_order
where expired_time &lt; now() and coupon_price &gt; 0 and coupon_order_status = 0
</select>








@@ -124,46 +308,32 @@
<result column="use_price" jdbcType="INTEGER" property="usePrice" />
<result column="price" jdbcType="INTEGER" property="price" />

<result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />
<result column="name" jdbcType="VARCHAR" property="bUserName" />
<result column="bphone" jdbcType="VARCHAR" property="bUserPhone" />
<result column="phone" jdbcType="VARCHAR" property="cUserPhone" />
<result column="merchant_name" jdbcType="VARCHAR" property="merchantName" />

<collection column="{productId=coupon_id}" property="merchantVoList"
ofType="com.iformall.domain.vo.WxMerchantVo"
javaType="java.util.ArrayList"
select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantNameList" >
</collection>
</resultMap>

<sql id="allAdminCouponOrderColumns">
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
m.name as merchant_name, bu.name, bu.phone as bphone, cu.phone
</sql>

<sql id="allBUserVerifiedCouponOrderColumns">
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
bu.name,cu.phone
</sql>

<sql id="allBUserOrderedCouponOrderColumns">
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
cu.phone
</sql>

<sql id="allCouponOrderColumns">
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price
bu.name, bu.phone as bphone, cu.phone, m.name as merchant_name
</sql>

<select id="findListOfAdmin" parameterType="com.iformall.domain.vo.WxCouponOrderBVo" resultMap="BVoResultMap">
select <include refid="allAdminCouponOrderColumns" />
from wx_coupon_order co
inner JOIN wx_order o on o.id = co.order_id
inner JOIN wx_coupon c on co.coupon_id = c.id
inner JOIN wx_coupon c on c.id = co.coupon_id
inner JOIN wx_c_user cu on cu.id = co.c_user_id
left JOIN wx_merchant_b_user bu on co.b_user_id = bu.id
left JOIN wx_merchant m on bu.merchant_id = m.id
left JOIN wx_merchant_b_user bu on bu.id = co.b_user_id
left JOIN wx_merchant m on m.id = bu.merchant_id
where 1 = 1
<if test=" null != id ">
and co.id = #{id}
</if>

<if test=" null != tenantId ">
and co.tenant_id = #{tenantId}
@@ -189,11 +359,34 @@

</select>

<select id="findListOfOrderedByDateForBUser" parameterType="map" resultMap="BVoResultMap">

<sql id="allBUserVerifiedCouponOrderColumns">
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
bu.name,
cu.phone
</sql>

<sql id="allBUserOrderedCouponOrderColumns">
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,
cu.phone
</sql>


<select id="findListOfOrderedByDateForBUser" parameterType="map" resultMap="BVoResultMap">
select <include refid="allBUserOrderedCouponOrderColumns" />
from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu
where o.id = co.order_id
and o.merchant_id = #{merchantId}
from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu,wx_coupon_merchant cm
(select tco.id as tcoid,
(select count(*) from wx_coupon_merchant tcm
where tcm.product_id = tco.coupon_id) as mc
from wx_coupon_order tco) com
where com.mc = 1
and com.tcoid = co.id
and o.id = co.order_id
and cm.merchant_id = #{merchantId}
and cm.product_id = c.id
and cm.status = 0
and co.coupon_id = c.id
and cu.id = co.c_user_id
<if test="startDate != null">
@@ -210,20 +403,24 @@
select <include refid="allBUserVerifiedCouponOrderColumns" />
from wx_coupon_order co,wx_order o,wx_coupon c,wx_c_user cu,wx_merchant_b_user bu
where o.id = co.order_id
and o.merchant_id = #{merchantId}
and co.coupon_id = c.id
and cu.id = co.c_user_id
and bu.id = co.b_user_id
and bu.merchant_id = #{merchantId}
<if test="startDate != null">
AND co.update_date &gt; #{startDate,jdbcType=TIMESTAMP}
</if>
<if test="endDate != null">
AND co.update_date &lt; #{endDate,jdbcType=TIMESTAMP}
</if>
AND co.coupon_order_status = '1'
AND co.coupon_order_status = '1'
order by co.update_date desc
</select>

<sql id="allCouponOrderColumns">
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price
</sql>

<select id="findListOfOrderedByDate" parameterType="map" resultMap="BaseResultMap">
select <include refid="allCouponOrderColumns" />
from wx_coupon_order co,wx_order o
@@ -235,7 +432,6 @@
<if test="endDate != null">
AND co.create_date &lt; #{endDate,jdbcType=TIMESTAMP}
</if>

</select>

<select id="findListOfVerifiedByDate" parameterType="map" resultMap="BaseResultMap">
@@ -255,21 +451,16 @@


<sql id="allCUserCouponOrderListColumns">
c.id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price,
co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,co.unit,
m.name
co.id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit
</sql>

<sql id="allCUserCouponOrderDetailColumns">
c.id,c.tenant_id,c.coupon_id,c.c_user_id,c.b_user_id,c.order_id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price,
co.merchant_id,co.type,co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,co.unit,co.detail,co.remark,
m.img_url,m.name,m.link_phone,m.status,
s.addr,s.shop_number,s.baidu_poi,
mb.building_name,mf.floor_name
co.id,co.tenant_id,co.coupon_id,co.c_user_id,co.b_user_id,co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.detail,c.remark
</sql>

<resultMap id="CVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCVo">

<id column="id" jdbcType="BIGINT" property="id" />
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
<result column="coupon_id" jdbcType="BIGINT" property="couponId" />
@@ -282,8 +473,6 @@
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
<result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />


<result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
<result column="title" jdbcType="VARCHAR" property="title" />
@@ -295,27 +484,19 @@
<result column="unit" jdbcType="INTEGER" property="unit" />
<result column="remark" jdbcType="VARCHAR" property="remark" />


<result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl" />
<result column="name" jdbcType="VARCHAR" property="merchantName" />
<result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone" />
<result column="status" jdbcType="VARCHAR" property="merchantStatus" />


<result column="addr" jdbcType="VARCHAR" property="addr"/>
<result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
<result column="building_name" jdbcType="VARCHAR" property="buildingName" />
<result column="floor_name" jdbcType="VARCHAR" property="floorName" />
<result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/>
<collection column="{productId=coupon_id}" property="merchantVoList"
ofType="com.iformall.domain.vo.WxMerchantVo"
javaType="java.util.ArrayList"
select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
</collection>
</resultMap>


<select id="findListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="CVoResultMap">
select <include refid="allCUserCouponOrderListColumns" />
from wx_coupon_order c,wx_coupon co,wx_merchant m
from wx_coupon_order c,wx_coupon co
where 1=1
and c.coupon_id = co.id
and co.merchant_id = m.id
<if test="cUserId != null">
and c.c_user_id = #{cUserId}
</if>
@@ -325,163 +506,27 @@
<if test="type != null">
and co.type = #{type}
</if>
<if test="type == null">
and co.type &lt; 5
</if>
<if test="type == null">
and co.type &lt; 5
</if>
<if test="couponOrderStatus != null">
AND c.coupon_order_status = #{couponOrderStatus}
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
</select>

<select id="selectDetailOfUser" parameterType="map" resultMap="CVoResultMap">
select <include refid="allCUserCouponOrderDetailColumns" />
from wx_coupon_order c,wx_coupon co,wx_merchant m
left join wx_merchant_shop ms on ms.merchant_id = m.id and ms.is_del = 0
left join wx_shop s on ms.shop_id = s.id
left join wx_mall_building mb on s.building = mb.id
left join wx_mall_floor mf on s.floor = mf.id
where c.coupon_id = co.id
and co.merchant_id = m.id
<if test="cUserId != null">
and c.c_user_id = #{cUserId}
</if>
<if test="merchantId != null">
and co.merchant_id = #{merchantId}
</if>
<if test="tenantId != null">
and c.tenant_id = #{tenantId}
</if>
<if test="couponOrderId != null">
and c.id = #{couponOrderId}
</if>

</select>



<select id="findCountByDateLimit" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_order
where tenant_id = #{tenantId}
and create_date &gt;= #{startTime}
and create_date &lt;= #{endTime}
</select>

<select id="couponDataMap" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
SELECT DATE_FORMAT(create_date,'%m/%d') as createTime,
COUNT(DISTINCT c_user_id) as couponUserCount,
count(*) as couponCount,
(select Count(*)
from wx_coupon_order c
where coupon_order_status=1
AND DATE_FORMAT(create_date,'%m/%d')=createTime
AND tenant_id=#{tenantId}
AND c.update_date &gt;= #{startTime}
AND c.update_date &lt;= #{endTime}) as verifyCount,
(select Count(DISTINCT c_user_id)
from wx_coupon_order d
where coupon_order_status=1
AND DATE_FORMAT(create_date,'%m/%d')=createTime
AND tenant_id=#{tenantId}
AND d.update_date &gt;= #{startTime}
AND d.update_date &lt;= #{endTime}) as verifyUserCount
from wx_coupon_order
where tenant_id=#{tenantId}
AND create_date &gt;= #{startTime}
AND create_date &lt;= #{endTime}
GROUP BY createTime
</select>

<select id="couponDataList" resultType="com.iformall.domain.vo.MarkingCouponDataReportVo" parameterType="hashmap">
SELECT DATE_FORMAT(wx_coupon_order.create_date,'%Y-%m-%d') as createTime,wx_coupon_order.coupon_id as couponId
,COUNT(DISTINCT c_user_id) as couponUserCount,count(*) as couponCount
,(select Count(coupon_id) from wx_coupon_order c
where coupon_order_status=1
and DATE_FORMAT(create_date,'%Y-%m-%d')=createTime
and tenant_id=#{tenantId}
and c.coupon_id=couponId
<if test="startTime != null">
and c.update_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and c.update_date &lt;= #{endTime}
</if>
) as verifyCount
,(select Count(DISTINCT c_user_id) from wx_coupon_order d
where coupon_order_status=1
and d.coupon_id=couponId
and DATE_FORMAT(create_date,'%Y-%m-%d')=createTime
and tenant_id=#{tenantId}
and d.coupon_id=couponId
<if test="startTime != null">
and d.update_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and d.update_date &lt;= #{endTime}
</if>
) as verifyUserCount
from wx_coupon_order
join wx_coupon on wx_coupon_order.coupon_id=wx_coupon.id
where wx_coupon_order.tenant_id=#{tenantId}
<if test="startTime != null">
and wx_coupon_order.create_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and wx_coupon_order.create_date &lt;= #{endTime}
</if>
<if test="couponType != null">
and wx_coupon.type = #{couponType}
</if>
<if test="couponTitle != null">
and wx_coupon.title like concat('%', #{couponTitle},'%')
</if>
GROUP BY createTime,couponId
order by createTime desc
</select>

<select id="touchUsersReportList" resultType="com.iformall.domain.vo.TouchUsersReportVo" parameterType="hashmap">
SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime
,COUNT(DISTINCT c_user_id) as userCount,count(*) as couponCount
,(select Count(*) from wx_coupon_order c
where coupon_order_status=1
and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime
and tenant_id=#{tenantId}
<if test="startTime != null">
and c.update_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and c.update_date &lt;= #{endTime}
</if>
)
as verifyCount
,(select Count(DISTINCT c_user_id) from wx_coupon_order d
where coupon_order_status=1
and DATE_FORMAT(create_date,'%Y-%m-%d')=xTime
and tenant_id=#{tenantId}
<if test="startTime != null">
and d.update_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and d.update_date &lt;= #{endTime}
</if>
)
as verifyUserCount
from wx_coupon_order
where tenant_id=#{tenantId}
<if test="startTime != null">
AND create_date &gt;= #{startTime}
</if>
<if test="endTime != null">
and create_date &lt;= #{endTime}
</if>
GROUP BY xTime
order by xTime desc
<select id="findDetail" parameterType="java.lang.Long" resultMap="CVoResultMap">
select <include refid="allCUserCouponOrderDetailColumns" />
from wx_coupon_order co,wx_coupon c
where co.coupon_id = c.id
and co.id = #{id}
</select>

<sql id="allCUserCouponOrderCarListColumns">
c.id,c.expired_time,c.coupon_order_status,c.create_date,c.update_date,c.coupon_price,
co.cover_img,co.title,co.sub_title,co.sale_price,co.use_price,co.price,co.unit,m.id as merchant_id,
m.name,json_extract(car.vendor_params,'$.id') as coupon_free_id
co.id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,
c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,
json_extract(car.vendor_params,'$.id') as coupon_free_id
</sql>

<resultMap id="CCarVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCarCVo">
@@ -498,8 +543,6 @@
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
<result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />


<result column="merchant_id" jdbcType="BIGINT" property="merchantId" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="cover_img" jdbcType="VARCHAR" property="coverImg" />
<result column="title" jdbcType="VARCHAR" property="title" />
@@ -510,105 +553,37 @@
<result column="price" jdbcType="INTEGER" property="price" />
<result column="remark" jdbcType="VARCHAR" property="remark" />

<result column="img_url" jdbcType="VARCHAR" property="merchantImgUrl" />
<result column="name" jdbcType="VARCHAR" property="merchantName" />
<result column="link_phone" jdbcType="VARCHAR" property="merchantLinkPhone" />
<result column="status" jdbcType="VARCHAR" property="merchantStatus" />


<result column="addr" jdbcType="VARCHAR" property="addr"/>
<result column="shop_number" jdbcType="VARCHAR" property="shopNumber"/>
<result column="building_name" jdbcType="VARCHAR" property="buildingName" />
<result column="floor_name" jdbcType="VARCHAR" property="floorName" />
<result column="baidu_poi" jdbcType="VARCHAR" property="baiduPoi"/>

<result column="coupon_free_id" jdbcType="INTEGER" property="couponFreeId"/>

<collection column="{productId=coupon_id}" property="merchantVoList"
ofType="com.iformall.domain.vo.WxMerchantVo"
javaType="java.util.ArrayList"
select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" >
</collection>
</resultMap>


<select id="findCarListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCarCVo" resultMap="CCarVoResultMap">
select <include refid="allCUserCouponOrderCarListColumns" />
from wx_coupon_order c,wx_coupon co,wx_merchant m, wx_coupon_car car
where 1=1
and c.coupon_id = co.id
and c.coupon_id = car.id
and co.merchant_id = m.id
from wx_coupon_order co,wx_coupon c, wx_coupon_car car
where co.coupon_id = c.id
and co.coupon_id = car.id
<if test="cUserId != null">
and c.c_user_id = #{cUserId}
and co.c_user_id = #{cUserId}
</if>
<if test="tenantId != null">
and c.tenant_id = #{tenantId}
and co.tenant_id = #{tenantId}
</if>
<if test="id != null">
and co.id = #{id}
</if>
<if test="type != null">
and co.type = #{type}
</if>
<if test="id != null">
and c.id = #{id}
and c.type = #{type}
</if>
<if test="couponOrderStatus != null">
AND c.coupon_order_status = #{couponOrderStatus}
AND co.coupon_order_status = #{couponOrderStatus}
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
</select>

<select id="queryForSceneRepotyHistoryVerified" resultType="com.iformall.domain.vo.MarkingSceneDataVo" parameterType="hashmap">
select DATE_FORMAT(update_date,'%Y-%m-%d') xTime, count(c.id) triggerCount
from wx_coupon_order c
where c.tenant_id = #{tenantId}
and c.coupon_order_status = 1
<if test=" null != startTime and null != endTime">
and c.update_date BETWEEN #{startTime} and #{endTime}
</if>
group by xTime
</select>

<select id="findVerifiedCountForCUser" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_order
where c_user_id = #{cUserId}
and update_date &gt;= #{startTime}
and update_date &lt;= #{endTime}
and coupon_order_status = 1
</select>

<select id="findOrderedCountForCUser" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_order
where c_user_id = #{cUserId}
and create_date &gt;= #{startTime}
and create_date &lt;= #{endTime}
</select>

<select id="findVerifiedCount" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_order
where tenant_id = #{tenantId}
and update_date &gt;= #{startTime}
and update_date &lt;= #{endTime}
and coupon_order_status = 1
</select>

<select id="findOrderedCount" resultType="java.lang.Integer">
select COUNT(*) FROM wx_coupon_order
where tenant_id = #{tenantId}
and create_date &gt;= #{startTime}
and create_date &lt;= #{endTime}
</select>

<select id="queryPriceTotalGroup" resultType="com.iformall.domain.vo.CUserDateAmountVo" >
SELECT DATE_FORMAT(create_date,'%Y-%m-%d') as xTime,IFNULL(SUM(coupon_price),0) as price from wx_coupon_order
where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt; #{endTime} GROUP BY xTime
</select>

<select id="queryPriceTotal" resultType="java.lang.Integer" >
SELECT IFNULL(SUM(coupon_price),0) from wx_coupon_order
where tenant_id=#{tenantId} AND create_date &gt;= #{startTime} and create_date &lt; #{endTime}
</select>

<update id="offExpiredCouponOrderByValidDate">
update wx_coupon_order SET coupon_order_status = 2, update_date = now()
where expired_time &lt; now() and coupon_price = 0 and coupon_order_status = 0
</update>

<select id="findExpiredCouponOrderByValidDate" parameterType="com.iformall.domain.po.WxCouponOrder" resultMap="BaseResultMap">
select <include refid="allColumns" /> from wx_coupon_order
where expired_time &lt; now() and coupon_price &gt; 0 and coupon_order_status = 0
</select>

</mapper>

Загрузка…
Отмена
Сохранить