Authored by tanling

Merge branch 'test6.9.10' of http://git.yoho.cn/ufo/yohoufo-fore into test6.9.10

Showing 30 changed files with 545 additions and 137 deletions
... ... @@ -15,6 +15,8 @@ public interface AppraiseOrderGoodsMapper {
List<AppraiseOrderGoods> selectByOrderCode(Long orderCode);
AppraiseOrderGoods selectOneByOrderCode(Long orderCode);
int updateDepotNo(AppraiseOrderGoods record);
int updateByPrimaryKey(AppraiseOrderGoods record);
... ...
... ... @@ -18,18 +18,25 @@ public interface AppraiseOrderMapper {
int updateByPrimaryKey(AppraiseOrder record);
List<AppraiseOrder> selectSubOrderList(long parentOrderCode);
int selectSubOrderCnt(@Param("parentOrderCode") long parentOrderCode);
List<AppraiseOrder> selectSubOrderList(@Param("parentOrderCode") long parentOrderCode,
@Param("offset")int offset,
@Param("limit")int limit);
AppraiseOrder selectByOrderCode(long orderCode);
int selectCntByOrderType(@Param("uid") int uid,
@Param("attributes") int attributes,
@Param("statusList")Collection<Integer> statusList);
@Param("statusList")Collection<Integer> statusList,
@Param("parentOnly") boolean parentOnly
);
List<AppraiseOrder> selectOrderListByOrderType(@Param("uid") int uid,
@Param("attributes") int attributes,
@Param("statusList")Collection<Integer> statusList,
@Param("parentOnly") boolean parentOnly,
@Param("offset")int offset,
@Param("limit")int limit);
... ... @@ -40,7 +47,7 @@ public interface AppraiseOrderMapper {
/**
* 根据订单列表查询信息列表
* @param appraiseOrderList
* @param orderList
* @return
*/
List<AppraiseOrder> selectByOrderCodeList(@Param("orderList")List<Long> orderList);
... ...
... ... @@ -25,4 +25,6 @@ public interface AppraiseOrderStorageMapper {
List<AppraiseOrderStorage> selectAllByOrderCodePrdId(@Param("orderCode")long orderCode,
@Param("productId")int productId);
List<AppraiseOrderStorage> selectByOrderCodes(@Param("orderCodes")Collection<Long> appraiseOrderCodes);
}
\ No newline at end of file
... ...
... ... @@ -22,6 +22,13 @@
where order_code = #{orderCode,jdbcType=BIGINT}
</select>
<select id="selectOneByOrderCode" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from appraise_order_goods
where order_code = #{orderCode,jdbcType=BIGINT} limit 0,1
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.AppraiseOrderGoods" useGeneratedKeys="true">
insert into appraise_order_goods (order_code, product_id, product_name,
product_code, image_url, depot_no,
... ...
... ... @@ -23,11 +23,18 @@
create_time, update_time, is_del, channel_no, attributes, platform_delivery_status
</sql>
<select id="selectSubOrderList" parameterType="java.lang.Long" resultMap="BaseResultMap">
<select id="selectSubOrderList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from appraise_order
where parent_order_code = #{parentOrderCode,jdbcType=INTEGER}
limit #{offset},#{limit}
</select>
<select id="selectSubOrderCnt" parameterType="java.lang.Long" resultType="java.lang.Integer">
select count(*) from appraise_order
where parent_order_code = #{parentOrderCode,jdbcType=INTEGER}
</select>
<select id="selectByOrderCode" parameterType="java.lang.Long" resultMap="BaseResultMap">
... ... @@ -45,6 +52,10 @@
<foreach collection="statusList" item="status" open="(" close=")" separator=",">
#{status,jdbcType=TINYINT}
</foreach>
<if test="parentOnly">
and parent_order_code is null
</if>
</select>
<select id="selectOrderListByOrderType" resultMap="BaseResultMap">
... ... @@ -57,6 +68,9 @@
<foreach collection="statusList" item="status" open="(" close=")" separator=",">
#{status,jdbcType=TINYINT}
</foreach>
<if test="parentOnly">
and parent_order_code is null
</if>
order by id desc limit #{offset},#{limit}
</select>
... ...
... ... @@ -158,4 +158,16 @@
from appraise_order_storage
where order_code = #{orderCode,jdbcType=BIGINT} ORDER BY id desc limit 1
</select>
<select id="selectByOrderCodes" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from appraise_order_storage
where order_code in
<foreach collection="orderCodes" item="orderCode" open="(" close=")" separator=",">
#{orderCode,jdbcType=BIGINT}
</foreach>
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -2,12 +2,14 @@ package com.yohoufo.order.controller;
import com.yoho.core.rest.annotation.ServiceDesc;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.req.BuyerOrderCancelReq;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.order.model.request.SaveQualityCheckInfoRequest;
import com.yohoufo.order.service.impl.AppraiseService;
import com.yohoufo.order.service.support.codegenerator.impl.OrderCodeGeneratorImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -29,6 +31,9 @@ public class AppraiseController {
@Autowired
private AppraiseService appraiseService;
@Autowired
private OrderCodeGeneratorImpl orderCodeGenerator;
/**
* 卖家到平台的物流单号更新,重新触发物流
*/
... ... @@ -207,4 +212,13 @@ public class AppraiseController {
appraiseService.updateDeptNo(appraiseExpressInfoBo);
return new ApiResponse();
}
@RequestMapping(params = "method=ufo.order.isServiceOrder")
@IgnoreSession
@IgnoreSignature
public ApiResponse updateDeptNo(Long orderCode) {
OrderCodeType type = OrderCodeType.getOrderCodeType(orderCodeGenerator.expId(orderCode).getType());
return new ApiResponse(200, "", type == OrderCodeType.GOODS_SERVICE || type == OrderCodeType.STORAGE_MANAGEMENT);
}
}
... ...
... ... @@ -211,9 +211,10 @@ public class SellerDepositOrderController {
.page(page)
.limit(limit).build();
logger.info("in method=ufo.depositOrderInStore.list req {}", req);
PageResp<DepositOrderInStorePrdListResp> resp = sellerDepositOrderService.getDepositOrderListInStore(req);
PageResp<DepositOrderInStorePrdListResp> resp = sellerDepositOrderListService.getDepositOrderListInStore(req);
return new ApiResponse.ApiResponseBuilder()
.code(200)
.data(resp)
.message("寄存订单入库单查询成功")
.build();
}
... ...
package com.yohoufo.order.event;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.function.Function;
@ToString(of = {"uid", "orderCode"})
public class SellerDepositOrderCancelAsyncEvent extends AsyncEvent {
@Getter@Setter
private int uid;
@Getter@Setter
private long orderCode;
public SellerDepositOrderCancelAsyncEvent(Function<SellerDepositOrderCancelAsyncEvent,Boolean> function) {
super(function);
}
@Override
AsyncEvent getAsyncEvent() {
return this;
}
}
... ...
... ... @@ -28,4 +28,6 @@ public interface DelayTime {
int CANCEL_SHAM_DELIVERY_TIME_MINUTE=48*60;
int MINUTES_120_HOURS = 120 * 60;
int SELLER_DEPOSIT_ORDER_PAY_TIME_LIMIT = 10;
}
... ...
... ... @@ -63,4 +63,7 @@ public interface TopicConstants {
*/
String DEPOSIT_FINISH_DELIVERY = "deposit.finishDelivery";
String SELLER_DEPOSIT_ORDER_AUTO_CANCEL = "sellerDepositOrder.autoCancel";
}
... ...
package com.yohoufo.order.mq.consumer;
import com.yohoufo.order.event.OrderCancelEvent;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class SellerDepositOrderAutoCancelMsgConsumer extends AbsOrderAutoCancelDelayMsgConsumer {
@Autowired
private SellerDepositOrderService sellerDepositOrderService;
@Override
public String getTopic() {
return TopicConstants.SELLER_DEPOSIT_ORDER_AUTO_CANCEL;
}
@Override
public void cancel(OrderCancelEvent event) {
sellerDepositOrderService.cancelByTimeout(event);
}
@Override
public void sendAgain(OrderCancelEvent cancelBean) {
producerTemplate.send(getTopic(), cancelBean, null, cancelBean.getPayExpire());
}
}
... ...
... ... @@ -7,6 +7,7 @@ import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.AppraiseOrderMapper;
... ... @@ -14,9 +15,12 @@ import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
import com.yohoufo.dal.order.model.AppraiseOrder;
import com.yohoufo.dal.order.model.AppraiseOrderMeta;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.event.EventHandlerContainer;
import com.yohoufo.order.event.SellerDepositOrderCancelAsyncEvent;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.model.response.PrepayResponse;
import com.yohoufo.order.mq.DelayTime;
import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -35,6 +39,9 @@ public class AppraiseOrderPaymentService extends AbstractOrderPaymentService {
@Autowired
private AppraiseOrderMetaMapper appraiseOrderMetaMapper;
@Autowired
private SellerDepositOrderService sellerDepositOrderService;
@Override
public boolean isTimeoutCancelStatus(OrderInfo orderInfo) {
if (orderInfo.getStatus() != null
... ... @@ -129,7 +136,10 @@ public class AppraiseOrderPaymentService extends AbstractOrderPaymentService {
}
return false;
}
final static List<Integer> canRefundStatusList = Arrays.asList(AppraiseOrderStatus.HAS_PAYED.getCode());
final static List<Integer> canRefundStatusList = Arrays.asList(AppraiseOrderStatus.WAITING_PAY.getCode(),
AppraiseOrderStatus.HAS_PAYED.getCode());
@Override
public boolean canRefund(OrderInfo orderInfo) {
OrderAttributes oa = OrderAttributes.getOrderAttributes(orderInfo.getAttributes());
... ... @@ -158,5 +168,18 @@ public class AppraiseOrderPaymentService extends AbstractOrderPaymentService {
@Override
public void processAfterPay(OrderInfo orderInfo) {
OrderAttributes oa = OrderAttributes.getOrderAttributes(orderInfo.getAttributes());
switch (oa){
case APPRAISE:
break;
case DEPOSITE:
SellerDepositOrderCancelAsyncEvent event = new SellerDepositOrderCancelAsyncEvent(sellerDepositOrderService::handleOrderCancelAsyncEvent);
event.setUid(orderInfo.getUid());
event.setOrderCode(orderInfo.getOrderCode());
EventBusPublisher.publishEvent(event);
logger.info("processAfterPay seller deposit order , SellerDepositOrderCancelAsyncEvent send out");
break;
}
}
}
... ...
... ... @@ -77,7 +77,7 @@ public class GoodsServiceRefundHandler extends AbsRefundOrderHandler {
.refundAmount(this.refundEarnestMoney.doubleValue())
.refundattch(moai).build();
BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
this.bleb = BillLogEvent.builder()
.buyerUid(uid).sellerUid(uid).orderCode(orderCode)
.payType(payment).refundCase(RefundCase.SELLER_EARNEST_MONEY)
;
... ...
... ... @@ -141,7 +141,7 @@ public abstract class AbsGoodsServiceOrderService implements IGoodsService {
@Override
public int findFlaw(AppraiseOrder appraiseOrder){
long orderCode = appraiseOrder.getOrderCode();
AppraiseOrderStatus targetStatus = AppraiseOrderStatus.FLAW,
AppraiseOrderStatus targetStatus = AppraiseOrderStatus.QUALITY_CHECK_FAKE,
expectedStatus = AppraiseOrderStatus.PLATFORM_RECEIVE;
int rows = triggerStatusChange(orderCode, targetStatus, expectedStatus);
... ...
... ... @@ -229,8 +229,9 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
PageResp.PageRespBuilder respBuilder = PageResp.builder();
int uid = req.getUid();
OrderAttributes orderAttributes = getOrderAttributes();
final boolean showParentOnly = true;
final List<Integer> statusList = getLegalStatus();
int total = appraiseOrderMapper.selectCntByOrderType(uid, orderAttributes.getCode(), statusList);
int total = appraiseOrderMapper.selectCntByOrderType(uid, orderAttributes.getCode(), statusList, showParentOnly);
int limit = req.getLimit();
if (total == 0){
return respBuilder
... ... @@ -242,7 +243,7 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
int offset = (req.getPage() - 1) * limit;
List<AppraiseOrder> orderList = appraiseOrderMapper.selectOrderListByOrderType(uid, orderAttributes.getCode(), statusList, offset, limit);
List<AppraiseOrder> orderList = appraiseOrderMapper.selectOrderListByOrderType(uid, orderAttributes.getCode(), statusList, showParentOnly, offset, limit);
List<Long> orderCodes = orderList.stream().map(AppraiseOrder::getOrderCode).collect(Collectors.toList());
List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectByOrderCodes(orderCodes);
... ...
... ... @@ -15,6 +15,7 @@ import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.resp.SellerDepositOrderDetailResp;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohobuy.ufo.model.order.vo.ProductVo;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
import com.yohoufo.dal.order.AppraiseOrderMapper;
... ... @@ -121,7 +122,7 @@ public class SellerDepositOrderDetailService extends AbsOrderViewService {
return SellerDepositOrderDetailResp.builder()
.orderCode(orderCode)
.uid(uid)
.earnestMoney(SellerOrderConvertor.formatFee(pao.getAmount()))
.earnestMoney(BigDecimalHelper.halfUp(pao.getAmount()).toPlainString())
.createTime(DateUtil.formatDate(pao.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS))
.timeout(timeout)
.statusDetail(statusDetail)
... ...
... ... @@ -6,6 +6,7 @@ import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.constants.SellerDepositOrderListType;
import com.yohobuy.ufo.model.order.req.SellerDepositOrderListReq;
import com.yohobuy.ufo.model.order.req.SellerDepositOrderPrdListReq;
import com.yohobuy.ufo.model.order.resp.DepositOrderInStorePrdListResp;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.resp.SellerDepositOrderListResp;
import com.yohobuy.ufo.model.order.vo.GoodsVo;
... ... @@ -58,11 +59,11 @@ public class SellerDepositOrderListService {
if (Objects.isNull(sellerDepositOrderListType)){
return respBuilder.build();
}
final boolean showParentOnly = true;
int uid = req.getUid();
OrderAttributes orderAttributes = getOrderAttributes();
final List<Integer> statusList = sellerDepositOrderListType.statusList();
int total = appraiseOrderMapper.selectCntByOrderType(uid, orderAttributes.getCode(), statusList);
int total = appraiseOrderMapper.selectCntByOrderType(uid, orderAttributes.getCode(), statusList, showParentOnly);
int limit = req.getLimit();
if (total == 0){
return respBuilder
... ... @@ -74,7 +75,7 @@ public class SellerDepositOrderListService {
int offset = (req.getPage() - 1) * limit;
List<AppraiseOrder> orderList = appraiseOrderMapper.selectOrderListByOrderType(uid, orderAttributes.getCode(), statusList, offset, limit);
List<AppraiseOrder> orderList = appraiseOrderMapper.selectOrderListByOrderType(uid, orderAttributes.getCode(), statusList, showParentOnly, offset, limit);
List<Long> orderCodes = orderList.stream().map(AppraiseOrder::getOrderCode).collect(Collectors.toList());
List<AppraiseOrderGoods> paogs = appraiseOrderGoodsMapper.selectByOrderCodes(orderCodes);
... ... @@ -127,6 +128,61 @@ public class SellerDepositOrderListService {
.productList(productList)
.build();
}
public PageResp<DepositOrderInStorePrdListResp> getDepositOrderListInStore(SellerDepositOrderPrdListReq req){
Long orderCode = req.getOrderCode();
int total = appraiseOrderMapper.selectSubOrderCnt(orderCode);
int limit = req.getLimit();
PageResp.PageRespBuilder<DepositOrderInStorePrdListResp> respBuilder = PageResp.builder();
respBuilder.page(req.getPage()).pageSize(limit).total(total);
if (total == 0){
return respBuilder.build();
}
int offset = (req.getPage() - 1) * limit;
List<AppraiseOrder> paoList = appraiseOrderMapper.selectSubOrderList(orderCode, offset, limit);
List<Long> orderCodes = paoList.parallelStream().map(AppraiseOrder::getOrderCode).collect(Collectors.toList());
//
List<AppraiseOrderGoods> paogList = appraiseOrderGoodsMapper.selectByOrderCodes(orderCodes);
Map<Long, AppraiseOrderGoods> orderCodeAppraiseOrderGoodsMap = paogList.parallelStream()
.collect(Collectors.toMap(AppraiseOrderGoods::getOrderCode,Function.identity()));
//
List<AppraiseOrderStorage> paosList = appraiseOrderStorageMapper.selectByOrderCodes(orderCodes);
Map<Long,AppraiseOrderStorage> orderCodeAppraiseOrderStorageMap = paosList.parallelStream()
.collect(Collectors.toMap(AppraiseOrderStorage::getOrderCode, Function.identity()));
List<DepositOrderInStorePrdListResp> dataList = paoList.parallelStream()
.map(pao->buildDepositOrderInStorePrdListResp(pao, orderCodeAppraiseOrderGoodsMap.get(pao.getOrderCode()),
orderCodeAppraiseOrderStorageMap.get(pao.getOrderCode())))
.collect(Collectors.toList());
respBuilder.data(dataList);
return respBuilder.build();
}
DepositOrderInStorePrdListResp buildDepositOrderInStorePrdListResp(AppraiseOrder pao,
AppraiseOrderGoods paog,
AppraiseOrderStorage paos){
AppraiseOrderStatus appraiseOrderStatus = AppraiseOrderStatus.getByCode(pao.getStatus());
OrderAttributes oa = OrderAttributes.getOrderAttributes(pao.getAttributes());
String refundEarnestMoney = null;
GoodsVo goods = GoodsVo.builder()
.productName(paog.getProductName())
.imgUrl(ImageUrlAssist.getAllProductPicUrl(paog.getImageUrl(), "goodsimg", "center", "d2hpdGU="))
.sizeName(paos.getSizeName())
.build();
DepositOrderInStorePrdListResp resp = DepositOrderInStorePrdListResp.builder()
.earnestMoney(BigDecimalHelper.halfUp(pao.getAmount()).toPlainString())
.refundEarnestMoney(refundEarnestMoney)
.goods(goods)
.orderCode(pao.getOrderCode())
.status(pao.getStatus())
.statuStr(appraiseOrderStatus.statusStr(oa))
.build();
return resp;
}
OrderAttributes getOrderAttributes(){
return OrderAttributes.DEPOSITE;
}
... ...
... ... @@ -6,14 +6,14 @@ import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohobuy.ufo.model.order.req.*;
import com.yohobuy.ufo.model.order.resp.DepositOrderInStorePrdListResp;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.resp.SellerDepositOrderComputeResp;
import com.yohobuy.ufo.model.order.resp.SellerDepositOrderSubmitResp;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohobuy.ufo.model.order.vo.GoodsVo;
import com.yohobuy.ufo.model.order.vo.ProductVo;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.AddressUtil;
import com.yohoufo.common.utils.BigDecimalHelper;
... ... @@ -25,14 +25,23 @@ import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.ClientType;
import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.event.OrderCancelEvent;
import com.yohoufo.order.event.PayConfirmEvent;
import com.yohoufo.order.event.SellerDepositOrderCancelAsyncEvent;
import com.yohoufo.order.model.PayQueryBo;
import com.yohoufo.order.model.dto.PlatformFeeDto;
import com.yohoufo.order.model.dto.SellerDepositOrderContext;
import com.yohoufo.order.model.dto.SellerDepositSubOrderContext;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.mq.DelayTime;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.mq.producer.TradeMqSender;
import com.yohoufo.order.service.DepositService;
import com.yohoufo.order.service.IGoodsService;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.handler.GoodsServiceRefundHandler;
import com.yohoufo.order.service.impl.*;
import com.yohoufo.order.service.pay.AbstractPayService;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
... ... @@ -91,6 +100,12 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
@Autowired
private PayRefundService payRefundService;
@Autowired
private ServiceOrderProcessor serviceOrderProcessor;
@Autowired
IPaymentService paymentService;
public SellerDepositOrderComputeResp compute(SellerDepositOrderComputeReq req){
... ... @@ -168,17 +183,10 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
public PageResp<DepositOrderInStorePrdListResp> getDepositOrderListInStore(SellerDepositOrderPrdListReq req){
return null;
}
@Autowired
private ServiceOrderProcessor serviceOrderProcessor;
public void cancel(SellerDepositOrderDetailReq req){
//TODO
long orderCode = req.getOrderCode();
if(serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
if(!serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
logger.warn("cancel AppraiseOrder not GoodsServiceOrder, orderCode {}", orderCode);
throw new UfoServiceException(400, "订单已迷路");
}
... ... @@ -219,6 +227,51 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
}
public int cancelByTimeout(OrderCancelEvent orderCancelEvent){
Long orderCode = orderCancelEvent.getOrderCode();
int uid = orderCancelEvent.getUid();
if(!serviceOrderProcessor.isGoodsServiceOrder(orderCode)){
logger.warn("auto cancel AppraiseOrder not GoodsServiceOrder, orderCode {}", orderCode);
throw new UfoServiceException(400, "订单已迷路");
}
ServiceOrderProcessor.ExistenceNode existenceNode = serviceOrderProcessor.isAppraiseOrder(orderCode);
if (!existenceNode.isExisted()){
logger.warn("auto cancel AppraiseOrder not exist, orderCode {}", orderCode);
throw new UfoServiceException(400, "订单已迷路");
}
AppraiseOrder pao = existenceNode.getAppraiseOrder();
OrderAttributes oa = OrderAttributes.getOrderAttributes(pao.getAttributes());
if (!OrderAttributes.DEPOSITE.equals(oa)){
logger.warn("auto cancel AppraiseOrder not deposit Order, orderCode {}", orderCode);
throw new UfoServiceException(400, "订单已迷路");
}
AppraiseOrderStatus appraiseOrderStatus = AppraiseOrderStatus.getByCode(pao.getStatus());
int rows = 0;
switch (appraiseOrderStatus){
case WAITING_PAY:
Payment payment = Payment.getPayment(pao.getPayment());
AbstractPayService payService = paymentService.getPayService(payment.getCode());
PayQueryBo payQueryBo = payService.payQuery(String.valueOf(orderCode), pao.getCreateTime());
if (payQueryBo != null && payQueryBo.isPayStatus()){
logger.info("seller deposit order auto cancel failed, confirm paid. uid is {}, orderCode is {}", uid, orderCode);
PayConfirmEvent event = new PayConfirmEvent(uid, orderCode, pao.getPayment());
EventBusPublisher.publishEvent(event);
}
// 如果近1分钟有预支付记录,则发送 自动取消延迟消息
if ( !orderCancelEvent.isFinalRetry()){
paymentService.checkPrePay(uid, orderCode);
}
rows = super.triggerStatusChange(orderCode, AppraiseOrderStatus.CANCEL_TIMEOUT, appraiseOrderStatus);
break;
default:
throw new UfoServiceException(400, "订单不支持取消");
}
return rows;
}
@Override
... ... @@ -491,5 +544,18 @@ public class SellerDepositOrderService extends AbsGoodsServiceOrderService imple
return rows;
}
@Autowired
private TradeMqSender tradeMqSender;
public boolean handleOrderCancelAsyncEvent(SellerDepositOrderCancelAsyncEvent event) {
logger.info("Subscribe Buyer timeout cancel delay msg, event {}", event);
OrderCancelEvent orderCancelEvent = OrderCancelEvent.builder()
.uid(event.getUid())
.orderCode(event.getOrderCode())
.payExpire(DelayTime.SELLER_DEPOSIT_ORDER_PAY_TIME_LIMIT)
.build();
tradeMqSender.send(TopicConstants.SELLER_DEPOSIT_ORDER_AUTO_CANCEL, orderCancelEvent, DelayTime.SELLER_DEPOSIT_ORDER_PAY_TIME_LIMIT);
return true;
}
}
... ...
... ... @@ -19,6 +19,7 @@ import java.util.List;
public class SellerOrderStatsConfiguration implements StatsConfiguration {
public static SellerOrderStatsConfiguration emptyConfiguration = SellerOrderStatsConfiguration.builder()
.statsCode("OrderQuantityStats")
.excludeUids(Lists.newArrayList())
.statsUnit(StatsUnit.MONTH)
.skupTypes(Lists.newArrayList())
... ...
... ... @@ -50,7 +50,7 @@ public class SellerPlatformServiceFeeSupport {
SellerOrderStatsConfiguration currentStatsConfig = statsConfigurationManager.getStatsConfig(currentStatsEntry);
SellerOrderStatsResult statsResult = (SellerOrderStatsResult) statsConfigurationManager.getStatsProcessor(currentStatsConfig.getStatsProcessorName()).getResult(currentStatsEntry, currentStatsConfig);
if (Objects.isNull(statsResult)) {
statsResult = createEmptyStatsResult(uid);
statsResult = createEmptyStatsResult(uid, currentStatsConfig.getStatsCode());
}
return this.buildSellerPlatformServiceFee(uid, statsResult);
}
... ... @@ -70,7 +70,7 @@ public class SellerPlatformServiceFeeSupport {
nextStatsEntry.setTime(nextStatsConfig.getStatsUnit().nextPeriodTimeTuple(nextStatsConfig.getStatsPeriod(), nextStatsConfig.getStatsPeriod()).getKey());
SellerOrderStatsResult statsResult = (SellerOrderStatsResult) statsConfigurationManager.getStatsProcessor(nextStatsConfig.getStatsProcessorName()).getResult(nextStatsEntry, nextStatsConfig);
if (Objects.isNull(statsResult)) {
statsResult = createEmptyStatsResult(uid);
statsResult = createEmptyStatsResult(uid, nextStatsConfig.getStatsCode());
}
return this.buildSellerPlatformServiceFee(uid, statsResult);
}
... ... @@ -106,8 +106,9 @@ public class SellerPlatformServiceFeeSupport {
return new SellerPlatformServiceFee(statsResult.getQuantity(), platformServiceFeeDefinition);
}
private SellerOrderStatsResult createEmptyStatsResult(int uid) {
private SellerOrderStatsResult createEmptyStatsResult(int uid, String statsCode) {
SellerOrderStatsResult statsResult = new SellerOrderStatsResult();
statsResult.setStatsCode(statsCode);
statsResult.setUid(uid);
statsResult.setQuantity(0);
statsResult.setEnterType(-1);
... ...
... ... @@ -15,7 +15,7 @@ public class CodeTest {
// System.out.print(result);
// System.out.println(" 反解结果: "+ orderCodeGenerator.expId(result));
// }
Long ordercode = 19952220626966L;
Long ordercode = 36378182115151L;
CodeMeta meta = orderCodeGenerator.expId(ordercode);
System.out.println(meta);
... ...
package com.yohoufo.order.service.seller;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.resp.SellerPlatformServiceFeeResp;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.SellerOrderStatsResult;
import com.yohoufo.order.BaseWebTest;
import com.yohoufo.order.common.EnterQuitEnum;
import com.yohoufo.order.event.SellerEnterTypeChangeEvent;
import com.yohoufo.order.model.bo.PlatformServiceFeeDefinition;
import com.yohoufo.order.model.bo.SellerServiceFeeRuleDefinition;
import com.yohoufo.order.service.cache.SellerServiceFeeRuleCacheService;
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
import com.yohoufo.order.service.listener.OrderChangeListenerContainer;
import com.yohoufo.order.service.seller.setting.SellerService;
import com.yohoufo.order.service.stats.StatsConfigManager;
import com.yohoufo.order.service.stats.impl.EmptyStatsProcessor;
import com.yohoufo.order.service.stats.impl.SellerOrderStatsConfiguration;
import com.yohoufo.order.service.stats.impl.SellerOrderStatsEntry;
import com.yohoufo.order.service.support.SellerPlatformServiceFeeSupport;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class SellerEnterTypeChangeEventTest extends BaseWebTest {
@Autowired
private OrderChangeListenerContainer orderChangeListenerContainer;
@Autowired
private SellerService sellerService;
@Autowired
@InjectMocks
private SellerPlatformServiceFeeSupport sellerPlatformServiceFeeSupport;
@Mock
private SellerServiceFeeRuleCacheService sellerServiceFeeRuleCacheService;
@Mock
private StatsConfigManager<SellerOrderStatsEntry, SellerOrderStatsConfiguration> statsConfigurationManager;
@Mock
private SellerService sellerService;
@Before
public void setup() throws IOException {
MockitoAnnotations.initMocks(this);
}
@Test
public void test_stats_event() {
public void test_stats_event() throws Exception{
BuyerOrder buyerOrder = new BuyerOrder();
buyerOrder.setUid(500031424);
buyerOrder.setOrderCode(9939757498185L);
buyerOrder.setSellerUid(500031424);
orderChangeListenerContainer.fireAsyncEvent(new BuyerOrderChangeEvent(buyerOrder, BuyerOrderChangeEvent.BizCase.APPRAISE_SUCCESS, OrderStatus.DONE));
TimeUnit.SECONDS.sleep(10);
}
@Test
public void test_enter_event() {
public void test_enter_event() throws Exception{
EventBusPublisher.publishEvent(SellerEnterTypeChangeEvent.builder().sellerUid(500031116).eventType(EnterQuitEnum.ENTER).build());
TimeUnit.SECONDS.sleep(10);
}
@Test
public void test_quit_event() {
EventBusPublisher.publishEvent(SellerEnterTypeChangeEvent.builder().sellerUid(500031424).eventType(EnterQuitEnum.QUIT).build());
public void test_quit_event() throws Exception{
EventBusPublisher.publishEvent(SellerEnterTypeChangeEvent.builder().sellerUid(500031116).eventType(EnterQuitEnum.QUIT).build());
TimeUnit.SECONDS.sleep(10);
}
@Test
public void platformServiceFeeDetail() {
SellerPlatformServiceFeeResp sellerPlatformServiceFeeResp = sellerService.platformServiceFeeDetail(500031424);
System.out.println(sellerPlatformServiceFeeResp);
Assert.assertNotNull(sellerPlatformServiceFeeResp);
Assert.assertEquals(sellerPlatformServiceFeeResp.getCurrentRate(), "5.0%");
public void getPlatformServiceFeeRate_when_superEnterType_and_first_level_rule() {
List<SellerServiceFeeRuleDefinition> rules = new ArrayList<>();
//{"rules":[{"threshold":0,"rate":0.045},{"threshold":10,"rate":0.044},{"threshold":20,"rate":0.04},{"threshold":50,"rate":0.039},{"threshold":100,"rate":0.035},{"threshold":200,"rate":0.033}]}
rules.add(SellerServiceFeeRuleDefinition.builder()
.statsCode("OrderQuantityStats")
.enterType(EntrySellerType.SUPER_ENTRY.getCode())
.serviceFeeDefinition(PlatformServiceFeeDefinition.convert("{\"rules\":[{\"threshold\":0,\"rate\":0.045},{\"threshold\":10,\"rate\":0.044},{\"threshold\":20,\"rate\":0.04},{\"threshold\":50,\"rate\":0.039},{\"threshold\":100,\"rate\":0.035},{\"threshold\":200,\"rate\":0.033}]}")).build());
Mockito.when(sellerServiceFeeRuleCacheService.getRuleDefinitions()).thenReturn(rules);
Mockito.when(statsConfigurationManager.getStatsConfig(Mockito.any(SellerOrderStatsEntry.class))).thenReturn(SellerOrderStatsConfiguration.emptyConfiguration);
Mockito.when(statsConfigurationManager.getStatsProcessor(SellerOrderStatsConfiguration.emptyConfiguration.getStatsProcessorName())).thenReturn(new EmptyStatsProcessor());
Mockito.when(sellerService.getEntrySellerType(500031424)).thenReturn(EntrySellerType.SUPER_ENTRY);
BigDecimal feeRate = sellerPlatformServiceFeeSupport.getPlatformServiceFeeRate(500031424, SkupType.IN_STOCK);
Assert.assertTrue(feeRate != null);
Assert.assertEquals(feeRate.toPlainString(), "0.045");
}
@Test
public void getPlatformServiceFeeRate() {
public void getPlatformServiceFeeRate_when_superEnterType_and_second_level_rule() {
List<SellerServiceFeeRuleDefinition> rules = new ArrayList<>();
//{"rules":[{"threshold":0,"rate":0.045},{"threshold":10,"rate":0.044},{"threshold":20,"rate":0.04},{"threshold":50,"rate":0.039},{"threshold":100,"rate":0.035},{"threshold":200,"rate":0.033}]}
rules.add(SellerServiceFeeRuleDefinition.builder()
.statsCode("OrderQuantityStats")
.enterType(EntrySellerType.SUPER_ENTRY.getCode())
.serviceFeeDefinition(PlatformServiceFeeDefinition.convert("{\"rules\":[{\"threshold\":0,\"rate\":0.045},{\"threshold\":10,\"rate\":0.044},{\"threshold\":20,\"rate\":0.04},{\"threshold\":50,\"rate\":0.039},{\"threshold\":100,\"rate\":0.035},{\"threshold\":200,\"rate\":0.033}]}")).build());
Mockito.when(sellerServiceFeeRuleCacheService.getRuleDefinitions()).thenReturn(rules);
Mockito.when(statsConfigurationManager.getStatsConfig(Mockito.any(SellerOrderStatsEntry.class))).thenReturn(SellerOrderStatsConfiguration.emptyConfiguration);
Mockito.when(statsConfigurationManager.getStatsProcessor(SellerOrderStatsConfiguration.emptyConfiguration.getStatsProcessorName())).thenReturn(new EmptyStatsProcessor() {
@Override
public SellerOrderStatsResult getResult(SellerOrderStatsEntry entry, SellerOrderStatsConfiguration configuration) {
SellerOrderStatsResult statsResult = new SellerOrderStatsResult();
statsResult.setStatsCode(configuration.getStatsCode());
statsResult.setUid(entry.getSellerUid());
statsResult.setEnterType(-1);
statsResult.setQuantity(11);
return statsResult;
}
});
Mockito.when(sellerService.getEntrySellerType(500031424)).thenReturn(EntrySellerType.SUPER_ENTRY);
BigDecimal feeRate = sellerPlatformServiceFeeSupport.getPlatformServiceFeeRate(500031424, SkupType.IN_STOCK);
Assert.assertEquals(feeRate.toPlainString(),"0.049");
Assert.assertTrue(feeRate != null);
Assert.assertEquals(feeRate.toPlainString(), "0.044");
}
@Test
public void getPlatformServiceFeeRate_withoutRules() {
Mockito.when(sellerServiceFeeRuleCacheService.getRuleDefinitions()).thenReturn(Lists.newArrayList());
Mockito.when(statsConfigurationManager.getStatsConfig(Mockito.any(SellerOrderStatsEntry.class))).thenReturn(SellerOrderStatsConfiguration.emptyConfiguration);
Mockito.when(statsConfigurationManager.getStatsProcessor(SellerOrderStatsConfiguration.emptyConfiguration.getStatsProcessorName())).thenReturn(new EmptyStatsProcessor());
Mockito.when(sellerService.getEntrySellerType(500031424)).thenReturn(EntrySellerType.SUPER_ENTRY);
BigDecimal feeRate = sellerPlatformServiceFeeSupport.getPlatformServiceFeeRate(500031424, SkupType.IN_STOCK);
Assert.assertEquals(feeRate,null);
Assert.assertTrue(feeRate == null);
}
}
... ...
package com.yohoufo.product.service;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.rest.client.hystrix.AsyncFuture;
import com.yoho.service.model.response.ProfileInfoRsp;
import com.yoho.service.model.social.response.UserInfoRspBO;
import com.yoho.service.model.uic.UicResponse;
import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.common.utils.MobileHelper;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
... ... @@ -63,6 +67,9 @@ public class MessageFacade {
@Autowired
private ProductMapper productMapper;
@Autowired
private ProductIdentifyService productIdentifyService;
/**
* 申请物权转移后
*/
... ... @@ -81,15 +88,10 @@ public class MessageFacade {
String applicantName = MobileHelper.coverMobile2(profileMap.get(Integer.parseInt(applicantUid)).getMobile());
//商品信息
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
Integer skup = buyerOrderGoods.getSkup();
//skup获取 productInfo
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
String prdName = sellerOrderGoods.getProductName();
String sizeName = sellerOrderGoods.getSizeName();
Product product = productMapper.selectByPrimaryKey(sellerOrderGoods.getProductId());
String productCode = product.getProductCode();
Map<String, Object> infoMap = productIdentifyService.getProductInfo(orderCode);
String prdName = (String) infoMap.get("productName");
String sizeName = (String) infoMap.get("size");
String productCode = (String) infoMap.get("productCode");
String params = buildParams(applicantName, prdName, sizeName,productCode);
InboxReqVO req = buildInboxReqVO(Integer.parseInt(ownerUid), params, ibtOfBuyer);
... ... @@ -144,16 +146,10 @@ public class MessageFacade {
Map<Integer, ProfileInfoRsp> profileMap = userInfoProxyService.queryIcoAndMobile(uidList);
String applicantMobile = profileMap.get(Integer.parseInt(applicantUid)).getMobile();
//商品信息
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
Integer skup = buyerOrderGoods.getSkup();
//skup获取 productInfo
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
String prdName = sellerOrderGoods.getProductName();
String sizeName = sellerOrderGoods.getSizeName();
Product product = productMapper.selectByPrimaryKey(sellerOrderGoods.getProductId());
String productCode = product.getProductCode();
Map<String, Object> infoMap = productIdentifyService.getProductInfo(orderCode);
String prdName = (String) infoMap.get("productName");
String sizeName = (String) infoMap.get("size");
String productCode = (String) infoMap.get("productCode");
String params = buildParams(prdName, sizeName,productCode);
InboxReqVO req = buildInboxReqVO(Integer.parseInt(applicantUid), params, ibtOfBuyer);
... ... @@ -189,16 +185,10 @@ public class MessageFacade {
Map<Integer, ProfileInfoRsp> profileMap = userInfoProxyService.queryIcoAndMobile(uidList);
String applicantMobile = profileMap.get(Integer.parseInt(applicantUid)).getMobile();
//商品信息
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
Integer skup = buyerOrderGoods.getSkup();
//skup获取 productInfo
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
String prdName = sellerOrderGoods.getProductName();
String sizeName = sellerOrderGoods.getSizeName();
Product product = productMapper.selectByPrimaryKey(sellerOrderGoods.getProductId());
String productCode = product.getProductCode();
Map<String, Object> infoMap = productIdentifyService.getProductInfo(orderCode);
String prdName = (String) infoMap.get("productName");
String sizeName = (String) infoMap.get("size");
String productCode = (String) infoMap.get("productCode");
String params = buildParams(prdName, sizeName,productCode);
InboxReqVO req = buildInboxReqVO(Integer.parseInt(applicantUid), params, ibtOfBuyer);
... ... @@ -233,17 +223,11 @@ public class MessageFacade {
List<String> uidList = Lists.newArrayList(applicantUid);
Map<Integer, ProfileInfoRsp> profileMap = userInfoProxyService.queryIcoAndMobile(uidList);
String applicantMobile = profileMap.get(Integer.parseInt(applicantUid)).getMobile();
//商品信息
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
Integer skup = buyerOrderGoods.getSkup();
//skup获取 productInfo
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
String prdName = sellerOrderGoods.getProductName();
String sizeName = sellerOrderGoods.getSizeName();
Product product = productMapper.selectByPrimaryKey(sellerOrderGoods.getProductId());
String productCode = product.getProductCode();
Map<String, Object> infoMap = productIdentifyService.getProductInfo(orderCode);
String prdName = (String) infoMap.get("productName");
String sizeName = (String) infoMap.get("size");
String productCode = (String) infoMap.get("productCode");
String params = buildParams(prdName, sizeName,productCode);
InboxReqVO req = buildInboxReqVO(Integer.parseInt(applicantUid), params, ibtOfBuyer);
... ...
... ... @@ -7,6 +7,8 @@ import com.yohoufo.dal.product.model.IdentifyRecord;
import com.yohoufo.product.response.IdentifyShareInfoResp;
import com.yohoufo.product.response.ProductIdentifyResp;
import java.util.Map;
public interface ProductIdentifyService {
ProductIdentifyResp queryIdentifyInfo(String tagId, String nfcUid) throws GatewayException;
... ... @@ -24,4 +26,6 @@ public interface ProductIdentifyService {
ProductIdentifyResp queryIdentifyInfoForPlatform(String tagId, String nfcUid) throws GatewayException;
void autoTransfer(Long orderCode, Integer toUid, Long buyerOrderCode); // 自动转移物权所属
Map<String, Object> getProductInfo(Long orderCode);
}
... ...
... ... @@ -7,8 +7,15 @@ import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.sun.org.apache.xpath.internal.operations.Bool;
import com.yoho.tools.common.beans.ApiResponse;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.constant.OrderConfigConstant;
import com.yohoufo.common.utils.QiniuLiveUrlUtil;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
... ... @@ -41,18 +48,6 @@ import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.common.redis.NoSyncGracefulRedisTemplate;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.common.utils.MobileHelper;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.OrderOperateRecordMapper;
import com.yohoufo.dal.order.OrdersPayMapper;
import com.yohoufo.dal.order.QiniuLiveRecordMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.OrderOperateRecord;
import com.yohoufo.dal.order.model.OrdersPay;
import com.yohoufo.dal.order.model.QiniuLiveRecord;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.dal.product.IdentifyRecordsMapper;
import com.yohoufo.dal.product.IdentifyRelationMapper;
import com.yohoufo.dal.product.ProductChainMapper;
... ... @@ -128,6 +123,13 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
@Autowired
private UserInfoProxyService userInfoProxyService;
@Autowired
private AppraiseOrderMapper appraiseOrderMapper;
@Autowired
private AppraiseOrderGoodsMapper appraiseOrderGoodsMapper;
@Autowired
private AppraiseOrderStorageMapper appraiseOrderStorageMapper;
@Autowired
private ProductMapper productMapper;
... ... @@ -151,6 +153,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
private String syncBlockChain_url;
@Autowired
UfoServiceCaller ufoServiceCaller;
@Autowired
OrderConfigConstant orderConfigConstant;
private static final String UIC_PROFILE_URL = "/profile/getProfile";
... ... @@ -207,14 +212,13 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
}
//根据鉴定记录 获取订单号
Long orderCode = identifyRecord.getOrderCode();
//2)订单号 获取订单详细信息
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if(buyerOrder == null){
Map<String, Object> infoMap = getProductInfo(orderCode);
Integer orderStatus = (Integer) (infoMap.get("status"));//5--订单已经完成
if(orderStatus == null){
throw new GatewayException(403, "订单不存在");
}
Integer buyerUid = buyerOrder.getUid();//买家
Integer buyerUid = (Integer) (infoMap.get("uid"));
// Integer sellerUid = buyerOrder.getSellerUid();//卖家
Integer orderStatus = buyerOrder.getStatus();//5--订单已经完成
//去获取用户的基本信息(头像等 不要去取此接口的手机号!))--异步
AsyncFuture<UserInfoRspBO> userInfoRspBOAsyncFuture = getUserBaseInfo(buyerUid);
... ... @@ -222,15 +226,11 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
AsyncFuture<UicResponse> uicResponseAsyncFuture = getProfileInfo(buyerUid);
//3)订单号获取 skup
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
Integer skup = buyerOrderGoods.getSkup();
//3)skup获取 productInfo
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
result.setProductImageUrl(ImageUrlAssist.getAllProductPicUrl(sellerOrderGoods.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
result.setProductImageUrl((String) infoMap.get("image"));
result.setNfcUid(identifyRecord.getNfcUid());
result.setProductId(sellerOrderGoods.getProductId());
result.setProductName(sellerOrderGoods.getProductName());
result.setProductSize(sellerOrderGoods.getSizeName());
result.setProductId((Integer) infoMap.get("productId"));
result.setProductName((String) infoMap.get("productName"));
result.setProductSize((String) infoMap.get("size"));
//4)vedioFileUrl视频链接
String vedioFileUrl = getLiveVideoUrlByOrderCode(orderCode);
... ... @@ -280,8 +280,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
//2)订单完成
if(orderStatus != null && orderStatus.intValue() == 5){//订单已完成
IdentifyTrackResp updateOrderTrack = new IdentifyTrackResp();
timeStr = formatDate(buyerOrder.getUpdateTime(), "yyyy.MM.dd HH:mm:ss");
updateOrderTrack.setTime(buyerOrder.getUpdateTime());
Integer updateTime = (Integer) infoMap.get("updateTime");
timeStr = formatDate(updateTime, "yyyy.MM.dd HH:mm:ss");
updateOrderTrack.setTime(updateTime);
updateOrderTrack.setTimeStr(timeStr);
updateOrderTrack.setContent("用户" + mobileMask + "成为商品物权所有人");
updateOrderTrack.setHeadIcon(headIcon);
... ... @@ -344,14 +345,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
//根据鉴定记录 获取订单号
Long orderCode = identifyRecord.getOrderCode();
//2)订单号 获取订单详细信息
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if(buyerOrder == null){
throw new GatewayException(403, "订单不存在");
}
//3)商品详细信息
result = getOrderDetail(buyerOrder, identifyRecord, tagId);
result = getOrderDetail(orderCode, identifyRecord, tagId);
//4)物权转移轨迹
List<IdentifyTrackResp> trackList = getTrackList(identifyRecord, result.getIdentifyPlat());
... ... @@ -391,14 +387,9 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
//根据鉴定记录 获取订单号
Long orderCode = identifyRecord.getOrderCode();
//2)订单号 获取订单详细信息
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if(buyerOrder == null){
throw new GatewayException(403, "订单不存在");
}
//3)商品详细信息
ProductIdentifyResp result = getOrderDetail(buyerOrder, identifyRecord, tagId);
ProductIdentifyResp result = getOrderDetail(orderCode, identifyRecord, tagId);
//4)物权转移轨迹
List<IdentifyTrackResp> trackList = getTrackList(identifyRecord, result.getIdentifyPlat());
... ... @@ -441,11 +432,17 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
//根据鉴定记录 获取订单号
Long orderCode = identifyRecord.getOrderCode();
//获取订单详细信息
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if(buyerOrder == null){
Object buyerOrder;
if (isServiceOrder(orderCode)) {
//获取订单详细信息
buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
} else {
buyerOrder = appraiseOrderMapper.selectByOrderCode(orderCode);
}
if (buyerOrder == null) {
throw new GatewayException(403, "订单不存在");
}
//向物权所有人发短信、站内信
messageFacade.applyToBeOwner(insertItem.getFromUid(), String.valueOf(uid), tagId, nfcUid, orderCode);
... ... @@ -728,22 +725,24 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
}
//获取订单详情
private ProductIdentifyResp getOrderDetail(BuyerOrder buyerOrder, IdentifyRecord identifyRecord, String tagId) {
private ProductIdentifyResp getOrderDetail(Long orderCode, IdentifyRecord identifyRecord, String tagId) throws GatewayException {
ProductIdentifyResp result = new ProductIdentifyResp();
//3)订单号获取 skup
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(buyerOrder.getOrderCode());
Integer skup = buyerOrderGoods.getSkup();
//3)skup获取 productInfo
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
result.setProductImageUrl(ImageUrlAssist.getAllProductPicUrl(sellerOrderGoods.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
Map<String, Object> infoMap = getProductInfo(orderCode);
Integer orderStatus = (Integer) (infoMap.get("status"));//5--订单已经完成
if(orderStatus == null){
throw new GatewayException(403, "订单不存在");
}
Integer buyerUid = (Integer) (infoMap.get("uid"));
result.setProductImageUrl((String) infoMap.get("image"));
result.setNfcUid(identifyRecord.getNfcUid());
result.setProductId(sellerOrderGoods.getProductId());
result.setProductName(sellerOrderGoods.getProductName());
result.setProductSize(sellerOrderGoods.getSizeName());
result.setProductId((Integer) infoMap.get("productId"));
result.setProductName((String) infoMap.get("productName"));
result.setProductSize((String) infoMap.get("size"));
//4)vedioFileUrl视频链接
String vedioFileUrl = getLiveVideoUrlByOrderCode(buyerOrder.getOrderCode());
String vedioFileUrl = getLiveVideoUrlByOrderCode(orderCode);
result.setVedioFileUrl(vedioFileUrl);
//查询区块链id
... ... @@ -758,7 +757,7 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
// result.setIdentifyTime(timeStr);
//查询鉴定师名字
OrderOperateRecord orderOperateRecord = orderOperateRecordMapper.selectByTypeAndOrderCode(OperateTypeEnum.OPERATE_TYPE_JUDGE_PASS.getCode(), buyerOrder.getOrderCode());
OrderOperateRecord orderOperateRecord = orderOperateRecordMapper.selectByTypeAndOrderCode(OperateTypeEnum.OPERATE_TYPE_JUDGE_PASS.getCode(), orderCode);
result.setIdentifyUserName(null == orderOperateRecord ? "" : orderOperateRecord.getUserName());
return result;
... ... @@ -819,6 +818,55 @@ public class ProductIdentifyServiceImpl implements ProductIdentifyService{
return result;
}
public Map<String, Object> getProductInfo(Long orderCode) {
Map<String, Object> resultMap = new HashMap<>();
if (isServiceOrder(orderCode)) {
AppraiseOrder order = appraiseOrderMapper.selectByOrderCode(orderCode);
AppraiseOrderGoods goods = appraiseOrderGoodsMapper.selectOneByOrderCode(orderCode);
AppraiseOrderStorage storage = appraiseOrderStorageMapper.selectByOrderCode(orderCode);
resultMap.put("image", goods == null ? "" : ImageUrlAssist.getAllProductPicUrl(goods.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
resultMap.put("productId", goods == null ? "" : goods.getProductId());
resultMap.put("productName", goods == null ? "" : goods.getProductName());
resultMap.put("productCode", goods == null ? "" : goods.getProductCode());
resultMap.put("size", storage == null ? "" : storage.getSizeName());
resultMap.put("color", storage == null ? "" : storage.getColorName());
resultMap.put("uid", order == null ? "" : order.getUid());
} else {
BuyerOrder buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
if (buyerOrder != null) {
resultMap.put("status", buyerOrder.getStatus());
resultMap.put("updateTime", buyerOrder.getUpdateTime());
}
//订单号获取 skup
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
Integer skup = buyerOrderGoods.getSkup();
//skup获取 productInfo
SellerOrderGoods goods = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
resultMap.put("image", goods == null ? "" : ImageUrlAssist.getAllProductPicUrl(goods.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
resultMap.put("productId", goods == null ? "" : goods.getProductId());
resultMap.put("productName", goods == null ? "" : goods.getProductName());
resultMap.put("size", goods == null ? "" : goods.getSizeName());
resultMap.put("color", goods == null ? "" : goods.getColorName());
resultMap.put("uid", buyerOrderGoods == null ? "" : buyerOrderGoods.getUid());
if (goods != null) {
Product productInfo = productMapper.selectByPrimaryKey(goods.getProductId());
resultMap.put("productCode", goods == null ? "" : productInfo.getProductCode());
}
if (!resultMap.containsKey("productCode")) {
resultMap.put("productCode", "");
}
}
return resultMap;
}
private boolean isServiceOrder(long orderCode) {
ApiResponse<Boolean> resp = ufoServiceCaller.call("ufo.order.isServiceOrder", ApiResponse.class, orderCode);
if (resp != null) {
return (Boolean) resp.getData();
}
return false;
}
/**
* 获取鉴定者 所在的鉴定中心名
... ...
package com.yohoufo.user.controller.certification;
import com.yoho.core.config.ConfigReader;
import com.yoho.tools.common.beans.ApiResponse;
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
import com.yohoufo.common.exception.GatewayException;
... ... @@ -36,9 +37,16 @@ public class CertificationController {
@Autowired
private ICertificationService certificationService;
@Autowired
private ConfigReader configReader;
@RequestMapping(params = "method=ufo.user.alipayCertification")
public ApiResponse alipayCertification(RealNameAuthorizeReqVO reqVO) throws GatewayException {
logger.info("CertificationController.alipayCertification: Enter alipayCertification param reqVO is {}", reqVO);
//若版本低于6.9.9, 提示升级版本
if(configReader.getBoolean("ufo.user.idCertUpdateVersionSwitch",false) && reqVO.getApp_version().compareTo("6.9.9") < 0){
throw new VersionNotSupportException();
}
//(1) 必要参数的校验
if(reqVO == null || reqVO.getUid() <= 0){
throw new GatewayException(400, "uid不能为空!");
... ... @@ -66,6 +74,10 @@ public class CertificationController {
@RequestMapping(params = "method=ufo.user.alipayCertifyResultQuery")
public ApiResponse alipayCertifyResultQuery(RealNameAuthorizeReqVO reqVO) throws GatewayException {
logger.info("CertificationController.alipayCertifyResultQuery: Enter. RealNameAuthorizeReqVO is {}", reqVO);
//若版本低于6.9.9提示升级版本
if(configReader.getBoolean("ufo.user.idCertUpdateVersionSwitch",false) && reqVO.getApp_version().compareTo("6.9.9") < 0){
throw new VersionNotSupportException();
}
//(1) 校验请求的参数
if (reqVO == null || StringUtils.isBlank(reqVO.getZhiMaBizNo())){
throw new GatewayException(400, "参数错误,zhiMaBizNo不能为空!");
... ...
... ... @@ -39,4 +39,7 @@ ufo.order.seller.hkAccountSettlementEmailTo=xiuchun.luo@yoho.cn
ufo.order.seller.noticeHKSellerEmailTo=chao.chen@yoho.cn,xiuchun.luo@yoho.cn
#实名认证开关
ufo.user.idCertSwitch=false
\ No newline at end of file
ufo.user.idCertSwitch=false
#实名认证提示版本升级开关
ufo.user.idCertUpdateVersionSwitch = true
\ No newline at end of file
... ...
... ... @@ -72,6 +72,11 @@ consumer:
delay:
interval: 10
- class: com.yohoufo.order.mq.consumer.SellerDepositOrderAutoCancelMsgConsumer
topic: sellerDepositOrder.autoCancel
delay:
interval: 10
#更新物流调拨信息
- address: 192.168.102.45:5672
username: yoho
... ...
... ... @@ -83,6 +83,11 @@ consumer:
delay:
interval: 10080
- class: com.yohoufo.order.mq.consumer.SellerDepositOrderAutoCancelMsgConsumer
topic: sellerDepositOrder.autoCancel
delay:
interval: 10
- address: ${rabbit_ufo}
username: ${rabbit_ufo_user}
password: ${rabbit_ufo_password}
... ...