Authored by mlge

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

Showing 22 changed files with 292 additions and 37 deletions
package com.yohoufo.dal.order;
import com.yohoufo.dal.order.model.BuyOrderNums;
import com.yohoufo.dal.order.model.BuyerOrder;
import org.apache.ibatis.annotations.Param;
... ... @@ -16,6 +17,8 @@ public interface BuyerOrderMapper {
BuyerOrder selectByPrimaryKey(Integer id);
List<BuyOrderNums> selectCntByUidStatusAll(@Param("uid") Integer uid);
BuyerOrder selectByOrderCodeUid(@Param("orderCode") Long orderCode, @Param("uid") int uid);
BuyerOrder selectByOrderCodeSellerUid(@Param("orderCode") Long orderCode, @Param("sellerUid") int uid);
... ...
package com.yohoufo.dal.order.model;
import lombok.Data;
@Data
public class BuyOrderNums {
private Integer num;
private Integer status;
}
... ...
... ... @@ -109,6 +109,16 @@
limit 1
</select>
<select id="selectCntByUidStatusAll" resultType="com.yohoufo.dal.order.model.BuyOrderNums">
select
status, count(1) num
from buyer_order
where uid=#{uid,jdbcType=INTEGER}
and buyer_order_status = 1
GROUP BY status;
</select>
<select id="selectOnlyByOrderCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.controller;
import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohobuy.ufo.model.order.common.SellerOrderListType;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.BuyerOrderNums;
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
... ... @@ -10,6 +11,7 @@ import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.annotation.InnerApi;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
... ... @@ -37,11 +39,23 @@ public class BuyerOrderController {
@Autowired
private SellerFeeService sellerFeeService;
@RequestMapping(params = "method=ufo.buyer.orderNums")
@ResponseBody
@IgnoreSession
@IgnoreSignature
// @InnerApi
public BuyerOrderNums getBuyerOrderNums(@RequestParam("uid") int uid){
BuyerOrderNums buyerOrderNums = buyerOrderService.getBuyerOrderNums(uid);
return buyerOrderNums;
}
/**
* [购买]订单列表
* 1: 全部
* 2:待付款
* 3:待发货
* 3:待发货s
* 4:待收货
* 5:交易成功
* 7:交易失败
... ...
... ... @@ -227,6 +227,7 @@ public class SellerOrderController {
@RequestParam(name = "skupList", required = true)String skupList
) throws GatewayException {
BatchChangePriceReq req = new BatchChangePriceReq();
req.setUid(uid);
req.setPrice(price);
... ... @@ -247,6 +248,7 @@ public class SellerOrderController {
@RequestParam(name = "batchNo", required = false)String batchNo,
@RequestParam(name = "skupList", required = false)String skupList,
@RequestParam(name="num", defaultValue = "1", required = false)int num) throws GatewayException {
BatchChangePriceReq req = new BatchChangePriceReq();
req.setStorageId(storage_id);
req.setUid(uid);
... ... @@ -257,6 +259,7 @@ public class SellerOrderController {
logger.info("in ufo.sellerOrder.computeChangePrice, req {}", req);
SoldPrdComputeBo computeBo = sellerOrderService.computeChangePrice(req);
return new ApiResponse.ApiResponseBuilder().code(200).data(computeBo).message("算费成功").build();
}
/**
... ...
package com.yohoufo.order.event;
import com.yohoufo.common.alarm.Event;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Builder;
/**
* Created by chao.chen on 2018/12/27.
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BuyerRefundCouponEvent extends Event {
public enum BizCase{
APPRAISE_FAIL, SELLER_DELIVER_TIMEOUT, SELLER_PLAY_BUYER, BUYER_CANCEL_BSD, BUYER_CANCEL_BDR
}
Integer uid;
Long orderCode;
BizCase bizCase;
}
... ...
... ... @@ -16,6 +16,7 @@ import com.yohoufo.order.common.RefundCase;
import com.yohoufo.order.common.TransferCase;
import com.yohoufo.order.constants.AlarmConfig;
import com.yohoufo.order.event.BillLogEvent;
import com.yohoufo.order.event.BuyerRefundCouponEvent;
import com.yohoufo.order.event.SellerCancelDeliverEvent;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.model.request.TransferMoneyRequest;
... ... @@ -30,7 +31,7 @@ import org.springframework.stereotype.Component;
import java.math.BigDecimal;
/**
/** 卖家超时发货
* Created by chenchao on 2018/9/30.
*/
@Component
... ... @@ -78,6 +79,9 @@ public class SellerOrderCancelDeliverDelayMsgConsumer implements YhConsumer {
DateUtil.getCurrentTimeSecond());
if(rows > 0){
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.SELLER_DELIVER_TIMEOUT)
.uid(buyerUid).orderCode(orderCode).build();
EventBusPublisher.publishEvent(brce);
//将卖家的保证金分账给平台和买家
TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode)
.type(TransferCase.SELLER_PLAY_BUYER.getCode()).transferCase(TransferCase.DELIVER_TIME_OUT)
... ...
... ... @@ -112,7 +112,8 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
CacheKeyBuilder.orderListKey(uid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderInfo.getOrderCode())));
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderInfo.getOrderCode()),
CacheKeyBuilder.buyerOrderNums(uid)));
}
... ...
package com.yohoufo.order.service;
import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohobuy.ufo.model.order.resp.BuyerOrderNums;
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.order.model.request.OrderRequest;
... ... @@ -9,8 +10,12 @@ import com.yohoufo.order.model.response.OrderSummaryResp;
public interface IBuyerOrderService extends IOrderListService, IOrderDetailService{
/**
* 查询待付款,待收货,待发货的订单数量
* @param uid
* @return
*/
BuyerOrderNums getBuyerOrderNums(int uid);
/**
* 取消订单
... ...
... ... @@ -52,7 +52,9 @@ public class CacheKeyBuilder {
ORDER_DETAIL("ufo:order:orderDetail:", "uid:{}:tabType:{}:orderCode:{}"),
SELLER_ORDER_DETAIL("ufo:order:orderDetail:", "uid:{}:tabType:{}:batchNo:{}:price{}:status{}");
SELLER_ORDER_DETAIL("ufo:order:orderDetail:", "uid:{}:tabType:{}:batchNo:{}:price{}:status{}"),
BUYER_ORDER_NUMS("ufo:order:buyer:nums", "uid:{}");
private String fix;
... ... @@ -87,6 +89,10 @@ public class CacheKeyBuilder {
return PatternKeyTemplate.ORDER_LIST_PAGE_LIMIT.getKey(req.getType(), req.getPage(), req.getLimit());
}
public static RedisKeyBuilder buyerOrderNums(int uid){
return KeyTemp.BUYER_ORDER_NUMS.builderKey(new Object[]{uid});
}
public static String skupListHashKey(OrderListRequest req){
return PatternKeyTemplate.SELLER_ORDER_LIST_PAGE_LIMIT.getKey(req.getType(), req.getSkupList(), req.getLimit());
}
... ...
... ... @@ -12,4 +12,6 @@ public interface ExpiredTime {
int ORDER_DETAIL = 300;
int ORDER_SUMMARY = 300;
int BUYER_ORDER_NUMS = 300;
}
... ...
... ... @@ -3,9 +3,11 @@ package com.yohoufo.order.service.cache;
import com.alibaba.fastjson.JSON;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.BuyerOrderNums;
import com.yohobuy.ufo.model.order.vo.OrderListVo;
import com.yohoufo.common.cache.CacheClient;
import com.yohoufo.common.cache.SnappyZipUtils;
import com.yohoufo.dal.order.model.BuyOrderNums;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.response.OrderDetailInfo;
... ... @@ -96,6 +98,20 @@ public class OrderCacheService {
}
public BuyerOrderNums getBuyerOrderNums(int uid){
RedisKeyBuilder redisKeyBuilder = CacheKeyBuilder.buyerOrderNums(uid);
BuyerOrderNums buyerOrderNums = cacheClient.get(redisKeyBuilder.getKey(), BuyerOrderNums.class);
return buyerOrderNums;
}
public void saveBuyerOrderNums(int uid, BuyerOrderNums buyOrderNums){
RedisKeyBuilder redisKeyBuilder = CacheKeyBuilder.buyerOrderNums(uid);
cacheClient.set(redisKeyBuilder.getKey(), ExpiredTime.BUYER_ORDER_NUMS , buyOrderNums);
logger.info("saveBuyerOrderNums cache ,uid {} nums {}", uid, buyOrderNums);
}
public OrderListVo getOrderListInfos(OrderListRequest req){
logger.info("hit OrderList cache ,req {}", req);
... ...
package com.yohoufo.order.service.handler;
import com.google.common.eventbus.Subscribe;
import com.yohoufo.common.alarm.IEventHandler;
import com.yohoufo.order.event.BuyerRefundCouponEvent;
import com.yohoufo.order.service.impl.BuyerOrderCancelService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* Created by chao.chen on 2018/12/27.
*/
@Component
public class BuyerRefundCouponAsyncHandler implements IEventHandler<BuyerRefundCouponEvent> {
private final Logger logger = LoggerUtils.getBuyerOrderLogger();
@Autowired
private BuyerOrderCancelService buyerOrderCancelService;
@Override
@Subscribe
public void handle(BuyerRefundCouponEvent event) {
logger.info("in handle BuyerRefundCouponEvent {}", event);
if (event == null){
return;
}
buyerOrderCancelService.refundCouponIfNeed(event.getUid(), event.getOrderCode());
}
}
... ...
package com.yohoufo.order.service.handler;
import com.google.common.eventbus.Subscribe;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.common.alarm.IEventHandler;
import com.yohoufo.order.event.PayConfirmEvent;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.service.IPaymentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class CleanGWOrderNumsEventHandler implements IEventHandler<PayConfirmEvent> {
final Logger logger = LoggerFactory.getLogger(getClass());
@Subscribe
@Override
public void handle(PayConfirmEvent event) {
}
}
\ No newline at end of file
... ...
... ... @@ -19,6 +19,7 @@ import com.yohoufo.order.common.TransferCase;
import com.yohoufo.order.constants.AlarmConfig;
import com.yohoufo.order.event.BillLogEvent;
import com.yohoufo.order.event.BuyerConfirmEvent;
import com.yohoufo.order.event.BuyerRefundCouponEvent;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.model.request.TransferMoneyRequest;
import com.yohoufo.order.model.response.AppraiseAddressResp;
... ... @@ -209,7 +210,8 @@ public class AppraiseService {
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid,TabType.BUY.getValue(), orderCode)));
CacheKeyBuilder.orderDetailKey(buyerUid,TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(buyerUid)));
LOGGER.info("in appraiseSuccess, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
sellerUid, sellerOrderCode, skup, earnestMoney );
... ... @@ -329,7 +331,11 @@ public class AppraiseService {
DateUtil.getCurrentTimeSecond());
if (rows > 0){
//refund coupons of buyer
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.APPRAISE_FAIL)
.uid(buyerUid).orderCode(orderCode).build();
EventBusPublisher.publishEvent(brce);
//
int sellerUid = buyerOrder.getSellerUid();
BuyerOrderGoods bog = buyerOrderGoodsMapper.selectByOrderCode(buyerUid, orderCode);
int skup = bog.getSkup();
... ... @@ -351,7 +357,8 @@ public class AppraiseService {
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sellerOrderGoods),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode)));
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(buyerUid)));
//将卖家的保证金分账给平台和买家
TransferCase transferCase = TransferCase.APPRAISE_FAIL;
... ... @@ -361,13 +368,7 @@ public class AppraiseService {
//先校验,提前把错误抛出
paymentService.transferMonCheck(tmReq);
//再分账
/*
boolean transferSuccessFlag=transferService.transfer(tmReq);
if(!transferSuccessFlag){
apiResponse.setCode(400);
apiResponse.setMessage("保证金分账失败");
}
*/
//改成异步的分账,不关心分账执行结果
executorService.execute(()->{
LOGGER.info("in appraiseFail,begin transfer async");
... ...
... ... @@ -130,7 +130,8 @@ public class BuyerOrderCancelService {
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(psog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode)));
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(buyerUid)));
logger.info("use one thread to execute buyer cancel BeforeSellerDeliver buyerUid {}, orderCode {}, skup {}, compensate {}, transferCase {}",
buyerUid, orderCode, skup, compensate, transferCase);
}
... ... @@ -185,7 +186,8 @@ public class BuyerOrderCancelService {
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(psog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode)));
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(buyerUid)));
logger.info("use one thread to execute buyer cancel BeforeDepotReceive buyerUid {}, orderCode {}, skup {}, compensate {}, transferCase {}",
buyerUid, orderCode, skup, compensate, transferCase);
}
... ... @@ -305,6 +307,7 @@ public class BuyerOrderCancelService {
*/
public void refundCouponIfNeed(int uid, long orderCode) {
try {
logger.info("buyer order cancel,refundCouponIfNeed uid {} orderCode {}", uid, orderCode);
OrderCoupon orderCoupon = orderCouponMapper.selectByUidAndOrderCode(uid, orderCode);
if (orderCoupon == null) {
logger.info("[{}] not need to refund coupon", orderCode);
... ...
... ... @@ -85,7 +85,8 @@ public class BuyerOrderMetaServiceImpl implements IBuyerOrderMetaService {
//清地址缓存
cacheCleaner.delete(Arrays.asList(
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), req.getOrderCode())));
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), req.getOrderCode()),
CacheKeyBuilder.buyerOrderNums(buyerUid)));
return rtn;
}
... ...
... ... @@ -9,6 +9,7 @@ import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.SkupStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
import com.yohobuy.ufo.model.order.resp.BuyerOrderNums;
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
... ... @@ -20,6 +21,7 @@ import com.yohoufo.common.utils.UserInfoHiddenHelper;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.BuyOrderNums;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.dal.order.model.SellerOrderGoods;
... ... @@ -45,6 +47,7 @@ import com.yohoufo.order.service.pay.AbstractPayService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -52,7 +55,9 @@ import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Service
public class BuyerOrderServiceImpl implements IBuyerOrderService {
... ... @@ -119,7 +124,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
CacheKeyBuilder.orderListKey(uid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(sog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderCode)));
CacheKeyBuilder.orderDetailKey(uid, TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(uid)));
} else {
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE); // 更新失败,可能是因为订单状态已经被并发修改
}
... ... @@ -398,7 +404,8 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(psog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode)));
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(buyerUid)));
}
... ... @@ -482,6 +489,58 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return orderDetailInfo;
}
/**
* 查询订单数量
* @param uid
* @return
*/
public BuyerOrderNums getBuyerOrderNums(int uid){
if (uid < 0){
logger.warn("buyer delete, uid or orderCode empty, uid {}", uid);
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
BuyerOrderNums buyerOrderNumsCache = orderCacheService.getBuyerOrderNums(uid);
if (buyerOrderNumsCache != null){
logger.info("getBuyerOrderNums result uid is {}, result is {}", uid, buyerOrderNumsCache);
return buyerOrderNumsCache;
}
List<BuyOrderNums> buyOrderNumList = buyerOrderMapper.selectCntByUidStatusAll(uid);
if (CollectionUtils.isEmpty(buyOrderNumList)){
return BuyerOrderNums.builder().build();
}
Map<Integer, Integer> buyOrderNumsMap = buyOrderNumList.stream().collect(Collectors.toMap(BuyOrderNums::getStatus, BuyOrderNums::getNum));
// 待付款
// 待发货
// 待收货
BuyerOrderNums buyerOrderNums = BuyerOrderNums.builder().uid(uid)
.waitingPayNum(getValueDefalutZero(buyOrderNumsMap, OrderListType.WAITING_PAY.getStatusQuery()))
.waitingSendNums(getValueDefalutZero(buyOrderNumsMap, OrderListType.WAITING_SEND.getStatusQuery()))
.waitingDeliveryNums(getValueDefalutZero(buyOrderNumsMap, OrderListType.WAITING_DELIVERY.getStatusQuery())).build();
orderCacheService.saveBuyerOrderNums(uid, buyerOrderNums);
return buyerOrderNums;
}
private int getValueDefalutZero(Map<Integer, Integer> map, List<Integer> status){
int sum = 0;
for(Integer key : status){
int num = Objects.isNull(map.get(key)) ? 0 : map.get(key);
sum+=num;
}
return sum;
}
@Override
public PageResp getOrderList(OrderListRequest request) {
... ...
... ... @@ -157,7 +157,8 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(psog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
CacheKeyBuilder.orderDetailKey(buyerUid,TabType.BUY.getValue(), orderCode)));
CacheKeyBuilder.orderDetailKey(buyerUid,TabType.BUY.getValue(), orderCode),
CacheKeyBuilder.buyerOrderNums(buyerUid)));
}
LOGGER.info("deliverToDepot update buyer order status result {} ",updateBuyerCnt);
... ...
... ... @@ -15,10 +15,7 @@ import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.*;
import com.yohoufo.order.constants.AlarmConfig;
import com.yohoufo.order.event.BillLogEvent;
import com.yohoufo.order.event.ErpCancelSellerOrderEvent;
import com.yohoufo.order.event.OrderCancelEvent;
import com.yohoufo.order.event.PayConfirmEvent;
import com.yohoufo.order.event.*;
import com.yohoufo.order.model.PayQueryBo;
import com.yohoufo.order.model.PayRefundBo;
import com.yohoufo.order.model.request.OrderRequest;
... ... @@ -411,30 +408,40 @@ public class SellerOrderCancelService {
* 根据codeType判断即可
*/
if (OrderCodeType.getSellerTypes().contains(codeType)){
logger.warn("cancelAfterPayExistBuyAction canceling order buyer operated, seller [uid:{} orderCode:{}],buyer [uid:{} orderCode:{}] codeType {} buyerOrderStatus {}",
logger.warn("cancelAfterPayExistBuyAction seller cancel self-order_code , seller [uid:{} orderCode:{}],buyer [uid:{} orderCode:{}] codeType {} buyerOrderStatus {}",
sellerUid, sellerOrderCode, buyerUid, buyerOrderCode, codeType, buyerOrderStatus);
String errorMsg = "您的商品已经被购买,不能下架该商品!";
throw new UfoServiceException(501, errorMsg);
}
if (!Objects.equals(buyerOrderStatus, OrderStatus.HAS_PAYED.getCode())){
logger.warn("cancelAfterPayExistBuyAction canceling buyer order status not normal, seller [uid:{} orderCode:{}],buyer [uid:{} orderCode:{}] codeType {} buyerOrderStatus {}",
sellerUid, sellerOrderCode, buyerUid, buyerOrderCode, codeType, buyerOrderStatus);
String errorMsg = "买家订单不可取消";
throw new UfoServiceException(501, errorMsg);
}
int result = 0;
//actions of buyer order and related
//update buyer Order
//target Buyer Order Status
Integer targetBOStatus;
targetBOStatus = OrderStatus.SELLER_CANCEL_AFTER_PAY.getCode();
BuyerOrder tbo = new BuyerOrder();
tbo.setUid(buyerUid);
tbo.setOrderCode(buyerOrderCode);
tbo.setStatus(targetBOStatus);
tbo.setUpdateTime(DateUtil.getCurrentTimeSecond());
result += buyerOrderMapper.updateByOrderCode(tbo);
OrderStatus targetBOStatus = OrderStatus.SELLER_CANCEL_AFTER_PAY;
int currentDT = DateUtil.getCurrentTimeSecond();
result += buyerOrderMapper.updateStatusByOrderCode(buyerOrderCode, buyerUid, buyerOrderStatus,
targetBOStatus.getCode(), currentDT);
if(result > 0) {
BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.SELLER_PLAY_BUYER)
.uid(buyerUid).orderCode(buyerOrderCode).build();
EventBusPublisher.publishEvent(brce);
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(sellerOrder.getSkup());
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(psog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), buyerOrderCode),
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), buyerOrderCode)));
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), buyerOrderCode),
CacheKeyBuilder.buyerOrderNums(buyerUid)));
//update seller order
SellerOrderStatus targetSOStatus;
... ...
... ... @@ -298,7 +298,8 @@ public class ShoppingServiceImpl implements IShoppingService {
//clean seller cache
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
CacheKeyBuilder.sellerOrderDetailKey(psog),
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), sellerOrderCode)
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), sellerOrderCode),
CacheKeyBuilder.buyerOrderNums(shoppingRequest.getUid())
));
NotPaidNoticeEvent notPaidNoticeEvent = NotPaidNoticeEvent.builder().actorType(TabType.BUY)
.uid(shoppingRequest.getUid()).orderCode(orderCode).build();
... ...
... ... @@ -2,6 +2,9 @@ package com.yohoufo.promotion.controller;
import com.yohobuy.ufo.model.promotion.response.CouponInfo;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.common.annotation.InnerApi;
import com.yohoufo.promotion.service.ICouponService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -55,6 +58,25 @@ public class CouponController {
/**
* 个人中心优惠券数量,给内部用接口
* @param uid
* @return
*/
@RequestMapping(params = "method=ufo.coupons.innerCnt")
@ResponseBody
@IgnoreSession
@IgnoreSignature
// @InnerApi
public ApiResponse queryCouponInnerCnt(@RequestParam(value = "uid") Integer uid) {
logger.info("query user coupons cnt, uid: {}", uid);
int couponCnt = couponService.queryCouponCnt(uid);
logger.info("query user coupons cnt uid: {}, v: {}", uid, couponCnt);
return new ApiResponse.ApiResponseBuilder().code(200).data(couponCnt).build();
}
/**
* 领券接口
* @param uid
* @return
... ...