Authored by sailing-PC\sailing

Merge branch 'master' into dev

# Conflicts:
#	order/src/main/java/com/yohoufo/order/controller/BuyerOrderController.java
Showing 19 changed files with 423 additions and 149 deletions
... ... @@ -29,4 +29,30 @@ public class AddressUtil {
return -1;
}
/**
* 加密地址
* @param str
* @return
*/
public static String getEncryptStr(String str){
String encryptStr = str;
try{
encryptStr = AES.encrypt(DynamicPropertyFactory.getInstance().getStringProperty("password.aes.key", "yoho9646yoho9646").get(), str);
}catch (Exception e){
logger.error("getEncryptStr failed. str is {}, e is {}", str, e);
}
logger.info("getEncryptStr, str is {}, encryptStr is {}", str, encryptStr);
return encryptStr;
}
public static void main(String[] args){
System.out.println(getEncryptStr("2395724"));
}
}
... ...
... ... @@ -11,7 +11,7 @@ public class BuyerOrder {
private Integer sellerUid;
private Byte clientType;
private Integer clientType;
private Byte payment;
... ... @@ -29,10 +29,12 @@ public class BuyerOrder {
private Integer updateTime;
private Byte orderStatus;
private String channelNo;
private Integer buyerOrderStatus;
private Integer sellerOrderStatus;
public Integer getId() {
return id;
}
... ... @@ -65,11 +67,11 @@ public class BuyerOrder {
this.sellerUid = sellerUid;
}
public Byte getClientType() {
public Integer getClientType() {
return clientType;
}
public void setClientType(Byte clientType) {
public void setClientType(Integer clientType) {
this.clientType = clientType;
}
... ... @@ -137,12 +139,21 @@ public class BuyerOrder {
this.updateTime = updateTime;
}
public Byte getOrderStatus() {
return orderStatus;
public Integer getBuyerOrderStatus() {
return buyerOrderStatus;
}
public void setBuyerOrderStatus(Integer buyerOrderStatus) {
this.buyerOrderStatus = buyerOrderStatus;
}
public Integer getSellerOrderStatus() {
return sellerOrderStatus;
}
public void setOrderStatus(Byte orderStatus) {
this.orderStatus = orderStatus;
public void setSellerOrderStatus(Integer sellerOrderStatus) {
this.sellerOrderStatus = sellerOrderStatus;
}
public String getChannelNo() {
... ...
... ... @@ -6,7 +6,7 @@
<result column="uid" jdbcType="INTEGER" property="uid" />
<result column="order_code" jdbcType="BIGINT" property="orderCode" />
<result column="seller_uid" jdbcType="INTEGER" property="sellerUid" />
<result column="client_type" jdbcType="TINYINT" property="clientType" />
<result column="client_type" jdbcType="INTEGER" property="clientType" />
<result column="payment" jdbcType="TINYINT" property="payment" />
<result column="payment_type" jdbcType="TINYINT" property="paymentType" />
<result column="is_cancel" jdbcType="TINYINT" property="isCancel" />
... ... @@ -15,12 +15,13 @@
<result column="status" jdbcType="TINYINT" property="status" />
<result column="create_time" jdbcType="INTEGER" property="createTime" />
<result column="update_time" jdbcType="INTEGER" property="updateTime" />
<result column="order_status" jdbcType="TINYINT" property="orderStatus" />
<result column="buyer_order_status" jdbcType="INTEGER" property="buyerOrderStatus" />
<result column="seller_order_status" jdbcType="INTEGER" property="sellerOrderStatus" />
<result column="channel_no" jdbcType="VARCHAR" property="channelNo" />
</resultMap>
<sql id="Base_Column_List">
id, uid, order_code, seller_uid, client_type, payment, payment_type, is_cancel, amount,
ship_fee, status, create_time, update_time, order_status, channel_no
ship_fee, status, create_time, update_time, buyer_order_status, seller_order_status, channel_no
</sql>
... ... @@ -39,7 +40,7 @@
from buyer_order
where
uid = #{uid,jdbcType=INTEGER}
and order_status = 1
and buyer_order_status = 1
<if test="status != null">
and status in
<foreach item="item" index="index" collection="status" open="(" separator="," close=")">
... ... @@ -55,7 +56,7 @@
from buyer_order
where
uid = #{uid,jdbcType=INTEGER}
and order_status = 1
and buyer_order_status = 1
<if test="status != null">
and status in
<foreach item="item" index="index" collection="status" open="(" separator="," close=")">
... ... @@ -74,7 +75,7 @@
from buyer_order
where order_code = #{orderCode,jdbcType=BIGINT}
and uid = #{uid,jdbcType=INTEGER}
and order_status = 1
and buyer_order_status = 1
limit 1
</select>
... ... @@ -83,17 +84,18 @@
delete from buyer_order
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrder" useGeneratedKeys="true">
insert into buyer_order (uid, order_code, seller_uid,
client_type, payment, payment_type,
is_cancel, amount, ship_fee,
status, create_time, update_time,
order_status, channel_no)
buyer_order_status, seller_order_status, channel_no)
values (#{uid,jdbcType=INTEGER}, #{orderCode,jdbcType=BIGINT}, #{sellerUid,jdbcType=INTEGER},
#{clientType,jdbcType=TINYINT}, #{payment,jdbcType=TINYINT}, #{paymentType,jdbcType=TINYINT},
#{clientType,jdbcType=INTEGER}, #{payment,jdbcType=TINYINT}, #{paymentType,jdbcType=TINYINT},
#{isCancel,jdbcType=TINYINT}, #{amount,jdbcType=DECIMAL}, #{shipFee,jdbcType=DECIMAL},
#{status,jdbcType=TINYINT}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
#{orderStatus,jdbcType=TINYINT}, #{channelNo,jdbcType=VARCHAR})
#{buyerOrderStatus,jdbcType=INTEGER}, #{sellerOrderStatus,jdbcType=INTEGER}, #{channelNo,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yohoufo.dal.order.model.BuyerOrder" useGeneratedKeys="true">
insert into buyer_order
... ... @@ -134,8 +136,11 @@
<if test="updateTime != null">
update_time,
</if>
<if test="orderStatus != null">
order_status,
<if test="buyerOrderStatus != null">
buyer_order_status,
</if>
<if test="sellerOrderStatus != null">
seller_order_status,
</if>
<if test="channelNo != null">
channel_no,
... ... @@ -178,8 +183,11 @@
<if test="updateTime != null">
#{updateTime,jdbcType=INTEGER},
</if>
<if test="orderStatus != null">
#{orderStatus,jdbcType=TINYINT},
<if test="buyerOrderStatus != null">
#{buyerOrderStatus,jdbcType=INTEGER},
</if>
<if test="sellerOrderStatus != null">
#{sellerOrderStatus,jdbcType=INTEGER},
</if>
<if test="channelNo != null">
#{channelNo,jdbcType=VARCHAR},
... ... @@ -225,8 +233,11 @@
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=INTEGER},
</if>
<if test="orderStatus != null">
order_status = #{orderStatus,jdbcType=TINYINT},
<if test="buyerOrderStatus != null">
buyer_order_status = #{buyerOrderStatus,jdbcType=INTEGER},
</if>
<if test="sellerOrderStatus != null">
seller_order_status = #{sellerOrderStatus,jdbcType=INTEGER},
</if>
<if test="channelNo != null">
channel_no = #{channelNo,jdbcType=VARCHAR},
... ... @@ -248,7 +259,8 @@
status = #{status,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
order_status = #{orderStatus,jdbcType=TINYINT},
buyer_order_status = #{buyerOrderStatus,jdbcType=INTEGER},
seller_order_status = #{sellerOrderStatus,jdbcType=INTEGER},
channel_no = #{channelNo,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
... ...
... ... @@ -59,7 +59,7 @@
</select>
<update id="addStorageNum">
update storage set storage_num = storage_num + #{storageNum,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
update_time = unix_timestamp()
where id = #{storageId,jdbcType=INTEGER}
</update>
... ...
... ... @@ -61,12 +61,12 @@
</select>
<update id="saleSkup" parameterType="java.lang.Integer">
update storage_price set status = 2,
update_time = unix_timestamp(),
update_time = unix_timestamp()
where skup = #{skup,jdbcType=INTEGER} and status = 1
</update>
<update id="cancelSaleSkup" parameterType="java.lang.Integer">
update storage_price set status = 1,
update_time = unix_timestamp(),
update_time = unix_timestamp()
where skup = #{skup,jdbcType=INTEGER} and status = 2
</update>
<select id="selectLeastPrice" resultMap="BaseResultMap">
... ...
package com.yohoufo.order.common;
public enum ClientType {
PC(1, "pc"),
IPHONE(3, "iphone"),
ANDROID(4, "android"),
IPAD(5, "ipad"),
H5(6, "h5");
int code;
String value;
ClientType(int code, String value) {
this.code = code;
this.value = value;
}
public int getCode() {
return code;
}
/**
*
* @param value
* @return
*/
public static int getClientType(String value){
for(ClientType v : values()){
if(v.value.equals(value)){
return v.getCode();
}
}
return -1;
}
}
... ...
... ... @@ -2,8 +2,8 @@ package com.yohoufo.order.common;
public enum Payment {
ALIPAY(1, "trade.precreate", "支付宝"),
WECHAT(2, "wx.unifiedOrder", "微信");
ALIPAY(2, "trade.precreate", "支付宝"),
WECHAT(1, "wx.unifiedOrder", "微信");
int code;
... ...
... ... @@ -22,7 +22,7 @@ public interface OrderConstant {
String MONEY_SIGN = "¥";
String PLUS_SIGN = "+";
String PLUS_SIGN = "+ ";
String DAMAGES_DESC = "如卖家原因导致交易失败,您将获得赔偿金";
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.controller;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.request.OrderListRequest;
import com.yohoufo.order.request.OrderRequest;
import com.yohoufo.order.response.OrderDetailInfo;
import com.yohoufo.order.response.OrderListInfoRsp;
import com.yohoufo.order.service.IBuyerOrderService;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -33,6 +34,7 @@ public class BuyerOrderController {
@ResponseBody
public ApiResponse getOrderList(@RequestParam("type") int type,
@RequestParam("uid") int uid,
@RequestParam("tabType") String tabType,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
... ... @@ -41,6 +43,7 @@ public class BuyerOrderController {
.type(type)
.page(page)
.limit(limit)
.tabType(tabType)
.build();
OrderListInfoRsp orderListInfoRsp = buyerOrderService.getOrderList(orderListRequest);
... ... @@ -65,6 +68,46 @@ public class BuyerOrderController {
.orderCode(orderCode)
.tabType(tabType)
.build();
return null;
OrderDetailInfo orderDetailInfo = buyerOrderService.getOrderDetail(orderRequest);
return new ApiResponse.ApiResponseBuilder().code(200).data(orderDetailInfo).message("订单详情").build();
}
/**
* 取消订单
*/
@RequestMapping(params = "method=app.buyer.cancel")
@ResponseBody
public ApiResponse cancel(@RequestParam("orderCode") long orderCode,
@RequestParam("uid") int uid) {
OrderRequest orderRequest = OrderRequest.builder()
.uid(uid)
.orderCode(orderCode)
.build();
buyerOrderService.cancel(orderRequest);
return new ApiResponse.ApiResponseBuilder().code(200).message("取消").build();
}
/**
* 确认收货
* @param orderCode
* @param uid
* @return
*/
@RequestMapping(params = "method=app.buyer.confirm")
@ResponseBody
public ApiResponse confirm(@RequestParam("orderCode") long orderCode,
@RequestParam("uid") int uid) {
OrderRequest orderRequest = OrderRequest.builder()
.uid(uid)
.orderCode(orderCode)
.build();
buyerOrderService.confirm(orderRequest);
return new ApiResponse.ApiResponseBuilder().code(200).message("取消").build();
}
}
... ...
... ... @@ -40,7 +40,7 @@ public class ShoppingController {
@RequestParam(name = "skup") int skup,
@RequestParam(name = "channelNo") String channelNo,
@RequestParam(name = "addressId") String addressId,
@RequestParam(name = "clientType") String clientType){
@RequestParam(name = "clientType", required = false) String clientType){
ShoppingRequest request = ShoppingRequest.builder().uid(uid).skup(skup).channelNo(channelNo).clientType(clientType).addressId(addressId).build();
OrderSubmitResponse paymentResponse = buyerOrderService.submit(request);
... ... @@ -54,4 +54,6 @@ public class ShoppingController {
}
... ...
... ... @@ -56,7 +56,7 @@ public class PaymentResponse {
private String deliveryWayName;
private int deliveryWayCost;
private String deliveryWayCost;
}
... ...
package com.yohoufo.order.service;
import com.yohoufo.order.request.OrderListRequest;
import com.yohoufo.order.request.OrderRequest;
import com.yohoufo.order.response.OrderDetailInfo;
import com.yohoufo.order.response.OrderListInfoRsp;
public interface IBuyerOrderService {
... ... @@ -11,5 +13,27 @@ public interface IBuyerOrderService {
* @param request
* @return
*/
public OrderListInfoRsp getOrderList(OrderListRequest request);
OrderListInfoRsp getOrderList(OrderListRequest request);
/**
* 获取订单详情
* @param orderRequest
* @return
*/
OrderDetailInfo getOrderDetail(OrderRequest orderRequest);
/**
* 取消订单
* @param orderRequest
*/
public void cancel(OrderRequest orderRequest);
/**
* 提交订单
* @param orderRequest
*/
public void confirm(OrderRequest orderRequest);
}
... ...
... ... @@ -2,11 +2,11 @@ package com.yohoufo.order.service;
import com.yohoufo.order.model.dto.OrderBuilder;
public interface IOrdeCreationService {
public interface ISubmitOrderService {
/**
* 创建订单
* @param orderBuilder
*/
public void create(OrderBuilder orderBuilder);
public void doSumbitOrder(OrderBuilder orderBuilder);
}
... ...
... ... @@ -49,6 +49,73 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
BuyerOrderMetaMapper buyerOrderMetaMapper;
/**
* 提交订单
* @param orderRequest
*/
public void confirm(OrderRequest orderRequest){
// 参数检查 ![待收货] 不合法
checkStatusAndRequest(orderRequest, OrderStatus.WAITING_RECEIVE);
// TODO 更新状态为待收货
}
/**
* 取消订单
* @param orderRequest
*/
public void cancel(OrderRequest orderRequest){
// 状态 ![待付款] 不合法
checkStatusAndRequest(orderRequest, OrderStatus.WAITING_PAY);
// TODO
// 更新订单状态
// 更新skup的状态[可售] 卖家订单为[出售中]
// 减product skup的库存
}
/**
*
* @param orderRequest
* @param orderStatusEx
*/
private void checkStatusAndRequest(OrderRequest orderRequest, OrderStatus orderStatusEx ) {
// 参数检查
if (orderRequest.getUid() < 0
|| orderRequest.getOrderCode() < 0){
logger.warn("check uid or orderCode empty");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
// 订单存在 & 待付款的状态
// 查询订单状态
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderRequest.getOrderCode(), orderRequest.getUid());
if (buyerOrder == null){
logger.warn("check orderCode exist, uid is {}, orderCode is {}",
orderRequest.getUid(), orderRequest.getOrderCode() );
throw new ServiceException(ServiceError.ORDER_NULL);
}
// 检查 订单状态
int status = buyerOrder.getStatus() == null ? -1 : buyerOrder.getStatus().intValue();
OrderStatus orderStatus = OrderStatus.getOrderStatus(status);
if (orderStatus == null || orderStatus.getCode() != orderStatusEx.getCode()){
logger.warn("check status invalidate, uid is {}, orderCode is {}, status is {}",
orderRequest.getUid(), orderRequest.getOrderCode(), buyerOrder.getStatus());
throw new ServiceException(ServiceError.ORDER_STATUS_INVALIDATE);
}
}
/**
* 获取订单详情
* @param orderRequest
* @return
*/
public OrderDetailInfo getOrderDetail(OrderRequest orderRequest){
// 参数检查
... ...
... ... @@ -76,6 +76,36 @@ public class PaymentServiceImpl implements IPaymentService {
@Autowired
OrderCodeGenerator orderCodeGenerator;
public void payConfirm(PaymentRequest request){
//
}
/**
* 订单退款
* 使用场景: [卖家发布商品]页面的[不卖了],
* 后台[鉴定中心]页面的[鉴定通过],保证金退还给卖家
*
* @param request
*/
public void refund(PaymentRequest request){
// TODO 这笔钱也是提现的时候 随着 分账|划分 一起将数据给出的?
// 入口参数检查
// 根据订单号,反解 卖家订单号 or 买家订单号
// 确认状态是已支付, 存在支付状态
// 退款
}
/**
* 支付
* @param request
... ...
... ... @@ -14,7 +14,7 @@ import com.yohoufo.order.model.dto.OrderBuilder;
import com.yohoufo.order.request.ShoppingRequest;
import com.yohoufo.order.response.OrderSubmitResponse;
import com.yohoufo.order.response.PaymentResponse;
import com.yohoufo.order.service.IOrdeCreationService;
import com.yohoufo.order.service.ISubmitOrderService;
import com.yohoufo.order.service.IShoppingService;
import com.yohoufo.order.service.proxy.UserProxyService;
import com.yohoufo.order.service.support.ShoppingSupport;
... ... @@ -24,7 +24,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal;
import java.util.Arrays;
import org.springframework.stereotype.Service;
... ... @@ -43,7 +42,7 @@ public class ShoppingServiceImpl implements IShoppingService {
OrderCodeGenerator orderCodeGenerator;
@Autowired
IOrdeCreationService ordeCreationService;
ISubmitOrderService ordeCreationService;
@Autowired
ServiceCaller serviceCaller;
... ... @@ -142,9 +141,12 @@ public class ShoppingServiceImpl implements IShoppingService {
.amount(skup.getGoodsPrice().add(shipFee))
.shipFee(shipFee)
.addressInfo(addressInfo)
.clientType(shoppingRequest.getClientType())
.build();
ordeCreationService.create(orderBuilder);
ordeCreationService.doSumbitOrder(orderBuilder);
// TODO 订单成功以后,开启15分取消消息
// 返回结果
... ...
... ... @@ -8,13 +8,13 @@ import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.ClientType;
import com.yohoufo.order.common.OrderStatus;
import com.yohoufo.order.common.SellerOrderStatus;
import com.yohoufo.order.common.SkupStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.dto.OrderBuilder;
import com.yohoufo.order.service.IOrdeCreationService;
import com.yohoufo.product.controller.ProductController;
import com.yohoufo.order.service.ISubmitOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -22,146 +22,165 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class OrdeCreationServiceImpl implements IOrdeCreationService {
public class SubmitOrderServiceImpl implements ISubmitOrderService {
private final Logger logger = LoggerFactory.getLogger(OrdeCreationServiceImpl.class);
private final Logger logger = LoggerFactory.getLogger(SubmitOrderServiceImpl.class);
@Autowired
SellerOrderGoodsMapper sellerOrderGoodsMapper;
OrderCreateService orderCreateService;
@Autowired
SellerOrderMapper sellerOrderMapper;
private UfoServiceCaller serviceCaller;
@Autowired
BuyerOrderMapper buyerOrderMapper;
@Autowired
BuyerOrderGoodsMapper buyerOrderGoodsMapper;
public void doSumbitOrder(OrderBuilder orderBuilder){
@Autowired
BuyerOrderMetaMapper buyerOrderMetaMapper;
// 减库存
descreaseStorage(orderBuilder);
@Autowired
private UfoServiceCaller serviceCaller;
// 创建订单
orderCreateService.createOrder(orderBuilder);
}
public void descreaseStorage(OrderBuilder orderBuilder){
/**
* 创建订单
* @param orderBuilder
*/
@Transactional
public void create(OrderBuilder orderBuilder){
boolean increaseNeed = false;
try{
// 扣减库存
// 入口参数:skup, product_id
ApiResponse apiResponse = serviceCaller.call("ufo.product.saleSkup",
ApiResponse.class, orderBuilder.getProductId(), orderBuilder.getSkup());
// 减库存失败
if (apiResponse.getCode() != 200){
logger.warn("submit create order, decrease storage faile, orderCode is {}, uid is {}, skup is {}, productId is {}",
orderBuilder.getOrderCode(), orderBuilder.getUid(), orderBuilder.getSkup(), orderBuilder.getProductId());
throw new ServiceException(ServiceError.ORDER_SKUP_CANNOT_SELL);
}
ApiResponse apiResponse = serviceCaller.call("ufo.product.saleSkup",
ApiResponse.class, orderBuilder.getProductId(), orderBuilder.getSkup());
// 减库存失败
if (apiResponse.getCode() != 200){
logger.warn("submit create order, decrease storage faile, orderCode is {}, uid is {}, skup is {}, productId is {}",
orderBuilder.getOrderCode(), orderBuilder.getUid(), orderBuilder.getSkup(), orderBuilder.getProductId());
throw new ServiceException(ServiceError.ORDER_SKUP_CANNOT_SELL);
}
}
@Service
public static class OrderCreateService{
@Autowired
SellerOrderGoodsMapper sellerOrderGoodsMapper;
@Autowired
SellerOrderMapper sellerOrderMapper;
@Autowired
BuyerOrderMapper buyerOrderMapper;
@Autowired
BuyerOrderGoodsMapper buyerOrderGoodsMapper;
@Autowired
BuyerOrderMetaMapper buyerOrderMetaMapper;
// product处减库存失败
increaseNeed = true;
@Autowired
private UfoServiceCaller serviceCaller;
/**
* 1.更新 表seller_order_goods skup的状态为不可售
* 2.更新 表seller_order 状态为已经售出
* 3.插入订单 表buyer_order
* 4.插入订单商品 buyer_order_goods
* 5.插入收货地址 buyer_order_meta
*/
// 1.表seller_order_goods ==> 不可售
SellerOrderGoods sellerOrderGoods = updSellerOrderGoods(orderBuilder);
/**
* 创建订单
* @param orderBuilder
*/
@Transactional
public void createOrder(OrderBuilder orderBuilder){
// 2.更新 表seller_order 状态 ==> 已售出
SellerOrder sellerOrder = updSellerOrder(orderBuilder);
try{
// 3.插入订单 表buyer_order
insertOrder(orderBuilder, sellerOrder.getUid());
/**
* 1.更新 表seller_order_goods skup的状态为不可售
* 2.更新 表seller_order 状态为已经售出
* 3.插入订单 表buyer_order
* 4.插入订单商品 buyer_order_goods
* 5.插入收货地址 buyer_order_meta
*/
// 4.插入订单商品 buyer_order_goods
insertOrderGoods(orderBuilder, sellerOrderGoods);
// 1.表seller_order_goods ==> 不可售
SellerOrderGoods sellerOrderGoods = updSellerOrderGoods(orderBuilder);
// 5.插入收货地址 buyer_order_meta 买家收货地址
insertOrderMeta(orderBuilder);
// 2.更新 表seller_order 状态 ==> 已售出
SellerOrder sellerOrder = updSellerOrder(orderBuilder);
// 3.插入订单 表buyer_order
insertOrder(orderBuilder, sellerOrder.getUid());
}catch (Exception ex){
// 4.插入订单商品 buyer_order_goods
insertOrderGoods(orderBuilder, sellerOrderGoods);
// 5.插入收货地址 buyer_order_meta 买家收货地址
insertOrderMeta(orderBuilder);
}catch (Exception ex){
if (increaseNeed){
// order处 更新状态失败,需要补库存
ApiResponse apiResponse = serviceCaller.call("ufo.product.cancelSaleSkup",ApiResponse.class, orderBuilder.getSkup());
// 补库存失败,需要报警手动补库存 TODO
if (apiResponse.getCode() != 200){
}
}
if (!(ex instanceof ServiceException)) {
//上报告警事件
if (!(ex instanceof ServiceException)) {
//上报告警事件
// EventBusPublisher.publishEvent(new SmsAlarmEvent(OrderHanders.submit, "submit", "订单(" + order.getOrderCode() + ")创建失败"));
throw new ServiceException(ServiceError.SHOPPING_SUBMIT_ORDER_FAIL, ex);
throw new ServiceException(ServiceError.SHOPPING_SUBMIT_ORDER_FAIL, ex);
}
throw ex;
}
throw ex;
}
}
private void insertOrderMeta(OrderBuilder orderBuilder) {
BuyerOrderMeta buyerOrderMeta = new BuyerOrderMeta();
buyerOrderMeta.setUid(orderBuilder.getUid());
buyerOrderMeta.setOrderCode(orderBuilder.getOrderCode());
buyerOrderMeta.setMetaKey(MetaKey.BUYER_DELIVERY_ADDRESS);
buyerOrderMeta.setMetaValue(JSONObject.toJSONString(orderBuilder.getAddressInfo()));
buyerOrderMetaMapper.insert(buyerOrderMeta);
}
private void insertOrderMeta(OrderBuilder orderBuilder) {
BuyerOrderMeta buyerOrderMeta = new BuyerOrderMeta();
buyerOrderMeta.setUid(orderBuilder.getUid());
buyerOrderMeta.setOrderCode(orderBuilder.getOrderCode());
buyerOrderMeta.setMetaKey(MetaKey.BUYER_DELIVERY_ADDRESS);
buyerOrderMeta.setMetaValue(JSONObject.toJSONString(orderBuilder.getAddressInfo()));
buyerOrderMetaMapper.insert(buyerOrderMeta);
}
private void insertOrderGoods(OrderBuilder orderBuilder, SellerOrderGoods sellerOrderGoods) {
BuyerOrderGoods buyerOrderGoods = new BuyerOrderGoods();
buyerOrderGoods.setSkup(orderBuilder.getSkup());
buyerOrderGoods.setOrderCode(orderBuilder.getOrderCode());
buyerOrderGoods.setGoodsPrice(sellerOrderGoods.getGoodsPrice());
buyerOrderGoods.setGoodsAmount(sellerOrderGoods.getGoodsPrice());
buyerOrderGoodsMapper.insertSelective(buyerOrderGoods);
}
private void insertOrderGoods(OrderBuilder orderBuilder, SellerOrderGoods sellerOrderGoods) {
BuyerOrderGoods buyerOrderGoods = new BuyerOrderGoods();
buyerOrderGoods.setSkup(orderBuilder.getSkup());
buyerOrderGoods.setOrderCode(orderBuilder.getOrderCode());
buyerOrderGoods.setGoodsPrice(sellerOrderGoods.getGoodsPrice());
buyerOrderGoods.setGoodsAmount(sellerOrderGoods.getGoodsPrice());
buyerOrderGoodsMapper.insertSelective(buyerOrderGoods);
}
private void insertOrder(OrderBuilder orderBuilder, int sellerUid) {
BuyerOrder buyerOrder = new BuyerOrder();
buyerOrder.setUid(orderBuilder.getUid());
buyerOrder.setOrderCode(orderBuilder.getOrderCode());
buyerOrder.setSellerUid(sellerUid);
buyerOrder.setPaymentType((byte) orderBuilder.getPaymentType());
buyerOrder.setAmount(orderBuilder.getAmount());
buyerOrder.setShipFee(orderBuilder.getShipFee());
buyerOrder.setChannelNo(orderBuilder.getChannelNo());
int now = DateUtil.getCurrentTimeSecond();
buyerOrder.setClientType(ClientType.getClientType(orderBuilder.getClientType()));
buyerOrder.setCreateTime(now);
buyerOrder.setUpdateTime(now);
buyerOrder.setStatus((byte) OrderStatus.WAITING_PAY.getCode());
buyerOrderMapper.insert(buyerOrder);
}
private void insertOrder(OrderBuilder orderBuilder, int sellerUid) {
BuyerOrder buyerOrder = new BuyerOrder();
buyerOrder.setUid(orderBuilder.getUid());
buyerOrder.setOrderCode(orderBuilder.getOrderCode());
buyerOrder.setSellerUid(sellerUid);
buyerOrder.setPaymentType((byte) orderBuilder.getPaymentType());
buyerOrder.setAmount(orderBuilder.getAmount());
buyerOrder.setShipFee(orderBuilder.getShipFee());
buyerOrder.setChannelNo(orderBuilder.getChannelNo());
int now = DateUtil.getCurrentTimeSecond();
buyerOrder.setCreateTime(now);
buyerOrder.setUpdateTime(now);
buyerOrder.setStatus((byte) OrderStatus.WAITING_PAY.getCode());
buyerOrderMapper.insert(buyerOrder);
}
private SellerOrder updSellerOrder(OrderBuilder orderBuilder) {
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(orderBuilder.getSkup());
sellerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
sellerOrder.setStatus(SellerOrderStatus.HAS_SELLED.getCode());
sellerOrderMapper.updateByPrimaryKeySelective(sellerOrder);
return sellerOrder;
}
private SellerOrder updSellerOrder(OrderBuilder orderBuilder) {
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(orderBuilder.getSkup());
sellerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
sellerOrder.setStatus(SellerOrderStatus.HAS_SELLED.getCode());
sellerOrderMapper.updateByPrimaryKeySelective(sellerOrder);
return sellerOrder;
private SellerOrderGoods updSellerOrderGoods(OrderBuilder orderBuilder) {
SellerOrderGoods sellerOrderGoods = new SellerOrderGoods();
sellerOrderGoods.setId(orderBuilder.getSkup());
sellerOrderGoods.setStatus(SkupStatus.CAN_NOT_SELL.getCode());
sellerOrderGoodsMapper.updateByPrimaryKeySelective(sellerOrderGoods);
return sellerOrderGoods;
}
}
private SellerOrderGoods updSellerOrderGoods(OrderBuilder orderBuilder) {
SellerOrderGoods sellerOrderGoods = new SellerOrderGoods();
sellerOrderGoods.setId(orderBuilder.getSkup());
sellerOrderGoods.setStatus(SkupStatus.CAN_NOT_SELL.getCode());
sellerOrderGoodsMapper.updateByPrimaryKeySelective(sellerOrderGoods);
return sellerOrderGoods;
}
}
... ...
... ... @@ -35,7 +35,7 @@ public class ShoppingSupport {
// 快递方式
PaymentResponse.DeliveryWay deliveryWay = new PaymentResponse.DeliveryWay();
deliveryWay.setDeliveryWayId(OrderConstant.DELIVERY_WAY_SF);
deliveryWay.setDeliveryWayCost(OrderConstant.DELIVERY_WAY_SF_COST);
deliveryWay.setDeliveryWayCost(OrderConstant.MONEY_SIGN + OrderConstant.DELIVERY_WAY_SF_COST);
deliveryWay.setDeliveryWayName(OrderConstant.DELIVERY_WAY_SF_NAME);
return deliveryWay;
}
... ... @@ -48,6 +48,7 @@ public class ShoppingSupport {
*/
public GoodsInfo getGoodsInfo(SellerOrderGoods skup) {
GoodsInfo goods = new GoodsInfo();
goods.setSkup(skup.getId());
goods.setProductName(skup.getProductName());
goods.setColorId(skup.getColorId() == null ? 0 : skup.getColorId());
goods.setColorName(skup.getColorName());
... ...
... ... @@ -216,7 +216,7 @@ public class ProductServiceImpl implements ProductService{
if (storageId == null) {
StoragePrice sp = storagePriceMapper.selectBySkup(skup);
storageId = sp.getStorageId();
if (storageId == null) {
if (sp == null || (storageId = sp.getStorageId()) == null) {
LOGGER.error("addStorageNum skup={}, storageId={}, num={}, find storageId is null", skup, storageId,
num);
}
... ...