Authored by mingdan.ge

union推广获利

Showing 21 changed files with 1388 additions and 0 deletions
package com.yoho.unions.common.enums;
/**
* Created by mingdan.ge on 2018/5/10.
*/
public enum ShareOrdersStatusEnum {
//10-已支付 -> 20-可结算、91-不可结算部分取消、92-不可结算退货、93-不可结算换货
//20-可结算 -> 30-打款中 -> 40-已打款
pay(1,"10","已支付"),
can_Settle(2,"20","可结算"),
Settle(3,"30","打款中"),
has_Settle(4,"40","已打款"),
order_cancel(2,"91","不可结算部分取消"),
order_return(2,"92","不可结算退货"),
order_exchange(2,"93","不可结算换货");
private int level;//低level可以变为高level
private String code;
private String desc;
ShareOrdersStatusEnum(int level,String code, String desc) {
this.level = level;
this.code = code;
this.desc = desc;
}
public static int getLevelByCode(String code) {
for (ShareOrdersStatusEnum e : values()) {
if (e.getCode().equals(code)) {
return e.getLevel();
}
}
return 0;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
... ...
package com.yoho.unions.dal;
import com.yoho.unions.dal.model.UnionShareOrders;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
public interface UnionShareOrdersMapper {
int deleteByPrimaryKey(Integer id);
int insert(UnionShareOrders record);
int insertSelective(UnionShareOrders record);
UnionShareOrders selectByPrimaryKey(Integer id);
UnionShareOrders selectByCode(String orderCode);
int selectCountByCondition(@Param("promoteUid")int promoteUid, @Param("status")String status);
BigDecimal selectAmountByCondition(@Param("promoteUid")int promoteUid, @Param("status")String status);
List<UnionShareOrders> selectListByCondition(@Param("promoteUid")int promoteUid, @Param("status")String status, @Param("offset") int offset, @Param("rows") int rows);
int updateByPrimaryKeySelective(UnionShareOrders record);
int updateStatus(@Param("id")int id,@Param("oldStatus")String oldStatus,@Param("newStatus")String newStatus,@Param("updateTime")int updateTime);
int updateByPrimaryKey(UnionShareOrders record);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal;
import com.yoho.unions.dal.model.UnionShareOrdersProduct;
public interface UnionShareOrdersProductMapper {
int deleteByPrimaryKey(Integer id);
int insert(UnionShareOrdersProduct record);
int insertSelective(UnionShareOrdersProduct record);
UnionShareOrdersProduct selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(UnionShareOrdersProduct record);
int updateByPrimaryKey(UnionShareOrdersProduct record);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal;
import com.yoho.unions.dal.model.UnionShareSettlement;
public interface UnionShareSettlementMapper {
int deleteByPrimaryKey(Integer id);
int insert(UnionShareSettlement record);
int insertSelective(UnionShareSettlement record);
UnionShareSettlement selectByPrimaryKey(Integer id);
UnionShareSettlement selectByCode(String settlementCode);
int updateByPrimaryKeySelective(UnionShareSettlement record);
int updateByPrimaryKey(UnionShareSettlement record);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal;
import com.yoho.unions.dal.model.UnionShareSettlementOrder;
public interface UnionShareSettlementOrderMapper {
int deleteByPrimaryKey(Integer id);
int insert(UnionShareSettlementOrder record);
int insertSelective(UnionShareSettlementOrder record);
UnionShareSettlementOrder selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(UnionShareSettlementOrder record);
int updateByPrimaryKey(UnionShareSettlementOrder record);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal;
import com.yoho.unions.dal.model.UnionShareUser;
public interface UnionShareUserMapper {
int deleteByPrimaryKey(Integer id);
int insert(UnionShareUser record);
int insertSelective(UnionShareUser record);
UnionShareUser selectByPrimaryKey(Integer id);
UnionShareUser selectByUid(Integer uid);
int selectCountByUid(Integer uid);
int updateByPrimaryKeySelective(UnionShareUser record);
int updateByPrimaryKey(UnionShareUser record);
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
import java.math.BigDecimal;
public class UnionShareOrders {
private Integer id;
private String orderCode;
private Integer promoteUid;
private String status;
private BigDecimal orderAmount;
private Integer orderTime;
private Byte isNew;
private BigDecimal amount;
private Integer createTime;
private Integer updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode == null ? null : orderCode.trim();
}
public Integer getPromoteUid() {
return promoteUid;
}
public void setPromoteUid(Integer promoteUid) {
this.promoteUid = promoteUid;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status == null ? null : status.trim();
}
public BigDecimal getOrderAmount() {
return orderAmount;
}
public void setOrderAmount(BigDecimal orderAmount) {
this.orderAmount = orderAmount;
}
public Integer getOrderTime() {
return orderTime;
}
public void setOrderTime(Integer orderTime) {
this.orderTime = orderTime;
}
public Byte getIsNew() {
return isNew;
}
public void setIsNew(Byte isNew) {
this.isNew = isNew;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
import java.math.BigDecimal;
public class UnionShareOrdersProduct {
private Integer id;
private Integer productSkn;
private String orderCode;
private String name;
private String image;
private BigDecimal price;
private Byte num;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getProductSkn() {
return productSkn;
}
public void setProductSkn(Integer productSkn) {
this.productSkn = productSkn;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode == null ? null : orderCode.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image == null ? null : image.trim();
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public Byte getNum() {
return num;
}
public void setNum(Byte num) {
this.num = num;
}
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
import java.math.BigDecimal;
public class UnionShareSettlement {
private Integer id;
private Integer settlementCode;
private BigDecimal settlementAmount;
private Integer settlementTime;
private Integer promoteUid;
private Byte status;
private Integer updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getSettlementCode() {
return settlementCode;
}
public void setSettlementCode(Integer settlementCode) {
this.settlementCode = settlementCode;
}
public BigDecimal getSettlementAmount() {
return settlementAmount;
}
public void setSettlementAmount(BigDecimal settlementAmount) {
this.settlementAmount = settlementAmount;
}
public Integer getSettlementTime() {
return settlementTime;
}
public void setSettlementTime(Integer settlementTime) {
this.settlementTime = settlementTime;
}
public Integer getPromoteUid() {
return promoteUid;
}
public void setPromoteUid(Integer promoteUid) {
this.promoteUid = promoteUid;
}
public Byte getStatus() {
return status;
}
public void setStatus(Byte status) {
this.status = status;
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
public class UnionShareSettlementOrder {
private Integer id;
private Integer settlementCode;
private String orderCode;
private Integer createTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getSettlementCode() {
return settlementCode;
}
public void setSettlementCode(Integer settlementCode) {
this.settlementCode = settlementCode;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode == null ? null : orderCode.trim();
}
public Integer getCreateTime() {
return createTime;
}
public void setCreateTime(Integer createTime) {
this.createTime = createTime;
}
}
\ No newline at end of file
... ...
package com.yoho.unions.dal.model;
public class UnionShareUser {
private Integer id;
private Integer uid;
private String unionType;
private Integer updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getUid() {
return uid;
}
public void setUid(Integer uid) {
this.uid = uid;
}
public String getUnionType() {
return unionType;
}
public void setUnionType(String unionType) {
this.unionType = unionType == null ? null : unionType.trim();
}
public Integer getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
}
\ 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.yoho.unions.dal.UnionShareOrdersMapper" >
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionShareOrders" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="VARCHAR" />
<result column="promote_uid" property="promoteUid" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="VARCHAR" />
<result column="order_amount" property="orderAmount" jdbcType="DECIMAL" />
<result column="order_time" property="orderTime" jdbcType="INTEGER" />
<result column="is_new" property="isNew" jdbcType="TINYINT" />
<result column="amount" property="amount" jdbcType="DECIMAL" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, order_code, promote_uid, status, order_amount, order_time, is_new, amount, create_time,
update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_share_orders
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByCode" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from union_share_orders
where order_code = #{orderCode,jdbcType=VARCHAR}
limit 1
</select>
<select id="selectCountByCondition" resultType="java.lang.Integer" >
select count(1) from union_share_orders
where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{status,jdbcType=VARCHAR}
</select>
<select id="selectAmountByCondition" resultType="java.math.BigDecimal" >
select IFNULL(sum(amount),0) from union_share_orders
where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{status,jdbcType=VARCHAR}
</select>
<select id="selectListByCondition" resultMap="BaseResultMap" >
select
<include refid="Base_Column_List" />
from union_share_orders
where promote_uid = #{promoteUid,jdbcType=INTEGER} and status = #{status,jdbcType=VARCHAR}
limit #{offset}, #{rows}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_orders
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
insert into union_share_orders (id, order_code, promote_uid,
status, order_amount, order_time,
is_new, amount, create_time,
update_time)
values (#{id,jdbcType=INTEGER}, #{orderCode,jdbcType=VARCHAR}, #{promoteUid,jdbcType=INTEGER},
#{status,jdbcType=VARCHAR}, #{orderAmount,jdbcType=DECIMAL}, #{orderTime,jdbcType=INTEGER},
#{isNew,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{createTime,jdbcType=INTEGER},
#{updateTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
insert into union_share_orders
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="orderCode != null" >
order_code,
</if>
<if test="promoteUid != null" >
promote_uid,
</if>
<if test="status != null" >
status,
</if>
<if test="orderAmount != null" >
order_amount,
</if>
<if test="orderTime != null" >
order_time,
</if>
<if test="isNew != null" >
is_new,
</if>
<if test="amount != null" >
amount,
</if>
<if test="createTime != null" >
create_time,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
#{orderCode,jdbcType=VARCHAR},
</if>
<if test="promoteUid != null" >
#{promoteUid,jdbcType=INTEGER},
</if>
<if test="status != null" >
#{status,jdbcType=VARCHAR},
</if>
<if test="orderAmount != null" >
#{orderAmount,jdbcType=DECIMAL},
</if>
<if test="orderTime != null" >
#{orderTime,jdbcType=INTEGER},
</if>
<if test="isNew != null" >
#{isNew,jdbcType=TINYINT},
</if>
<if test="amount != null" >
#{amount,jdbcType=DECIMAL},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
update union_share_orders
<set >
<if test="orderCode != null" >
order_code = #{orderCode,jdbcType=VARCHAR},
</if>
<if test="promoteUid != null" >
promote_uid = #{promoteUid,jdbcType=INTEGER},
</if>
<if test="status != null" >
status = #{status,jdbcType=VARCHAR},
</if>
<if test="orderAmount != null" >
order_amount = #{orderAmount,jdbcType=DECIMAL},
</if>
<if test="orderTime != null" >
order_time = #{orderTime,jdbcType=INTEGER},
</if>
<if test="isNew != null" >
is_new = #{isNew,jdbcType=TINYINT},
</if>
<if test="amount != null" >
amount = #{amount,jdbcType=DECIMAL},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareOrders" >
update union_share_orders
set order_code = #{orderCode,jdbcType=VARCHAR},
promote_uid = #{promoteUid,jdbcType=INTEGER},
status = #{status,jdbcType=VARCHAR},
order_amount = #{orderAmount,jdbcType=DECIMAL},
order_time = #{orderTime,jdbcType=INTEGER},
is_new = #{isNew,jdbcType=TINYINT},
amount = #{amount,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateStatus" >
update union_share_orders
set status = #{newStatus,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER} and status = #{oldStatus,jdbcType=VARCHAR}
</update>
</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.yoho.unions.dal.UnionShareOrdersProductMapper" >
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionShareOrdersProduct" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="product_skn" property="productSkn" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="VARCHAR" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="image" property="image" jdbcType="VARCHAR" />
<result column="price" property="price" jdbcType="DECIMAL" />
<result column="num" property="num" jdbcType="TINYINT" />
</resultMap>
<sql id="Base_Column_List" >
id, product_skn, order_code, name, image, price, num
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_share_orders_product
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_orders_product
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareOrdersProduct" >
insert into union_share_orders_product (id, product_skn, order_code,
name, image, price,
num)
values (#{id,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, #{orderCode,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{image,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL},
#{num,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareOrdersProduct" >
insert into union_share_orders_product
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="productSkn != null" >
product_skn,
</if>
<if test="orderCode != null" >
order_code,
</if>
<if test="name != null" >
name,
</if>
<if test="image != null" >
image,
</if>
<if test="price != null" >
price,
</if>
<if test="num != null" >
num,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="productSkn != null" >
#{productSkn,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
#{orderCode,jdbcType=VARCHAR},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="image != null" >
#{image,jdbcType=VARCHAR},
</if>
<if test="price != null" >
#{price,jdbcType=DECIMAL},
</if>
<if test="num != null" >
#{num,jdbcType=TINYINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionShareOrdersProduct" >
update union_share_orders_product
<set >
<if test="productSkn != null" >
product_skn = #{productSkn,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
order_code = #{orderCode,jdbcType=VARCHAR},
</if>
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="image != null" >
image = #{image,jdbcType=VARCHAR},
</if>
<if test="price != null" >
price = #{price,jdbcType=DECIMAL},
</if>
<if test="num != null" >
num = #{num,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareOrdersProduct" >
update union_share_orders_product
set product_skn = #{productSkn,jdbcType=INTEGER},
order_code = #{orderCode,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
image = #{image,jdbcType=VARCHAR},
price = #{price,jdbcType=DECIMAL},
num = #{num,jdbcType=TINYINT}
where id = #{id,jdbcType=INTEGER}
</update>
</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.yoho.unions.dal.UnionShareSettlementMapper" >
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionShareSettlement" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="settlement_code" property="settlementCode" jdbcType="VARCHAR" />
<result column="settlement_amount" property="settlementAmount" jdbcType="DECIMAL" />
<result column="settlement_time" property="settlementTime" jdbcType="INTEGER" />
<result column="promote_uid" property="promoteUid" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, settlement_code, settlement_amount, settlement_time, promote_uid, status, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_share_settlement
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByCode" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_share_settlement
where settlement_code = #{settlementCode,jdbcType=VARCHAR}
limit 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_settlement
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareSettlement" >
insert into union_share_settlement (id, settlement_code, settlement_amount,
settlement_time, promote_uid, status,
update_time)
values (#{id,jdbcType=INTEGER}, #{settlementCode,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL},
#{settlementTime,jdbcType=INTEGER}, #{promoteUid,jdbcType=INTEGER}, #{status,jdbcType=TINYINT},
#{updateTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareSettlement" >
insert into union_share_settlement
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="settlementCode != null" >
settlement_code,
</if>
<if test="settlementAmount != null" >
settlement_amount,
</if>
<if test="settlementTime != null" >
settlement_time,
</if>
<if test="promoteUid != null" >
promote_uid,
</if>
<if test="status != null" >
status,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="settlementCode != null" >
#{settlementCode,jdbcType=VARCHAR},
</if>
<if test="settlementAmount != null" >
#{settlementAmount,jdbcType=DECIMAL},
</if>
<if test="settlementTime != null" >
#{settlementTime,jdbcType=INTEGER},
</if>
<if test="promoteUid != null" >
#{promoteUid,jdbcType=INTEGER},
</if>
<if test="status != null" >
#{status,jdbcType=TINYINT},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionShareSettlement" >
update union_share_settlement
<set >
<if test="settlementCode != null" >
settlement_code = #{settlementCode,jdbcType=VARCHAR},
</if>
<if test="settlementAmount != null" >
settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
</if>
<if test="settlementTime != null" >
settlement_time = #{settlementTime,jdbcType=INTEGER},
</if>
<if test="promoteUid != null" >
promote_uid = #{promoteUid,jdbcType=INTEGER},
</if>
<if test="status != null" >
status = #{status,jdbcType=TINYINT},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareSettlement" >
update union_share_settlement
set settlement_code = #{settlementCode,jdbcType=VARCHAR},
settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
settlement_time = #{settlementTime,jdbcType=INTEGER},
promote_uid = #{promoteUid,jdbcType=INTEGER},
status = #{status,jdbcType=TINYINT},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</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.yoho.unions.dal.UnionShareSettlementOrderMapper" >
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionShareSettlementOrder" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="settlement_code" property="settlementCode" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, settlement_code, order_code, create_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_share_settlement_order
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_settlement_order
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareSettlementOrder" >
insert into union_share_settlement_order (id, settlement_code, order_code,
create_time)
values (#{id,jdbcType=INTEGER}, #{settlementCode,jdbcType=INTEGER}, #{orderCode,jdbcType=VARCHAR},
#{createTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareSettlementOrder" >
insert into union_share_settlement_order
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="settlementCode != null" >
settlement_code,
</if>
<if test="orderCode != null" >
order_code,
</if>
<if test="createTime != null" >
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="settlementCode != null" >
#{settlementCode,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
#{orderCode,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionShareSettlementOrder" >
update union_share_settlement_order
<set >
<if test="settlementCode != null" >
settlement_code = #{settlementCode,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
order_code = #{orderCode,jdbcType=VARCHAR},
</if>
<if test="createTime != null" >
create_time = #{createTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareSettlementOrder" >
update union_share_settlement_order
set settlement_code = #{settlementCode,jdbcType=INTEGER},
order_code = #{orderCode,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</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.yoho.unions.dal.UnionShareUserMapper" >
<resultMap id="BaseResultMap" type="com.yoho.unions.dal.model.UnionShareUser" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="union_type" property="unionType" jdbcType="VARCHAR" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, uid, union_type, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_share_user
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from union_share_user
where uid = #{uid,jdbcType=INTEGER}
</select>
<select id="selectCountByUid" parameterType="java.lang.Integer" >
select count(1) from union_share_user
where uid = #{uid,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from union_share_user
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.unions.dal.model.UnionShareUser" >
insert into union_share_user (id, uid, union_type,
update_time)
values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=INTEGER}, #{unionType,jdbcType=VARCHAR},
#{updateTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.unions.dal.model.UnionShareUser" >
insert into union_share_user
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="uid != null" >
uid,
</if>
<if test="unionType != null" >
union_type,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="uid != null" >
#{uid,jdbcType=INTEGER},
</if>
<if test="unionType != null" >
#{unionType,jdbcType=VARCHAR},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.unions.dal.model.UnionShareUser" >
update union_share_user
<set >
<if test="uid != null" >
uid = #{uid,jdbcType=INTEGER},
</if>
<if test="unionType != null" >
union_type = #{unionType,jdbcType=VARCHAR},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.unions.dal.model.UnionShareUser" >
update union_share_user
set uid = #{uid,jdbcType=INTEGER},
union_type = #{unionType,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
... ...
package com.yoho.unions.server.mqconsumer;
import com.yoho.core.common.utils.JsonUtil;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yoho.service.model.union.bo.ShareSettlementBo;
import com.yoho.unions.server.service.IUnionShareService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Created by mingdan.ge on 2018/5/10.
*/
public class UnionSettleUpdateConsumer implements YhConsumer {
private Logger logger = LoggerFactory.getLogger(UnionSettleUpdateConsumer.class);
@Autowired
private IUnionShareService unionShareService;
@Override
public void handleMessage(Object o) throws Exception{
logger.info("UnionSettleUpdateConsumer,handleMessage {}", o);
try {
if (null == o) {
return;
}
ShareSettlementBo bo = JsonUtil.jsonToObject(o.toString(), ShareSettlementBo.class);
//TODO 提现结算单状态变更
unionShareService.updateSettlementStatus(bo);
} catch (Exception e) {
logger.warn("UnionSettleUpdateConsumer,handleMessage fail! obj is {}, e {}",o,e.getMessage());
}
}
}
\ No newline at end of file
... ...
package com.yoho.unions.server.mqconsumer;
import com.yoho.core.common.utils.JsonUtil;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yoho.service.model.union.bo.ShareOrderBo;
import com.yoho.unions.server.service.IUnionShareService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Created by mingdan.ge on 2018/5/10.
*/
public class UnionShareOrderConsumer implements YhConsumer {
private Logger logger = LoggerFactory.getLogger(UnionShareOrderConsumer.class);
@Autowired
private IUnionShareService unionShareService;
@Override
public void handleMessage(Object o) throws Exception{
logger.info("UnionShareOrderConsumer,handleMessage {}", o);
try {
if (null == o) {
return;
}
ShareOrderBo bo = JsonUtil.jsonToObject(o.toString(), ShareOrderBo.class);
//TODO 订单插入或更新
unionShareService.saveOrUpdateOrder(bo);
} catch (Exception e) {
logger.warn("UnionShareOrderConsumer,handleMessage fail! obj is {}, e {}",o,e.getMessage());
}
}
}
... ...
package com.yoho.unions.server.service;
import com.yoho.service.model.union.bo.ShareOrderBo;
import com.yoho.service.model.union.bo.ShareSettlementBo;
/**
* 联盟红人推广返利
* Created by mingdan.ge on 2018/5/10.
*/
public interface IUnionShareService {
void saveOrUpdateOrder(ShareOrderBo bo);
void updateSettlementStatus(ShareSettlementBo bo);
}
... ...
package com.yoho.unions.server.service.impl;
import com.yoho.service.model.union.bo.ShareOrderBo;
import com.yoho.service.model.union.bo.ShareSettlementBo;
import com.yoho.unions.common.enums.ShareOrdersStatusEnum;
import com.yoho.unions.common.utils.DateUtil;
import com.yoho.unions.dal.*;
import com.yoho.unions.dal.model.UnionShareOrders;
import com.yoho.unions.dal.model.UnionShareOrdersProduct;
import com.yoho.unions.dal.model.UnionShareSettlement;
import com.yoho.unions.server.service.IUnionShareService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
/**
* 联盟红人推广返利
* Created by mingdan.ge on 2018/5/10.
*/
@Service
public class UnionShareServiceImpl implements IUnionShareService {
private Logger logger = LoggerFactory.getLogger(UnionShareServiceImpl.class);
@Autowired
private UnionShareOrdersMapper unionShareOrdersMapper;
@Autowired
private UnionShareOrdersProductMapper unionShareOrdersProductMapper;
@Autowired
private UnionShareSettlementMapper unionShareSettlementMapper;
@Autowired
private UnionShareSettlementOrderMapper unionShareSettlementOrderMapper;
@Autowired
private UnionShareUserMapper unionShareUserMapper;
/**
* 订单插入或更新
*/
@Override
public void saveOrUpdateOrder(ShareOrderBo bo) {
if (bo == null) {
return;
}
UnionShareOrders unionShareOrders = unionShareOrdersMapper.selectByCode(bo.getOrderCode());
//新增
if (unionShareOrders == null) {
insertOrder(bo);
//todo 清缓存
return;
}
//更新
if (ShareOrdersStatusEnum.pay.getCode().equals(bo.getStatus())) {
//订单为支付状态,数据已存在
return;
}
if (!checkOrderStatusChangePass(unionShareOrders.getStatus(), bo.getStatus())) {
//订单状态不可变更
return;
}
int result = unionShareOrdersMapper.updateStatus(unionShareOrders.getId(), unionShareOrders.getStatus(), bo.getStatus(), DateUtil.getCurrentTimeSecond());
if (result == 0) {
//没有更新到数据,应该有并发更新事件,查询新的再试一下
UnionShareOrders unionShareOrdersNew = unionShareOrdersMapper.selectByCode(bo.getOrderCode());
if (unionShareOrdersNew == null) {
//查不到数据,不该出现的情况,目前没有硬删数据的途径
return;
}
if (!checkOrderStatusChangePass(unionShareOrdersNew.getStatus(), bo.getStatus())) {
//订单状态不可变更
return;
}
unionShareOrdersMapper.updateStatus(unionShareOrdersNew.getId(), unionShareOrdersNew.getStatus(), bo.getStatus(), DateUtil.getCurrentTimeSecond());
}
//todo 清缓存
}
/**
* 保存订单信息
* */
private void insertOrder(ShareOrderBo bo) {
//新增订单信息
UnionShareOrders insertReq = new UnionShareOrders();
BeanUtils.copyProperties(bo, insertReq);
insertReq.setCreateTime(DateUtil.getCurrentTimeSecond());
insertReq.setUpdateTime(insertReq.getCreateTime());
unionShareOrdersMapper.insertSelective(insertReq);
//新增订单商品信息
bo.getProductList().forEach(p->{
UnionShareOrdersProduct insertPro = new UnionShareOrdersProduct();
BeanUtils.copyProperties(p, insertPro);
unionShareOrdersProductMapper.insertSelective(insertPro);
});
}
/**
* 判断是否可以进行状态变更
* */
private boolean checkOrderStatusChangePass(String oldStatus, String newStatus) {
if (ShareOrdersStatusEnum.getLevelByCode(oldStatus) < ShareOrdersStatusEnum.getLevelByCode(newStatus)) {
return true;
}
return false;
}
/**
* 提现
*/
public void addSettlement(ShareSettlementBo bo) {
if (bo == null || bo.getPromoteUid() == null) {
return;
}
//查询该用户是否为特邀用户
int count = unionShareUserMapper.selectCountByUid(bo.getPromoteUid());
if (count == 0) {
//不是特邀用户
return;
}
//todo 锁定当前用户,锁定状态写入redis,已被锁定则返回
//查询当前是否有可提现的订单
int orderCount = unionShareOrdersMapper.selectCountByCondition(bo.getPromoteUid(),ShareOrdersStatusEnum.can_Settle.getCode());
if (orderCount == 0 ) {
//没有可以提现的订单
return;
}
//todo 生成取现单,绑定订单
//todo 解锁当前用户,锁定状态写入redis
}
/**
* 获取当前可取现数额
* */
public BigDecimal getSettlementAmount(int uid) {
//todo 存redis
return unionShareOrdersMapper.selectAmountByCondition(uid,ShareOrdersStatusEnum.can_Settle.getCode())
}
/**
* 提现关联订单
* */
public void relateSettlementAndOrder(int uid) {
int count = unionShareOrdersMapper.selectCountByCondition(uid,ShareOrdersStatusEnum.can_Settle.getCode());
if (count == 0) {
return;
}
//todo 根据count大小批量绑定和更新订单
// unionShareSettlementOrderMapper
}
/**
* 提现结算单状态变更
* */
@Override
public void updateSettlementStatus(ShareSettlementBo bo) {
if (bo == null) {
return;
}
//是否打款成功:1-处理中,2-已打款
if (bo.getStatus() == null || bo.getStatus().intValue() != 2) {
return;
}
UnionShareSettlement unionShareSettlement = unionShareSettlementMapper.selectByCode(bo.getSettlementCode());
if (unionShareSettlement == null) {
return;
}
//更新结算状态
UnionShareSettlement updateReq = new UnionShareSettlement();
updateReq.setId(unionShareSettlement.getId());
updateReq.setStatus(bo.getStatus());
updateReq.setUpdateTime(DateUtil.getCurrentTimeSecond());
unionShareSettlementMapper.updateByPrimaryKeySelective(updateReq);
//todo 清缓存
}
}
... ...
... ... @@ -8,6 +8,15 @@ consumer:
- class: com.yoho.unions.server.mqconsumer.OrderPushConsumer
topic: union.order_push
- class: com.yoho.unions.server.mqconsumer.UnionShareOrderConsumer
topic: erp.order.unionShareOrder
- class: com.yoho.unions.server.mqconsumer.UnionSettleUpdateConsumer
topic: erp.fms.unionSettleUpdate
producer:
- address: 192.168.102.45:5672
producers:
- bean: yhProducer #only once named in classpath
... ...