Authored by tanling

Merge branch 'master' of http://git.yoho.cn/ufo/yohoufo-fore

# Conflicts:
#	order/src/main/java/com/yohoufo/order/constants/MetaKey.java
... ... @@ -11,7 +11,7 @@ MAINTAINER jimi <jimi.ji@yoho.cn>
ENV TZ Asia/Shanghai
#COPY deploy/target/yohoufo-fore-web.war /usr/local/tomcat/webapps/yohoufo-fore-web.war
COPY deploy/target/ufo-gwateway.war /usr/local/tomcat/webapps/ufo-gwateway.war
COPY deploy/target/ufo-gateway.war /usr/local/tomcat/webapps/ufo-gateway.war
RUN sed -i 's/<Connector port="8080" protocol/<Connector port="8080" protocol/g' /usr/local/tomcat/conf/server.xml
... ...
... ... @@ -14,4 +14,5 @@ public interface MetaKey {
String BUYER_DELIVERY_ADDRESS = "delivery_address";
String SELLER_FEE = "fee";
}
... ...
package com.yohoufo.order.constants;
/**0:未付保证金,1:已付保证金,2:卖家取消,4:已完成
* Created by chenchao on 2018/9/17.
*/
public enum SellerOrderStatus {
NOT_PAY(0,"未付保证金"),
PAY_SUCCESS(1, "已付保证金"),
SELLER_CANCEL(2,"卖家取消"),
FINISH(4,"已完成");
int code;
String desc;
SellerOrderStatus(int code , String desc){
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
package com.yohoufo.order.constants;
/**
* Created by chenchao on 2018/9/17.
*/
public enum SkupStatus {
NOT_AVAILABLE(0,"不可售"), AVAILABLE(1, "可售");
private int code;
private String desc;
SkupStatus(int code,String desc){
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
... ... @@ -189,13 +189,42 @@ public class SellerOrderService {
return context;
}
/**
* 卖家支付完成后调用
* @param uid
* @param orderCode
*/
public void processAfterPay(int uid, long orderCode){
//todo update order info, set payment status
//todo update skup status
//todo sync skup to prd service by rpc
}
/**
* 发货
* @param buyerOrderCode
* @param expressNum
*/
public void deliverGoods(int uid, long buyerOrderCode,String expressNum){
//
}
/**
* 查物流详情
* 只查卖家自己填的物流单
* @param uid
* @param buyerOrderCode
* @param expressNum
* @return
*/
public Object queryLogistics(int uid, long buyerOrderCode, String expressNum){
return null;
}
public SoldPrdComputeBo buildSoldPrdComputeBo(BigDecimal prdPrice){
... ...
... ... @@ -2,7 +2,7 @@ package com.yohoufo.order.service;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.constants.SkupStatus;
import com.yohoufo.order.common.SkupStatus;
import com.yohoufo.order.model.GoodsInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -37,7 +37,7 @@ public class SkupService {
SellerOrderGoods sellerOrderGoods = new SellerOrderGoods();
//最关键的两个数据项
sellerOrderGoods.setStorageId(goodsInfo.getStorageId());
sellerOrderGoods.setStatus(SkupStatus.NOT_AVAILABLE.getCode());
sellerOrderGoods.setStatus(SkupStatus.CAN_NOT_SELL.getCode());
//if not exist ,not
sellerOrderGoods.setProductId(goodsInfo.getProductId());
sellerOrderGoods.setProductName(goodsInfo.getProductName());
... ...
... ... @@ -5,6 +5,7 @@ import com.yohoufo.order.model.GoodsInfo;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.service.SkupService;
import com.yohoufo.order.service.impl.SellerAddressService;
import com.yohoufo.order.service.impl.SellerFeeService;
import com.yohoufo.order.service.impl.SellerOrderCreateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -28,6 +29,9 @@ public class SellerOrderSubmitHandler {
@Autowired
private SellerAddressService sellerAddressService;
@Autowired
private SellerFeeService sellerFeeService;
@Transactional(propagation = Propagation.REQUIRES_NEW)
public Long submit(SellerOrderContext context) throws GatewayException {
int uid = context.getUid();
... ... @@ -46,6 +50,8 @@ public class SellerOrderSubmitHandler {
sellerOrderCreateService.createOrder(context);
//寄回地址:back_delivery_address
sellerAddressService.saveSendBackAddress(context);
//record every fee items
sellerFeeService.saveFee(context);
return 0L;
}
... ...
package com.yohoufo.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.yohoufo.dal.order.SellerOrderMetaMapper;
import com.yohoufo.dal.order.model.SellerOrderMeta;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.SellerOrderContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* Created by chenchao on 2018/9/17.
*/
@Service
public class SellerFeeService {
private final Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private SellerOrderMetaMapper somMapper;
@Transactional(propagation = Propagation.REQUIRED)
public int saveFee(SellerOrderContext ctx){
logger.info("in seller saveFee, uid {}", ctx.getUid());
SellerOrderMeta som = new SellerOrderMeta();
som.setUid(ctx.getUid());
som.setSkup(ctx.getSoldProduct().getSkup());
som.setMetaKey(MetaKey.SELLER_FEE);
String value = JSONObject.toJSONString(ctx.getSellerOrderComputeResult());
som.setMetaValue(value);
return somMapper.insertSelective(som);
}
}
... ...
package com.yohoufo.order.service.impl;
import com.yohoufo.order.service.impl.visitor.AutoCancelCase;
import com.yohoufo.order.service.impl.visitor.OffShelveCancelCase;
import com.yohoufo.order.service.impl.visitor.UserCancelCase;
import org.springframework.stereotype.Service;
/**
* Created by chenchao on 2018/9/17.
*/
@Service
public class SellerOrderCancelService {
public void cancel(UserCancelCase cancelCase){
//未支付时
//支付完成,没有买家下单
//支付完成,有买家下单
}
public void cancel(AutoCancelCase autoCancelCase){
}
public void cancel(OffShelveCancelCase offShelveCancelCase){
}
}
... ...
... ... @@ -4,7 +4,7 @@ import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.order.constants.SellerOrderCancelStatus;
import com.yohoufo.order.constants.SellerOrderStatus;
import com.yohoufo.order.common.SellerOrderStatus;
import com.yohoufo.order.model.SellerOrderContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -29,7 +29,7 @@ public class SellerOrderCreateService {
condition.setSkup(context.getSoldProduct().getSkup());
condition.setIsCancel(SellerOrderCancelStatus.NO.getCode());
condition.setCreateTime(currentTiem);
condition.setStatus(SellerOrderStatus.NOT_PAY.getCode());
condition.setStatus(SellerOrderStatus.WAITING_PAY.getCode());
condition.setEarnestMoney(context.getSellerOrderComputeResult().getEarnestMoney());
condition.setIncome(context.getSellerOrderComputeResult().getIncome());
return sellerOrderMapper.insertSelective(condition);
... ...
package com.yohoufo.order.service.impl.visitor;
import com.yohoufo.order.service.impl.SellerOrderCancelService;
/**
* Created by chenchao on 2018/9/17.
*/
public abstract class AbsSellerOrderCancelCase implements SellerOrderCancelCase{
private int uid;
private long orderCode;
public AbsSellerOrderCancelCase(int uid, long orderCode) {
this.uid = uid;
this.orderCode = orderCode;
}
public abstract void accept(SellerOrderCancelService visitor);
public int getUid() {
return uid;
}
public long getOrderCode() {
return orderCode;
}
}
... ...
package com.yohoufo.order.service.impl.visitor;
import com.yohoufo.order.service.impl.SellerOrderCancelService;
/**未支付 超时取消
* Created by chenchao on 2018/9/17.
*/
public class AutoCancelCase extends AbsSellerOrderCancelCase {
public AutoCancelCase(int uid, long orderCode) {
super(uid, orderCode);
}
@Override
public void accept(SellerOrderCancelService visitor) {
visitor.cancel(this);
}
}
... ...
package com.yohoufo.order.service.impl.visitor;
import com.yohoufo.order.service.impl.SellerOrderCancelService;
/**skup下架取消
* Created by chenchao on 2018/9/17.
*/
public class OffShelveCancelCase extends AbsSellerOrderCancelCase {
public OffShelveCancelCase(int uid, long orderCode) {
super(uid, orderCode);
}
@Override
public void accept(SellerOrderCancelService visitor) {
visitor.cancel(this);
}
}
... ...
package com.yohoufo.order.service.impl.visitor;
import com.yohoufo.order.service.impl.SellerOrderCancelService;
/**
* Created by chenchao on 2018/9/17.
*/
public interface SellerOrderCancelCase {
void accept(SellerOrderCancelService visitor);
}
... ...
package com.yohoufo.order.service.impl.visitor;
import com.yohoufo.order.service.impl.SellerOrderCancelService;
/**
* Created by chenchao on 2018/9/17.
*/
public class UserCancelCase extends AbsSellerOrderCancelCase {
public UserCancelCase(int uid, long orderCode) {
super(uid, orderCode);
}
@Override
public void accept(SellerOrderCancelService visitor) {
visitor.cancel(this);
}
}
... ...
... ... @@ -84,15 +84,15 @@ public class ProductController {
@ApiOperation(name = "ufo.product.storage.leastprice", desc="sku的最低价")
@RequestMapping(params = "method=ufo.product.storage.leastprice")
//@Cachable(expire=600)
public ApiResponse queryStorageLeastprice(
public StorageLeastPriceResp queryStorageLeastprice(
@RequestParam(value = "storage_id", required = true) Integer storageId) {
if (storageId == null) {
return new ApiResponse(500, "storageId Is Null", null);
return null;
}
StorageLeastPriceResp resp = productService.queryStorageLeastPrice(storageId);
return new ApiResponse.ApiResponseBuilder().data(queryStorageLeastprice()).code(200).message("storage.leastprice").build();
return queryStorageLeastprice();
}
... ... @@ -105,16 +105,16 @@ public class ProductController {
@ApiOperation(name = "ufo.product.storage.data", desc="sku信息")
@RequestMapping(params = "method=ufo.product.storage.data")
//@Cachable(expire=600)
public ApiResponse queryStorageInfo(
public StorageDataResp queryStorageInfo(
@RequestParam(value = "storage_id", required = true) Integer storageId) {
if (storageId == null) {
return new ApiResponse(500, "storageId Is Null", null);
return null;
}
StorageDataResp resp = productService.queryStorageInfo(storageId);
return new ApiResponse.ApiResponseBuilder().data(queryStorageData()).code(200).message("storage.data").build();
return queryStorageData();
}
... ...
... ... @@ -21,7 +21,7 @@ login.skip.modify.weakPwd=${login.skip.modify.weakPwd}
#zookeeper address
zkAddress=${zkAddress}
# web context
web.context=gateway
web.context=ufo-gateway
#\u5bc6\u7801AES\u52a0\u5bc6\u5bc6\u94a5
password.aes.key=${password.aes.key}
... ...