Authored by sailing-PC\sailing

Merge branch 'dev'

... ... @@ -23,13 +23,13 @@ public interface TradeBillsMapper {
//根据用户uid,获取用户总支出
List<Map<String, Object>> selectSpendAmountByUid(@Param("uid") Integer uid);
int deleteByPrimaryKey(Integer id);
int insertSelective(TradeBills record);
int updateByPrimaryKeySelective(TradeBills record);
int updateByPrimaryKey(TradeBills record);
/**
int deleteByPrimaryKey(Integer id);
int insertSelective(TradeBills record);
int updateByPrimaryKeySelective(TradeBills record);
int updateByPrimaryKey(TradeBills record);
**/
}
... ...
... ... @@ -33,10 +33,20 @@ public class TradeBills {
//yoho收入
private BigDecimal systemAmount;
//0:订单未完结;1:订单完结
//100:成功;200:失败,201:没有支付宝账号;202:金额不合法;299:转账失败
private Integer tradeStatus;
private Integer createTime;
}
//手工打款相关字段
//操作员id
private Integer dealUid;
//打款状态:1 表示成功, 现在只有成功的才记录
private Integer dealStatus;
//打款时间
private Integer dealTime;
//打款关联id
private Integer dealRelateId;
}
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yohoufo.dal.order.TradeBillsMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.TradeBills">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="order_code" jdbcType="BIGINT" property="orderCode" />
<result column="user_type" jdbcType="TINYINT" property="userType" />
<result column="pay_type" jdbcType="TINYINT" property="payType" />
<result column="trade_type" jdbcType="INTEGER" property="tradeType" />
<result column="income_outcome" jdbcType="TINYINT" property="incomeOutcome" />
<result column="amount" jdbcType="DECIMAL" property="amount" />
<result column="system_amount" jdbcType="DECIMAL" property="systemAmount" />
<result column="trade_status" jdbcType="TINYINT" property="tradeStatus" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
</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
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from trade_bills
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectCountGoodsIncomeOrCompensateIncomeByUid" resultType="java.lang.Integer" parameterType="java.lang.Integer" >
select
count(id)
from trade_bills
where uid = #{uid,jdbcType=INTEGER} and ( trade_type = 2 or trade_type = 3 )
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.TradeBills" useGeneratedKeys="true">
insert into trade_bills (uid, order_code, user_type,pay_type,trade_type,
income_outcome,amount,system_amount,trade_status,create_time)
values (#{uid},#{orderCode},#{userType},#{payType},#{tradeType},
#{incomeOutcome},#{amount},#{systemAmount},
#{tradeStatus},#{createTime})
</insert>
<select id="selectGoodsIncomeOrCompensateIncomeTradeBillsWithPageByUid" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from trade_bills
where uid = #{uid,jdbcType=INTEGER} and ( trade_type = 2 or trade_type = 3 )
limit #{start,jdbcType=INTEGER},#{limit,jdbcType=INTEGER}
</select>
<select id="selectIncomeAmountByUid" resultType="java.util.HashMap">
select trade_type as tradeType,sum(amount) as allAmount from trade_bills
where uid = #{uid} and income_outcome = 1 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 group by trade_type
</select>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yohoufo.dal.order.TradeBillsMapper">
<resultMap id="BaseResultMap" type="com.yohoufo.dal.order.model.TradeBills">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="order_code" jdbcType="BIGINT" property="orderCode" />
<result column="user_type" jdbcType="TINYINT" property="userType" />
<result column="pay_type" jdbcType="TINYINT" property="payType" />
<result column="trade_type" jdbcType="INTEGER" property="tradeType" />
<result column="income_outcome" jdbcType="TINYINT" property="incomeOutcome" />
<result column="amount" jdbcType="DECIMAL" property="amount" />
<result column="system_amount" jdbcType="DECIMAL" property="systemAmount" />
<result column="trade_status" jdbcType="TINYINT" property="tradeStatus" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
<result column="deal_uid" jdbcType="INTEGER" property="dealUid" />
<result column="deal_status" jdbcType="TINYINT" property="dealStatus" />
<result column="deal_time" jdbcType="INTEGER" property="dealTime" />
<result column="deal_relate_id" jdbcType="INTEGER" property="dealRelateId" />
</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
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from trade_bills
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectCountGoodsIncomeOrCompensateIncomeByUid" resultType="java.lang.Integer" parameterType="java.lang.Integer" >
select
count(id)
from trade_bills
where uid = #{uid,jdbcType=INTEGER} and ( trade_type = 2 or trade_type = 3 )
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.TradeBills" useGeneratedKeys="true">
insert into trade_bills (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)
values (#{uid},#{orderCode},#{userType},#{payType},#{tradeType},
#{incomeOutcome},#{amount},#{systemAmount},
#{tradeStatus},#{createTime},#{dealUid},#{dealStatus}#{dealTime},#{dealRelateId})
</insert>
<select id="selectGoodsIncomeOrCompensateIncomeTradeBillsWithPageByUid" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from trade_bills
where uid = #{uid,jdbcType=INTEGER} and ( trade_type = 2 or trade_type = 3 )
limit #{start,jdbcType=INTEGER},#{limit,jdbcType=INTEGER}
</select>
<select id="selectIncomeAmountByUid" resultType="java.util.HashMap">
select trade_type as tradeType,sum(amount) as allAmount from trade_bills
where uid = #{uid} and income_outcome = 1 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 group by trade_type
</select>
<!--
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from trade_bills
where id = #{id,jdbcType=INTEGER}
... ... @@ -189,4 +196,6 @@
create_time = #{createTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
-->
</mapper>
\ No newline at end of file
... ...
... ... @@ -28,7 +28,30 @@ public enum ButtonShow {
bo = new ButtonShowBo(name(), code, value);
}
ButtonShow(String code,String value, String confirmTips) {
this.code = code;
this.value = value;
bo = new ButtonShowBo(name(), code, value, confirmTips);
}
public ButtonShowBo getBo() {
return bo;
}
public ButtonShowBo getBo(CancelType cancelType) {
switch (cancelType){
case SELF_BEFORE_PAY:
bo.setConfirmTips("您确定不卖此商品吗?");
break;
case PLAY_SELF:
bo.setConfirmTips("您确定不卖此商品么?取消后保证金将原路退换至您的支付宝账户");
break;
case PLAY_BUYER:
bo.setConfirmTips("您确定不卖此商品么?取消后保证金将作为赔偿金打入买家账户");
break;
}
return bo;
}
}
... ...
... ... @@ -19,7 +19,9 @@ public enum CancelType {
/**
* 买家下单后取消售卖
*/
PLAY_BUYER(SellerOrderStatus.PLAY_SELF),
PLAY_BUYER(SellerOrderStatus.PLAY_BUYER),
PLAY_SELF(SellerOrderStatus.PLAY_SELF),
/**
* yoho下架
*/
... ...
... ... @@ -38,7 +38,7 @@ public enum OrderStatus {
"待发货",
Arrays.asList(ButtonShow.NOT_SOLD, ButtonShow.DELIVER_GOODS),
Arrays.asList(ButtonShow.NOT_SOLD, ButtonShow.DELIVER_GOODS),
OrderDetailDesc.Seller.BUYER_HAS_PAID
OrderDetailDesc.Seller.BUYER_HAS_PAID, CancelType.PLAY_BUYER
)
}),
... ... @@ -265,6 +265,7 @@ public enum OrderStatus {
*/
String detailDesc;
public Node(String statusStr,
List<ButtonShow> listButtons,
List<ButtonShow> detailButtons,
... ... @@ -278,5 +279,19 @@ public enum OrderStatus {
};
this.detailDesc = detailDesc;
}
public Node(String statusStr,
List<ButtonShow> listButtons,
List<ButtonShow> detailButtons,
String detailDesc, CancelType cancelType) {
this.statusStr = statusStr;
if (listButtons != null && !listButtons.isEmpty()){
this.listButtons = listButtons.parallelStream().map(buttonShow -> buttonShow.getBo(cancelType)).collect(Collectors.toList());
}
if (detailButtons !=null && !detailButtons.isEmpty()){
this.detailButtons = detailButtons.parallelStream().map(buttonShow -> buttonShow.getBo(cancelType)).collect(Collectors.toList());
};
this.detailDesc = detailDesc;
}
}
}
... ...
... ... @@ -18,8 +18,8 @@ public enum SkupStatus {
*/
CAN_SELL(1, "出售中",
new Node(
Arrays.asList(ButtonShow.NOT_SOLD.getBo(), ButtonShow.SHOW_DETAIL.getBo()),
Arrays.asList(ButtonShow.NOT_SOLD.getBo()),
Arrays.asList(ButtonShow.NOT_SOLD.getBo(CancelType.PLAY_SELF), ButtonShow.SHOW_DETAIL.getBo()),
Arrays.asList(ButtonShow.NOT_SOLD.getBo(CancelType.PLAY_SELF)),
OrderDetailDesc.Seller.PAY_FINISH,
OrderDetailDesc.PaymentTips.AUTO_RETURN_SELLER
)
... ... @@ -29,8 +29,8 @@ public enum SkupStatus {
*/
CAN_NOT_SELL(0,"待付保证金",
new Node(
Arrays.asList(ButtonShow.NOT_SOLD.getBo(), ButtonShow.PAY_EARNESTMONEY.getBo()),
Arrays.asList(ButtonShow.NOT_SOLD.getBo(), ButtonShow.PAY_EARNESTMONEY.getBo()),
Arrays.asList(ButtonShow.NOT_SOLD.getBo(CancelType.SELF_BEFORE_PAY), ButtonShow.PAY_EARNESTMONEY.getBo()),
Arrays.asList(ButtonShow.NOT_SOLD.getBo(CancelType.SELF_BEFORE_PAY), ButtonShow.PAY_EARNESTMONEY.getBo()),
OrderDetailDesc.Seller.WAIT_PAY,
OrderDetailDesc.PaymentTips.AUTO_RETURN_SELLER
)
... ...
... ... @@ -16,5 +16,12 @@ public class ButtonShowBo {
String code;
String text;
String confirmTips;
public ButtonShowBo(String name, String code, String text) {
this.name = name;
this.code = code;
this.text = text;
}
}
... ...
... ... @@ -56,8 +56,8 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
@Autowired
private BuyerOrderMapper buyerOrderMapper;
@Resource( name = "yhProducer")
private YhProducer yhProducer;
@Resource( name = "ufoExpressInfoProducer")
private YhProducer ufoExpressInfoProducer;
@Autowired
private AppraiseAddressService appraiseAddressService;
... ... @@ -74,7 +74,8 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
@Autowired
InBoxFacade inBoxFacade;
private static String EXPRESS_MQ_SEND = "logistics.logistics_data";
//private static String EXPRESS_MQ_SEND = "logistics.logistics_data";
private static String EXPRESS_MQ_SEND = "order.updateChangeRefundOrderExpressInfo";
/**
*
... ... @@ -201,7 +202,7 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
mqInfo.setBusinessType(5);
try{
yhProducer.send(EXPRESS_MQ_SEND, mqInfo);
ufoExpressInfoProducer.send(EXPRESS_MQ_SEND, mqInfo);
LOGGER.info("send express mq success. topic is {}, param is {}", EXPRESS_MQ_SEND, mqInfo);
}catch (Exception e){
LOGGER.warn("send express mq failed. param is {}, exception is {}", mqInfo, e);
... ...
... ... @@ -2,12 +2,13 @@ package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.service.model.response.UserAddressRspBO;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.req.SellerOrderCancelReq;
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.alarm.SmsAlarmEvent;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.common.utils.AddressUtil;
import com.yohoufo.common.utils.DateUtil;
... ... @@ -18,7 +19,6 @@ import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.common.*;
import com.yohoufo.order.convert.AddressInfoConvertor;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.event.ErpCancelSellerOrderEvent;
import com.yohoufo.order.event.EventHandlerContainer;
... ... @@ -176,7 +176,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
//step 2: generate skup ,action :set price status(unsaleable)
if (Objects.isNull(goodsInfo)){
log.warn("in computePublishPrd storageId not exist in prd , uid {}, storageId {}", uid, storageId);
throw new GatewayException(400, "商品不存在");
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
}
context.setSoldProduct(goodsInfo);
checkPrice(storageId, goodsInfo.getPrice(), true);
... ... @@ -191,18 +191,26 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
long orderCode = orderCodeGenerator.generate(OrderCodeType.SELLER_TYPE);
if (orderCode <= 0L){
log.warn("in publishPrd storageId not exist in prd , uid {}, storageId {}", uid, storageId);
throw new GatewayException(501, "保证金订单生成失败");
throw new ServiceException(ServiceError.EARNESTMONEY_ORDER_CREATE_FAIL);
}
context.setOrderCode(orderCode);
//submit all as atomic operation, use transaction of DB
//all include : 1. skup, 2. order , 3. 寄回地址
orderSubmitHandler.submit(context);
try{
orderSubmitHandler.submit(context);
}catch (Exception ex){
String content = "用户"+ uid + "发布商品"+storageId + "失败";
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("sellerOrder.create", "create", content);
EventBusPublisher.publishEvent(smsAlarmEvent);
log.warn("in publishPrd create order fail , uid {}, storageId {}", uid, storageId);
throw new ServiceException(ServiceError.EARNESTMONEY_ORDER_CREATE_FAIL);
}
boolean syncPrdFlag = productProxyService.syncSkup(context.getSellerOrderGoods(), SkupStatus.CAN_NOT_SELL);
log.info("publish finish, syncPrdFlag {}, req {}, orderCode {}", syncPrdFlag, req, orderCode);
//发布支付超时取消消息
pushAutoCancelEvent(context);
//TODO 发消息
// 发消息
OrderSubmitResp resp = OrderSubmitResp.builder().orderCode(orderCode).productId(goodsInfo.getProductId()).build();
return resp;
}
... ... @@ -225,6 +233,12 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
BigDecimal salePrice = context.getSalePrice();
try {
StorageDataResp prdResp = productProxyService.getStorageData(storageId);
if (!Integer.valueOf(1).equals(prdResp.getStatus())) {
log.info("in getProductDetail occur product out shelve, uid {}, storageId {}", uid, storageId);
return null;
}
GoodsInfo goodsInfo = new GoodsInfo();
goodsInfo.setUid(uid);
goodsInfo.setProductId(prdResp.getProductId());
... ...
... ... @@ -26,4 +26,6 @@ public class StorageDataResp {
@JSONField(name = "size")
private GoodsSize size;
@JSONField(name = "status")
private Integer status;
}
... ...
... ... @@ -158,6 +158,7 @@ public class ProductServiceImpl implements ProductService{
if (product != null) {
resp.setProductId(product.getId());
resp.setProductName(product.getProductName());
resp.setStatus(product.getShelveStatus());
}
}
return resp;
... ...
... ... @@ -42,6 +42,10 @@ producer:
producers:
- bean: yhProducer
- address: 192.168.102.45:5672
producers:
- bean: ufoExpressInfoProducer
- address: 192.168.103.58:5672
username: yoho
password: yoho
... ...
... ... @@ -3,10 +3,6 @@ consumer:
username: ${rabbit_order_user}
password: ${rabbit_order_password}
consumers:
#更新物流调拨信息
- class: com.yohoufo.order.mq.consumer.ExpressInfoUpdateConsumer
topic: ufo.order.updateExpressInfo
- class: com.yohoufo.order.mq.consumer.SellerOrderAutoCancelDelayMsgConsumer
topic: sellerOrder.autoCancel
delay:
... ... @@ -38,6 +34,15 @@ consumer:
delay:
interval: 2160
- address: ${rabbit_common}
username: ${rabbit_common_user}
password: ${rabbit_common_password}
consumers:
#更新物流调拨信息
- class: com.yohoufo.order.mq.consumer.ExpressInfoUpdateConsumer
topic: ufo.order.updateExpressInfo
producer:
- address: ${rabbit_order}
username: ${rabbit_order_user}
... ... @@ -51,4 +56,10 @@ producer:
username: ${rabbit_common_user}
password: ${rabbit_common_password}
producers:
- bean: yhProducer
\ No newline at end of file
- bean: yhProducer
- address: ${rabbit_common}
username: ${rabbit_common_user}
password: ${rabbit_common_password}
producers:
- bean: ufoExpressInfoProducer
\ No newline at end of file
... ...