Commit ac94eea4 authored by shiyu's avatar shiyu

计算平台佣金的新逻辑

parent c18c027e
package com.wwdz.ch.core.consts;
/**
* 账单类的枚举
*/
public class BillEnum {
/**
* 用户账户明细的状态
*/
public enum AccountDetailStateEnum {
ENTRY(1, "已入账"),
WAIT_ENTRY(0, "待入账"),
INVALID(-1, "无效"),
;
private int code;
private String des;
AccountDetailStateEnum(int code, String des) {
this.code = code;
this.des = des;
}
public static String getNameByCode(int code) {
for (BillEnum.AccountDetailStateEnum accountDetailStateEnum : BillEnum.AccountDetailStateEnum.values()) {
if (code == accountDetailStateEnum.getCode()) {
return accountDetailStateEnum.getDes();
}
}
return null;
}
public int getCode() {
return code;
}
public String getDes() {
return des;
}
}
/**
* 用户账户明细的类型
*/
public enum AccountDetailTypeEnum {
ORDER(1, "订单收入"),
CHANNEL(2, "平台佣金"),
INTRODUCE(3, "介绍佣金"),
;
private int code;
private String des;
AccountDetailTypeEnum(int code, String des) {
this.code = code;
this.des = des;
}
public static String getNameByCode(int code) {
for (BillEnum.AccountDetailTypeEnum accountDetailTypeEnum : BillEnum.AccountDetailTypeEnum.values()) {
if (code == accountDetailTypeEnum.getCode()) {
return accountDetailTypeEnum.getDes();
}
}
return null;
}
public int getCode() {
return code;
}
public String getDes() {
return des;
}
}
/**
* 用户账户明细收支类型
*/
public enum FundTypeEnum {
INCOME(1, "收入"),
EXPENDITURE(-1, "支出"),
;
private int code;
private String des;
FundTypeEnum(int code, String des) {
this.code = code;
this.des = des;
}
public static String getNameByCode(int code) {
for (BillEnum.FundTypeEnum fundTypeEnum : BillEnum.FundTypeEnum.values()) {
if (code == fundTypeEnum.getCode()) {
return fundTypeEnum.getDes();
}
}
return null;
}
public int getCode() {
return code;
}
public String getDes() {
return des;
}
}
}
package com.wwdz.ch.core.consts;
import tk.mybatis.spring.mapper.SpringBootBindUtil;
import java.math.BigDecimal;
/**
* 一些常用的参数定义
*
......@@ -84,4 +88,9 @@ public interface CommConsts {
* 消息跳转专场拍品详情
*/
public final static String ITEM_OF_SPECIAL_PERFORMANCE_URL = "/pages/saleAuctionDetail/index";
/**
* 微信手续费,按照最高的1%计算
*/
public final static double WX_COMMISSION_REBATE = 0.01;
}
......@@ -4,16 +4,14 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
* @author shiyu
* @date 2024/05/14
* @date 2024/07/10
*/
@Data
public class DistributorProfit implements Entity {
public class DistributorProfit implements Serializable {
private Long id;
/**
......@@ -41,6 +39,11 @@ public class DistributorProfit implements Entity {
*/
private Long amount;
/**
* 实际到账金额
*/
private Long realAmount;
/**
* 商品成本,供货价
*/
......@@ -90,6 +93,7 @@ public class DistributorProfit implements Entity {
sb.append(", itemId=").append(itemId);
sb.append(", itemNum=").append(itemNum);
sb.append(", amount=").append(amount);
sb.append(", realAmount=").append(realAmount);
sb.append(", itemCost=").append(itemCost);
sb.append(", channelCost=").append(channelCost);
sb.append(", introduceCost=").append(introduceCost);
......@@ -120,6 +124,7 @@ public class DistributorProfit implements Entity {
&& (this.getItemId() == null ? other.getItemId() == null : this.getItemId().equals(other.getItemId()))
&& (this.getItemNum() == null ? other.getItemNum() == null : this.getItemNum().equals(other.getItemNum()))
&& (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
&& (this.getRealAmount() == null ? other.getRealAmount() == null : this.getRealAmount().equals(other.getRealAmount()))
&& (this.getItemCost() == null ? other.getItemCost() == null : this.getItemCost().equals(other.getItemCost()))
&& (this.getChannelCost() == null ? other.getChannelCost() == null : this.getChannelCost().equals(other.getChannelCost()))
&& (this.getIntroduceCost() == null ? other.getIntroduceCost() == null : this.getIntroduceCost().equals(other.getIntroduceCost()))
......@@ -139,6 +144,7 @@ public class DistributorProfit implements Entity {
result = prime * result + ((getItemId() == null) ? 0 : getItemId().hashCode());
result = prime * result + ((getItemNum() == null) ? 0 : getItemNum().hashCode());
result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode());
result = prime * result + ((getRealAmount() == null) ? 0 : getRealAmount().hashCode());
result = prime * result + ((getItemCost() == null) ? 0 : getItemCost().hashCode());
result = prime * result + ((getChannelCost() == null) ? 0 : getChannelCost().hashCode());
result = prime * result + ((getIntroduceCost() == null) ? 0 : getIntroduceCost().hashCode());
......@@ -163,6 +169,7 @@ public class DistributorProfit implements Entity {
itemId("item_id", "itemId", "BIGINT", false),
itemNum("item_num", "itemNum", "INTEGER", false),
amount("amount", "amount", "BIGINT", false),
realAmount("real_amount", "realAmount", "BIGINT", false),
itemCost("item_cost", "itemCost", "BIGINT", false),
channelCost("channel_cost", "channelCost", "BIGINT", false),
introduceCost("introduce_cost", "introduceCost", "BIGINT", false),
......
......@@ -950,6 +950,138 @@ public class DistributorProfitExample {
return (Criteria) this;
}
public Criteria andRealAmountIsNull() {
addCriterion("real_amount is null");
return (Criteria) this;
}
public Criteria andRealAmountIsNotNull() {
addCriterion("real_amount is not null");
return (Criteria) this;
}
public Criteria andRealAmountEqualTo(Long value) {
addCriterion("real_amount =", value, "realAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRealAmountEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("real_amount = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRealAmountNotEqualTo(Long value) {
addCriterion("real_amount <>", value, "realAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRealAmountNotEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("real_amount <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRealAmountGreaterThan(Long value) {
addCriterion("real_amount >", value, "realAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRealAmountGreaterThanColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("real_amount > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRealAmountGreaterThanOrEqualTo(Long value) {
addCriterion("real_amount >=", value, "realAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRealAmountGreaterThanOrEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("real_amount >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRealAmountLessThan(Long value) {
addCriterion("real_amount <", value, "realAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRealAmountLessThanColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("real_amount < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRealAmountLessThanOrEqualTo(Long value) {
addCriterion("real_amount <=", value, "realAmount");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distributor_profit
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andRealAmountLessThanOrEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("real_amount <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andRealAmountIn(List<Long> values) {
addCriterion("real_amount in", values, "realAmount");
return (Criteria) this;
}
public Criteria andRealAmountNotIn(List<Long> values) {
addCriterion("real_amount not in", values, "realAmount");
return (Criteria) this;
}
public Criteria andRealAmountBetween(Long value1, Long value2) {
addCriterion("real_amount between", value1, value2, "realAmount");
return (Criteria) this;
}
public Criteria andRealAmountNotBetween(Long value1, Long value2) {
addCriterion("real_amount not between", value1, value2, "realAmount");
return (Criteria) this;
}
public Criteria andItemCostIsNull() {
addCriterion("item_cost is null");
return (Criteria) this;
......
......@@ -10,7 +10,7 @@ import lombok.Data;
/**
* @author shiyu
* @date 2024/07/08
* @date 2024/07/10
*/
@Data
public class UserAccountDetail implements Entity {
......@@ -22,9 +22,14 @@ public class UserAccountDetail implements Entity {
private Long userId;
/**
* 订单id
* 交易id
*/
private String orderId;
private String transactionId;
/**
* 金额
*/
private Long amount;
/**
* 收入或支出的类型
......@@ -37,12 +42,12 @@ public class UserAccountDetail implements Entity {
private Integer fundType;
/**
* 状态
* 状态:待入账;已入账;无效
*/
private Integer state;
/**
* 创建时间
* 创建时间(订单创建时间)
*/
private Date createTime;
......@@ -61,7 +66,8 @@ public class UserAccountDetail implements Entity {
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", userId=").append(userId);
sb.append(", orderId=").append(orderId);
sb.append(", transactionId=").append(transactionId);
sb.append(", amount=").append(amount);
sb.append(", type=").append(type);
sb.append(", fundType=").append(fundType);
sb.append(", state=").append(state);
......@@ -86,7 +92,8 @@ public class UserAccountDetail implements Entity {
UserAccountDetail other = (UserAccountDetail) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
&& (this.getTransactionId() == null ? other.getTransactionId() == null : this.getTransactionId().equals(other.getTransactionId()))
&& (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getFundType() == null ? other.getFundType() == null : this.getFundType().equals(other.getFundType()))
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
......@@ -100,7 +107,8 @@ public class UserAccountDetail implements Entity {
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
result = prime * result + ((getTransactionId() == null) ? 0 : getTransactionId().hashCode());
result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getFundType() == null) ? 0 : getFundType().hashCode());
result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
......@@ -119,7 +127,8 @@ public class UserAccountDetail implements Entity {
public enum Column {
id("id", "id", "BIGINT", false),
userId("user_id", "userId", "BIGINT", false),
orderId("order_id", "orderId", "VARCHAR", false),
transactionId("transaction_id", "transactionId", "VARCHAR", false),
amount("amount", "amount", "BIGINT", false),
type("type", "type", "INTEGER", true),
fundType("fund_type", "fundType", "INTEGER", false),
state("state", "state", "INTEGER", true),
......
......@@ -36,6 +36,12 @@ public class DistributorProfitRequestDto implements Entity {
*/
private Long amount;
/**
* 实际金额
* 要扣除微信的手续费
*/
private Long realAmount;
/**
* 商品成本,供货价
*/
......
......@@ -17,19 +17,25 @@ public class UserAccountDetailRequestDto extends BaseRequestDto implements Entit
private Long userId;
/**
* 订单id
* 交易id
* 可以是订单号,也可以是转账记录id
*/
private String orderId;
private String transactionId;
/**
* 批量查询订单id
* 金额
*/
private List<String> orderIdList;
private Long amount;
/**
* 查询时需要排除的订单id
* 批量查询交易id
*/
private List<String> filterOrderIdList;
private List<String> transactionIdList;
/**
* 查询时需要排除的交易id
*/
private List<String> filterTransactionIdList;
/**
* 收入或支出的类型
......
package com.wwdz.ch.db.dto.request.distribution;
import com.wwdz.ch.db.dto.request.BaseRequestDto;
import com.xxdxxs.entity.Entity;
import lombok.Data;
@Data
public class UserBillRequestDto extends BaseRequestDto implements Entity {
private Integer id;
/**
* 账单id
*/
private String billId;
/**
* 账期
*/
private String accountPeriod;
/**
* 用户id
*/
private Long userId;
/**
* 总入账金额
*/
private Long totalEntryAmount;
/**
* 总待入账金额
*/
private Long totalWaitEntryAmount;
/**
* 订单入账金额
*/
private Long orderEntryAmount;
/**
* 订单待入账金额
*/
private Long orderWaitEntryAmount;
/**
* 介绍佣金入账金额
*/
private Long introduceEntryAmount;
/**
* 介绍佣金待入账金额
*/
private Long introduceWaitEntryAmount;
/**
* 状态
*/
private Integer state;
}
......@@ -21,7 +21,6 @@ public class UserAccountDetailDaoImpl implements UserAccountDetailDao {
@Override
public boolean insert(UserAccountDetail userAccountDetail) {
userAccountDetail.setCreateTime(new Date());
userAccountDetail.setUpdateTime(new Date());
return userAccountDetailMapper.insert(userAccountDetail) > 0;
}
......@@ -31,7 +30,7 @@ public class UserAccountDetailDaoImpl implements UserAccountDetailDao {
UserAccountDetailExample example = new UserAccountDetailExample();
UserAccountDetailExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(userAccountDetail.getUserId(), criteria::andUserIdEqualTo);
JdbcHelper.ifPresent(userAccountDetail.getOrderId(), criteria::andOrderIdEqualTo);
JdbcHelper.ifPresent(userAccountDetail.getTransactionId(), criteria::andTransactionIdEqualTo);
userAccountDetail.setUpdateTime(new Date());
return userAccountDetailMapper.updateByExampleSelective(userAccountDetail, example) > 0;
}
......@@ -42,9 +41,9 @@ public class UserAccountDetailDaoImpl implements UserAccountDetailDao {
UserAccountDetailExample example = new UserAccountDetailExample();
UserAccountDetailExample.Criteria criteria = example.createCriteria();
JdbcHelper.ifPresent(dto.getUserId(), criteria::andUserIdEqualTo);
JdbcHelper.ifPresent(dto.getOrderId(), criteria::andOrderIdEqualTo);
JdbcHelper.ifPresent(dto.getOrderIdList(), criteria::andOrderIdIn);
JdbcHelper.ifPresent(dto.getFilterOrderIdList(), criteria::andOrderIdNotIn);
JdbcHelper.ifPresent(dto.getTransactionId(), criteria::andTransactionIdEqualTo);
JdbcHelper.ifPresent(dto.getTransactionIdList(), criteria::andTransactionIdIn);
JdbcHelper.ifPresent(dto.getFilterTransactionIdList(), criteria::andTransactionIdNotIn);
JdbcHelper.ifPresent(dto.getState(), criteria::andStateEqualTo);
JdbcHelper.ifPresent(dto.getType(), criteria::andTypeEqualTo);
JdbcHelper.ifPresent(dto.getFundType(), criteria::andFundTypeEqualTo);
......
package com.wwdz.ch.db.mapper.distribution;
import com.wwdz.ch.db.domain.distribution.UserBill;
import com.wwdz.ch.db.domain.distribution.UserBillExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface UserBillMapper {
long countByExample(UserBillExample example);
int deleteByExample(UserBillExample example);
int deleteByPrimaryKey(Integer id);
int insert(UserBill record);
int insertSelective(UserBill record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_bill
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UserBill selectOneByExample(UserBillExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_bill
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UserBill selectOneByExampleSelective(@Param("example") UserBillExample example, @Param("selective") UserBill.Column ... selective);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_bill
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List<UserBill> selectByExampleSelective(@Param("example") UserBillExample example, @Param("selective") UserBill.Column ... selective);
List<UserBill> selectByExample(UserBillExample example);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table user_bill
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
UserBill selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") UserBill.Column ... selective);
UserBill selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") UserBill record, @Param("example") UserBillExample example);
int updateByExample(@Param("record") UserBill record, @Param("example") UserBillExample example);
int updateByPrimaryKeySelective(UserBill record);
int updateByPrimaryKey(UserBill record);
}
\ No newline at end of file
......@@ -8,6 +8,7 @@
<result column="item_id" jdbcType="BIGINT" property="itemId" />
<result column="item_num" jdbcType="INTEGER" property="itemNum" />
<result column="amount" jdbcType="BIGINT" property="amount" />
<result column="real_amount" jdbcType="BIGINT" property="realAmount" />
<result column="item_cost" jdbcType="BIGINT" property="itemCost" />
<result column="channel_cost" jdbcType="BIGINT" property="channelCost" />
<result column="introduce_cost" jdbcType="BIGINT" property="introduceCost" />
......@@ -16,7 +17,6 @@
<result column="type" jdbcType="INTEGER" property="type" />
<result column="is_valid" jdbcType="BIT" property="isValid" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
......@@ -76,8 +76,8 @@
</where>
</sql>
<sql id="Base_Column_List">
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, introduce_cost, profit, create_time, `type`, is_valid
id, distribution_order_id, distributor_id, item_id, item_num, amount, real_amount,
item_cost, channel_cost, introduce_cost, profit, create_time, `type`, is_valid
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.distribution.DistributorProfitExample" resultMap="BaseResultMap">
select
......@@ -112,8 +112,8 @@
</foreach>
</when>
<otherwise>
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, introduce_cost, profit, create_time, `type`, is_valid
id, distribution_order_id, distributor_id, item_id, item_num, amount, real_amount,
item_cost, channel_cost, introduce_cost, profit, create_time, `type`, is_valid
</otherwise>
</choose>
from distributor_profit
......@@ -144,8 +144,8 @@
</foreach>
</when>
<otherwise>
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, introduce_cost, profit, create_time, `type`, is_valid
id, distribution_order_id, distributor_id, item_id, item_num, amount, real_amount,
item_cost, channel_cost, introduce_cost, profit, create_time, `type`, is_valid
</otherwise>
</choose>
from distributor_profit
......@@ -167,14 +167,14 @@
</selectKey>
insert into distributor_profit (distribution_order_id, distributor_id,
item_id, item_num, amount,
item_cost, channel_cost, introduce_cost,
profit, create_time, `type`,
is_valid)
real_amount, item_cost, channel_cost,
introduce_cost, profit, create_time,
`type`, is_valid)
values (#{distributionOrderId,jdbcType=VARCHAR}, #{distributorId,jdbcType=BIGINT},
#{itemId,jdbcType=BIGINT}, #{itemNum,jdbcType=INTEGER}, #{amount,jdbcType=BIGINT},
#{itemCost,jdbcType=BIGINT}, #{channelCost,jdbcType=BIGINT}, #{introduceCost,jdbcType=BIGINT},
#{profit,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=INTEGER},
#{isValid,jdbcType=BIT})
#{realAmount,jdbcType=BIGINT}, #{itemCost,jdbcType=BIGINT}, #{channelCost,jdbcType=BIGINT},
#{introduceCost,jdbcType=BIGINT}, #{profit,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
#{type,jdbcType=INTEGER}, #{isValid,jdbcType=BIT})
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.DistributorProfit">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
......@@ -197,6 +197,9 @@
<if test="amount != null">
amount,
</if>
<if test="realAmount != null">
real_amount,
</if>
<if test="itemCost != null">
item_cost,
</if>
......@@ -235,6 +238,9 @@
<if test="amount != null">
#{amount,jdbcType=BIGINT},
</if>
<if test="realAmount != null">
#{realAmount,jdbcType=BIGINT},
</if>
<if test="itemCost != null">
#{itemCost,jdbcType=BIGINT},
</if>
......@@ -285,6 +291,9 @@
<if test="record.amount != null">
amount = #{record.amount,jdbcType=BIGINT},
</if>
<if test="record.realAmount != null">
real_amount = #{record.realAmount,jdbcType=BIGINT},
</if>
<if test="record.itemCost != null">
item_cost = #{record.itemCost,jdbcType=BIGINT},
</if>
......@@ -319,6 +328,7 @@
item_id = #{record.itemId,jdbcType=BIGINT},
item_num = #{record.itemNum,jdbcType=INTEGER},
amount = #{record.amount,jdbcType=BIGINT},
real_amount = #{record.realAmount,jdbcType=BIGINT},
item_cost = #{record.itemCost,jdbcType=BIGINT},
channel_cost = #{record.channelCost,jdbcType=BIGINT},
introduce_cost = #{record.introduceCost,jdbcType=BIGINT},
......@@ -348,6 +358,9 @@
<if test="amount != null">
amount = #{amount,jdbcType=BIGINT},
</if>
<if test="realAmount != null">
real_amount = #{realAmount,jdbcType=BIGINT},
</if>
<if test="itemCost != null">
item_cost = #{itemCost,jdbcType=BIGINT},
</if>
......@@ -379,6 +392,7 @@
item_id = #{itemId,jdbcType=BIGINT},
item_num = #{itemNum,jdbcType=INTEGER},
amount = #{amount,jdbcType=BIGINT},
real_amount = #{realAmount,jdbcType=BIGINT},
item_cost = #{itemCost,jdbcType=BIGINT},
channel_cost = #{channelCost,jdbcType=BIGINT},
introduce_cost = #{introduceCost,jdbcType=BIGINT},
......@@ -421,8 +435,8 @@
</foreach>
</when>
<otherwise>
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, introduce_cost, profit, create_time, `type`, is_valid
id, distribution_order_id, distributor_id, item_id, item_num, amount, real_amount,
item_cost, channel_cost, introduce_cost, profit, create_time, `type`, is_valid
</otherwise>
</choose>
from distributor_profit
......
......@@ -4,7 +4,8 @@
<resultMap id="BaseResultMap" type="com.wwdz.ch.db.domain.distribution.UserAccountDetail">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="order_id" jdbcType="VARCHAR" property="orderId" />
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
<result column="amount" jdbcType="BIGINT" property="amount" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="fund_type" jdbcType="INTEGER" property="fundType" />
<result column="state" jdbcType="INTEGER" property="state" />
......@@ -70,7 +71,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, user_id, order_id, `type`, fund_type, `state`, create_time, update_time
id, user_id, transaction_id, amount, `type`, fund_type, `state`, create_time, update_time
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.distribution.UserAccountDetailExample" resultMap="BaseResultMap">
select
......@@ -99,13 +100,14 @@
distinct
</if>
<choose>
<when test="selective != null and selective.length > 0">
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, user_id, order_id, `type`, fund_type, `state`, create_time, update_time
id, user_id, transaction_id, amount, `type`, fund_type, `state`, create_time, update_time
</otherwise>
</choose>
from user_account_detail
......@@ -130,13 +132,14 @@
-->
select
<choose>
<when test="selective != null and selective.length > 0">
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, user_id, order_id, `type`, fund_type, `state`, create_time, update_time
id, user_id, transaction_id, amount, `type`, fund_type, `state`, create_time, update_time
</otherwise>
</choose>
from user_account_detail
......@@ -156,12 +159,12 @@
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into user_account_detail (user_id, order_id, `type`,
fund_type, `state`, create_time,
update_time)
values (#{userId,jdbcType=BIGINT}, #{orderId,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER},
#{fundType,jdbcType=INTEGER}, #{state,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP})
insert into user_account_detail (user_id, transaction_id, amount,
`type`, fund_type, `state`,
create_time, update_time)
values (#{userId,jdbcType=BIGINT}, #{transactionId,jdbcType=VARCHAR}, #{amount,jdbcType=BIGINT},
#{type,jdbcType=INTEGER}, #{fundType,jdbcType=INTEGER}, #{state,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.UserAccountDetail">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
......@@ -172,8 +175,11 @@
<if test="userId != null">
user_id,
</if>
<if test="orderId != null">
order_id,
<if test="transactionId != null">
transaction_id,
</if>
<if test="amount != null">
amount,
</if>
<if test="type != null">
`type`,
......@@ -195,8 +201,11 @@
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="orderId != null">
#{orderId,jdbcType=VARCHAR},
<if test="transactionId != null">
#{transactionId,jdbcType=VARCHAR},
</if>
<if test="amount != null">
#{amount,jdbcType=BIGINT},
</if>
<if test="type != null">
#{type,jdbcType=INTEGER},
......@@ -230,8 +239,11 @@
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if test="record.orderId != null">
order_id = #{record.orderId,jdbcType=VARCHAR},
<if test="record.transactionId != null">
transaction_id = #{record.transactionId,jdbcType=VARCHAR},
</if>
<if test="record.amount != null">
amount = #{record.amount,jdbcType=BIGINT},
</if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=INTEGER},
......@@ -257,7 +269,8 @@
update user_account_detail
set id = #{record.id,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
order_id = #{record.orderId,jdbcType=VARCHAR},
transaction_id = #{record.transactionId,jdbcType=VARCHAR},
amount = #{record.amount,jdbcType=BIGINT},
`type` = #{record.type,jdbcType=INTEGER},
fund_type = #{record.fundType,jdbcType=INTEGER},
`state` = #{record.state,jdbcType=INTEGER},
......@@ -273,8 +286,11 @@
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="orderId != null">
order_id = #{orderId,jdbcType=VARCHAR},
<if test="transactionId != null">
transaction_id = #{transactionId,jdbcType=VARCHAR},
</if>
<if test="amount != null">
amount = #{amount,jdbcType=BIGINT},
</if>
<if test="type != null">
`type` = #{type,jdbcType=INTEGER},
......@@ -297,7 +313,8 @@
<update id="updateByPrimaryKey" parameterType="com.wwdz.ch.db.domain.distribution.UserAccountDetail">
update user_account_detail
set user_id = #{userId,jdbcType=BIGINT},
order_id = #{orderId,jdbcType=VARCHAR},
transaction_id = #{transactionId,jdbcType=VARCHAR},
amount = #{amount,jdbcType=BIGINT},
`type` = #{type,jdbcType=INTEGER},
fund_type = #{fundType,jdbcType=INTEGER},
`state` = #{state,jdbcType=INTEGER},
......@@ -332,13 +349,14 @@
select
'true' as QUERYID,
<choose>
<when test="selective != null and selective.length > 0">
<when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
</when>
<otherwise>
id, user_id, order_id, `type`, fund_type, `state`, create_time, update_time
id, user_id, transaction_id, amount, `type`, fund_type, `state`, create_time, update_time
</otherwise>
</choose>
from user_account_detail
......
......@@ -72,7 +72,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution"
targetProject="ch-dao/src/main/java"/>
<table tableName="user_bank_card" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<table tableName="distributor_profit" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table>
......
......@@ -533,33 +533,37 @@ public class SupplierItemServiceImpl implements SupplierItemService {
Long itemId;
String shareRecordId = dto.getShareRecordId();
CollectionShareRecord collectionShareRecord = null;
long introducerId = CommConsts.SYSTEM_ACCOUNT;
if (StringUtils.isEmpty(shareRecordId) && dto.getId() == null) {
return Result.failed("商品信息为空");
} else if (StringUtils.hasLength(shareRecordId) && ! shareRecordId.equals(CommConsts.DEFAULT_SHARE_ID)) {
collectionShareRecord = collectionShareRecordDao.findById(dto.getShareRecordId());
introducerId = collectionShareRecord.getSharerId();
itemId = collectionShareRecord.getShareTargetId();
} else {
itemId = dto.getId();
}
if (itemId == null) {
return Result.failed("没有对应的商品id");
}
if (collectionShareRecord.getItemUserId().longValue() != dto.getUserId().longValue()) {
//客态进入别人的藏馆,自动关注
FollowFansRecordRequestDto followFansRecordRequestDto = new FollowFansRecordRequestDto();
followFansRecordRequestDto.setFollowerId(collectionShareRecord.getItemUserId());
followFansRecordRequestDto.setFansId(dto.getUserId());
followFansRecordRequestDto.setIntroducerId(collectionShareRecord.getSharerId());
followFansRecordService.follow(followFansRecordRequestDto);
followFansRecordRequestDto.setIntroducerId(introducerId);
Result followResult = followFansRecordService.follow(followFansRecordRequestDto);
if (followResult.getSuccess()) {
logger.info("通过藏品详情分享点击,用户id:{} 关注了 用户id为 {}, 介绍人为", dto.getUserId(), collectionShareRecord.getItemUserId(), collectionShareRecord.getSharerId());
}
} else {
itemId = dto.getId();
logger.info("通过藏品详情分享点击关注用户返回信息 : {}" + followResult.getErrmsg());
}
if (itemId == null) {
return Result.failed("没有对应的商品id");
}
//拍卖专场进入详情页,增加围观次数
specialPerformanceConfigDao.addViewNum(itemId);
/* if (StringUtils.hasLength(shareRecordId) && !shareRecordId.equals(CommConsts.DEFAULT_SHARE_ID)) {
if (collectionShareRecord.getItemUserId().longValue() != dto.getUserId().longValue()) {
}
}*/
//查询商品所属专场id
SpecialPerformanceConfigRequestDto specialPerformanceConfigRequestDto = new SpecialPerformanceConfigRequestDto();
specialPerformanceConfigRequestDto.setItemId(itemId);
......
package com.wwdz.ch.wx.impl.distribution;
import com.wwdz.ch.core.consts.BillEnum;
import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.distribution.UserAccountDetailDao;
import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.wwdz.ch.db.domain.distribution.DistributorProfit;
import com.wwdz.ch.db.domain.distribution.UserAccountDetail;
import com.wwdz.ch.db.dto.request.distribution.UserAccountDetailRequestDto;
import com.wwdz.ch.wx.service.distribution.UserAccountDetailService;
import com.xxdxxs.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -11,6 +17,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
@Service
public class UserAccountDetailServiceImpl implements UserAccountDetailService {
......@@ -19,10 +27,63 @@ public class UserAccountDetailServiceImpl implements UserAccountDetailService {
@Autowired
UserAccountDetailDao userAccountDetailDao;
@Transactional(propagation=Propagation.REQUIRED)
@Override
public Result create(UserAccountDetailRequestDto dto) throws Exception {
public Result create(DistributionOrder distributionOrder, DistributorProfit distributorProfit) throws Exception {
try {
//订单金额
long orderAmount = distributionOrder.getAmount();
//平台佣金
long channelCost = distributorProfit.getChannelCost();
//介绍佣金
long introduceCost = distributorProfit.getIntroduceCost();
//卖家实际收益
long sellerProfitAmount = orderAmount - channelCost - introduceCost;
//记录卖家的收益
UserAccountDetail userAccountDetail = new UserAccountDetail();
userAccountDetail.setUserId(distributionOrder.getSellerId());
userAccountDetail.setTransactionId(distributionOrder.getDistributionOrderId());
userAccountDetail.setAmount(sellerProfitAmount);
userAccountDetail.setType(BillEnum.AccountDetailTypeEnum.ORDER.getCode());
userAccountDetail.setFundType(BillEnum.FundTypeEnum.INCOME.getCode());
//创建订单时状态是无效,等买家付款后变为待入账,订单完成变成已入账
userAccountDetail.setState(BillEnum.AccountDetailStateEnum.INVALID.getCode());
userAccountDetail.setCreateTime(distributionOrder.getCreateTime());
userAccountDetailDao.insert(userAccountDetail);
//记录平台佣金
UserAccountDetail channelAccountDetail = new UserAccountDetail();
channelAccountDetail.setUserId(CommConsts.SYSTEM_ACCOUNT);
channelAccountDetail.setTransactionId(distributionOrder.getDistributionOrderId());
channelAccountDetail.setAmount(channelCost);
channelAccountDetail.setType(BillEnum.AccountDetailTypeEnum.CHANNEL.getCode());
channelAccountDetail.setFundType(BillEnum.FundTypeEnum.INCOME.getCode());
//创建订单时状态是无效,等买家付款后变为待入账,订单完成变成已入账
channelAccountDetail.setState(BillEnum.AccountDetailStateEnum.INVALID.getCode());
channelAccountDetail.setCreateTime(distributionOrder.getCreateTime());
userAccountDetailDao.insert(channelAccountDetail);
//记录介绍佣金,判断介绍人是平台还是用户
UserAccountDetail introduceAccountDetail = new UserAccountDetail();
if (StringUtils.isEmpty(distributionOrder.getShareRecordId()) || CommConsts.DEFAULT_SHARE_ID.equals(distributionOrder.getShareRecordId())) {
introduceAccountDetail.setUserId(CommConsts.SYSTEM_ACCOUNT);
} else {
}
introduceAccountDetail.setTransactionId(distributionOrder.getDistributionOrderId());
introduceAccountDetail.setAmount(channelCost);
introduceAccountDetail.setType(BillEnum.AccountDetailTypeEnum.CHANNEL.getCode());
introduceAccountDetail.setFundType(BillEnum.FundTypeEnum.INCOME.getCode());
//创建订单时状态是无效,等买家付款后变为待入账,订单完成变成已入账
introduceAccountDetail.setState(BillEnum.AccountDetailStateEnum.INVALID.getCode());
introduceAccountDetail.setCreateTime(distributionOrder.getCreateTime());
userAccountDetailDao.insert(introduceAccountDetail);
return Result.success();
......@@ -31,4 +92,7 @@ public class UserAccountDetailServiceImpl implements UserAccountDetailService {
throw new Exception(e);
}
}
}
package com.wwdz.ch.wx.service.distribution;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.wwdz.ch.db.domain.distribution.DistributorProfit;
import com.wwdz.ch.db.dto.request.distribution.UserAccountDetailRequestDto;
public interface UserAccountDetailService {
......@@ -10,5 +12,5 @@ public interface UserAccountDetailService {
* @param dto
* @return
*/
Result create(UserAccountDetailRequestDto dto) throws Exception;
Result create(DistributionOrder distributionOrder, DistributorProfit distributorProfit) throws Exception;
}
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