Authored by tanling

Merge branch 'dev_1226_gatewaynums' into test6.8.4

# Conflicts:
#	order/src/main/java/com/yohoufo/order/controller/SellerOrderController.java
#	order/src/main/java/com/yohoufo/order/service/impl/BuyerOrderServiceImpl.java
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;
}se
/**
* [购买]订单列表
* 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();
}
/**
... ...
... ... @@ -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);
... ...
... ... @@ -210,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 );
... ... @@ -356,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;
... ...
... ... @@ -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);
}
... ...
... ... @@ -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;
... ... @@ -44,7 +46,11 @@ import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.pay.AbstractPayService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.ProductProxyService;
<<<<<<< HEAD
import com.yohoufo.order.utils.LoggerUtils;
=======
import org.apache.commons.collections.CollectionUtils;
>>>>>>> dev_1226_gatewaynums
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -52,7 +58,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 +127,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 +407,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 +492,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);
... ...
... ... @@ -440,7 +440,8 @@ public class SellerOrderCancelService {
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
... ...