Authored by sailing-PC\sailing

optimized

... ... @@ -64,20 +64,12 @@ public class SellerOrderController {
public ApiResponse publishPrd(@RequestParam(name = "uid", required = true)int uid,
@RequestParam(name = "storage_id", required = true)int storage_id,
@RequestParam(name="price", required = true)String price,
@RequestParam(name="consignee")String consignee,
@RequestParam(name="address_id")Integer address_id,
@RequestParam(name="address")String address,
@RequestParam(name="zipCode")String zipCode,
@RequestParam(name="phone")String phone) throws GatewayException {
@RequestParam(name="address_id")Integer address_id) throws GatewayException {
SellerOrderSubmitReq req = SellerOrderSubmitReq.builder()
.uid(uid)
.storageId(storage_id)
.price(price)
.addressId(address_id)
.consignee(consignee)
.address(address)
.zipCode(zipCode)
.phone(phone)
.build();
logger.info("in ufo.sellerOrder.publishPrd, req {}", req);
Long orderCode = sellerOrderService.publishPrd(req);
... ...
package com.yohoufo.order.service;
import com.yoho.core.dal.datasource.annotation.Database;
import com.yoho.service.model.response.UserAddressRspBO;
import com.yohobuy.ufo.model.order.bo.PlatformFee;
import com.yohobuy.ufo.model.order.bo.SoldPrdComputeBo;
import com.yohobuy.ufo.model.order.req.SellerOrderComputeReq;
... ... @@ -18,6 +19,7 @@ import com.yohoufo.order.model.dto.PlatformFeeDto;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
import com.yohoufo.order.service.handler.SellerOrderSubmitHandler;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.product.model.GoodsSize;
import com.yohoufo.product.response.StorageDataResp;
... ... @@ -40,22 +42,21 @@ public class SellerOrderService {
@Autowired
private SellerOrderMapper sellerOrderMapper;
@Autowired
private UfoServiceCaller ufoServiceCaller;
@Autowired
private SellerOrderComputeHandler computeHandler;
@Autowired
private OrderCodeGenerator orderCodeGenerator;
@Autowired
private SellerOrderSubmitHandler orderSubmitHandler;
@Autowired
private UserProxyService userProxyService;
public SoldPrdComputeBo computePublishPrd(SellerOrderComputeReq req) throws GatewayException {
... ... @@ -197,10 +198,13 @@ public class SellerOrderService {
//the address of send back 2 seller
AddressInfo backAddress = new AddressInfo();
backAddress.setAddress_id(req.getAddressId());
backAddress.setAddress(req.getAddress());
backAddress.setConsignee(req.getConsignee());
backAddress.setPhone(req.getPhone());
backAddress.setZipCode(req.getZipCode());
//
UserAddressRspBO addressRspBO = userProxyService.getAddressInfo(uid, req.getAddressId());
backAddress.setAddress(addressRspBO.getAddress());
backAddress.setConsignee(addressRspBO.getUid());
backAddress.setPhone(addressRspBO.getPhone());
backAddress.setZipCode(addressRspBO.getZipCode());
//
SellerOrderContext context = new SellerOrderContext();
... ...
... ... @@ -17,6 +17,7 @@ import com.yohoufo.order.response.OrderSubmitResponse;
import com.yohoufo.order.response.ShoppingPaymentResponse;
import com.yohoufo.order.service.IOrdeCreationService;
import com.yohoufo.order.service.IShoppingService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.support.ShoppingSupport;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import org.apache.commons.lang3.StringUtils;
... ... @@ -49,6 +50,10 @@ public class ShoppingServiceImpl implements IShoppingService {
@Autowired
ServiceCaller serviceCaller;
@Autowired
private UserProxyService userProxyService;
/**
* 结算页数据
* @param request
... ... @@ -124,7 +129,7 @@ public class ShoppingServiceImpl implements IShoppingService {
// 生成订单号
long orderCode = orderCodeGenerator.generate(OrderCodeType.BUYER_TYPE);
UserAddressRspBO addressInfo = getAddressInfo(shoppingRequest, addressId);
UserAddressRspBO addressInfo = userProxyService.getAddressInfo(shoppingRequest.getUid(), addressId);
// 减库存,skup更新成不可售,入库
BigDecimal shipFee = new BigDecimal(OrderConstant.DELIVERY_WAY_SF_COST);
... ... @@ -149,27 +154,7 @@ public class ShoppingServiceImpl implements IShoppingService {
}
/**
* 获取用户信息
* @param shoppingRequest
* @param addressId
* @return
*/
private UserAddressRspBO getAddressInfo(ShoppingRequest shoppingRequest, int addressId) {
// 收货地址信息, 入口参数:uid, address_id
UserAddressReqBO userAddressReqBO = new UserAddressReqBO();
userAddressReqBO.setUid(shoppingRequest.getUid());
userAddressReqBO.setId(addressId);
//超时,使用默认地址,后续需要手动补充地址
UserAddressRspBO defaultResponse = new UserAddressRspBO();
defaultResponse.setAreaCode(OrderConstant.EMPTY_ADDRESS_CODE);
defaultResponse.setId(String.valueOf(addressId));
UserAddressRspBO userAddressBO = serviceCaller.asyncCall("users.getAddress", userAddressReqBO,
UserAddressRspBO.class, defaultResponse).get(500, TimeUnit.MILLISECONDS);
return userAddressBO;
}
}
... ...
package com.yohoufo.order.service.proxy;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.service.model.request.UserAddressReqBO;
import com.yoho.service.model.response.UserAddressRspBO;
import com.yohoufo.order.constants.OrderConstant;
import com.yohoufo.order.request.ShoppingRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.concurrent.TimeUnit;
/**
* Created by chenchao on 2018/9/18.
*/
@Service
public class UserProxyService {
@Autowired
ServiceCaller serviceCaller;
/**
* 获取用户信息
* @param uid
* @param addressId
* @return
*/
public UserAddressRspBO getAddressInfo(int uid, int addressId) {
// 收货地址信息, 入口参数:uid, address_id
UserAddressReqBO userAddressReqBO = new UserAddressReqBO();
userAddressReqBO.setUid(uid);
userAddressReqBO.setId(addressId);
//超时,使用默认地址,后续需要手动补充地址
UserAddressRspBO defaultResponse = new UserAddressRspBO();
defaultResponse.setAreaCode(OrderConstant.EMPTY_ADDRESS_CODE);
defaultResponse.setId(String.valueOf(addressId));
UserAddressRspBO userAddressBO = serviceCaller.asyncCall("users.getAddress", userAddressReqBO,
UserAddressRspBO.class, defaultResponse).get(500, TimeUnit.MILLISECONDS);
return userAddressBO;
}
}
... ...