Authored by chenchao

fix serialize & deserialize issue

package com.yohoufo.order.charge.model;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
import lombok.*;
/**
* Created by jiexiang.wu on 2018/11/19.
... ... @@ -10,6 +8,7 @@ import lombok.ToString;
@Data
@ToString
@Builder
@NoArgsConstructor@AllArgsConstructor
public class CouponPayResult {
/**
* 优惠券码
... ...
package com.yohoufo.order.charge.model;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.*;
import org.apache.commons.collections.CollectionUtils;
import java.util.Collections;
... ... @@ -16,6 +13,8 @@ import java.util.Optional;
*/
@ToString
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CouponPayResultList {
//有可用券张数,不代表就用券
... ...
... ... @@ -255,7 +255,7 @@ public class ActionStatusHold {
*/
static List<Integer> SellerCanModifyAddressBySelf = Lists.newArrayList(OrderStatus.HAS_PAYED.getCode());
static List<Integer> SELLER_COMPUTE_BY_BUYERORDER = Lists.newArrayList(OrderStatus.HAS_PAYED.getCode());
}
public static List<Integer> getUnfinishedOrderStatusCode(){
... ... @@ -305,4 +305,8 @@ public class ActionStatusHold {
public static boolean sellerCanModifyAddressBySelf(Integer buyerOrderStatus){
return SellerASH.SellerCanModifyAddressBySelf.contains(buyerOrderStatus);
}
public static boolean sellerCanUseCoupon(Integer buyerOrderStatus){
return SellerASH.SELLER_COMPUTE_BY_BUYERORDER.contains(buyerOrderStatus);
}
}
... ...
... ... @@ -6,11 +6,8 @@ import com.yohobuy.ufo.model.order.constants.SkupType;
import com.yohobuy.ufo.model.order.req.*;
import com.yohobuy.ufo.model.order.resp.*;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.order.annotation.BlackUserType;
import com.yohoufo.order.common.BlackTypeEnum;
import com.yohoufo.order.model.request.OrderListRequest;
... ... @@ -27,7 +24,6 @@ import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
... ... @@ -590,7 +586,7 @@ public class SellerOrderController {
}
@RequestMapping(params = "method=ufo.sellerOrder.computeByBuyerOrder")
@RequestMapping(params = "method=ufo.sellerOrder.computeWithCoupon")
@ResponseBody
public ApiResponse computeWhenSellerDeliver(@RequestParam(name = "uid", required = true)int uid,
@RequestParam("orderCode") long orderCode,
... ... @@ -604,8 +600,8 @@ public class SellerOrderController {
.autoRecommended(autoRecommended)
.build();
logger.info("in ufo.sellerOrder.computeByBuyerOrder, req {}", req);
SoldPrdComputeBo computeBo = sellerOrderService.computeByBuyerOrder(req);
logger.info("in ufo.sellerOrder.computeWithCoupon, req {}", req);
SoldPrdComputeBo computeBo = sellerOrderService.computeWithCoupon(req);
return new ApiResponse.ApiResponseBuilder().code(200).data(computeBo).message("发货算费成功").build();
}
... ...
package com.yohoufo.order.model.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.bo.SellerCouponSimpleBo;
import com.yohobuy.ufo.model.order.dto.PlatformFeeDto;
... ... @@ -31,18 +32,16 @@ public class SellerOrderComputeResult {
*/
BigDecimal couponCutAmount;
/**
* 使用的券
*/
private transient List<SellerCouponSimpleBo> usedCoupons;
/**
* 可以使用的券列表 selectCoupon阶段使用
*/
@JSONField(serialize = false, deserialize=false)
private transient List<CouponMatchResult> usableCouponMatchResults;
/**
* 优惠券支付结果,可以多个
*/
@JSONField(serialize = false, deserialize = false)
private transient CouponPayResultList couponPayResultList;
/**
... ...
... ... @@ -932,35 +932,42 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
public SoldPrdComputeBo computeByBuyerOrder(SellerFeeComputeWithOrderReq req){
log.info("in computeByBuyerOrder {}",req);
public SoldPrdComputeBo computeWithCoupon(SellerFeeComputeWithOrderReq req){
log.info("in computeWithCoupon {}",req);
int uid = req.getUid();
if (uid<1){
log.warn("computeByBuyerOrder uid error,{}", req);
log.warn("computeWithCoupon uid error,{}", req);
throw new UfoServiceException(401, "用户信息不正确");
}
Long orderCode = req.getOrderCode();
if (Objects.isNull(orderCode)){
log.warn("computeByBuyerOrder orderCode error,{}", req);
log.warn("computeWithCoupon orderCode error,{}", req);
throw new UfoServiceException(401, "订单号不正确");
}
BuyerOrderAssistant.PreparedData preparedData = buyerOrderAssistant.prepare(orderCode);
BuyerOrder pbo = preparedData.getBuyerOrder();
if (Objects.isNull(pbo)){
log.warn("computeByBuyerOrder can not find order in DB,{}", req);
log.warn("computeWithCoupon can not find order in DB,{}", req);
throw new UfoServiceException(401, "订单号不正确");
}
if (!pbo.getSellerUid().equals(uid)){
log.warn("computeByBuyerOrder can not find seller self order in DB,{}", req);
log.warn("computeWithCoupon can not find seller self order in DB,{}", req);
throw new UfoServiceException(401, "非你所属的订单");
}
Integer status;
if (!ActionStatusHold.sellerCanUseCoupon(status=pbo.getStatus())){
log.warn("computeWithCoupon buyer order status not support,{} status {}", req,status);
throw new UfoServiceException(401, "订单当前状态不能用券");
}
SellerOrderGoods psog = preparedData.getSellerOrderGoods();
SellerOrderComputeResult computeResult = sellerFeeService.getSellerOrderComputeResult(psog.getUid(), psog.getId());
//autoRecommended
//todo next version maybe set autoRecommended
boolean autoRecommended = "Y".equalsIgnoreCase(req.getAutoRecommended());
//
SellerOrderChargeParam chargeParam = SellerOrderChargeParam.builder()
... ... @@ -971,7 +978,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
sorboc.setBusinessClient(req.getBusinessClient());
sorboc.setCouponCode(req.getCouponCode());
sorboc.setSkupInfo(psog);
sorboc.setAutoRecommended(autoRecommended);
//sorboc.setAutoRecommended(autoRecommended);
sorboc.setChargeParam(chargeParam);
sorboc.setSellerOrderComputeResult(computeResult);
... ...
... ... @@ -93,6 +93,7 @@ public class SellerFeeService {
public SellerOrderComputeResult getSellerOrderComputeResult(int uid, int skup){
try {
SellerOrderMeta meta = somMapper.selectByMetaKey(uid, skup, MetaKey.SELLER_FEE);
logger.info("get SellerOrderComputeResult uid {} skup {} result {}", uid, skup, meta.getMetaValue());
SellerOrderComputeResult computeResult = JSONObject.parseObject(meta.getMetaValue(), SellerOrderComputeResult.class);
return computeResult;
}catch (Exception ex){
... ...