Authored by qinchao

Merge branch 'master' into test6.8.6.5

... ... @@ -30,12 +30,5 @@ public interface TradeBillsMapper {
TradeBills selectByDealRelateId(Integer dealRelateId);
/**
int deleteByPrimaryKey(Integer id);
int insertSelective(TradeBills record);
int updateByPrimaryKey(TradeBills record);
**/
List<TradeBills> selectByKeyProps(TradeBills condition);
}
... ...
... ... @@ -21,9 +21,7 @@
<result column="deal_user_name" jdbcType="VARCHAR" property="dealUserName" />
</resultMap>
<sql id="Base_Column_List">
id,uid, order_code, user_type,pay_type,trade_type,
income_outcome,amount,system_amount,trade_status,create_time
,deal_uid,deal_status,deal_time,deal_relate_id,deal_user_name
id,uid, order_code, user_type,pay_type,trade_type,income_outcome,amount,system_amount,trade_status,create_time,deal_uid,deal_status,deal_time,deal_relate_id,deal_user_name
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
... ... @@ -80,12 +78,7 @@
group by trade_type
</select>
<!--
<select id="selectSpendAmountByUid" resultType="java.util.HashMap">
select trade_type as tradeType,sum(amount) as allAmount from trade_bills
where uid = #{uid} and income_outcome = 2 and ( trade_type = 2 or trade_type = 3 ) and (trade_status = 100 or (trade_status != 100 and deal_status !=1 )) group by trade_type
</select>
-->
<update id="updateToOkByPrimaryKey" parameterType="com.yohoufo.dal.order.model.TradeBills" >
update trade_bills
... ... @@ -145,99 +138,16 @@
</update>
<!--
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from trade_bills
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insertSelective" parameterType="com.yohoufo.dal.order.model.TradeBills" >
insert into trade_bills
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="uid != null" >
uid,
</if>
<if test="orderCode != null" >
order_code,
</if>
<if test="userType != null" >
user_type,
</if>
<if test="payType != null" >
pay_type,
</if>
<if test="tradeType != null" >
trade_type,
</if>
<if test="incomeOutcome != null" >
income_outcome,
</if>
<if test="amount != null" >
amount,
</if>
<if test="systemAmount != null" >
system_amount,
</if>
<if test="tradeStatus != null" >
trade_status,
</if>
<if test="createTime != null" >
create_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="uid != null" >
#{uid,jdbcType=INTEGER},
</if>
<if test="orderCode != null" >
#{orderCode,jdbcType=BIGINT},
</if>
<if test="userType != null" >
#{userType,jdbcType=INTEGER},
</if>
<if test="payType != null" >
#{payType,jdbcType=INTEGER},
</if>
<if test="tradeType != null" >
#{tradeType,jdbcType=INTEGER},
</if>
<if test="incomeOutcome != null" >
#{incomeOutcome,jdbcType=INTEGER},
</if>
<if test="amount != null" >
#{amount,jdbcType=DECIMAL},
</if>
<if test="systemAmount != null" >
#{systemAmount,jdbcType=DECIMAL},
</if>
<if test="tradeStatus != null" >
#{tradeStatus,jdbcType=INTEGER},
</if>
<if test="createTime != null" >
#{createTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.order.model.TradeBills" >
update trade_bills
set uid = #{uid,jdbcType=INTEGER},
order_code = #{orderCode,jdbcType=BIGINT},
user_type = #{userType,jdbcType=INTEGER},
pay_type = #{payType,jdbcType=INTEGER},
trade_type = #{tradeType,jdbcType=INTEGER},
income_outcome = #{incomeOutcome,jdbcType=INTEGER},
amount = #{amount,jdbcType=DECIMAL},
system_amount = #{systemAmount,jdbcType=DECIMAL},
trade_status = #{tradeStatus,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
-->
<select id="selectByKeyProps" parameterType="com.yohoufo.dal.order.model.TradeBills" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from trade_bills
where 1=1
<if test="orderCode != null" >
and order_code = #{orderCode,jdbcType=BIGINT}
</if>
<if test="tradeType != null" >
and trade_type = #{tradeType,jdbcType=INTEGER}
</if>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -4,7 +4,9 @@ import com.yohobuy.ufo.model.order.bo.ButtonShowBo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.bo.TimeoutBo;
import com.yohobuy.ufo.model.order.common.*;
import com.yohoufo.dal.order.TradeBillsMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.TradeBills;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.model.dto.BuyerPenaltyCalResult;
... ... @@ -35,13 +37,16 @@ public abstract class AbsOrderViewService {
private OrdersPayService ordersPayService;
@Autowired
private BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler;
BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler;
@Autowired
OrderCodeGenerator orderCodeGenerator;
@Autowired
private OrderTimeoutFactory orderTimeoutFactory;
OrderTimeoutFactory orderTimeoutFactory;
@Autowired
TradeBillsMapper tradeBillsMapper;
abstract Logger getLogger();
... ... @@ -116,6 +121,18 @@ public abstract class AbsOrderViewService {
return confirmTips;
}
double queryBuyerPenaltyAmount(Long orderCode){
TradeBills condition = new TradeBills();
condition.setOrderCode(orderCode);
condition.setTradeType(3);
List<TradeBills> tbs = tradeBillsMapper.selectByKeyProps(condition);
double penaltyAmount = 0D;
if (tbs != null && tbs.size() > 0){
TradeBills ptb = tbs.get(0);
penaltyAmount = ptb.getAmount() == null ? penaltyAmount : ptb.getAmount().doubleValue();
}
return penaltyAmount;
}
String formatDetailDesc(BuyerOrder buyerOrder, String temp){
Object[] formatParms = new Object[1];
... ... @@ -125,8 +142,7 @@ public abstract class AbsOrderViewService {
if (orderStatus == OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.getCode()
|| orderStatus == OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode()) {
BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, OrderStatus.getOrderStatus(orderStatus));
formatParms[0] = bpcr.getPenaltyAmount();
formatParms[0] = queryBuyerPenaltyAmount(buyerOrder.getOrderCode());
detailDesc = MessageFormatter.arrayFormat(temp, formatParms).getMessage();
}
}catch (Exception ex){
... ...
... ... @@ -106,7 +106,8 @@ public class BuyerOrderCancelService {
BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetOrderStatus);
logger.info("in buyer cancel BeforeSellerDeliver, event {} BuyerPenaltyCalResult {}", bsdEvent, bpcr);
//买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
if(bsdEvent.getAmount()==null||bsdEvent.getAmount().compareTo(bpcr.getPenaltyAmount()) < 0){
BigDecimal penaltyAmount;
if(bsdEvent.getAmount()==null||bsdEvent.getAmount().compareTo(penaltyAmount=bpcr.getPenaltyAmount()) < 0){
logger.warn("in buyer cancel BeforeSellerDeliver not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bsdEvent, bpcr);
throw new com.yohoufo.common.exception.UfoServiceException(400,"买家赔偿金低于商品售价,不允许取消");
}
... ... @@ -116,8 +117,8 @@ public class BuyerOrderCancelService {
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime);
if (rows>0) {
boolean noResponsibility = Objects.isNull(bpcr.getPenaltyAmount())
|| BigDecimal.ZERO.compareTo(bpcr.getPenaltyAmount()) == 0;
boolean noResponsibility = Objects.isNull(penaltyAmount)
|| BigDecimal.ZERO.compareTo(penaltyAmount) == 0;
//退还优惠券
refundCouponIfNeed(buyerUid, orderCode);
int skup = bsdEvent.getSkup();
... ... @@ -136,7 +137,7 @@ public class BuyerOrderCancelService {
inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode);
}else {
inBoxFacade.buyerCancelBeforeSellerDeliver(buyerUid, orderCode,
bpcr.getPenaltyAmount().toPlainString(), psog);
penaltyAmount.toPlainString(), psog);
}
//TODO 整个过程异步去执行(考虑退费依赖订单状态)
//(退费)退保证金给卖家
... ... @@ -222,7 +223,8 @@ public class BuyerOrderCancelService {
BuyerPenaltyCalResult bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetOrderStatus);
logger.info("in buyer cancel BeforeDepotReceive, event {} compensate {}", bdrEvent, bpcr);
//买家实付金额(货款+运费)小于赔偿金的额度,不够赔偿的,则不允许取消
if(bdrEvent.getAmount()==null||bdrEvent.getAmount().compareTo(bpcr.getPenaltyAmount()) < 0){
BigDecimal penaltyAmount;
if(bdrEvent.getAmount()==null||bdrEvent.getAmount().compareTo(penaltyAmount=bpcr.getPenaltyAmount()) < 0){
logger.warn("in buyer cancel BeforeDepotReceive not allow cancel cause of buyer amount lower than BuyerCompensateMoney, event {} compensate {}", bdrEvent, bpcr);
throw new com.yohoufo.common.exception.UfoServiceException(400,"买家赔偿金低于商品售价,不允许取消");
}
... ... @@ -231,8 +233,8 @@ public class BuyerOrderCancelService {
int currentTime = DateUtil.getCurrentTimeSecond();
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), targetOrderStatus.getCode(), currentTime);
if (rows>0) {
boolean noResponsibility = Objects.isNull(bpcr.getPenaltyAmount())
|| BigDecimal.ZERO.compareTo(bpcr.getPenaltyAmount()) == 0;
boolean noResponsibility = Objects.isNull(penaltyAmount)
|| BigDecimal.ZERO.compareTo(penaltyAmount) == 0;
//退还优惠券
refundCouponIfNeed(buyerUid, orderCode);
... ... @@ -252,7 +254,7 @@ public class BuyerOrderCancelService {
inBoxFacade.noticeSellerWhenBuyerCancelNoResponsibility(psog, orderCode);
}else {
inBoxFacade.buyerCancelBeforeDepotReceive(buyerUid, orderCode,
bpcr.getPenaltyAmount().toPlainString(), psog);
penaltyAmount.toPlainString(), psog);
}
//整个过程异步去执行(考虑退费依赖订单状态)
//(退费)退保证金给卖家
... ...
... ... @@ -845,11 +845,13 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER;
bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetStatus);
occr = bpcr2occr(bpcr);
occr.setNeedPenalty(true);
break;
case SELLER_SEND_OUT:
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetStatus);
occr = bpcr2occr(bpcr);
occr.setNeedPenalty(true);
break;
}
return occr;
... ...
... ... @@ -19,7 +19,6 @@ import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.constants.ViewType;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.dto.BuyerPenaltyCalResult;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
... ... @@ -27,9 +26,7 @@ import com.yohoufo.order.mq.DelayTime;
import com.yohoufo.order.service.AbsSellerOrderViewService;
import com.yohoufo.order.service.IOrderDetailService;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
import com.yohoufo.order.service.impl.processor.SellerOrderPrepareProcessor;
import com.yohoufo.order.service.proxy.DeliveryMinutesService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
... ... @@ -93,8 +90,8 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
@Autowired
private OrderOverTimeService orderOverTimeService;
@Autowired
private BuyerCancelCompensateComputeHandler buyerCancelCompensateComputeHandler;
private static List<SkupStatus> noNeedShowOrderCode = Arrays.asList(SkupStatus.CAN_NOT_SELL,SkupStatus.CAN_SELL,
SkupStatus.SELF_CANCEL_PAY, SkupStatus.TIMEOUT_CANCEL,
... ... @@ -414,15 +411,17 @@ public class SellerOrderDetailService extends AbsOrderDetailService implements I
return statusDetail;
}
private String formatDetailDesc(BuyerOrder buyerOrder,OrderStatus orderStatus, TabType tabType){
String detailDesc = orderStatus.getDetailDesc(tabType);
if (Objects.nonNull(orderStatus)
&& (OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.equals(orderStatus)
|| OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE.equals(orderStatus))){
BuyerPenaltyCalResult bpcr ;
final OrderStatus targetStatus = orderStatus;
bpcr = buyerCancelCompensateComputeHandler.calBuyerPenaltyCalResult(buyerOrder, targetStatus);
detailDesc = String.format(detailDesc, BigDecimalHelper.halfUp(bpcr.getPenaltyAmount()).doubleValue());
double penaltyAmount = queryBuyerPenaltyAmount(buyerOrder.getOrderCode());
detailDesc = String.format(detailDesc, penaltyAmount);
}
//发货时间需要替换
if(orderStatus.getCode() == OrderStatus.HAS_PAYED.getCode()
... ...
... ... @@ -884,15 +884,20 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}
if (OrderCodeType.BUYER_TYPE.equals(codeType)){
String confirmDesc = getConfirmDesc4BuyerOrder(orderCode);
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
String confirmDesc = getConfirmDesc4BuyerOrder(buyerOrder);
occr.setConfirmDesc(confirmDesc);
//
if (buyerOrder !=null && OrderStatus.HAS_PAYED.getCode() == buyerOrder.getStatus()){
occr.setNeedPenalty(true);
}
}
return occr;
}
private String getConfirmDesc4BuyerOrder(long orderCode){
private String getConfirmDesc4BuyerOrder(BuyerOrder buyerOrder){
String confirmDesc = null;
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder == null){
return "订单不存在";
}
... ...