Commit 38baf36c authored by hezhen's avatar hezhen

添加优惠卷

parent 08c2af74
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
<module>xx-tour</module> <module>xx-tour</module>
<module>xx-im</module> <module>xx-im</module>
<module>xx-campsite</module> <module>xx-campsite</module>
<module>xx-activity</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>
<developers> <developers>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ace-security</artifactId>
<groupId>com.github.wxiaoqi</groupId>
<version>2.0-SNAPSHOT</version>
</parent>
<groupId>com.xxfc.platform</groupId>
<modules>
<module>xx-activity-api</module>
<module>xx-activity-server</module>
</modules>
<modelVersion>4.0.0</modelVersion>
<artifactId>xx-activity</artifactId>
<packaging>pom</packaging>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.xxfc.common</groupId>
<artifactId>xx-common-platform</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-activity-api</artifactId>
<dependencies>
<dependency>
<groupId>com.github.wxiaoqi</groupId>
<artifactId>ace-admin-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.xxfc.platform.activity.constant;
/**
* 优惠卷用处
*/
public enum CouponUsed{
SHOP(10, "店铺优惠券"),
SHOPNEW(11,"新人店铺券"),
GOOD(20,"商品优惠券"),
CATA(30, "类目优惠券"),
ALL(60, "平台优惠券"),
ALLNEW(61, "新人平台券");
Integer code;
String msg;
CouponUsed(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.xxfc.platform.activity.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 优惠券表
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-21 14:34:49
*/
@Data
@Table(name = "coupon")
public class Coupon implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键id")
private Integer id;
/**
* 优惠券标题(有图片则显示图片):无门槛50元优惠券 | 单品最高减2000元
*/
@Column(name = "title")
@ApiModelProperty(value = "优惠券标题(有图片则显示图片):无门槛50元优惠券 | 单品最高减2000元")
private String title;
/**
* 图片
*/
@Column(name = "icon")
@ApiModelProperty(value = "图片")
private String icon;
/**
* 可用于:10店铺优惠券 11新人店铺券 20商品优惠券 30类目优惠券 60平台优惠券 61新人平台券
*/
@Column(name = "used")
@ApiModelProperty(value = "可用于:10店铺优惠券 11新人店铺券 20商品优惠券 30类目优惠券 60平台优惠券 61新人平台券")
private Integer used;
/**
* 0-全平台;1-租车;2-旅游;3-营地
*/
@Column(name = "channel")
@ApiModelProperty(value = "0-全平台;1-租车;2-旅游;3-营地")
private Integer channel;
/**
* 0-普通用户;1-会员用户
*/
@Column(name = "user_type")
@ApiModelProperty(value = "0-普通用户;1-会员用户")
private Integer userType;
/**
* 1满减券 2叠加满减券 3无门槛券(需要限制大小)
*/
@Column(name = "type")
@ApiModelProperty(value = "1满减券 2叠加满减券 3无门槛券(需要限制大小)")
private Integer type;
/**
* 1可用于特价商品 2不能 默认不能(商品优惠卷除外)
*/
@Column(name = "with_special")
@ApiModelProperty(value = "1可用于特价商品 2不能 默认不能(商品优惠卷除外)")
private Integer withSpecial;
/**
* 店铺或商品流水号
*/
@Column(name = "with_sn")
@ApiModelProperty(value = "店铺或商品流水号")
private String withSn;
/**
* 满多少金额
*/
@Column(name = "with_amount")
@ApiModelProperty(value = "满多少金额")
private BigDecimal withAmount;
/**
* 用券抵扣金额
*/
@Column(name = "used_amount")
@ApiModelProperty(value = "用券抵扣金额")
private BigDecimal usedAmount;
/**
* 配额:发券数量
*/
@Column(name = "quota")
@ApiModelProperty(value = "配额:发券数量")
private Integer quota;
/**
* 每人限领次数
*/
@Column(name = "limit_collar")
@ApiModelProperty(value = "每人限领次数")
private Integer limitCollar;
/**
* 已领取的优惠券数量
*/
@Column(name = "take_count")
@ApiModelProperty(value = "已领取的优惠券数量")
private Integer takeCount;
/**
* 已使用的优惠券数量
*/
@Column(name = "used_count")
@ApiModelProperty(value = "已使用的优惠券数量")
private Integer usedCount;
/**
* 发放开始时间
*/
@Column(name = "start_time")
@ApiModelProperty(value = "发放开始时间")
private Long startTime;
/**
* 发放结束时间
*/
@Column(name = "end_time")
@ApiModelProperty(value = "发放结束时间")
private Long endTime;
/**
* 时效:1绝对时效(领取后XXX-XXX时间段有效) 2相对时效(领取后N天有效)
*/
@Column(name = "valid_type")
@ApiModelProperty(value = "时效:1绝对时效(领取后XXX-XXX时间段有效) 2相对时效(领取后N天有效)")
private Integer validType;
/**
* 使用开始时间
*/
@Column(name = "valid_start_time")
@ApiModelProperty(value = "使用开始时间")
private Long validStartTime;
/**
* 使用结束时间
*/
@Column(name = "valid_end_time")
@ApiModelProperty(value = "使用结束时间")
private Long validEndTime;
/**
* 自领取之日起有效天数
*/
@Column(name = "valid_days")
@ApiModelProperty(value = "自领取之日起有效天数")
private Integer validDays;
/**
* 1生效 2失效 3已结束
*/
@Column(name = "status")
@ApiModelProperty(value = "1生效 2失效 3已结束")
private Integer status;
/**
* 跳转链接
*/
@Column(name = "url")
@ApiModelProperty(value = "跳转链接")
private String url;
/**
* 创建人
*/
@Column(name = "crt_user")
@ApiModelProperty(value = "创建人")
private Integer crtUser;
/**
* 创建人名称
*/
@Column(name = "crt_name")
@ApiModelProperty(value = "创建人名称")
private String crtName;
/**
* 创建时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Long crtTime;
/**
* 更新时间
*/
@Column(name = "upd_user")
@ApiModelProperty(value = "更新时间")
private Integer updUser;
/**
* 更新人名称
*/
@Column(name = "upd_name")
@ApiModelProperty(value = "更新人名称")
private String updName;
/**
* 创建时间
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "创建时间", hidden = true )
private Long updTime;
/**
* 是否删除;0-正常;1-删除
*/
@Column(name = "is_del")
@ApiModelProperty(value = "是否删除;0-正常;1-删除")
private Integer isDel;
}
package com.xxfc.platform.activity.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
/**
* 我的优惠卷
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-21 14:34:49
*/
@Data
@Table(name = "user_coupon")
public class UserCoupon implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
@Id
@GeneratedValue(generator = "JDBC")
@ApiModelProperty("主键id")
private Integer id;
/**
* 优惠卡券id
*/
@Column(name = "coupon_id")
@ApiModelProperty(value = "优惠卡券id")
private Integer couponId;
/**
* 用户id
*/
@Column(name = "user_id")
@ApiModelProperty(value = "用户id")
private Integer userId;
/**
* 券号
*/
@Column(name = "ticker_no")
@ApiModelProperty(value = "券号")
private String tickerNo;
/**
* 0-未使用;1-已使用
*/
@Column(name = "is_use")
@ApiModelProperty(value = "0-未使用;1-已使用")
private Integer isUse;
/**
* 使用订单号
*/
@Column(name = "order_no")
@ApiModelProperty(value = "使用订单号")
private String orderNo;
/**
* 领卷时间
*/
@Column(name = "crt_time")
@ApiModelProperty(value = "领卷时间", hidden = true )
private Long crtTime;
/**
* 更新时间
*/
@Column(name = "upd_time")
@ApiModelProperty(value = "更新时间", hidden = true )
private Long updTime;
/**
* 使用时间
*/
@Column(name = "use_time")
@ApiModelProperty(value = "使用时间")
private Long useTime;
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.xxfc.common</groupId>
<artifactId>xx-common-platform-web</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-activity-server</artifactId>
<dependencies>
<!-- 自己项目 -->
<dependency>
<groupId>com.xxfc.platform</groupId>
<artifactId>xx-activity-api</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- 此插件用来生成通用mapper的代码 -->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<configurationFile>
${basedir}/src/main/resources/builder/generatorConfig.xml
</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.30</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>${mapper.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.xxfc.platform.activity;
import com.ace.cache.EnableAceCache;
import com.github.wxiaoqi.security.auth.client.EnableAceAuthClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableScheduling;
import tk.mybatis.spring.annotation.MapperScan;
/**
* @author libin
* @version 1.0
* @description 活动
* @data 2019/6/14 11:19
*/
@SpringBootApplication(scanBasePackages = {
"com.xxfc.platform",
"com.github.wxiaoqi",
})
@EnableDiscoveryClient
@EnableScheduling
@EnableAceAuthClient
@EnableFeignClients({"com.github.wxiaoqi.security.auth.client.feign", "com.github.wxiaoqi.security.admin.feign","com.xxfc.platform"})
@EnableAceCache
@EnableCaching
@MapperScan(basePackages = "com.xxfc.platform.activity.mapper")
public class ActivityApplication {
public static void main(String[] args) {
SpringApplication.run(ActivityApplication.class, args);
}
}
package com.xxfc.platform.activity.biz;
import com.xxfc.platform.activity.constant.CouponUsed;
import com.xxfc.platform.activity.entity.Coupon;
import org.springframework.stereotype.Service;
import com.xxfc.platform.activity.mapper.CouponMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
/**
* 优惠券表
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-21 14:34:49
*/
@Service
public class CouponBiz extends BaseBiz<CouponMapper, Coupon> {
//获取优惠卷
public Coupon getCouponByUsed(Integer used){
Example example=new Example(Coupon.class);
example.createCriteria().andEqualTo("used",used )
.andEqualTo("status",1).andEqualTo("isDel",0);
List<Coupon> list=selectByExample(example);
if (list.size()>0){
return list.get(0);
}
return null;
}
}
\ No newline at end of file
package com.xxfc.platform.activity.biz;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import com.xxfc.platform.activity.entity.Coupon;
import com.xxfc.platform.activity.entity.UserCoupon;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xxfc.platform.activity.mapper.UserCouponMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz;
import tk.mybatis.mapper.entity.Example;
/**
* 我的优惠卷
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-21 14:34:49
*/
@Service
@Slf4j
public class UserCouponBiz extends BaseBiz<UserCouponMapper, UserCoupon> {
@Autowired
private CouponBiz couponBiz;
//自动发送优惠卷
public ObjectRestResponse authledCoupon(Integer userId){
if (userId==null||userId==0){
return ObjectRestResponse.createFailedResult(ResultCode.NULL_CODE,"参数不能为空");
}
Coupon coupon=couponBiz.getCouponByUsed(userId);
if (coupon==null){
log.error(userId+"----无可领取优惠卷");
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE,"无可领取优惠卷");
}
Integer couponId=coupon.getId();
Example example=new Example(UserCoupon.class);
example.createCriteria().andEqualTo("userId",userId).andEqualTo("couponId",couponId);
return ObjectRestResponse.succ();
}
}
\ No newline at end of file
package com.xxfc.platform.activity.mapper;
import com.xxfc.platform.activity.entity.Coupon;
import tk.mybatis.mapper.common.Mapper;
/**
* 优惠券表
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-21 14:34:49
*/
public interface CouponMapper extends Mapper<Coupon> {
}
package com.xxfc.platform.activity.mapper;
import com.xxfc.platform.activity.entity.UserCoupon;
import tk.mybatis.mapper.common.Mapper;
/**
* 我的优惠卷
*
* @author libin
* @email 18178966185@163.com
* @date 2019-06-21 14:34:49
*/
public interface UserCouponMapper extends Mapper<UserCoupon> {
}
package com.xxfc.platform.activity.rest;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.activity.biz.CouponBiz;
import com.xxfc.platform.activity.entity.Coupon;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("coupon")
public class CouponController extends BaseController<CouponBiz, Coupon> {
}
\ No newline at end of file
package com.xxfc.platform.activity.rest;
import com.github.wxiaoqi.security.common.rest.BaseController;
import com.xxfc.platform.activity.biz.UserCouponBiz;
import com.xxfc.platform.activity.entity.UserCoupon;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("userCoupon")
public class UserCouponController extends BaseController<UserCouponBiz, UserCoupon> {
}
\ No newline at end of file
#spring:
# application:
# name: vehicle
# cloud:
# nacos:
# config:
# server-addr: 127.0.0.1:8848
# file-extension: yaml
# profiles:
# active: dev
spring:
profiles:
active: dev
application:
name: xx-activity
cloud:
nacos:
config:
file-extension: yaml
---
spring:
profiles: dev
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848
---
spring:
profiles: pro
cloud:
nacos:
config:
server-addr: 10.5.52.2:8848
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<!--<properties resource="dev.properties"/>-->
<context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<property name="mergeable" value="false"></property>
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="tk.mybatis.mapper.common.Mapper"/>
</plugin>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/vehicle?useUnicode=true&amp;characterEncoding=UTF8"
userId="root"
password="xx2019fc">
</jdbcConnection>
<javaModelGenerator targetPackage="${targetModelPackage}" targetProject="${targetJavaProject}"/>
<sqlMapGenerator targetPackage="${targetXMLPackage}" targetProject="${targetResourcesProject}"/>
<javaClientGenerator targetPackage="${targetMapperPackage}" targetProject="${targetJavaProject}"
type="XMLMAPPER"/>
<!-- <table tableName="vehicle" domainObjectName="Vehicle">-->
<!-- </table>-->
<!-- <table tableName="vehicle_book_info" domainObjectName="VehicleBookInfo">-->
<!-- </table>-->
<!-- <table tableName="vehicle_book_record" domainObjectName="VehicleBookRecord">-->
<!-- </table>-->
<!-- <table tableName="branch_company" domainObjectName="BranchCompany">-->
<!-- </table>-->
<!-- <table tableName="branch_company_stock_info" domainObjectName="BranchCompanyStockInfo"></table>-->
<!-- <table tableName="branch_company_stock_apply_info" domainObjectName="BranchCompanyStockApplyInfo"></table>-->
<table tableName="vehicle_upkeep_item" domainObjectName="VehicleUpkeepItem"></table>
<table tableName="vehicle_upkeep_log" domainObjectName="VehicleUpkeepLog"></table>
</context>
</generatorConfiguration>
\ No newline at end of file
<?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.xxfc.platform.activity.mapper.CouponMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.activity.entity.Coupon" id="couponMap">
<result property="id" column="id"/>
<result property="title" column="title"/>
<result property="icon" column="icon"/>
<result property="used" column="used"/>
<result property="channel" column="channel"/>
<result property="userType" column="user_type"/>
<result property="type" column="type"/>
<result property="withSpecial" column="with_special"/>
<result property="withSn" column="with_sn"/>
<result property="withAmount" column="with_amount"/>
<result property="usedAmount" column="used_amount"/>
<result property="quota" column="quota"/>
<result property="limitCollar" column="limit_collar"/>
<result property="takeCount" column="take_count"/>
<result property="usedCount" column="used_count"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="validType" column="valid_type"/>
<result property="validStartTime" column="valid_start_time"/>
<result property="validEndTime" column="valid_end_time"/>
<result property="validDays" column="valid_days"/>
<result property="status" column="status"/>
<result property="url" column="url"/>
<result property="crtUser" column="crt_user"/>
<result property="crtName" column="crt_name"/>
<result property="crtTime" column="crt_time"/>
<result property="updUser" column="upd_user"/>
<result property="updName" column="upd_name"/>
<result property="updTime" column="upd_time"/>
<result property="isDel" column="is_del"/>
</resultMap>
</mapper>
\ No newline at end of file
<?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.xxfc.platform.activity.mapper.UserCouponMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.xxfc.platform.activity.entity.UserCoupon" id="userCouponMap">
<result property="id" column="id"/>
<result property="couponId" column="coupon_id"/>
<result property="userId" column="user_id"/>
<result property="tickerNo" column="ticker_no"/>
<result property="isUse" column="is_use"/>
<result property="orderNo" column="order_no"/>
<result property="crtTime" column="crt_time"/>
<result property="updTime" column="upd_time"/>
<result property="useTime" column="use_time"/>
</resultMap>
</mapper>
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<groupId>com.xxfc.platform</groupId> <groupId>com.xxfc.platform</groupId>
<artifactId>xx-tour-api</artifactId> <artifactId>xx-tour-api</artifactId>
<version>2.0-SNAPSHOT</version> <version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment