提交 f291b0d9 authored 作者: luojie's avatar luojie

修改优惠券接口

上级 aa6cff1c
package com.diaoyun.zion.chinafrica.dao;
import com.diaoyun.zion.chinafrica.entity.TbCfCouponCategoryEntity;
import com.diaoyun.zion.master.dao.BaseDao;
import java.util.List;
/**
* 优惠券发放Dao
*
* @author lipengjun
* @date 2019-10-22 10:23:49
*/
public interface TbCfCouponCategoryDao extends BaseDao<TbCfCouponCategoryEntity> {
/**
* 获取优惠券类型
* @param categoryId
* @return
*/
List<TbCfCouponCategoryEntity> queryByCouponCategoryId(String categoryId);
}
package com.diaoyun.zion.chinafrica.entity;
import java.io.Serializable;
/**
* 优惠券类型表实体
* 表名 tb_cf_coupon_category
*
* @author lipengjun
* @date 2019-10-22 10:23:49
*/
public class TbCfCouponCategoryEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 优惠券类型id
*/
private String couponCategoryId;
/**
* 优惠券类型名称
*/
private String couponCategoryName;
/**
* 设置:优惠券类型id
*/
public void setCouponCategoryId(String couponCategoryId) {
this.couponCategoryId = couponCategoryId;
}
/**
* 获取:优惠券类型id
*/
public String getCouponCategoryId() {
return couponCategoryId;
}
/**
* 设置:优惠券类型名称
*/
public void setCouponCategoryName(String couponCategoryName) {
this.couponCategoryName = couponCategoryName;
}
/**
* 获取:优惠券类型名称
*/
public String getCouponCategoryName() {
return couponCategoryName;
}
}
......@@ -27,12 +27,12 @@ public class TbCfCouponEntity implements Serializable {
* 优惠券类型
*/
@ApiModelProperty("优惠券类型")
private Integer couponCategoryId;
private String couponCategoryId;
/**
* 优惠券类型
*/
@ApiModelProperty("优惠券类型名称")
private Integer couponCategoryName;
private String couponCategoryName;
/**
* 可用于类目
*/
......@@ -140,22 +140,22 @@ public class TbCfCouponEntity implements Serializable {
/**
* 设置:优惠券类型
*/
public void setCouponCategoryId(Integer couponCategoryId) {
public void setCouponCategoryId(String couponCategoryId) {
this.couponCategoryId = couponCategoryId;
}
/**
* 获取:优惠券类型
*/
public Integer getCouponCategoryId() {
public String getCouponCategoryId() {
return couponCategoryId;
}
public Integer getCouponCategoryName() {
public String getCouponCategoryName() {
return couponCategoryName;
}
public void setCouponCategoryName(Integer couponCategoryName) {
public void setCouponCategoryName(String couponCategoryName) {
this.couponCategoryName = couponCategoryName;
}
......
package com.diaoyun.zion.chinafrica.service;
import com.diaoyun.zion.chinafrica.entity.TbCfCouponCategoryEntity;
import java.util.List;
import java.util.Map;
/**
* 优惠券类型表Service接口
*
* @author lipengjun
* @date 2019-10-22 10:23:49
*/
public interface TbCfCouponCategoryService {
/**
* 根据主键查询实体
*
* @param
* @return 实体
*/
TbCfCouponCategoryEntity queryObject(String couponCategoryId);
/**
* 分页查询
*
* @param map 参数
* @return list
*/
List<TbCfCouponCategoryEntity> queryList(Map<String, Object> map);
/**
* 分页统计总数
*
* @param map 参数
* @return 总数
*/
int queryTotal(Map<String, Object> map);
/**
* 保存实体
*
* @param tbCfCouponCategory 实体
* @return 保存条数
*/
int save(TbCfCouponCategoryEntity tbCfCouponCategory);
/**
* 根据主键更新实体
*
* @param tbCfCouponCategory 实体
* @return 更新条数
*/
int update(TbCfCouponCategoryEntity tbCfCouponCategory);
/**
* 根据主键删除
*
* @param couponCategoryId
* @return 删除条数
*/
int delete(String couponCategoryId);
/**
* 根据主键批量删除
*
* @param couponCategoryIds
* @return 删除条数
*/
int deleteBatch(String[] couponCategoryIds);
/**
* 根据优惠券类型id查询
* @param categoryId
* @return
*/
List<TbCfCouponCategoryEntity> queryByCouponCategoryId(String categoryId);
}
package com.diaoyun.zion.chinafrica.service.impl;
import com.diaoyun.zion.chinafrica.dao.TbCfCouponCategoryDao;
import com.diaoyun.zion.chinafrica.entity.TbCfCouponCategoryEntity;
import com.diaoyun.zion.chinafrica.service.TbCfCouponCategoryService;
import com.diaoyun.zion.master.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* 优惠券类型Service实现类
*
* @author lipengjun
* @date 2019-10-22 10:23:49
*/
@Service("tbCfCouponCategoryService")
public class TbCfCouponCategoryServiceImpl implements TbCfCouponCategoryService {
@Autowired
private TbCfCouponCategoryDao tbCfCouponCategoryDao;
@Override
public TbCfCouponCategoryEntity queryObject(String couponCategoryId) {
return tbCfCouponCategoryDao.queryObject(couponCategoryId);
}
@Override
public List<TbCfCouponCategoryEntity> queryList(Map<String, Object> map) {
return tbCfCouponCategoryDao.queryList(map);
}
@Override
public int queryTotal(Map<String, Object> map) {
return tbCfCouponCategoryDao.queryTotal(map);
}
@Override
public int save(TbCfCouponCategoryEntity tbCfCouponCategory) {
tbCfCouponCategory.setCouponCategoryId(IdUtil.createIdbyUUID());
return tbCfCouponCategoryDao.save(tbCfCouponCategory);
}
@Override
public int update(TbCfCouponCategoryEntity tbCfCouponCategory) {
return tbCfCouponCategoryDao.update(tbCfCouponCategory);
}
@Override
public int delete(String couponCategoryId) {
return tbCfCouponCategoryDao.delete(couponCategoryId);
}
@Override
public int deleteBatch(String[] couponCategoryIds) {
return tbCfCouponCategoryDao.deleteBatch(couponCategoryIds);
}
@Override
public List<TbCfCouponCategoryEntity> queryByCouponCategoryId(String categoryId) {
return tbCfCouponCategoryDao.queryByCouponCategoryId(categoryId);
}
}
......@@ -164,13 +164,13 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
tokenManager.addToken(token, tbCfUserInfoVo);
result.setMessage(ResultCodeEnum.SUCCESS.getDesc());
result.setData(tbCfUserInfoVo);
/*
//获取购物返券
List<TbCfCouponEntity> couponList = tbCfCouponDao.getCouponByCategory(CouponCategoryEnum.REGISTER.getValue(),new Date());
if(!couponList.isEmpty()) {
//领取优惠券
tbCfCouponService.takeCoupon(couponList.get(0).getCouponId(),tbCfUserInfoVo.getUserId());
}
}*/
} else {
result.setCode(ResultCodeEnum.VALIDATE_ERROR.getCode());
result.setMessage("The mailbox or nick has been registered");
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.platform.dao.TbCfCouponCategoryDao">
<resultMap type="com.diaoyun.zion.chinafrica.entity.TbCfCouponCategoryEntity" id="tbCfCouponCategoryMap">
<result property="couponCategoryId" column="coupon_category_id"/>
<result property="couponCategoryName" column="coupon_category_name"/>
</resultMap>
<select id="queryObject" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponCategoryEntity">
select
`coupon_category_id`,
`coupon_category_name`
from tb_cf_coupon_category
where coupon_category_id = #{id}
</select>
<select id="queryByCouponCategoryId" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponCategoryEntity">
select
`coupon_category_id`,
`coupon_category_name`
from tb_cf_coupon_category
where coupon_category_id = #{id}
</select>
<select id="queryList" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponCategoryEntity">
select
`coupon_category_id`,
`coupon_category_name`
from tb_cf_coupon_category
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by coupon_category_id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from tb_cf_coupon_category
WHERE 1=1
<if test="name != null and name.trim() != ''">
AND name LIKE concat('%',#{name},'%')
</if>
</select>
<insert id="save" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfCouponCategoryEntity">
insert into tb_cf_coupon_category(
`coupon_category_id`,
`coupon_category_name`)
values(
#{couponCategoryId},
#{couponCategoryName})
</insert>
<update id="update" parameterType="com.diaoyun.zion.chinafrica.entity.TbCfCouponCategoryEntity">
update tb_cf_coupon_category
<set>
<if test="couponCategoryName != null">`coupon_category_name` = #{couponCategoryName}</if>
</set>
where coupon_category_id = #{couponCategoryId}
</update>
<delete id="delete">
delete from tb_cf_coupon_category where coupon_category_id = #{value}
</delete>
<delete id="deleteBatch">
delete from tb_cf_coupon_category where coupon_category_id in
<foreach item="couponCategoryId" collection="array" open="(" separator="," close=")">
#{couponCategoryId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -187,7 +187,29 @@
</delete>
<!--查询用户所有有效的优惠券-->
<select id="queryUserAvailableCoupon" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity">
select DISTINCT t2.* from tb_cf_take_coupon t1,tb_cf_coupon t2,tb_cf_issue_coupon t3
select DISTINCT
t2.coupon_id,
t2.coupon_category_id,
t4.coupon_category_name,
t2.coupon_use,
t2.coupon_title,
t2.coupon_icon,
t2.with_station_id,
t2.with_amount,
t2.deduct_amount,
t2.quato,
t2.take_count,
t2.used_count,
t2.start_time,
t2.end_time,
t2.valid_start_time,
t2.valid_end_time,
t2.status,
t2.create_user_id,
t2.create_time,
t2.update_user_id,
t2.update_time
from tb_cf_take_coupon t1,tb_cf_coupon t2,tb_cf_issue_coupon t3,tb_cf_coupon_category t4
where ((t3.user_id=#{userId} and t3.coupon_id=t2.coupon_id and t2.status=1 and t3.enable_flag=1)
or (t1.user_id=#{userId} and t1.coupon_id=t2.coupon_id and t2.status=1 and t1.enable_flag=1))
and <![CDATA[ t2.valid_start_time<=#{nowTime}]]> and <![CDATA[t2.valid_end_time>=#{nowTime}]]>
......@@ -200,13 +222,56 @@
<!--获取已使用的优惠券-->
<select id="queryUserUsedCoupon" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity">
select t2.* from tb_cf_take_coupon t1,tb_cf_coupon t2 ,tb_cf_issue_coupon t3
select DISTINCT
t2.coupon_id,
t2.coupon_category_id,
t4.coupon_category_name,
t2.coupon_use,
t2.coupon_title,
t2.coupon_icon,
t2.with_station_id,
t2.with_amount,
t2.deduct_amount,
t2.quato,
t2.take_count,
t2.used_count,
t2.start_time,
t2.end_time,
t2.valid_start_time,
t2.valid_end_time,
t2.status,
t2.create_user_id,
t2.create_time,
t2.update_user_id,
t2.update_time
from tb_cf_take_coupon t1,tb_cf_coupon t2 ,tb_cf_issue_coupon t3,tb_cf_coupon_category t4
where ((t1.user_id=#{userId} and t1.coupon_id=t2.coupon_id and t1.enable_flag=0)
or (t3.user_id=#{userId} and t3.coupon_id=t2.coupon_id and t3.enable_flag=0))
</select>
<!--获取已过期的优惠券-->
<select id="queryUserExpiredoupon" resultType="com.diaoyun.zion.chinafrica.entity.TbCfCouponEntity">
select t2.* from tb_cf_take_coupon t1,tb_cf_coupon t2 ,tb_cf_issue_coupon t3
select DISTINCT
t2.coupon_id,
t2.coupon_category_id,
t4.coupon_category_name,
t2.coupon_use,
t2.coupon_title,
t2.coupon_icon,
t2.with_station_id,
t2.with_amount,
t2.deduct_amount,
t2.quato,
t2.take_count,
t2.used_count,
t2.start_time,
t2.end_time,
t2.valid_start_time,
t2.valid_end_time,
t2.status,
t2.create_user_id,
t2.create_time,
t2.update_user_id,
t2.update_time from tb_cf_take_coupon t1,tb_cf_coupon t2 ,tb_cf_issue_coupon t3,tb_cf_coupon_category t4
where ((t1.user_id=#{userId} and t1.coupon_id=t2.coupon_id and <![CDATA[ t2.valid_end_time<#{nowTime}]]> and t1.enable_flag=1)
or (t1.user_id=#{userId} and t1.coupon_id=t2.coupon_id and <![CDATA[ t2.valid_end_time<#{nowTime}]]> and t1.enable_flag=1))
</select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论