Commit 5d2e2de9 authored by shiyu's avatar shiyu

订单表加上佣金相关字段

parent b96beb9e
package com.wwdz.ch.db.domain.distribution;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
......@@ -10,7 +11,7 @@ import lombok.Data;
/**
* @author shiyu
* @date 2024/06/17
* @date 2024/08/02
*/
@Data
public class DistributionOrder implements Entity {
......@@ -146,6 +147,36 @@ public class DistributionOrder implements Entity {
*/
private Integer type;
/**
* 供货价
*/
private Long supplyPrice;
/**
* 介绍佣金金额
*/
private Long introduceAmount;
/**
* 介绍佣金比例
*/
private BigDecimal introduceRebate;
/**
* 介绍人id
*/
private Long introducerId;
/**
* 平台佣金金额
*/
private Long channelAmount;
/**
* 平台佣金比例
*/
private BigDecimal channelRebate;
private static final long serialVersionUID = 1L;
@Override
......@@ -181,6 +212,12 @@ public class DistributionOrder implements Entity {
sb.append(", state=").append(state);
sb.append(", logisticsState=").append(logisticsState);
sb.append(", type=").append(type);
sb.append(", supplyPrice=").append(supplyPrice);
sb.append(", introduceAmount=").append(introduceAmount);
sb.append(", introduceRebate=").append(introduceRebate);
sb.append(", introducerId=").append(introducerId);
sb.append(", channelAmount=").append(channelAmount);
sb.append(", channelRebate=").append(channelRebate);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
......@@ -224,7 +261,13 @@ public class DistributionOrder implements Entity {
&& (this.getShareRecordId() == null ? other.getShareRecordId() == null : this.getShareRecordId().equals(other.getShareRecordId()))
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
&& (this.getLogisticsState() == null ? other.getLogisticsState() == null : this.getLogisticsState().equals(other.getLogisticsState()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()));
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
&& (this.getSupplyPrice() == null ? other.getSupplyPrice() == null : this.getSupplyPrice().equals(other.getSupplyPrice()))
&& (this.getIntroduceAmount() == null ? other.getIntroduceAmount() == null : this.getIntroduceAmount().equals(other.getIntroduceAmount()))
&& (this.getIntroduceRebate() == null ? other.getIntroduceRebate() == null : this.getIntroduceRebate().equals(other.getIntroduceRebate()))
&& (this.getIntroducerId() == null ? other.getIntroducerId() == null : this.getIntroducerId().equals(other.getIntroducerId()))
&& (this.getChannelAmount() == null ? other.getChannelAmount() == null : this.getChannelAmount().equals(other.getChannelAmount()))
&& (this.getChannelRebate() == null ? other.getChannelRebate() == null : this.getChannelRebate().equals(other.getChannelRebate()));
}
@Override
......@@ -258,6 +301,12 @@ public class DistributionOrder implements Entity {
result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
result = prime * result + ((getLogisticsState() == null) ? 0 : getLogisticsState().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
result = prime * result + ((getSupplyPrice() == null) ? 0 : getSupplyPrice().hashCode());
result = prime * result + ((getIntroduceAmount() == null) ? 0 : getIntroduceAmount().hashCode());
result = prime * result + ((getIntroduceRebate() == null) ? 0 : getIntroduceRebate().hashCode());
result = prime * result + ((getIntroducerId() == null) ? 0 : getIntroducerId().hashCode());
result = prime * result + ((getChannelAmount() == null) ? 0 : getChannelAmount().hashCode());
result = prime * result + ((getChannelRebate() == null) ? 0 : getChannelRebate().hashCode());
return result;
}
......@@ -295,7 +344,13 @@ public class DistributionOrder implements Entity {
shareRecordId("share_record_id", "shareRecordId", "VARCHAR", false),
state("state", "state", "INTEGER", true),
logisticsState("logistics_state", "logisticsState", "INTEGER", false),
type("type", "type", "INTEGER", true);
type("type", "type", "INTEGER", true),
supplyPrice("supply_price", "supplyPrice", "BIGINT", false),
introduceAmount("introduce_amount", "introduceAmount", "BIGINT", false),
introduceRebate("introduce_rebate", "introduceRebate", "DECIMAL", false),
introducerId("introducer_id", "introducerId", "BIGINT", false),
channelAmount("channel_amount", "channelAmount", "BIGINT", false),
channelRebate("channel_rebate", "channelRebate", "DECIMAL", false);
/**
* This field was generated by MyBatis Generator.
......
......@@ -4,6 +4,7 @@ import com.wwdz.ch.db.dto.request.BaseRequestDto;
import com.xxdxxs.entity.Entity;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
......@@ -149,6 +150,36 @@ public class DistributionOrderRequestDto extends BaseRequestDto implements Entit
*/
private String refundPrice;
/**
* 供货价
*/
private Long supplyPrice;
/**
* 介绍佣金金额
*/
private Long introduceAmount;
/**
* 介绍佣金比例
*/
private BigDecimal introduceRebate;
/**
* 介绍人id
*/
private Long introducerId;
/**
* 平台佣金金额
*/
private Long channelAmount;
/**
* 平台佣金比例
*/
private BigDecimal channelRebate;
/**
* 退款接口请求秘钥
*/
......
......@@ -29,6 +29,12 @@
<result column="state" jdbcType="INTEGER" property="state" />
<result column="logistics_state" jdbcType="INTEGER" property="logisticsState" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="supply_price" jdbcType="BIGINT" property="supplyPrice" />
<result column="introduce_amount" jdbcType="BIGINT" property="introduceAmount" />
<result column="introduce_rebate" jdbcType="DECIMAL" property="introduceRebate" />
<result column="introducer_id" jdbcType="BIGINT" property="introducerId" />
<result column="channel_amount" jdbcType="BIGINT" property="channelAmount" />
<result column="channel_rebate" jdbcType="DECIMAL" property="channelRebate" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
......@@ -93,7 +99,8 @@
buyer_openid, shop_id, seller_id, amount, address_id, receiver_name, receiver_phone,
receiver_address, logistics_code, waybill, create_time, pay_time, delivery_time,
signed_time, finish_time, update_time, share_record_id, `state`, logistics_state,
`type`
`type`, supply_price, introduce_amount, introduce_rebate, introducer_id, channel_amount,
channel_rebate
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.distribution.DistributionOrderExample" resultMap="BaseResultMap">
select
......@@ -132,7 +139,8 @@
buyer_openid, shop_id, seller_id, amount, address_id, receiver_name, receiver_phone,
receiver_address, logistics_code, waybill, create_time, pay_time, delivery_time,
signed_time, finish_time, update_time, share_record_id, `state`, logistics_state,
`type`
`type`, supply_price, introduce_amount, introduce_rebate, introducer_id, channel_amount,
channel_rebate
</otherwise>
</choose>
from distribution_order
......@@ -167,7 +175,8 @@
buyer_openid, shop_id, seller_id, amount, address_id, receiver_name, receiver_phone,
receiver_address, logistics_code, waybill, create_time, pay_time, delivery_time,
signed_time, finish_time, update_time, share_record_id, `state`, logistics_state,
`type`
`type`, supply_price, introduce_amount, introduce_rebate, introducer_id, channel_amount,
channel_rebate
</otherwise>
</choose>
from distribution_order
......@@ -195,7 +204,9 @@
waybill, create_time, pay_time,
delivery_time, signed_time, finish_time,
update_time, share_record_id, `state`,
logistics_state, `type`)
logistics_state, `type`, supply_price,
introduce_amount, introduce_rebate, introducer_id,
channel_amount, channel_rebate)
values (#{distributionOrderId,jdbcType=VARCHAR}, #{prepayId,jdbcType=VARCHAR}, #{transactionId,jdbcType=VARCHAR},
#{itemId,jdbcType=BIGINT}, #{itemNum,jdbcType=INTEGER}, #{buyerId,jdbcType=BIGINT},
#{buyerOpenid,jdbcType=VARCHAR}, #{shopId,jdbcType=BIGINT}, #{sellerId,jdbcType=BIGINT},
......@@ -204,7 +215,9 @@
#{waybill,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{payTime,jdbcType=TIMESTAMP},
#{deliveryTime,jdbcType=TIMESTAMP}, #{signedTime,jdbcType=TIMESTAMP}, #{finishTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{shareRecordId,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER},
#{logisticsState,jdbcType=INTEGER}, #{type,jdbcType=INTEGER})
#{logisticsState,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, #{supplyPrice,jdbcType=BIGINT},
#{introduceAmount,jdbcType=BIGINT}, #{introduceRebate,jdbcType=DECIMAL}, #{introducerId,jdbcType=BIGINT},
#{channelAmount,jdbcType=BIGINT}, #{channelRebate,jdbcType=DECIMAL})
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.DistributionOrder">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
......@@ -290,6 +303,24 @@
<if test="type != null">
`type`,
</if>
<if test="supplyPrice != null">
supply_price,
</if>
<if test="introduceAmount != null">
introduce_amount,
</if>
<if test="introduceRebate != null">
introduce_rebate,
</if>
<if test="introducerId != null">
introducer_id,
</if>
<if test="channelAmount != null">
channel_amount,
</if>
<if test="channelRebate != null">
channel_rebate,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="distributionOrderId != null">
......@@ -370,6 +401,24 @@
<if test="type != null">
#{type,jdbcType=INTEGER},
</if>
<if test="supplyPrice != null">
#{supplyPrice,jdbcType=BIGINT},
</if>
<if test="introduceAmount != null">
#{introduceAmount,jdbcType=BIGINT},
</if>
<if test="introduceRebate != null">
#{introduceRebate,jdbcType=DECIMAL},
</if>
<if test="introducerId != null">
#{introducerId,jdbcType=BIGINT},
</if>
<if test="channelAmount != null">
#{channelAmount,jdbcType=BIGINT},
</if>
<if test="channelRebate != null">
#{channelRebate,jdbcType=DECIMAL},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.wwdz.ch.db.domain.distribution.DistributionOrderExample" resultType="java.lang.Long">
......@@ -462,6 +511,24 @@
<if test="record.type != null">
`type` = #{record.type,jdbcType=INTEGER},
</if>
<if test="record.supplyPrice != null">
supply_price = #{record.supplyPrice,jdbcType=BIGINT},
</if>
<if test="record.introduceAmount != null">
introduce_amount = #{record.introduceAmount,jdbcType=BIGINT},
</if>
<if test="record.introduceRebate != null">
introduce_rebate = #{record.introduceRebate,jdbcType=DECIMAL},
</if>
<if test="record.introducerId != null">
introducer_id = #{record.introducerId,jdbcType=BIGINT},
</if>
<if test="record.channelAmount != null">
channel_amount = #{record.channelAmount,jdbcType=BIGINT},
</if>
<if test="record.channelRebate != null">
channel_rebate = #{record.channelRebate,jdbcType=DECIMAL},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -495,7 +562,13 @@
share_record_id = #{record.shareRecordId,jdbcType=VARCHAR},
`state` = #{record.state,jdbcType=INTEGER},
logistics_state = #{record.logisticsState,jdbcType=INTEGER},
`type` = #{record.type,jdbcType=INTEGER}
`type` = #{record.type,jdbcType=INTEGER},
supply_price = #{record.supplyPrice,jdbcType=BIGINT},
introduce_amount = #{record.introduceAmount,jdbcType=BIGINT},
introduce_rebate = #{record.introduceRebate,jdbcType=DECIMAL},
introducer_id = #{record.introducerId,jdbcType=BIGINT},
channel_amount = #{record.channelAmount,jdbcType=BIGINT},
channel_rebate = #{record.channelRebate,jdbcType=DECIMAL}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
......@@ -581,6 +654,24 @@
<if test="type != null">
`type` = #{type,jdbcType=INTEGER},
</if>
<if test="supplyPrice != null">
supply_price = #{supplyPrice,jdbcType=BIGINT},
</if>
<if test="introduceAmount != null">
introduce_amount = #{introduceAmount,jdbcType=BIGINT},
</if>
<if test="introduceRebate != null">
introduce_rebate = #{introduceRebate,jdbcType=DECIMAL},
</if>
<if test="introducerId != null">
introducer_id = #{introducerId,jdbcType=BIGINT},
</if>
<if test="channelAmount != null">
channel_amount = #{channelAmount,jdbcType=BIGINT},
</if>
<if test="channelRebate != null">
channel_rebate = #{channelRebate,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
......@@ -611,7 +702,13 @@
share_record_id = #{shareRecordId,jdbcType=VARCHAR},
`state` = #{state,jdbcType=INTEGER},
logistics_state = #{logisticsState,jdbcType=INTEGER},
`type` = #{type,jdbcType=INTEGER}
`type` = #{type,jdbcType=INTEGER},
supply_price = #{supplyPrice,jdbcType=BIGINT},
introduce_amount = #{introduceAmount,jdbcType=BIGINT},
introduce_rebate = #{introduceRebate,jdbcType=DECIMAL},
introducer_id = #{introducerId,jdbcType=BIGINT},
channel_amount = #{channelAmount,jdbcType=BIGINT},
channel_rebate = #{channelRebate,jdbcType=DECIMAL}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectOneByExample" parameterType="com.wwdz.ch.db.domain.distribution.DistributionOrderExample" resultMap="BaseResultMap">
......@@ -651,7 +748,8 @@
buyer_openid, shop_id, seller_id, amount, address_id, receiver_name, receiver_phone,
receiver_address, logistics_code, waybill, create_time, pay_time, delivery_time,
signed_time, finish_time, update_time, share_record_id, `state`, logistics_state,
`type`
`type`, supply_price, introduce_amount, introduce_rebate, introducer_id, channel_amount,
channel_rebate
</otherwise>
</choose>
from distribution_order
......@@ -663,7 +761,6 @@
</if>
limit 1
</select>
<select id="countGroupByStateForDistributor" parameterType="java.lang.Long" resultType="com.wwdz.ch.db.bean.DistributionOrderNum">
select state, count(distribution_order_id) as num from distribution_order where seller_id = #{sellerId} group by state
</select>
......
......@@ -72,7 +72,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution"
targetProject="ch-dao/src/main/java"/>
<table tableName="group_purchase_config" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<table tableName="distribution_order" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table>
......
......@@ -271,7 +271,16 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
//把介绍人作为该订单的分享链接字段的值
introducerId = followFansRecord.getIntroducerId();
}
//查询该用户和藏家的介绍人
FollowFansRecordRequestDto followFansRecordRequestDto = new FollowFansRecordRequestDto();
followFansRecordRequestDto.setFollowerId(auctionConfig.getCreatorId());
followFansRecordRequestDto.setFansId(auctionRecord.getUserId());
double rebate = distributorProfitService.getIntroduceRebate(followFansRecordRequestDto);
DistributionOrder distributionOrder = new DistributionOrder();
distributionOrder.setIntroducerId(introducerId);
distributionOrder.setIntroduceRebate(BigDecimal.valueOf(rebate));
distributionOrder.setItemId(dto.getItemId());
distributionOrder.setItemNum(1);
distributionOrder.setShareRecordId(String.valueOf(introducerId));
......@@ -292,11 +301,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
DistributorProfit distributorProfit = new DistributorProfit();
SupplierItem supplierItem = supplierItemDao.findById(dto.getItemId());
//查询该用户和藏家的介绍人
FollowFansRecordRequestDto followFansRecordRequestDto = new FollowFansRecordRequestDto();
followFansRecordRequestDto.setFollowerId(auctionConfig.getCreatorId());
followFansRecordRequestDto.setFansId(auctionRecord.getUserId());
double rebate = distributorProfitService.getIntroduceRebate(followFansRecordRequestDto);
double introduceCost = distributionOrder.getAmount().doubleValue() * rebate;
//实际订单到账金额
......@@ -313,7 +318,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
distributorProfit.setItemNum(distributionOrder.getItemNum());
distributorProfit.setAmount(distributionOrder.getAmount());
distributorProfit.setRealAmount(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(realAmount)));
distributorProfit.setItemCost(auctionConfig.getStartPrice());
distributorProfit.setItemCost(supplierItem.getSupplyPrice());
distributorProfit.setChannelCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(channelServiceCost)));
distributorProfit.setIntroduceCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(introduceCost)));
//拍卖订单,藏家的利润就是商品设置的供货价
......@@ -419,7 +424,12 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
//把介绍人作为该订单的分享链接字段的值
introducerId = followFansRecord.getIntroducerId();
}
//介绍人分佣
double rebate = distributorProfitService.getIntroduceRebate(followFansRecordRequestDto);
DistributionOrder distributionOrder = new DistributionOrder();
distributionOrder.setIntroduceRebate(BigDecimal.valueOf(rebate));
distributionOrder.setIntroducerId(introducerId);
distributionOrder.setItemId(itemId);
distributionOrder.setItemNum(dto.getItemNum());
distributionOrder.setShareRecordId(String.valueOf(introducerId));
......@@ -461,8 +471,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
//暂时先不考虑
double channelServiceCost = distributionOrder.getAmount().doubleValue() * channelCostRebate;
//介绍人分佣,自己推荐获得的订单无需计算介绍佣金
double rebate = distributorProfitService.getIntroduceRebate(followFansRecordRequestDto);
double introduceCost = distributionOrder.getAmount().doubleValue() * rebate;
distributorProfit.setDistributionOrderId(distributionOrderId);
distributorProfit.setDistributorId(distributionOrder.getSellerId());
......@@ -470,7 +479,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
distributorProfit.setItemNum(distributionOrder.getItemNum());
distributorProfit.setAmount(distributionOrder.getAmount());
distributorProfit.setRealAmount(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(realAmount)));
distributorProfit.setItemCost(null);
distributorProfit.setItemCost(supplierItem.getSupplyPrice());
distributorProfit.setChannelCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(channelServiceCost)));
distributorProfit.setIntroduceCost(PriceUtil.convertPriceFromStr(PriceUtil.convertDoubleToString(introduceCost)));
long profit = distributionOrder.getAmount() - distributorProfit.getChannelCost() - distributorProfit.getIntroduceCost();
......@@ -519,6 +528,9 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
//把介绍人作为该订单的分享链接字段的值
introducerId = followFansRecord.getIntroducerId();
}
//查询该用户和藏家的介绍人
double rebate = distributorProfitService.getIntroduceRebate(followFansRecordRequestDto);
String distributionOrderId = IdUtils.getOrderNumber(DISTRIBUTION_ORDER_PREFIX);
DistributionOrderRequestDto prePayDto = new DistributionOrderRequestDto();
prePayDto.setDistributionOrderId(distributionOrderId);
......@@ -535,6 +547,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
map.put("prepayId", prepayId);
DistributionOrder distributionOrder = new DistributionOrder();
distributionOrder.setIntroducerId(introducerId);
distributionOrder.setIntroduceRebate(BigDecimal.valueOf(rebate));
distributionOrder.setItemId(itemId);
distributionOrder.setItemNum(dto.getItemNum());
distributionOrder.setShareRecordId(String.valueOf(introducerId));
......@@ -569,8 +583,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
groupPurchaseRecordDao.insert(groupPurchaseRecord);
//计算利润
//查询该用户和藏家的介绍人
double rebate = distributorProfitService.getIntroduceRebate(followFansRecordRequestDto);
double introduceCost = distributionOrder.getAmount().doubleValue() * rebate;
//实际订单到账金额
......
......@@ -206,6 +206,8 @@ public class SpecialPerformanceServiceImpl implements SpecialPerformanceService
updateDto.setState(SpecialPerformanceEnum.StateEnum.END.getCode());
updateDto.setUpdateTime(now);
specialPerformanceDao.update(updateDto);
//删除专场商品
offShelvesItemOfSpecialPerformance(specialPerformance.getId());
specialPerformance.setState(SpecialPerformanceEnum.StateEnum.END.getCode());
}
int specialPerformanceId = specialPerformance.getId();
......@@ -454,6 +456,8 @@ public class SpecialPerformanceServiceImpl implements SpecialPerformanceService
updateDto.setState(SpecialPerformanceEnum.StateEnum.END.getCode());
updateDto.setUpdateTime(now);
specialPerformanceDao.update(updateDto);
//删除专场商品
offShelvesItemOfSpecialPerformance(dto.getSpecialPerformanceId());
resultMap.put("state", SpecialPerformanceEnum.StateEnum.END.getCode());
resultMap.put("stateName", SpecialPerformanceEnum.StateEnum.END.getDes());
} else {
......@@ -567,7 +571,6 @@ public class SpecialPerformanceServiceImpl implements SpecialPerformanceService
logger.info("================专场id: {}, 即将开始通知消息全部发送成功 ==============", specialPerformance.getId());
}
private void sendStartSubscribeMsg(SpecialPerformance specialPerformance, DisposableSubscribeRecord disposableSubscribeRecord, String msg){
AuctionOfferNoticeMsg auctionOfferNoticeMsg = new AuctionOfferNoticeMsg();
auctionOfferNoticeMsg.setSpecialPerformanceTitle(specialPerformance.getTitle());
......@@ -588,6 +591,28 @@ public class SpecialPerformanceServiceImpl implements SpecialPerformanceService
disposableSubscribeRecordDao.updateInvalid(disposableSubscribeRecord.getOpenid(), disposableSubscribeRecord.getTargetId(), disposableSubscribeRecord.getTemplateId());
}
@Override
public Result offShelvesItemOfSpecialPerformance(int specialPerformanceId) {
try {
List<SpecialPerformanceConfig> list = specialPerformanceConfigDao.findAllItem(specialPerformanceId);
for (SpecialPerformanceConfig specialPerformanceConfig : list) {
long itemId = specialPerformanceConfig.getItemId();
SupplierItem oldItem = supplierItemDao.findById(itemId);
if (oldItem.getIsOnSale()) {
return Result.failed("先下架商品");
}
SupplierItem supplierItem = new SupplierItem();
supplierItem.setId(itemId);
supplierItem.setIsDeleted(true);
supplierItemDao.update(supplierItem);
}
return Result.success();
} catch (Exception e) {
logger.error("下架已结束的专场商品 error {}", e);
}
return Result.failed();
}
}
......@@ -2,10 +2,14 @@ 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.consts.DistributionEnum;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.PriceUtil;
import com.wwdz.ch.db.dao.CollectorWhiteListDao;
import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
import com.wwdz.ch.db.dao.distribution.UserAccountDetailDao;
import com.wwdz.ch.db.dao.distribution.UserBillDao;
import com.wwdz.ch.db.domain.CollectorWhiteList;
import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.wwdz.ch.db.domain.distribution.DistributorProfit;
import com.wwdz.ch.db.domain.distribution.UserAccountDetail;
......@@ -40,6 +44,12 @@ public class UserAccountDetailServiceImpl implements UserAccountDetailService {
@Autowired
UserBillService userBillService;
@Autowired
CollectorWhiteListDao collectorWhiteListDao;
@Autowired
DistributionOrderDao distributionOrderDao;
@Transactional(propagation=Propagation.REQUIRED)
@Override
......@@ -84,7 +94,7 @@ public class UserAccountDetailServiceImpl implements UserAccountDetailService {
|| CommConsts.SYSTEM_ACCOUNT.equals(distributionOrder.getShareRecordId())) {
introduceAccountDetail.setUserId(CommConsts.SYSTEM_ACCOUNT);
} else {
introduceAccountDetail.setUserId(Long.valueOf(distributionOrder.getShareRecordId()));
introduceAccountDetail.setUserId(distributionOrder.getIntroducerId() == null ? Long.valueOf(distributionOrder.getShareRecordId()) : distributionOrder.getIntroducerId());
}
introduceAccountDetail.setTransactionId(distributionOrder.getDistributionOrderId());
introduceAccountDetail.setAmount(introduceCost);
......@@ -95,6 +105,20 @@ public class UserAccountDetailServiceImpl implements UserAccountDetailService {
introduceAccountDetail.setCreateTime(distributionOrder.getCreateTime());
userAccountDetailDao.insert(introduceAccountDetail);
//更新订单表中的佣金字段
DistributionOrder updateDto = new DistributionOrder();
updateDto.setDistributionOrderId(distributionOrder.getDistributionOrderId());
updateDto.setSupplyPrice(distributorProfit.getItemCost());
updateDto.setIntroduceAmount(introduceCost);
updateDto.setChannelAmount(channelCost);
//查询平台佣金,拍卖和团购的不需要计算平台佣金比例,直接用供货价结算
if (distributionOrder.getType() == DistributionEnum.DistributionTypeEnum.FIXED_PRICE.getCode()
|| distributionOrder.getType() == DistributionEnum.DistributionTypeEnum.COLLECT.getCode()) {
CollectorWhiteList collectorWhiteList = collectorWhiteListDao.findById(distributionOrder.getSellerId());
updateDto.setChannelRebate(collectorWhiteList.getChannelCostRebate());
}
distributionOrderDao.update(distributionOrder);
//计算用户账单
Result result = userBillService.payCalculate(distributionOrder, distributorProfit);
if (!result.getSuccess()) {
......
......@@ -24,6 +24,7 @@ import com.wwdz.ch.db.dto.request.distribution.DisposableSubscribeRecordRequestD
import com.wwdz.ch.db.dto.request.distribution.SpecialPerformanceConfigRequestDto;
import com.wwdz.ch.db.dto.request.distribution.SpecialPerformanceRequestDto;
import com.wwdz.ch.wx.service.distribution.DistributionOrderService;
import com.wwdz.ch.wx.service.distribution.SpecialPerformanceService;
import com.xxdxxs.utils.DateUtils;
import com.xxdxxs.utils.JsonUtils;
import com.xxdxxs.utils.StringUtils;
......@@ -70,6 +71,9 @@ public class SpecialPerformanceNoticeJob {
@Autowired
SpecialPerformanceConfigDao specialPerformanceConfigDao;
@Autowired
SpecialPerformanceService specialPerformanceService;
@Autowired
RedissonClient redissonClient;
......@@ -424,11 +428,15 @@ public class SpecialPerformanceNoticeJob {
} else if (specialPerformance.getEndTime().before(now)) {
//超过结束时间,状态设置为结束
specialPerformanceDao.updateState(specialPerformance.getId(), SpecialPerformanceEnum.StateEnum.END.getCode());
//删除专场商品
specialPerformanceService.offShelvesItemOfSpecialPerformance(specialPerformance.getId());
}
} else if (specialPerformance.getState().intValue() == SpecialPerformanceEnum.StateEnum.PROCESSING.getCode()) {
//超过结束时间,状态设置为结束
if (specialPerformance.getEndTime().before(now)) {
specialPerformanceDao.updateState(specialPerformance.getId(), SpecialPerformanceEnum.StateEnum.END.getCode());
//删除专场商品
specialPerformanceService.offShelvesItemOfSpecialPerformance(specialPerformance.getId());
}
}
//查询该专场下的商品,自动更新状态
......
......@@ -27,6 +27,13 @@ public interface SpecialPerformanceService {
*/
Result findItemList(SpecialPerformanceRequestDto dto);
/**
* 专场结束删除对应商品
* @param specialPerformanceId
* @return
*/
Result offShelvesItemOfSpecialPerformance(int specialPerformanceId);
/**
* 手动发送专场进行中短信给用户
* @return
......
......@@ -44,8 +44,8 @@ public class GroupPurchaseController {
@ApiOperation(value = "取消团购订单")
@PostMapping("/cancelDeposit")
public Result cancelDeposit(@RequestBody GroupPurchaseRecordRequestDto dto) {
@PostMapping("/cancelOrder")
public Result cancelOrder(@RequestBody GroupPurchaseRecordRequestDto dto) {
logger.info("取消团购订单,请求参数:{}", JSON.toJSONString(dto));
if (!StringUtils.isAllNotEmpty(dto.getDistributionOrderId())) {
return Result.failed(ResultCode.PARAM_ERROR);
......
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