Commit 2ce031c5 authored by shiyu's avatar shiyu

标签取消关联

parent d588ec1b
...@@ -3,13 +3,12 @@ package com.wwdz.ch.db.domain.distribution; ...@@ -3,13 +3,12 @@ package com.wwdz.ch.db.domain.distribution;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import com.xxdxxs.entity.Entity; import com.xxdxxs.entity.Entity;
import lombok.Data; import lombok.Data;
/** /**
* @author shiyu * @author shiyu
* @date 2024/01/31 * @date 2024/04/11
*/ */
@Data @Data
public class DistributorProfit implements Entity { public class DistributorProfit implements Entity {
...@@ -50,6 +49,11 @@ public class DistributorProfit implements Entity { ...@@ -50,6 +49,11 @@ public class DistributorProfit implements Entity {
*/ */
private Long channelCost; private Long channelCost;
/**
* 介绍人佣金
*/
private Long introduceCost;
/** /**
* 利润 * 利润
*/ */
...@@ -81,6 +85,7 @@ public class DistributorProfit implements Entity { ...@@ -81,6 +85,7 @@ public class DistributorProfit implements Entity {
sb.append(", amount=").append(amount); sb.append(", amount=").append(amount);
sb.append(", itemCost=").append(itemCost); sb.append(", itemCost=").append(itemCost);
sb.append(", channelCost=").append(channelCost); sb.append(", channelCost=").append(channelCost);
sb.append(", introduceCost=").append(introduceCost);
sb.append(", profit=").append(profit); sb.append(", profit=").append(profit);
sb.append(", createTime=").append(createTime); sb.append(", createTime=").append(createTime);
sb.append(", isValid=").append(isValid); sb.append(", isValid=").append(isValid);
...@@ -109,6 +114,7 @@ public class DistributorProfit implements Entity { ...@@ -109,6 +114,7 @@ public class DistributorProfit implements Entity {
&& (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount())) && (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
&& (this.getItemCost() == null ? other.getItemCost() == null : this.getItemCost().equals(other.getItemCost())) && (this.getItemCost() == null ? other.getItemCost() == null : this.getItemCost().equals(other.getItemCost()))
&& (this.getChannelCost() == null ? other.getChannelCost() == null : this.getChannelCost().equals(other.getChannelCost())) && (this.getChannelCost() == null ? other.getChannelCost() == null : this.getChannelCost().equals(other.getChannelCost()))
&& (this.getIntroduceCost() == null ? other.getIntroduceCost() == null : this.getIntroduceCost().equals(other.getIntroduceCost()))
&& (this.getProfit() == null ? other.getProfit() == null : this.getProfit().equals(other.getProfit())) && (this.getProfit() == null ? other.getProfit() == null : this.getProfit().equals(other.getProfit()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getIsValid() == null ? other.getIsValid() == null : this.getIsValid().equals(other.getIsValid())); && (this.getIsValid() == null ? other.getIsValid() == null : this.getIsValid().equals(other.getIsValid()));
...@@ -126,6 +132,7 @@ public class DistributorProfit implements Entity { ...@@ -126,6 +132,7 @@ public class DistributorProfit implements Entity {
result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode()); result = prime * result + ((getAmount() == null) ? 0 : getAmount().hashCode());
result = prime * result + ((getItemCost() == null) ? 0 : getItemCost().hashCode()); result = prime * result + ((getItemCost() == null) ? 0 : getItemCost().hashCode());
result = prime * result + ((getChannelCost() == null) ? 0 : getChannelCost().hashCode()); result = prime * result + ((getChannelCost() == null) ? 0 : getChannelCost().hashCode());
result = prime * result + ((getIntroduceCost() == null) ? 0 : getIntroduceCost().hashCode());
result = prime * result + ((getProfit() == null) ? 0 : getProfit().hashCode()); result = prime * result + ((getProfit() == null) ? 0 : getProfit().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getIsValid() == null) ? 0 : getIsValid().hashCode()); result = prime * result + ((getIsValid() == null) ? 0 : getIsValid().hashCode());
...@@ -148,6 +155,7 @@ public class DistributorProfit implements Entity { ...@@ -148,6 +155,7 @@ public class DistributorProfit implements Entity {
amount("amount", "amount", "BIGINT", false), amount("amount", "amount", "BIGINT", false),
itemCost("item_cost", "itemCost", "BIGINT", false), itemCost("item_cost", "itemCost", "BIGINT", false),
channelCost("channel_cost", "channelCost", "BIGINT", false), channelCost("channel_cost", "channelCost", "BIGINT", false),
introduceCost("introduce_cost", "introduceCost", "BIGINT", false),
profit("profit", "profit", "BIGINT", false), profit("profit", "profit", "BIGINT", false),
createTime("create_time", "createTime", "TIMESTAMP", false), createTime("create_time", "createTime", "TIMESTAMP", false),
isValid("is_valid", "isValid", "BIT", false); isValid("is_valid", "isValid", "BIT", false);
......
...@@ -1214,6 +1214,138 @@ public class DistributorProfitExample { ...@@ -1214,6 +1214,138 @@ public class DistributorProfitExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andIntroduceCostIsNull() {
addCriterion("introduce_cost is null");
return (Criteria) this;
}
public Criteria andIntroduceCostIsNotNull() {
addCriterion("introduce_cost is not null");
return (Criteria) this;
}
public Criteria andIntroduceCostEqualTo(Long value) {
addCriterion("introduce_cost =", value, "introduceCost");
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 andIntroduceCostEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("introduce_cost = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andIntroduceCostNotEqualTo(Long value) {
addCriterion("introduce_cost <>", value, "introduceCost");
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 andIntroduceCostNotEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("introduce_cost <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andIntroduceCostGreaterThan(Long value) {
addCriterion("introduce_cost >", value, "introduceCost");
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 andIntroduceCostGreaterThanColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("introduce_cost > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andIntroduceCostGreaterThanOrEqualTo(Long value) {
addCriterion("introduce_cost >=", value, "introduceCost");
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 andIntroduceCostGreaterThanOrEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("introduce_cost >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andIntroduceCostLessThan(Long value) {
addCriterion("introduce_cost <", value, "introduceCost");
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 andIntroduceCostLessThanColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("introduce_cost < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andIntroduceCostLessThanOrEqualTo(Long value) {
addCriterion("introduce_cost <=", value, "introduceCost");
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 andIntroduceCostLessThanOrEqualToColumn(DistributorProfit.Column column) {
addCriterion(new StringBuilder("introduce_cost <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andIntroduceCostIn(List<Long> values) {
addCriterion("introduce_cost in", values, "introduceCost");
return (Criteria) this;
}
public Criteria andIntroduceCostNotIn(List<Long> values) {
addCriterion("introduce_cost not in", values, "introduceCost");
return (Criteria) this;
}
public Criteria andIntroduceCostBetween(Long value1, Long value2) {
addCriterion("introduce_cost between", value1, value2, "introduceCost");
return (Criteria) this;
}
public Criteria andIntroduceCostNotBetween(Long value1, Long value2) {
addCriterion("introduce_cost not between", value1, value2, "introduceCost");
return (Criteria) this;
}
public Criteria andProfitIsNull() { public Criteria andProfitIsNull() {
addCriterion("profit is null"); addCriterion("profit is null");
return (Criteria) this; return (Criteria) this;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<result column="amount" jdbcType="BIGINT" property="amount" /> <result column="amount" jdbcType="BIGINT" property="amount" />
<result column="item_cost" jdbcType="BIGINT" property="itemCost" /> <result column="item_cost" jdbcType="BIGINT" property="itemCost" />
<result column="channel_cost" jdbcType="BIGINT" property="channelCost" /> <result column="channel_cost" jdbcType="BIGINT" property="channelCost" />
<result column="introduce_cost" jdbcType="BIGINT" property="introduceCost" />
<result column="profit" jdbcType="BIGINT" property="profit" /> <result column="profit" jdbcType="BIGINT" property="profit" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="is_valid" jdbcType="BIT" property="isValid" /> <result column="is_valid" jdbcType="BIT" property="isValid" />
...@@ -74,7 +75,7 @@ ...@@ -74,7 +75,7 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost, id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, profit, create_time, is_valid channel_cost, introduce_cost, profit, create_time, is_valid
</sql> </sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.distribution.DistributorProfitExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.wwdz.ch.db.domain.distribution.DistributorProfitExample" resultMap="BaseResultMap">
select select
...@@ -103,14 +104,14 @@ ...@@ -103,14 +104,14 @@
distinct distinct
</if> </if>
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost, id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, profit, create_time, is_valid channel_cost, introduce_cost, profit, create_time, is_valid
</otherwise> </otherwise>
</choose> </choose>
from distributor_profit from distributor_profit
...@@ -135,14 +136,14 @@ ...@@ -135,14 +136,14 @@
--> -->
select select
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost, id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, profit, create_time, is_valid channel_cost, introduce_cost, profit, create_time, is_valid
</otherwise> </otherwise>
</choose> </choose>
from distributor_profit from distributor_profit
...@@ -164,12 +165,14 @@ ...@@ -164,12 +165,14 @@
</selectKey> </selectKey>
insert into distributor_profit (distribution_order_id, distributor_id, insert into distributor_profit (distribution_order_id, distributor_id,
item_id, item_num, amount, item_id, item_num, amount,
item_cost, channel_cost, profit, item_cost, channel_cost, introduce_cost,
create_time, is_valid) profit, create_time, is_valid
)
values (#{distributionOrderId,jdbcType=VARCHAR}, #{distributorId,jdbcType=BIGINT}, values (#{distributionOrderId,jdbcType=VARCHAR}, #{distributorId,jdbcType=BIGINT},
#{itemId,jdbcType=BIGINT}, #{itemNum,jdbcType=INTEGER}, #{amount,jdbcType=BIGINT}, #{itemId,jdbcType=BIGINT}, #{itemNum,jdbcType=INTEGER}, #{amount,jdbcType=BIGINT},
#{itemCost,jdbcType=BIGINT}, #{channelCost,jdbcType=BIGINT}, #{profit,jdbcType=BIGINT}, #{itemCost,jdbcType=BIGINT}, #{channelCost,jdbcType=BIGINT}, #{introduceCost,jdbcType=BIGINT},
#{createTime,jdbcType=TIMESTAMP}, #{isValid,jdbcType=BIT}) #{profit,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{isValid,jdbcType=BIT}
)
</insert> </insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.DistributorProfit"> <insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.DistributorProfit">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
...@@ -198,6 +201,9 @@ ...@@ -198,6 +201,9 @@
<if test="channelCost != null"> <if test="channelCost != null">
channel_cost, channel_cost,
</if> </if>
<if test="introduceCost != null">
introduce_cost,
</if>
<if test="profit != null"> <if test="profit != null">
profit, profit,
</if> </if>
...@@ -230,6 +236,9 @@ ...@@ -230,6 +236,9 @@
<if test="channelCost != null"> <if test="channelCost != null">
#{channelCost,jdbcType=BIGINT}, #{channelCost,jdbcType=BIGINT},
</if> </if>
<if test="introduceCost != null">
#{introduceCost,jdbcType=BIGINT},
</if>
<if test="profit != null"> <if test="profit != null">
#{profit,jdbcType=BIGINT}, #{profit,jdbcType=BIGINT},
</if> </if>
...@@ -274,6 +283,9 @@ ...@@ -274,6 +283,9 @@
<if test="record.channelCost != null"> <if test="record.channelCost != null">
channel_cost = #{record.channelCost,jdbcType=BIGINT}, channel_cost = #{record.channelCost,jdbcType=BIGINT},
</if> </if>
<if test="record.introduceCost != null">
introduce_cost = #{record.introduceCost,jdbcType=BIGINT},
</if>
<if test="record.profit != null"> <if test="record.profit != null">
profit = #{record.profit,jdbcType=BIGINT}, profit = #{record.profit,jdbcType=BIGINT},
</if> </if>
...@@ -298,6 +310,7 @@ ...@@ -298,6 +310,7 @@
amount = #{record.amount,jdbcType=BIGINT}, amount = #{record.amount,jdbcType=BIGINT},
item_cost = #{record.itemCost,jdbcType=BIGINT}, item_cost = #{record.itemCost,jdbcType=BIGINT},
channel_cost = #{record.channelCost,jdbcType=BIGINT}, channel_cost = #{record.channelCost,jdbcType=BIGINT},
introduce_cost = #{record.introduceCost,jdbcType=BIGINT},
profit = #{record.profit,jdbcType=BIGINT}, profit = #{record.profit,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
is_valid = #{record.isValid,jdbcType=BIT} is_valid = #{record.isValid,jdbcType=BIT}
...@@ -329,6 +342,9 @@ ...@@ -329,6 +342,9 @@
<if test="channelCost != null"> <if test="channelCost != null">
channel_cost = #{channelCost,jdbcType=BIGINT}, channel_cost = #{channelCost,jdbcType=BIGINT},
</if> </if>
<if test="introduceCost != null">
introduce_cost = #{introduceCost,jdbcType=BIGINT},
</if>
<if test="profit != null"> <if test="profit != null">
profit = #{profit,jdbcType=BIGINT}, profit = #{profit,jdbcType=BIGINT},
</if> </if>
...@@ -350,6 +366,7 @@ ...@@ -350,6 +366,7 @@
amount = #{amount,jdbcType=BIGINT}, amount = #{amount,jdbcType=BIGINT},
item_cost = #{itemCost,jdbcType=BIGINT}, item_cost = #{itemCost,jdbcType=BIGINT},
channel_cost = #{channelCost,jdbcType=BIGINT}, channel_cost = #{channelCost,jdbcType=BIGINT},
introduce_cost = #{introduceCost,jdbcType=BIGINT},
profit = #{profit,jdbcType=BIGINT}, profit = #{profit,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
is_valid = #{isValid,jdbcType=BIT} is_valid = #{isValid,jdbcType=BIT}
...@@ -382,14 +399,14 @@ ...@@ -382,14 +399,14 @@
select select
'true' as QUERYID, 'true' as QUERYID,
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost, id, distribution_order_id, distributor_id, item_id, item_num, amount, item_cost,
channel_cost, profit, create_time, is_valid channel_cost, introduce_cost, profit, create_time, is_valid
</otherwise> </otherwise>
</choose> </choose>
from distributor_profit from distributor_profit
......
...@@ -89,6 +89,11 @@ public class DistributionOrderDetailVo implements Entity { ...@@ -89,6 +89,11 @@ public class DistributionOrderDetailVo implements Entity {
*/ */
private String channelCost; private String channelCost;
/**
* 介绍人分佣
*/
private String introduceCost;
/** /**
* 盈利 * 盈利
*/ */
......
...@@ -13,9 +13,12 @@ import com.wwdz.ch.core.notify.AliSmsSender; ...@@ -13,9 +13,12 @@ import com.wwdz.ch.core.notify.AliSmsSender;
import com.wwdz.ch.core.type.PageSearchResult; import com.wwdz.ch.core.type.PageSearchResult;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.*; import com.wwdz.ch.core.util.*;
import com.wwdz.ch.db.dao.FollowFansRecordDao;
import com.wwdz.ch.db.dao.distribution.*; import com.wwdz.ch.db.dao.distribution.*;
import com.wwdz.ch.db.domain.FollowFansRecord;
import com.wwdz.ch.db.domain.User; import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.db.domain.distribution.*; import com.wwdz.ch.db.domain.distribution.*;
import com.wwdz.ch.db.dto.request.FollowFansRecordRequestDto;
import com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto; import com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto;
import com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto; import com.wwdz.ch.db.dto.request.distribution.SupplierItemRequestDto;
import com.wwdz.ch.wx.api.WxAppletApi; import com.wwdz.ch.wx.api.WxAppletApi;
...@@ -101,6 +104,9 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { ...@@ -101,6 +104,9 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
@Autowired @Autowired
WxAppletApi wxAppletApi; WxAppletApi wxAppletApi;
@Autowired
FollowFansRecordDao followFansRecordDao;
@Transactional @Transactional
@Override @Override
public Result createDistributionOrder(DistributionOrderRequestDto dto) { public Result createDistributionOrder(DistributionOrderRequestDto dto) {
...@@ -365,6 +371,106 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { ...@@ -365,6 +371,106 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
return Result.failed("拍卖分销订单下单失败"); return Result.failed("拍卖分销订单下单失败");
} }
@Override
public Result createCollectionOrder(DistributionOrderRequestDto dto) {
try {
Long itemId = dto.getItemId();
String shareRecordId = dto.getShareRecordId();
if (StringUtils.hasLength(shareRecordId)) {
//查询分享记录详细信息
DistributorShareRecord distributorShareRecord = distributorShareRecordDao.findById(shareRecordId);
if (distributorShareRecord == null) {
return Result.failed("该分享链接无效");
}
if (!distributorShareRecord.getEnabled()) {
return Result.failed("该分享链接已失效");
}
itemId = distributorShareRecord.getItemId();
}
//查询商品信息,检查商品库存
SupplierItem supplierItem = supplierItemDao.findById(itemId);
int stock = supplierItem.getStock();
if (stock <= 0) {
return Result.failed("商品库存不足");
}
//商品限购数量
if (dto.getItemNum() > stock) {
return Result.failed("超出库存");
}
String distributionOrderId = IdUtils.getOrderNumber(DISTRIBUTION_ORDER_PREFIX);
DistributionOrderRequestDto prePayDto = new DistributionOrderRequestDto();
prePayDto.setDistributionOrderId(distributionOrderId);
prePayDto.setAmount(String.valueOf(supplierItem.getDistributionPrice() * dto.getItemNum()));
prePayDto.setBuyerOpenid(dto.getBuyerOpenid());
prePayDto.setItemName(supplierItem.getName());
Result prePayResult = wxPayServiceApi.createPrepareOrder(prePayDto);
if (!prePayResult.getSuccess()) {
return Result.failed("购买藏品预下单失败");
}
String prepayId = (String) prePayResult.getData();
//查询该用户和藏家的介绍人
FollowFansRecordRequestDto followFansRecordRequestDto = new FollowFansRecordRequestDto();
followFansRecordRequestDto.setFollowerId(supplierItem.getCreatorId());
followFansRecordRequestDto.setFansId(dto.getBuyerId());
FollowFansRecord followFansRecord = followFansRecordDao.findOne(followFansRecordRequestDto);
//把介绍人作为该订单的分享链接字段的值
long introducerId = followFansRecord.getIntroducerId();
DistributionOrder distributionOrder = new DistributionOrder();
distributionOrder.setItemId(itemId);
distributionOrder.setItemNum(dto.getItemNum());
distributionOrder.setShareRecordId(String.valueOf(introducerId));
distributionOrder.setDistributionOrderId(distributionOrderId);
distributionOrder.setPrepayId(prepayId);
distributionOrder.setBuyerId(dto.getBuyerId());
distributionOrder.setBuyerOpenid(dto.getBuyerOpenid());
distributionOrder.setShopId(supplierItem.getCreatorId());
distributionOrder.setSellerId(supplierItem.getCreatorId());
distributionOrder.setAmount(supplierItem.getDistributionPrice() * dto.getItemNum());
distributionOrder.setAddressId(dto.getAddressId());
distributionOrder.setReceiverAddress(dto.getReceiverAddress());
distributionOrder.setReceiverName(dto.getReceiverName());
distributionOrder.setReceiverPhone(dto.getReceiverPhone());
distributionOrder.setCreateTime(new Date());
distributionOrder.setUpdateTime(new Date());
distributionOrder.setType(DistributionEnum.DistributionTypeEnum.COLLECT.getCode());
distributionOrder.setState(DistributionEnum.DistributionOrderStateEnum.PRE_PAY.getCode());
distributionOrderDao.insert(distributionOrder);
Map<String, String> map = new HashMap<>();
map.put("distributionOrderId", distributionOrderId);
map.put("prepayId", prepayId);
//计算分销商的利润
DistributorProfit distributorProfit = new DistributorProfit();
//平台服务费
double channelServiceCost = distributionOrder.getAmount().doubleValue() * 0.05;
//介绍人分佣,自己推荐获得的订单无需计算介绍佣金
double introduceCost = 0;
if (supplierItem.getCreatorId() != introducerId) {
introduceCost = distributionOrder.getAmount().doubleValue() * 0.03;
}
distributorProfit.setDistributionOrderId(distributionOrderId);
distributorProfit.setDistributorId(distributionOrder.getSellerId());
distributorProfit.setItemId(distributionOrder.getItemId());
distributorProfit.setItemNum(distributionOrder.getItemNum());
distributorProfit.setAmount(distributionOrder.getAmount());
distributorProfit.setItemCost(null);
distributorProfit.setChannelCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(channelServiceCost)));
distributorProfit.setIntroduceCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(introduceCost)));
long profit = distributionOrder.getAmount() - distributorProfit.getChannelCost() - distributorProfit.getIntroduceCost();
distributorProfit.setProfit(profit);
distributorProfit.setCreateTime(new Date());
distributorProfit.setIsValid(false);
distributorProfitDao.insert(distributorProfit);
return Result.success(map);
} catch (Exception e) {
logger.error("创建藏品一口价订单失败 error : {}", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
return Result.failed("藏品一口价订单下单失败");
}
@Override @Override
public Result auctionPay(DistributionOrderRequestDto dto) { public Result auctionPay(DistributionOrderRequestDto dto) {
try { try {
...@@ -891,7 +997,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { ...@@ -891,7 +997,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
double channelServiceCost = distributionOrder.getAmount().doubleValue() * 0.05; double channelServiceCost = distributionOrder.getAmount().doubleValue() * 0.05;
//介绍人分佣 //介绍人分佣
double introduceCost = distributionOrder.getAmount().doubleValue() * 0.03;
//利润 //利润
......
...@@ -621,8 +621,8 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -621,8 +621,8 @@ public class SupplierItemServiceImpl implements SupplierItemService {
} }
//删除去掉的标签对应的关系 //删除去掉的标签对应的关系
List<CollectionItemsRelation> collectionItemsRelations = collectionItemsRelationDao.findByItemId(dto.getId()); List<CollectionItemsRelation> collectionItemsRelations = collectionItemsRelationDao.findByItemId(dto.getId());
if (!CollectionUtils.isEmpty(collectionItemsRelations) && StringUtils.hasLength(dto.getCollectionBookId())) {
List<Long> collectionBookIds = collectionItemsRelations.stream().map(CollectionItemsRelation::getCollectionBookId).collect(Collectors.toList()); List<Long> collectionBookIds = collectionItemsRelations.stream().map(CollectionItemsRelation::getCollectionBookId).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collectionItemsRelations) && StringUtils.hasLength(dto.getCollectionBookId())) {
List<String> newLinkIds = StringUtils.stringToList(dto.getCollectionBookId(), ";"); List<String> newLinkIds = StringUtils.stringToList(dto.getCollectionBookId(), ";");
collectionBookIds.forEach(id -> { collectionBookIds.forEach(id -> {
//新选的标签中不包含原来的数据,说明该标签和商品的关联关系取消 //新选的标签中不包含原来的数据,说明该标签和商品的关联关系取消
...@@ -633,6 +633,14 @@ public class SupplierItemServiceImpl implements SupplierItemService { ...@@ -633,6 +633,14 @@ public class SupplierItemServiceImpl implements SupplierItemService {
collectionItemsRelationDao.delete(deleteDto); collectionItemsRelationDao.delete(deleteDto);
} }
}); });
} else if (StringUtils.isEmpty(dto.getCollectionBookId()) && !CollectionUtils.isEmpty(collectionBookIds)) {
//取消所有的标签关联
collectionBookIds.forEach(id -> {
CollectionItemsRelationRequestDto deleteDto = new CollectionItemsRelationRequestDto();
deleteDto.setCollectionBookId(id);
deleteDto.setItemId(dto.getId());
collectionItemsRelationDao.delete(deleteDto);
});
} }
return Result.success(); return Result.success();
} catch (Exception e) { } catch (Exception e) {
......
...@@ -21,6 +21,15 @@ public interface DistributionOrderService { ...@@ -21,6 +21,15 @@ public interface DistributionOrderService {
Result createAuctionOrder(DistributionOrderRequestDto dto); Result createAuctionOrder(DistributionOrderRequestDto dto);
/**
* 创建藏品一口价订单
* @param dto
* @return
*/
Result createCollectionOrder(DistributionOrderRequestDto dto);
/** /**
* 拍卖订单付款,先调用微信预支付接口,再拿prepay_id获取支付参数返回前端 * 拍卖订单付款,先调用微信预支付接口,再拿prepay_id获取支付参数返回前端
* @param dto * @param dto
......
...@@ -61,6 +61,20 @@ public class DistributionOrderController { ...@@ -61,6 +61,20 @@ public class DistributionOrderController {
} }
@ApiOperation(value = "购买用户藏品下单,尚未付款")
@PostMapping("/createCollectionOrder")
public Result createCollectionOrder(@RequestBody DistributionOrderRequestDto dto) {
logger.info("购买用户藏品下单,请求参数:{}", JSON.toJSONString(dto));
Validator validator = new Validator(FormHandler.ofEntity(dto));
validator.set("itemId", "商品id").must().number()
.end();
if (!validator.isValid()) {
return Result.failed(validator.getErrorInfo());
}
return distributionOrderService.createCollectionOrder(dto);
}
@ApiOperation(value = "拍卖分销单付款,预下单并获取支付参数") @ApiOperation(value = "拍卖分销单付款,预下单并获取支付参数")
@PostMapping("/auctionPay") @PostMapping("/auctionPay")
public Result auctionPay(@RequestBody DistributionOrderRequestDto dto) { public Result auctionPay(@RequestBody DistributionOrderRequestDto dto) {
......
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