Authored by caoyan

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

Showing 30 changed files with 364 additions and 113 deletions
... ... @@ -10,3 +10,4 @@
MANIFEST.MF
deploy/.gitignore
product/.gitignore
*/.factorypath
... ...
... ... @@ -42,4 +42,9 @@ public interface ExpressRecordMapper {
* @return
*/
int updateDeptNoByOrder(@Param("orderCodeList") List<Long> orderCodeList, @Param("expressType") Integer expressType, @Param("depotNum") Integer depotNum);
int updateWaybillCode(@Param("orderCode") Long orderCode,
@Param("uid") Integer uid,
@Param("expressType") Integer expressType,
@Param("waybillCode") String waybillCode);
}
\ No newline at end of file
... ...
... ... @@ -67,6 +67,9 @@ public class TradeBills {
private String payErrorCode;
//支付阶段,0:普通,1:定金
private int payLevel = 0;
/**
* suggest use new enum, define class as blow
* {@link com.yohoufo.order.common.BillTradeStatus}
... ...
... ... @@ -93,9 +93,9 @@ public interface StoragePriceMapper {
int updateBatchDepotNum(@Param("skupList") List<Integer> skupList, @Param("depotNum") Integer depotNo);
/**
* 查询现货各尺码的最低价
* 查询某类型库存各尺码的最低价
* @param productId
* @return
*/
List<StoragePrice> selectInStockLeastPByProductId(@Param("productId") Integer productId, @Param("preSaleFlag") Integer preSaleFlag);
List<StoragePrice> selectLeastPByProductId(@Param("productId") Integer productId, @Param("preSaleFlag") Integer preSaleFlag);
}
\ No newline at end of file
... ...
... ... @@ -60,4 +60,9 @@
</foreach>
and express_type = #{expressType, jdbcType=INTEGER}
</update>
<update id="updateWaybillCode">
update express_record set waybill_code=#{waybillCode}
where order_code=#{orderCode} and uid=#{uid} and express_type=#{expressType}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -6,6 +6,7 @@
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="order_code" jdbcType="BIGINT" property="orderCode" />
<result column="paid_order_code" jdbcType="BIGINT" property="paidOrderCode" />
<result column="pay_level" jdbcType="TINYINT" property="payLevel" />
<result column="user_type" jdbcType="TINYINT" property="userType" />
<result column="pay_type" jdbcType="TINYINT" property="payType" />
<result column="trade_type" jdbcType="INTEGER" property="tradeType" />
... ... @@ -23,7 +24,7 @@
<result column="pay_error_code" jdbcType="VARCHAR" property="payErrorCode" />
</resultMap>
<sql id="Base_Column_List">
id,uid, order_code,paid_order_code, user_type,pay_type,trade_type,income_outcome,amount,system_amount,trade_status,create_time,
id,uid, order_code,paid_order_code,pay_level, user_type,pay_type,trade_type,income_outcome,amount,system_amount,trade_status,create_time,
deal_uid,deal_status,deal_time,deal_relate_id,deal_user_name,pay_error_code
</sql>
... ... @@ -42,10 +43,10 @@
</select>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.TradeBills" useGeneratedKeys="true">
insert into trade_bills (id, uid, order_code, paid_order_code, user_type,pay_type,trade_type,
insert into trade_bills (id, uid, order_code, paid_order_code,pay_level, user_type,pay_type,trade_type,
income_outcome,amount,system_amount,trade_status,create_time
,deal_uid,deal_status,deal_time,deal_relate_id,deal_user_name,pay_error_code)
values (#{id},#{uid},#{orderCode},#{paidOrderCode},#{userType},#{payType},#{tradeType},
values (#{id},#{uid},#{orderCode},#{paidOrderCode},#{payLevel},#{userType},#{payType},#{tradeType},
#{incomeOutcome},#{amount},#{systemAmount},
#{tradeStatus},#{createTime},#{dealUid},#{dealStatus},
#{dealTime},#{dealRelateId},#{dealUserName},#{payErrorCode})
... ...
... ... @@ -271,7 +271,7 @@
</foreach>
</update>
<select id="selectInStockLeastPByProductId" resultMap="BaseResultMap">
<select id="selectLeastPByProductId" resultMap="BaseResultMap">
select t.id as id, t.skup as skup, t.storage_id as storage_id, t.price as price, t.status as status, t.pre_sale_flag as pre_sale_flag, t.region as region from storage_price t,
(select id from (select id ,storage_id
from storage_price FORCE INDEX (`idx_storage_id_price`)
... ...
... ... @@ -7,5 +7,8 @@ public enum RefundCase {
SELLER_EARNEST_MONEY,
BUYER_GOODS_MONEY;
BUYER_GOODS_MONEY,
//求购定金
BID_DEPOSIT_MONEY;
}
... ...
package com.yohoufo.order.controller;
import com.yoho.core.rest.annotation.ServiceDesc;
import com.yohobuy.ufo.model.order.req.AppraiseOrderWaybillUpdateReq;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.order.service.impl.AppraiseOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/erp/appraiseOrder")
@ServiceDesc("appraiseOrder")
public class ErpAppraiseOrderController {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private AppraiseOrderService appraiseOrderService;
@IgnoreSession
@IgnoreSignature
@RequestMapping("/updateWaybillCode")
public ApiResponse updateWaybillCode(@RequestBody AppraiseOrderWaybillUpdateReq req){
logger.info("in updateWaybillCode Of AppraiseOrder req {}", req);
appraiseOrderService.updateWaybillCode(req);
return new ApiResponse.ApiResponseBuilder().code(200).message("修改快递单号成功").build();
}
}
... ...
... ... @@ -35,4 +35,6 @@ public class BillLogEvent extends Event{
BigDecimal amount;
Integer tradeStatus;
int payLevel;
}
... ...
... ... @@ -86,9 +86,6 @@ public abstract class AbstractBuyerOrderStateChanger<T extends RequestedStatusCh
protected CacheCleaner cacheCleaner;
@Autowired
protected IPaymentService paymentService;
@Autowired
protected ProductMapper productMapper;
@Autowired
... ...
... ... @@ -24,7 +24,7 @@ public class BillLogAsyncHandler implements IEventHandler<BillLogEvent> {
public void handle(BillLogEvent event) {
logger.info("in BillLogAsyncHandler.handle event {}", event);
switch (event.getRefundCase()){
switch (event.getRefundCase()) {
case SELLER_EARNEST_MONEY:
//Integer uid, Integer skup, Long orderCode, Integer payType, BigDecimal amount, Integer tradeStatus
tradeBillsService.backPayEnsureRecord(event);
... ... @@ -32,11 +32,14 @@ public class BillLogAsyncHandler implements IEventHandler<BillLogEvent> {
case BUYER_GOODS_MONEY:
//Integer uid, Integer sellerUid, Integer skup,
//Long orderCode, Integer payType, BigDecimal amount, Integer tradeStatus
tradeBillsService.backPayBuyRecord(event.getBuyerUid(), event.getSellerUid(), event.getSkup(), event.getOrderCode(),event.getPaidOrderCode(),
tradeBillsService.backPayBuyRecord(event.getBuyerUid(), event.getSellerUid(), event.getSkup(), event.getOrderCode(), event.getPaidOrderCode(),
event.getPayType(), event.getAmount(), event.getTradeStatus());
break;
case BID_DEPOSIT_MONEY:
//定金退款记录
tradeBillsService.backDepositPayBuyRecord(event.getBuyerUid(), event.getOrderCode(), event.getPaidOrderCode(),
event.getPayType(), event.getAmount(), event.getPayLevel(), event.getTradeStatus());
break;
}
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
import com.yohoufo.dal.order.model.AppraiseOrderMeta;
import com.yohoufo.order.constants.MetaKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class AppraiseOrderAddressService {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private AppraiseOrderMetaMapper appraiseOrderMetaMapper;
public AddressInfo getNoHiddenAddressInfo(Long orderCode){
final String key = MetaKey.RECALL_ADDRESS;
List<AppraiseOrderMeta> aomAddressList = appraiseOrderMetaMapper.selectByOrderCodeMetaKeys(orderCode, Lists.newArrayList(key));
return Optional.ofNullable(aomAddressList)
.map(appraiseOrderMetas -> appraiseOrderMetas.get(0))
.map(appraiseOrderMeta -> JSONObject.parseObject(appraiseOrderMeta.getMetaValue(),AddressInfo.class))
.orElse(null);
}
}
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.ProductInfo;
import com.yohobuy.ufo.model.order.bo.AppraiseOrderGoodsBo;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.AppraiseOrderStatus;
import com.yohobuy.ufo.model.order.common.EnumExpressType;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.req.*;
import com.yohobuy.ufo.model.order.resp.*;
import com.yohobuy.ufo.model.order.vo.AddressInfo;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.lock.RedisLock;
import com.yohoufo.common.lock.RedisLockFactory;
import com.yohoufo.common.utils.AddressUtil;
import com.yohoufo.common.utils.BigDecimalHelper;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.AppraiseOrderGoodsMapper;
import com.yohoufo.dal.order.AppraiseOrderMapper;
import com.yohoufo.dal.order.AppraiseOrderMetaMapper;
import com.yohoufo.dal.order.OrdersPayTransferMapper;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.ClientType;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.convert.AppraiseOrderGoodsConvertor;
import com.yohoufo.order.model.dto.AppraiseOrderContext;
import com.yohoufo.order.model.response.AppraiseAddressResp;
import com.yohoufo.order.service.IExpressInfoService;
import com.yohoufo.order.service.IGoodsService;
import com.yohoufo.order.service.handler.GoodsServiceRefundHandler;
import com.yohoufo.order.service.handler.transfer.TransferChancelSelector;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.service.proxy.UserProxyService;
... ... @@ -43,13 +45,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.yohoufo.order.utils.ServiceExceptions.throwServiceExceptionIf;
@Service
public class AppraiseOrderService extends AbsGoodsServiceOrderService implements IGoodsService {
private final Logger logger = LoggerUtils.getBuyerOrderLogger();
... ... @@ -88,7 +90,7 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
OrderCodeGenerator orderCodeGenerator;
@Autowired
private TransferChancelSelector transferChancelSelector;
private ExpressRecordMapper expressRecordMapper;
@Autowired
TransferService transferService;
... ... @@ -96,6 +98,15 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
@Autowired
OrdersPayTransferMapper ordersPayTransferMapper;
@Autowired
private AppraiseAddressService appraiseAddressService;
@Autowired
private AppraiseOrderAddressService appraiseOrderAddressService;
@Autowired
private RedisLockFactory redisLockFactory;
public AppraiseOrderComputeResp compute(AppraiseOrderComputeReq req){
logger.info("in AppraiseOrderService.compute req {}", req);
... ... @@ -452,4 +463,66 @@ public class AppraiseOrderService extends AbsGoodsServiceOrderService implements
inBoxFacade.paidAppraiseOrderNotice(orderInfo.getUid(), orderInfo.getOrderCode(), targetStatus);
}
public void updateWaybillCode(AppraiseOrderWaybillUpdateReq req){
Long orderCode = req.getOrderCode();
String waybillCode = req.getSellerWaybillCode();
if (Objects.isNull(orderCode) || orderCode<=0L || StringUtils.isBlank(waybillCode)){
logger.warn("appraise order updateWaybillCode params of req illegal, req {}", req);
throw new UfoServiceException(400, "请求参数不合法");
}
//
AppraiseOrder pao = appraiseOrderMapper.selectByOrderCode(orderCode);
if (Objects.isNull(pao)){
logger.warn("appraise order updateWaybillCode order not exist, req {}", req);
throw new UfoServiceException(400, "订单不存在");
}
Integer status = pao.getStatus();
if (status.equals(AppraiseOrderStatus.SELLER_SEND_OUT.getCode()) ){
RedisKeyBuilder redisLockKey = RedisKeyBuilder.newInstance()
.appendFixed("ufo:order:lock:appraiseOrder:updateWaybillCode:")
.appendVar(orderCode);
RedisLock lock = redisLockFactory.newLock(redisLockKey, 5, TimeUnit.SECONDS);
throwServiceExceptionIf(!lock.tryLock(), "正在修改快递记录中");
try{
doUpdateWaybill(req, pao);
}finally {
lock.unlock();
}
}else{
logger.warn("updateWaybillCode status of order not match ,req {} status {}", req, status);
}
}
private void doUpdateWaybill(AppraiseOrderWaybillUpdateReq req, AppraiseOrder pao){
Long orderCode = req.getOrderCode();
String changedWaybillCode = req.getSellerWaybillCode().trim();
final EnumExpressType teet = EnumExpressType.EXPRESS_TYPE_1;
ExpressRecord record = expressRecordMapper.selectByOrderCodeAndExpressType(orderCode, teet.getCode());
if (Objects.isNull(record)){
logger.warn("appraise order updateWaybillCode ExpressRecord not exist, req {}", req);
throw new UfoServiceException(400, "快递记录不存在");
}
if (record.getWaybillCode().trim().equalsIgnoreCase(changedWaybillCode)){
logger.warn("appraise order updateWaybillCode waybillCode not change, req {}", req);
throw new UfoServiceException(400, "快递单号没有变化");
}
int rows = expressRecordMapper.updateWaybillCode(orderCode, pao.getUid(), teet.getCode(), changedWaybillCode);
if (rows>0){
String depotMobile = appraiseAddressService.optInitAddressByDepotNum(record.getDepotNum())
.map(AppraiseAddressResp::getMobile)
.orElse(null);
AddressInfo noHiddenAddress = appraiseOrderAddressService.getNoHiddenAddressInfo(orderCode);
String sellerMobile = Optional.ofNullable(noHiddenAddress)
.map(AddressInfo::getMobile)
.orElse(null);
List<String> mobiles = Lists.newArrayList(sellerMobile, depotMobile);
expressInfoService.triggerExpressMQ(pao.getUid(), record.getLogisticsType(), orderCode, changedWaybillCode, mobiles);
}
}
}
... ...
... ... @@ -593,7 +593,11 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
}
@Override
public void triggerExpressMQ(Integer uid, Integer expressCompanyId, Long orderCode, String wayBillCode, List<String> mobiles) {
public void triggerExpressMQ(Integer uid,
Integer expressCompanyId,
Long orderCode,
String wayBillCode,
List<String> mobiles) {
// 发送mq获取物流信息
sendExpressMQ(uid, expressCompanyId, orderCode, wayBillCode, mobiles);
LOGGER.info("triggerExpressMQ end ! send express to erp ");
... ...
... ... @@ -871,8 +871,8 @@ public class PaymentServiceImpl implements IPaymentService {
tradeBills.setPayType(optMarkPaidPayType(req.getSceneId()).get());
markPaid(logTag, tradeBills, lockKey);
}
// 退货款或普通用户退保证金
else if (isRefundGoodsMoneyTradeBills(tradeBills) || isRefundEarnestMoneyTradeBills(tradeBills)) {
// 退求购定金、货款、普通用户退保证金
else if (isRefundGoodsMoneyOrDepositMoneyTradeBills(tradeBills) || isRefundEarnestMoneyTradeBills(tradeBills)) {
refund(logTag, tradeBills, amount, lockKey);
}
// 转账
... ... @@ -905,9 +905,9 @@ public class PaymentServiceImpl implements IPaymentService {
}
// '1:买家uid; 2:卖家uid','1:保证金;2:货款;3:补偿款', '1:用户收入; 2:用户支出'
private boolean isRefundGoodsMoneyTradeBills(TradeBills tradeBills) {
private boolean isRefundGoodsMoneyOrDepositMoneyTradeBills(TradeBills tradeBills) {
return tradeBills.getUserType() == 1
&& tradeBills.getTradeType() == 2
&& (tradeBills.getTradeType() == 1 || tradeBills.getTradeType() == 2)
&& tradeBills.getIncomeOutcome() == 1;
}
... ... @@ -945,6 +945,7 @@ public class PaymentServiceImpl implements IPaymentService {
logger.info("{}, refund money is {}", logTag, tradeBills);
refundManager.create(orderCode, amount.doubleValue())
.withPaidOrderCode(tradeBills.getPaidOrderCode())
.withPayLevel(tradeBills.getPayLevel())
.withRefundPostHandler(context -> {
PayRefundBo refundBo = context.getResponse();
//退款申请成功
... ...
... ... @@ -112,7 +112,7 @@ public class SellerOrderViewService {
Integer cnt = orderCacheService.getOrderSummary(uid, TabType.SELL, businessClient);
if (cnt == null) {
final BusinessClientEnum bce = OrderAssist.findBusinessClient(businessClient);
List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient(bce);
List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient4Seller(bce);
Integer num = sellerOrderGoodsMapper.selectCntByUidStatusList(uid, Arrays.asList(SkupStatus.CAN_SELL.getCode()), orderTypes);
List<SellerOrderListType> types = Arrays.asList(SellerOrderListType.SEND_OUT, SellerOrderListType.WAITING_PAY);
List<Integer> statusList = types.parallelStream().flatMap(solt -> solt.getStatus().parallelStream()).collect(Collectors.toList());
... ... @@ -141,7 +141,7 @@ public class SellerOrderViewService {
final String actor = TabType.SELL.getValue();
//not hit in cache
if (CollectionUtils.isEmpty(list)) {
List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient(bce);
List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient4Seller(bce);
list = new ArrayList<>(8);
SellerOrderListType insale = SellerOrderListType.IN_SALE;
int num = sellerOrderGoodsMapper.selectCntByUidStatusList(uid, Arrays.asList(SkupStatus.CAN_SELL.getCode()), orderTypes);
... ...
... ... @@ -184,6 +184,38 @@ public class TradeBillsService {
}
/**
* 定金退款流水记录
*
* @param uid
* @param orderCode
* @param payType
* @param amount
* @param tradeStatus
*/
public void backDepositPayBuyRecord(Integer uid, Long orderCode, Long paidOrderCode, Integer payType, BigDecimal amount, int payLevel, Integer tradeStatus) {
if (payType != null && Payment.WALLET.getCode() == payType) {
return;
}
// 增加流水记录
TradeBills record = new TradeBills();
record.setUid(uid);
record.setOrderCode(orderCode);
record.setPaidOrderCode(ObjectUtils.defaultIfNull(paidOrderCode, 0L));
record.setUserType(1);// 1:买家uid; 2:卖家uid
record.setPayType(payType);// 1:支付宝; 2:微信
record.setTradeType(1);//1:保证金;2:货款;3:补偿款
record.setIncomeOutcome(1);// 1:用户收入; 2:用户支出
record.setAmount(amount);
record.setSystemAmount(amount.negate());
record.setTradeStatus(tradeStatus);//0:订单未完结;1:订单完结
record.setCreateTime((int) (System.currentTimeMillis() / 1000));
record.setPayLevel(payLevel);
addTradeBills(record);
}
public void addTradeBills(TradeBills record) {
try {
tradeBillsMapper.insert(record);
... ...
... ... @@ -7,14 +7,18 @@ import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.order.common.RefundCase;
import com.yohoufo.order.event.BillLogEvent;
import com.yohoufo.order.model.PayRefundBo;
import com.yohoufo.order.model.RequestedStatusChangeBuyerOrder;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.service.AbstractBuyerOrderStateChanger;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.impl.PayRefundService;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.LinkedHashMap;
... ... @@ -31,7 +35,7 @@ import static com.yohoufo.order.common.RefundCase.SELLER_EARNEST_MONEY;
public class BuyerOrderBidingCancelChanger extends AbstractBuyerOrderStateChanger<RequestedStatusChangeBuyerOrder> {
@Autowired
private IPaymentService paymentService;
private PayRefundService payRefundService;
/**
* @param statusChangeBuyerOrder
... ... @@ -65,17 +69,28 @@ public class BuyerOrderBidingCancelChanger extends AbstractBuyerOrderStateChange
private void refundDeposit(BuyerOrder buyerOrder) {
int uid = buyerOrder.getUid();
long orderCode = buyerOrder.getOrderCode();
//定金金额
double refundAmount = getDepositAmount(buyerOrder);
PaymentRequest paymentRequest = PaymentRequest.builder()
.uid(uid)
.refundCase(SELLER_EARNEST_MONEY)
.orderCode(orderCode)
.payLevel(OrderConstant.PAY_LEVEL_DEPOSIT)
.refundAmount(getDepositAmount(buyerOrder))
.refundAmount(refundAmount)
.refundattch(MerchantOrderAttachInfo.builder().type(SellerWalletDetail.Type.BID_DEPOSIT.getValue()).build())
.build();
val billLogEventBuilder = BillLogEvent.builder()
.buyerUid(uid)
.orderCode(orderCode)
.payType(buyerOrder.getPayment())
.refundCase(RefundCase.BID_DEPOSIT_MONEY)
.amount(BigDecimal.valueOf(refundAmount))
.payLevel(OrderConstant.PAY_LEVEL_DEPOSIT);
logger.info("[{}] refund deposit,paymentRequest:{}", orderCode, paymentRequest);
PayRefundBo payRefundBo = paymentService.refund(paymentRequest);
PayRefundBo payRefundBo = payRefundService.refund(paymentRequest, billLogEventBuilder);
logger.info("[{}] refund deposit end,result:{}", buyerOrder.getOrderCode(), payRefundBo);
}
... ...
... ... @@ -26,6 +26,7 @@ import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.model.request.TranseferCellNode;
import com.yohoufo.order.model.request.TransferMoneyRequest;
import com.yohoufo.order.service.AbstractBuyerOrderStateChanger;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.handler.RefundEarnestMoneyHandler;
import com.yohoufo.order.service.impl.PayRefundService;
import com.yohoufo.order.service.impl.TransferService;
... ... @@ -62,6 +63,9 @@ public class BuyerOrderWaitingPayCancelChanger extends AbstractBuyerOrderStateCh
@Autowired
private PayRefundService payRefundService;
@Autowired
private IPaymentService paymentService;
@Override
protected boolean beforeChange(RequestedCancelEventStatusChangeBuyerOrder statusChangeBuyerOrder) {
BuyerOrder buyerOrder = statusChangeBuyerOrder.getBuyerOrder();
... ...
... ... @@ -15,13 +15,15 @@ import com.yohoufo.common.alarm.SmsAlarmEvent;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.RefundCase;
import com.yohoufo.order.constants.ActivityTypeEnum;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.event.BillLogEvent;
import com.yohoufo.order.model.PayRefundBo;
import com.yohoufo.order.model.bo.ActivityBo;
import com.yohoufo.order.model.bo.BidOrderMetaBo;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.service.IPaymentService;
import com.yohoufo.order.service.impl.PayRefundService;
import com.yohoufo.order.service.listener.BuyerOrderChangeEvent;
import com.yohoufo.order.service.proxy.BargainProxyService;
import com.yohoufo.order.service.proxy.BaseServiceCaller;
... ... @@ -32,11 +34,13 @@ import com.yohoufo.order.service.stats.impl.SellerOrderStatsEntry;
import com.yohoufo.order.service.support.BuyerOrderMetaMapperSupport;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.RetryerUtils;
import lombok.val;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
... ... @@ -78,7 +82,7 @@ public class BuyerOrderChangeBusinessPostProcessor {
private SellerService sellerService;
@Autowired
private IPaymentService paymentService;
private PayRefundService payRefundService;
@Autowired
private StatsConfigManager<SellerOrderStatsEntry, SellerOrderStatsConfiguration> statsConfigurationManager;
... ... @@ -319,17 +323,26 @@ public class BuyerOrderChangeBusinessPostProcessor {
private void refundBidDeposit(BuyerOrder buyerOrder) {
int uid = buyerOrder.getUid();
long orderCode = buyerOrder.getOrderCode();
double refundAmount = getDepositAmount(buyerOrder);
PaymentRequest paymentRequest = PaymentRequest.builder()
.uid(uid)
.refundCase(SELLER_EARNEST_MONEY)
.orderCode(orderCode)
.payLevel(OrderConstant.PAY_LEVEL_DEPOSIT)
.refundAmount(getDepositAmount(buyerOrder))
.refundAmount(refundAmount)
.refundattch(MerchantOrderAttachInfo.builder().type(SellerWalletDetail.Type.BID_DEPOSIT.getValue()).build())
.build();
val billLogEventBuilder = BillLogEvent.builder()
.buyerUid(uid)
.orderCode(orderCode)
.payType(buyerOrder.getPayment())
.refundCase(RefundCase.BID_DEPOSIT_MONEY)
.amount(BigDecimal.valueOf(refundAmount))
.payLevel(OrderConstant.PAY_LEVEL_DEPOSIT);
logger.info("[{}] refund deposit,paymentRequest:{}", orderCode, paymentRequest);
PayRefundBo payRefundBo = paymentService.refund(paymentRequest);
PayRefundBo payRefundBo = payRefundService.refund(paymentRequest, billLogEventBuilder);
logger.info("[{}] refund deposit end,result:{}", buyerOrder.getOrderCode(), payRefundBo);
}
... ...
... ... @@ -402,10 +402,11 @@ public abstract class AbstractAlipayService extends AbstractPayService {
//收集来的错误码
//TODO 错误码需要不断完善
if (Objects.nonNull(abtee =AlipayBatchTransferErrorEnum.getByCode(errorCode))) {
String desc = formatErrorDesc(abtee, transferOrderCode);
return TransferResult.builder()
.code(501)
.payErrorCode(errorCode)
.msg(abtee.getDesc())
.msg(desc)
.build();
} else {
... ... @@ -428,6 +429,14 @@ public abstract class AbstractAlipayService extends AbstractPayService {
}
private static String formatErrorDesc(AlipayBatchTransferErrorEnum abtee, String transferOrderCode){
String desc = abtee.getDesc();
if (abtee.equals(AlipayBatchTransferErrorEnum.TRANS_NO_NOT_UNIQUE)){
desc = String.format(desc, transferOrderCode);
}
return desc;
}
public PayQueryBo transferQuery(String buyerOrderCode) {
JSONObject result = transferQueryAsOriginalResult(buyerOrderCode);
// 查询结果转换成 共通的对象
... ...
... ... @@ -132,6 +132,8 @@ public class OrderAssist {
private static final List<Integer> FLEAMARKET_CLIENT_ORDERTYPES = new ArrayList<Integer>(){
{
add(OrderAttributes.COMMON_IN_STOCK.getCode());
add(OrderAttributes.FLAW.getCode());
add(OrderAttributes.SECOND_HAND.getCode());
}
};
... ... @@ -143,6 +145,11 @@ public class OrderAssist {
return null;
}
public static List<Integer> matchOrderTypesByBusinessClient4Seller(BusinessClientEnum businessClientEnum){
return null;
}
public static String matchClientName(BusinessClientEnum businessClientEnum){
if (Objects.nonNull(businessClientEnum)
&& BusinessClientEnum.TAOBAO_FLEAMARKET_CLIENT.equals(businessClientEnum)){
... ...
package com.yohoufo.product.request;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.builder.ToStringBuilder;
public class ProductSearchReq {
... ... @@ -33,29 +34,7 @@ public class ProductSearchReq {
@Override
public String toString() {
return new ToStringBuilder(this)
.append("page", page)
.append("order", order)
.append("gender", gender)
.append("viewNum", viewNum)
.append("brand", brand)
.append("size", size)
.append("query", query)
.append("maxSort", maxSort)
.append("midSort", midSort)
.append("series", series)
.append("pool", pool)
.append("isSoonSale", isSoonSale)
.append("not_id", not_id)
.append("id", id)
.append("isIdFilter", isIdFilter)
.append("filterYearMonth",filterYearMonth)
.append("startTime",startTime)
.append("endTime",endTime)
.append("contain_yoho",containYoho)
.append("businessClient",businessClient)
.append("preSaleFlag", preSaleFlag)
.toString();
return JSONObject.toJSONString(this);
}
... ...
... ... @@ -84,7 +84,7 @@ public class ProductSearchServiceImpl implements ProductSearchService {
@Override
public JSONObject searchProductList(ProductSearchReq req) {
SearchParam searchParam = new SearchParam().buildPageSearchParam(req);
SearchParam searchParam = new SearchParam().buildPageSearchParam(req).setShowChannel(req.getBusinessClient());
/*if (req.getMidSort() == null && req.getMidSort() == null) {
searchParam.setXianYuSort(req.getBusinessClient(), configReader);
}*/
... ... @@ -107,7 +107,7 @@ public class ProductSearchServiceImpl implements ProductSearchService {
}
req.setId(info.getContainsProductIds());
req.setNot_id(info.getExcludeProductIds());
logger.info("contains {} ex {}",info.getContainsProductIds(), info.getExcludeProductIds());
//logger.info("contains {} ex {}",info.getContainsProductIds(), info.getExcludeProductIds());
searchParam = new SearchParam().buildPageSearchParam(req).setShowChannel(req.getBusinessClient());
} else if (StringUtils.equals("Y", req.getIsSoonSale())) {
url = ProductSearchConstants.SOON_SALE_PRODUCT_LIST_URL;
... ... @@ -115,14 +115,12 @@ public class ProductSearchServiceImpl implements ProductSearchService {
url = ProductSearchConstants.FAVORITE_PRODUCT_LIST_URL;
} else if (StringUtils.isNotBlank(req.getQuery())
|| (req.getSearchType() != null && req.getSearchType() == 6)) {
searchParam.setShowChannel(req.getBusinessClient());
url = ProductSearchConstants.PRODUCT_SEARCH_QUERY_URL;
} else if (StringUtils.isNotBlank(req.getPool())
|| (req.getSearchType() != null && (req.getSearchType() == 0 || req.getSearchType() == 1))) {
searchParam.setShowChannel(req.getBusinessClient());
url = ProductSearchConstants.PRODUCT_POOL_URL;
}
JSONObject data = searchAssistService.search(searchParam.getParam(), url);
// 将图片的相对路径转成绝对路径
if (null != data) {
... ... @@ -334,7 +332,7 @@ public class ProductSearchServiceImpl implements ProductSearchService {
Product product = productHelpService.selectByIdCache(productId);
if (product != null) {
ProductSearchReq req = new ProductSearchReq().setNot_id(productId + "").setMidSort(product.getMidSortId() + "").setBrand(product.getBrandId() + "").setQuery(product.getProductName());
SearchParam searchParam = new SearchParam().buildSearchParam(req);
SearchParam searchParam = new SearchParam().buildSearchParam(req).setShowChannel(businessClient);
JSONObject data = searchAssistService.search(searchParam.getParam(), ProductSearchConstants.PRODUCT_RECOMMEND_LIST_URL);
if(data != null && !CollectionUtils.isEmpty(data.getJSONArray("product_list"))) {
... ... @@ -564,6 +562,17 @@ public class ProductSearchServiceImpl implements ProductSearchService {
private CouponInfo getCouponInfo(String token) {
ApiResponse resp = ufoServiceCaller.call("ufo.coupons.getProductIds", ApiResponse.class, token);
return (CouponInfo) resp.getData();
CouponInfo couponInfo = (CouponInfo) resp.getData();
// 如果券包含的商品列表、排除的商品列表太多,则调用搜索的时候会报参数链接太长,所以这里进行截取
if (StringUtils.isNotEmpty(couponInfo.getContainsProductIds())
&& couponInfo.getContainsProductIds().length() > 1800) {
couponInfo.setContainsProductIds(couponInfo.getContainsProductIds().substring(0, 1799));
}
if (StringUtils.isNotEmpty(couponInfo.getExcludeProductIds())
&& couponInfo.getExcludeProductIds().length() > 1800) {
couponInfo.setExcludeProductIds(couponInfo.getExcludeProductIds().substring(0, 1799));
}
return couponInfo;
}
}
... ...
package com.yohoufo.product.service.impl;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.function.Predicate;
... ... @@ -74,24 +71,30 @@ public class StoragePriceService {
* @return
*/
public List<StoragePrice> setStoragePriceCache(Integer productId) {
List<StoragePrice> sizePriceCacheList = storagePriceMapper.selectInStockLeastPByProductId(productId, StorageTypeEnum.NORMAL.getType());
List<StoragePrice> sizePriceCacheList = storagePriceMapper.selectLeastPByProductId(productId, StorageTypeEnum.NORMAL.getType());
productCacheService.setCacheByString(UfoProductCacheKeyEnum.STORAGE_PRICE_IN_STOCK_INFO_KEY, sizePriceCacheList, productId);
return sizePriceCacheList;
}
public List<StoragePrice> setSecondStoragePriceCache(Integer productId) {
List<StoragePrice> sizePriceCacheList = storagePriceMapper.selectInStockLeastPByProductId(productId, StorageTypeEnum.DEFECT.getType());
if(CollectionUtils.isEmpty(sizePriceCacheList)) {
sizePriceCacheList = Lists.newArrayList();
List<StoragePrice> defectPriceCacheList = storagePriceMapper.selectLeastPByProductId(productId, StorageTypeEnum.DEFECT.getType());
List<StoragePrice> secondSizePriceCacheList = storagePriceMapper.selectLeastPByProductId(productId, StorageTypeEnum.SECOND.getType());
List<StoragePrice> sizePriceCacheList = new ArrayList<>();
if(CollectionUtils.isNotEmpty(defectPriceCacheList)) {
sizePriceCacheList.addAll(defectPriceCacheList);
}
List<StoragePrice> secondSizePriceCacheList = storagePriceMapper.selectInStockLeastPByProductId(productId, StorageTypeEnum.SECOND.getType());
if(CollectionUtils.isEmpty(secondSizePriceCacheList)) {
productCacheService.setCacheByString(UfoProductCacheKeyEnum.STORAGE_PRICE_SECOND_INFO_KEY, sizePriceCacheList, productId);
return sizePriceCacheList;
if(CollectionUtils.isNotEmpty(secondSizePriceCacheList)) {
sizePriceCacheList.addAll(secondSizePriceCacheList);
}
sizePriceCacheList.addAll(secondSizePriceCacheList);
if(CollectionUtils.isEmpty(sizePriceCacheList)) {
return Lists.newArrayList();
}
Map<Integer, List<StoragePrice>> storagePriceMap = sizePriceCacheList.stream().collect(Collectors.groupingBy(StoragePrice::getStorageId));
List<StoragePrice> resultStoragePriceList = Lists.newArrayList();
for(Entry<Integer, List<StoragePrice>> entry : storagePriceMap.entrySet()) {
... ... @@ -103,8 +106,7 @@ public class StoragePriceService {
Collections.sort(entry.getValue(), new Comparator<StoragePrice>() {
@Override
public int compare(StoragePrice o1, StoragePrice o2) {
//升序
return o1.getPrice().compareTo(o2.getPrice());
return o1.getPrice().compareTo(o2.getPrice()); //升序
}
});
... ... @@ -163,15 +165,14 @@ public class StoragePriceService {
Map<Integer, StoragePrice> storagePriceMap = selectSecondLeastP(productId);
goodsSizes.stream().forEach(item -> {
StoragePrice storagePrice = storagePriceMap.get(item.getId());//二手
if (null != storagePrice && null != item.getSuggestHighPrice()
&& storagePrice.getPrice().compareTo(item.getSuggestHighPrice()) > 0) { //高于建议价,不展示skup
item.setStorageNum(0);
item.setSkup(0);
if (null == storagePrice) {
item.setSecondHandStorageNum(0);
item.setSecondHandSkup(0);
} else {
item.setSecondHandLeastPrice(storagePrice == null ? null : storagePrice.getPrice());
item.setStatus(storagePrice == null ? null : storagePrice.getStatus());
item.setSkup(storagePrice == null ? 0 : storagePrice.getSkup());
item.setStorageNum(item.getSkup() == null || item.getSkup() == 0 ? 0 : 1);
item.setSecondHandLeastPrice(storagePrice.getPrice());
item.setSecondHandSkup(storagePrice.getSkup());
item.setSecondHandStorageNum(1);
item.setSecondHandStatus(1);
}
});
}
... ...
... ... @@ -54,6 +54,7 @@ public class ConfigTypeController {
/**
* <p>修改配置信息</p>
* 内部调用
*/
@ApiOperation(name = "ufo.resource.updateConfigTypeContent", desc = "修改配置信息")
@RequestMapping(params = "method=ufo.resource.updateConfigTypeContent")
... ...
... ... @@ -52,8 +52,13 @@ public class ResourcesController {
request.getClientType());
return new ApiResponse.ApiResponseBuilder().data(data).code(200).message("resources data").build();
}
/**
* 内部调用
* @param req
* @return
*/
@ApiOperation(name = "clearResourceCache", desc="资源位清除缓存")
@RequestMapping(value = "/clearResourceCache")
@IgnoreSession
... ...
... ... @@ -25,6 +25,8 @@ public class ResourcesGoodsPoolController {
private ResourcesGoodsPoolService resourcesGoodsPoolService;
/**
* 商品模块 内部调用
*
* <p>获取配置列表,返回map</p>
*
*/
... ...
... ... @@ -535,12 +535,13 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${yoho.logs.basedir}/${ufo.gateway.env.namespace}/archived/mq-consumer.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days' worth of history -->
<maxHistory>${yoho.logs.maxHistory}</maxHistory>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
... ... @@ -551,12 +552,13 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${yoho.logs.basedir}/${ufo.gateway.env.namespace}/archived/mq-producer.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days' worth of history -->
<maxHistory>${yoho.logs.maxHistory}</maxHistory>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
... ... @@ -567,12 +569,13 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${yoho.logs.basedir}/${ufo.gateway.env.namespace}/archived/seller-order.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days' worth of history -->
<maxHistory>${yoho.logs.maxHistory}</maxHistory>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
... ... @@ -583,17 +586,20 @@
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${yoho.logs.basedir}/${ufo.gateway.env.namespace}/archived/buyer-order.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days' worth of history -->
<maxHistory>${yoho.logs.maxHistory}</maxHistory>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>${yoho.logs.maxFileSize}</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<!-- 数据库操作日志 -->
<logger name="java.sql.PreparedStatement" value="${yoho.logs.level.core}"/>
<logger name="java.sql.Connection" value="${yoho.logs.level.core}"/>
... ...