Commit 887d1e55 authored by shiyu's avatar shiyu

平台服务费可配置

parent 9d04736e
......@@ -40,6 +40,11 @@ public class PriceUtil {
}
public static BigDecimal convertToDivide(BigDecimal number){
return number.divide(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_DOWN);
}
public static Long convertPriceUnit(Long price){
BigDecimal bigDecimal = new BigDecimal(price);
bigDecimal = bigDecimal.multiply(new BigDecimal(100));
......
......@@ -9,4 +9,6 @@ public interface CollectorWhiteListDao {
void upsert(CollectorWhiteList collectorWhiteList);
CollectorWhiteList findById(long collectorId);
}
package com.wwdz.ch.db.domain;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import com.xxdxxs.entity.Entity;
import lombok.Data;
/**
* @author shiyu
* @date 2024/04/09
* @date 2024/06/18
*/
@Data
public class CollectorWhiteList implements Entity {
......@@ -19,6 +22,11 @@ public class CollectorWhiteList implements Entity {
*/
private Long collectorId;
/**
* 平台服务费比例
*/
private BigDecimal channelCostRebate;
/**
* 创建时间
*/
......@@ -39,6 +47,7 @@ public class CollectorWhiteList implements Entity {
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", collectorId=").append(collectorId);
sb.append(", channelCostRebate=").append(channelCostRebate);
sb.append(", createTime=").append(createTime);
sb.append(", isValid=").append(isValid);
sb.append(", serialVersionUID=").append(serialVersionUID);
......@@ -60,6 +69,7 @@ public class CollectorWhiteList implements Entity {
CollectorWhiteList other = (CollectorWhiteList) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getCollectorId() == null ? other.getCollectorId() == null : this.getCollectorId().equals(other.getCollectorId()))
&& (this.getChannelCostRebate() == null ? other.getChannelCostRebate() == null : this.getChannelCostRebate().equals(other.getChannelCostRebate()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getIsValid() == null ? other.getIsValid() == null : this.getIsValid().equals(other.getIsValid()));
}
......@@ -70,6 +80,7 @@ public class CollectorWhiteList implements Entity {
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getCollectorId() == null) ? 0 : getCollectorId().hashCode());
result = prime * result + ((getChannelCostRebate() == null) ? 0 : getChannelCostRebate().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getIsValid() == null) ? 0 : getIsValid().hashCode());
return result;
......@@ -85,6 +96,7 @@ public class CollectorWhiteList implements Entity {
public enum Column {
id("id", "id", "INTEGER", false),
collectorId("collector_id", "collectorId", "BIGINT", false),
channelCostRebate("channel_cost_rebate", "channelCostRebate", "DECIMAL", false),
createTime("create_time", "createTime", "TIMESTAMP", false),
isValid("is_valid", "isValid", "BIT", false);
......
package com.wwdz.ch.db.domain;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
......@@ -412,6 +413,138 @@ public class CollectorWhiteListExample {
return (Criteria) this;
}
public Criteria andChannelCostRebateIsNull() {
addCriterion("channel_cost_rebate is null");
return (Criteria) this;
}
public Criteria andChannelCostRebateIsNotNull() {
addCriterion("channel_cost_rebate is not null");
return (Criteria) this;
}
public Criteria andChannelCostRebateEqualTo(BigDecimal value) {
addCriterion("channel_cost_rebate =", value, "channelCostRebate");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table collector_white_list
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andChannelCostRebateEqualToColumn(CollectorWhiteList.Column column) {
addCriterion(new StringBuilder("channel_cost_rebate = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andChannelCostRebateNotEqualTo(BigDecimal value) {
addCriterion("channel_cost_rebate <>", value, "channelCostRebate");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table collector_white_list
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andChannelCostRebateNotEqualToColumn(CollectorWhiteList.Column column) {
addCriterion(new StringBuilder("channel_cost_rebate <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andChannelCostRebateGreaterThan(BigDecimal value) {
addCriterion("channel_cost_rebate >", value, "channelCostRebate");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table collector_white_list
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andChannelCostRebateGreaterThanColumn(CollectorWhiteList.Column column) {
addCriterion(new StringBuilder("channel_cost_rebate > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andChannelCostRebateGreaterThanOrEqualTo(BigDecimal value) {
addCriterion("channel_cost_rebate >=", value, "channelCostRebate");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table collector_white_list
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andChannelCostRebateGreaterThanOrEqualToColumn(CollectorWhiteList.Column column) {
addCriterion(new StringBuilder("channel_cost_rebate >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andChannelCostRebateLessThan(BigDecimal value) {
addCriterion("channel_cost_rebate <", value, "channelCostRebate");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table collector_white_list
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andChannelCostRebateLessThanColumn(CollectorWhiteList.Column column) {
addCriterion(new StringBuilder("channel_cost_rebate < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andChannelCostRebateLessThanOrEqualTo(BigDecimal value) {
addCriterion("channel_cost_rebate <=", value, "channelCostRebate");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table collector_white_list
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andChannelCostRebateLessThanOrEqualToColumn(CollectorWhiteList.Column column) {
addCriterion(new StringBuilder("channel_cost_rebate <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andChannelCostRebateIn(List<BigDecimal> values) {
addCriterion("channel_cost_rebate in", values, "channelCostRebate");
return (Criteria) this;
}
public Criteria andChannelCostRebateNotIn(List<BigDecimal> values) {
addCriterion("channel_cost_rebate not in", values, "channelCostRebate");
return (Criteria) this;
}
public Criteria andChannelCostRebateBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("channel_cost_rebate between", value1, value2, "channelCostRebate");
return (Criteria) this;
}
public Criteria andChannelCostRebateNotBetween(BigDecimal value1, BigDecimal value2) {
addCriterion("channel_cost_rebate not between", value1, value2, "channelCostRebate");
return (Criteria) this;
}
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
......
......@@ -37,4 +37,13 @@ public class CollectorWhiteListDaoImpl implements CollectorWhiteListDao {
collectorWhiteListMapper.insert(collectorWhiteList);
}
}
@Override
public CollectorWhiteList findById(long collectorId) {
CollectorWhiteListExample example = new CollectorWhiteListExample();
CollectorWhiteListExample.Criteria criteria = example.createCriteria();
criteria.andCollectorIdEqualTo(collectorId);
criteria.andIsValidEqualTo(true);
return collectorWhiteListMapper.selectOneByExample(example);
}
}
......@@ -4,6 +4,7 @@
<resultMap id="BaseResultMap" type="com.wwdz.ch.db.domain.CollectorWhiteList">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="collector_id" jdbcType="BIGINT" property="collectorId" />
<result column="channel_cost_rebate" jdbcType="DECIMAL" property="channelCostRebate" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="is_valid" jdbcType="BIT" property="isValid" />
</resultMap>
......@@ -66,7 +67,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, collector_id, create_time, is_valid
id, collector_id, channel_cost_rebate, create_time, is_valid
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.CollectorWhiteListExample" resultMap="BaseResultMap">
select
......@@ -95,13 +96,13 @@
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, collector_id, create_time, is_valid
id, collector_id, channel_cost_rebate, create_time, is_valid
</otherwise>
</choose>
from collector_white_list
......@@ -126,13 +127,13 @@
-->
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, collector_id, create_time, is_valid
id, collector_id, channel_cost_rebate, create_time, is_valid
</otherwise>
</choose>
from collector_white_list
......@@ -152,10 +153,10 @@
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID()
</selectKey>
insert into collector_white_list (collector_id, create_time, is_valid
)
values (#{collectorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{isValid,jdbcType=BIT}
)
insert into collector_white_list (collector_id, channel_cost_rebate, create_time,
is_valid)
values (#{collectorId,jdbcType=BIGINT}, #{channelCostRebate,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP},
#{isValid,jdbcType=BIT})
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.CollectorWhiteList">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
......@@ -166,6 +167,9 @@
<if test="collectorId != null">
collector_id,
</if>
<if test="channelCostRebate != null">
channel_cost_rebate,
</if>
<if test="createTime != null">
create_time,
</if>
......@@ -177,6 +181,9 @@
<if test="collectorId != null">
#{collectorId,jdbcType=BIGINT},
</if>
<if test="channelCostRebate != null">
#{channelCostRebate,jdbcType=DECIMAL},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
......@@ -200,6 +207,9 @@
<if test="record.collectorId != null">
collector_id = #{record.collectorId,jdbcType=BIGINT},
</if>
<if test="record.channelCostRebate != null">
channel_cost_rebate = #{record.channelCostRebate,jdbcType=DECIMAL},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
......@@ -215,6 +225,7 @@
update collector_white_list
set id = #{record.id,jdbcType=INTEGER},
collector_id = #{record.collectorId,jdbcType=BIGINT},
channel_cost_rebate = #{record.channelCostRebate,jdbcType=DECIMAL},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
is_valid = #{record.isValid,jdbcType=BIT}
<if test="_parameter != null">
......@@ -227,6 +238,9 @@
<if test="collectorId != null">
collector_id = #{collectorId,jdbcType=BIGINT},
</if>
<if test="channelCostRebate != null">
channel_cost_rebate = #{channelCostRebate,jdbcType=DECIMAL},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
......@@ -239,6 +253,7 @@
<update id="updateByPrimaryKey" parameterType="com.wwdz.ch.db.domain.CollectorWhiteList">
update collector_white_list
set collector_id = #{collectorId,jdbcType=BIGINT},
channel_cost_rebate = #{channelCostRebate,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=TIMESTAMP},
is_valid = #{isValid,jdbcType=BIT}
where id = #{id,jdbcType=INTEGER}
......@@ -270,13 +285,13 @@
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, collector_id, create_time, is_valid
id, collector_id, channel_cost_rebate, create_time, is_valid
</otherwise>
</choose>
from collector_white_list
......
......@@ -63,16 +63,16 @@
<!--生成Model类存放位置-->
<javaModelGenerator targetPackage="com.wwdz.ch.db.domain.distribution" targetProject="ch-dao/src/main/java">
<javaModelGenerator targetPackage="com.wwdz.ch.db.domain" targetProject="ch-dao/src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.wwdz.ch.db.mapper.distribution" targetProject="ch-dao/src/main/resources"/>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution"
<sqlMapGenerator targetPackage="com.wwdz.ch.db.mapper" targetProject="ch-dao/src/main/resources"/>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper"
targetProject="ch-dao/src/main/java"/>
<table tableName="distribution_order" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<table tableName="collector_white_list" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table>
......
......@@ -11,8 +11,10 @@ import com.wwdz.ch.core.notify.AliSmsSender;
import com.wwdz.ch.core.type.PageSearchResult;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.*;
import com.wwdz.ch.db.dao.CollectorWhiteListDao;
import com.wwdz.ch.db.dao.FollowFansRecordDao;
import com.wwdz.ch.db.dao.distribution.*;
import com.wwdz.ch.db.domain.CollectorWhiteList;
import com.wwdz.ch.db.domain.FollowFansRecord;
import com.wwdz.ch.db.domain.distribution.*;
import com.wwdz.ch.db.dto.request.FollowFansRecordRequestDto;
......@@ -120,6 +122,9 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
@Autowired
IdentifyOrderService identifyOrderService;
@Autowired
CollectorWhiteListDao collectorWhiteListDao;
@Transactional
@Override
public Result createDistributionOrder(DistributionOrderRequestDto dto) {
......@@ -470,7 +475,15 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
//计算分销商的利润
DistributorProfit distributorProfit = new DistributorProfit();
//平台服务费,默认15%
double channelServiceCost = distributionOrder.getAmount().doubleValue() * 0.15;
CollectorWhiteList collectorWhiteList = collectorWhiteListDao.findById(supplierItem.getCreatorId());
double channelCostRebate = 0.15;
if (collectorWhiteList != null) {
BigDecimal channelCost = collectorWhiteList.getChannelCostRebate();
channelCost = PriceUtil.convertToDivide(channelCost);
channelCostRebate = channelCost.doubleValue();
}
logger.info("藏家id:{} 生成新订单,平台服务费比例:{}", supplierItem.getCreatorId(), channelCostRebate);
double channelServiceCost = distributionOrder.getAmount().doubleValue() * channelCostRebate;
//介绍人分佣,自己推荐获得的订单无需计算介绍佣金
// double introduceCost = 0;
// if (supplierItem.getCreatorId() != introducerId) {
......@@ -1318,4 +1331,10 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
}
return Result.failed();
}
public static void main(String[] args) {
BigDecimal bigDecimal = new BigDecimal("15.00");
bigDecimal = PriceUtil.convertToDivide(bigDecimal);
System.out.println(bigDecimal.doubleValue());
}
}
......@@ -199,6 +199,7 @@ public class SupplierItemServiceImpl implements SupplierItemService {
try {
List<SupplierItemVo> supplierItemVos = new ArrayList<>();
List<SupplierItem> supplierItemList = supplierItemDao.findList(dto);
PageInfo pageInfo = new PageInfo(supplierItemList);
for (SupplierItem supplierItem : supplierItemList) {
SupplierItemVo supplierItemVo = new SupplierItemVo();
EntityMapper.copyAttribute(supplierItem, supplierItemVo);
......@@ -208,7 +209,7 @@ public class SupplierItemServiceImpl implements SupplierItemService {
supplierItemVo.setHomePageImage(MediaUtil.getHomePageImage(supplierItem.getImages(), supplierItem.getVideos()));
supplierItemVos.add(supplierItemVo);
}
return Result.success(supplierItemVos);
return Result.success(PageSearchResult.of(pageInfo, supplierItemVos));
} catch (Exception e) {
logger.error("查询商品列表失败 error : {}", e);
}
......
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