Authored by mali

Merge branch 'dev'

... ... @@ -28,6 +28,14 @@ public interface ExpressInfoMapper {
List<ExpressInfo> queryExpressInfo(@Param("uid") Integer uid, @Param("orderCode") Long orderCode, @Param("expressType") Integer expressType);
/**
* 根据uid、订单号和快递单号查询快递信息查找第一笔订单信息
* @param uid
* @param orderCode 订单号
* @return
*/
ExpressInfo queryFirstExpressInfo(@Param("uid") Integer uid, @Param("orderCode") Long orderCode, @Param("waybillCode") String waybillCode);
/**
* 根据uid、订单号、物流类型和快递状态查询快递信息
* @param uid
* @param orderCode
... ...
... ... @@ -152,6 +152,13 @@
ORDER BY create_time DESC
</select>
<select id="queryFirstExpressInfo" resultMap="BaseResultMap">
SELECT <include refid="Base_Column_List" />
FROM express_info
where uid = #{uid} and order_code = #{orderCode} and waybill_code = #{waybillCode}
limit 1
</select>
<select id="selectByOrderCodeAndStatesAndUidAndExpressType" resultMap="BaseResultMap">
SELECT id, uid, order_code, waybill_code, accept_address, accept_remark, logistics_type, create_time, express_type, state
FROM express_info
... ...
... ... @@ -73,8 +73,8 @@ public class ExpressInfoController {
* @return
*/
@RequestMapping(params = "method=ufo.order.expressDetailInfo")
public ApiResponse queryExpressDetailInfo(@RequestParam("orderCode") Long orderCode) {
ExpressInfoRespBo expressInfoRespBo = expressInfoService.queryExpressDetailInfo(orderCode);
public ApiResponse queryExpressDetailInfo(@RequestParam("uid") Integer uid,@RequestParam("orderCode") Long orderCode) {
ExpressInfoRespBo expressInfoRespBo = expressInfoService.queryExpressDetailInfo(uid,orderCode);
return new ApiResponse.ApiResponseBuilder().code(200).data(expressInfoRespBo).build();
}
}
... ...
... ... @@ -67,7 +67,7 @@ public class SellerOrderController {
.uid(uid)
.storageId(storage_id)
.price(price)
.addressId(address_id)
.addressId(1)
.build();
logger.info("in ufo.sellerOrder.publishPrd, req {}", req);
Long orderCode = sellerOrderService.publishPrd(req);
... ...
... ... @@ -10,15 +10,9 @@ import com.yohoufo.common.constant.ExpressInfoConstant;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.dal.order.ExpressInfoMapper;
import com.yohoufo.dal.order.SellerOrderMapper;
import com.yohoufo.dal.order.model.BuyerOrder;
import com.yohoufo.dal.order.model.ExpressInfo;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.order.common.OrderCodeType;
import com.yohoufo.order.mq.publisher.ConsumerExceptionPublisher;
import com.yohoufo.order.service.IExpressInfoService;
import com.yohoufo.order.service.support.codegenerator.OrderCodeGenerator;
import com.yohoufo.order.service.support.codegenerator.bean.CodeMeta;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
... ... @@ -27,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Objects;
@Component
... ... @@ -42,16 +35,8 @@ private static final Logger LOGGER = LoggerFactory.getLogger(ExpressInfoUpdateCo
private ExpressInfoMapper expressInfoMapper;
@Autowired
private SellerOrderMapper sellerOrderMapper;
@Autowired
private BuyerOrderMapper buyerOrderMapper;
@Autowired
private IExpressInfoService expressInfoService;
@Autowired
private OrderCodeGenerator orderCodeGenerator;
@Autowired
private ConsumerExceptionPublisher consumerExceptionPublisher;
... ... @@ -85,47 +70,34 @@ private static final Logger LOGGER = LoggerFactory.getLogger(ExpressInfoUpdateCo
LOGGER.info("handle express info update message, not give me a uid, message is {}.", message);
return;
}
// 判断是买家订单号还是卖家订单号
boolean buyer = true;
//根据订单号判断是买家还是卖家
CodeMeta codeMeta = orderCodeGenerator.expId(orderCode);
if (Objects.isNull(codeMeta)){
LOGGER.warn("getExpressType orderCode illegal, req {}", orderCode);
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
//卖家
if(OrderCodeType.SELLER_TYPE.getType() == codeMeta.getType()){
buyer=false;
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
if (buyer) {
// 买家
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeSellerUid(orderCode, uid);
if (Objects.isNull(buyerOrder)) {
LOGGER.info("handle express info update message, orders not found, message is {}.", message);
return;
}
} else {
// 卖家
SellerOrder sellerOrder = sellerOrderMapper.selectByOrderCodeUid(orderCode, uid);
if (Objects.isNull(sellerOrder)) {
LOGGER.info("handle express info update message, orders not found, message is {}.", message);
return;
}
String waybillCode = jsonMsg.getString("waybillCode");
//根据uid,orderCode,waybillCode查状态expressType
ExpressInfo firstExpressInfo = expressInfoMapper.queryFirstExpressInfo(uid,orderCode,waybillCode);
if(firstExpressInfo==null){
LOGGER.warn("updateExpressInfo first express info not exist, uid is {} orderCode is {} waybillCode is {}", uid,orderCode,waybillCode);
throw new ServiceException(400,"not find express type info");
}
int createTime = jsonMsg.getIntValue("createTime");
//int smsType = jsonMsg.getIntValue("businessType");
int state = jsonMsg.getIntValue("state");
// 正常订单,签收消息
if (state == ExpressInfoConstant.EXPRESS_STATUS_SIGN) {
handleAcceptExpress(jsonMsg);
handleAcceptExpress(jsonMsg,firstExpressInfo.getExpressType().intValue());
return;
}
int logisticsType = jsonMsg.getIntValue("logisticsType");
String waybillCode = jsonMsg.getString("waybillCode");
// 正常订单,物流调拨消息(获取不到物流信息,标记为未发货)
if (state == ExpressInfoConstant.EXPRESS_STATUS_UNSING
... ... @@ -148,7 +120,7 @@ private static final Logger LOGGER = LoggerFactory.getLogger(ExpressInfoUpdateCo
expressInfo.setAcceptRemark(StringUtils.defaultString(acceptRemark));
expressInfo.setLogisticsType(logisticsType);
expressInfo.setCreateTime(createTime);
expressInfo.setExpressType(expressInfoService.getExpressType(orderCode).byteValue());
expressInfo.setExpressType(firstExpressInfo.getExpressType());
expressInfo.setState(state);
expressInfoMapper.insert(expressInfo);
}
... ... @@ -174,7 +146,7 @@ private static final Logger LOGGER = LoggerFactory.getLogger(ExpressInfoUpdateCo
/**
* 确认收货处理
*/
public void handleAcceptExpress(JSONObject jsonMsg) {
private void handleAcceptExpress(JSONObject jsonMsg,Integer expressType) {
int state = jsonMsg.getIntValue("state");
long orderCode = jsonMsg.getLongValue("orderCode");
int logisticsType = jsonMsg.getIntValue("logisticsType");
... ... @@ -184,7 +156,6 @@ private static final Logger LOGGER = LoggerFactory.getLogger(ExpressInfoUpdateCo
int uid = jsonMsg.getIntValue("uid");
int createTime = DateUtil.getCurrentTimeSecond();
Integer expressType = expressInfoService.getExpressType(orderCode);
List<ExpressInfo> expressInfos = expressInfoMapper.selectByOrderCodeAndStatesAndUidAndExpressType(uid, orderCode, Lists.newArrayList(ExpressInfoConstant.EXPRESS_STATUS_SIGN), expressType);
processExpressInfo(expressInfos, state, logisticsType, orderCode, waybillCode, acceptAddress, acceptRemark, createTime, uid, expressType);
}
... ...
... ... @@ -42,7 +42,7 @@ public interface IExpressInfoService {
* @param orderCode
* @return
*/
ExpressInfoRespBo queryExpressDetailInfo(Long orderCode);
ExpressInfoRespBo queryExpressDetailInfo(Integer uid,Long orderCode);
/**
... ... @@ -54,5 +54,5 @@ public interface IExpressInfoService {
* @param orderCode
* @return
*/
Integer getExpressType(Long orderCode);
//Integer getExpressType(Long orderCode);
}
... ...
... ... @@ -56,71 +56,137 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
@Autowired
private BuyerOrderMapper buyerOrderMapper;
@Autowired
private OrderCodeGenerator orderCodeGenerator;
@Resource( name = "yhProducer")
private YhProducer yhProducer;
private static String EXPRESS_MQ_SEND = "logistics.logistics_data";
/**
*
* @param uid 卖家的uid
* @param expressCompanyId 快递公司id
* @param orderCode 订单号 :一定是买家订单编号
* @param wayBillCode 快递单号
*/
@Override
public void deliverToDepot(Integer uid,Integer expressCompanyId, Long orderCode, String wayBillCode) {
LOGGER.info("deliverToDepot uid={} ,expressCompanyId = {}, orderCode = {}, wayBillCode = {}", new Object[]{uid ,expressCompanyId, orderCode, wayBillCode});
//保存物流信息+更新订单状态;
//本阶段的物流类型和订单状态
Integer expressType = ExpressInfoConstant.EXPRESS_TYPE_1;
OrderStatus orderStatus=OrderStatus.SELLER_SEND_OUT;
Integer expressType = ExpressInfoConstant.EXPRESS_TYPE_1;
LOGGER.info("deliverToDepot saveExpressAndUpdateBuyerOrderStatus uid={} ,expressCompanyId = {}, orderCode = {}, wayBillCode = {} " +
",expressType = {} ,orderStatus = {}", new Object[]{uid ,expressCompanyId, orderCode, wayBillCode,expressType,orderStatus});
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("getOrderInfo order not exist, orderCode is {}", orderCode);
LOGGER.warn("deliverToDepot getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
if(uid!=buyerOrder.getUid()){
LOGGER.warn("deliverToDepot saveExpressAndUpdateBuyerOrderStatus uid {} not equal buyer order uid {}",uid, buyerOrder.getUid());
throw new ServiceException(ServiceError.ORDER_NULL);
//卖家的uid
if(uid.intValue()!=buyerOrder.getSellerUid().intValue()){
LOGGER.warn("deliverToDepot saveExpressAndUpdateBuyerOrderStatus uid {} not equal buyer order sellerUid {}",uid, buyerOrder.getSellerUid());
throw new ServiceException(400,"参数错误,传入的卖家uid与订单卖家uid不一致");
}
Integer dealUid=buyerOrder.getSellerUid();
// 保存订单物流信息
int ts=DateUtil.getCurrentTimeSecond();
ExpressInfo expressInfo=new ExpressInfo();
expressInfo.setUid(uid);
expressInfo.setOrderCode(orderCode);
expressInfo.setWaybillCode(wayBillCode);
expressInfo.setLogisticsType(expressCompanyId);
expressInfo.setCreateTime(ts);
expressInfo.setExpressType(expressType.byteValue());
expressInfo.setState(0);
LOGGER.info("deliverToDepot save express info {} ", expressInfo);
expressInfoMapper.insert(expressInfo);
saveExpress(dealUid,expressCompanyId,orderCode,wayBillCode,expressType);
// 更新买家订单状态
buyerOrder.setStatus(orderStatus.getCode());
buyerOrder.setUpdateTime(ts);
buyerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
LOGGER.info("deliverToDepot update buyer order {} ", buyerOrder);
buyerOrderMapper.updateByPrimaryKeySelective(buyerOrder);
// 发送mq获取物流信息
sendExpressMQ(uid,expressCompanyId,orderCode,wayBillCode);
sendExpressMQ(dealUid,expressCompanyId,orderCode,wayBillCode);
LOGGER.info("deliverToDepot end ! send express to erp ");
}
@Override
public void appraiseFail(Integer expressCompanyId, Long orderCode, String wayBillCode) {
LOGGER.info("appraiseFail expressCompanyId = {}, orderCode = {}, wayBillCode = {}", new Object[]{expressCompanyId, orderCode, wayBillCode});
// TODO
OrderStatus orderStatus=OrderStatus.CHECKING_FAKE;
Integer expressType = ExpressInfoConstant.EXPRESS_TYPE_3;
LOGGER.info("appraiseFail expressCompanyId = {}, orderCode = {}, wayBillCode = {} " +
",expressType = {} ,orderStatus = {}", new Object[]{expressCompanyId, orderCode, wayBillCode,expressType,orderStatus});
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("appraiseFail getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
Integer dealUid=buyerOrder.getSellerUid();
// 保存订单物流信息
saveExpress(dealUid,expressCompanyId,orderCode,wayBillCode,expressType);
// 更新买家订单状态
buyerOrder.setStatus(orderStatus.getCode());
buyerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
LOGGER.info("appraiseFail update buyer order {} ", buyerOrder);
buyerOrderMapper.updateByPrimaryKeySelective(buyerOrder);
// 发送mq获取物流信息
sendExpressMQ(dealUid,expressCompanyId,orderCode,wayBillCode);
LOGGER.info("appraiseFail end ! send express to erp ");
}
@Override
public void appraiseSuccess(Integer expressCompanyId, Long orderCode, String wayBillCode) {
LOGGER.info("appraiseSuccess expressCompanyId = {}, orderCode = {}, wayBillCode = {}", new Object[]{expressCompanyId, orderCode, wayBillCode});
// TODO
OrderStatus orderStatus=OrderStatus.WAITING_RECEIVE;
Integer expressType = ExpressInfoConstant.EXPRESS_TYPE_2;
LOGGER.info("appraiseSuccess expressCompanyId = {}, orderCode = {}, wayBillCode = {} " +
",expressType = {} ,orderStatus = {}", new Object[]{expressCompanyId, orderCode, wayBillCode,expressType,orderStatus});
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if (buyerOrder == null){
LOGGER.warn("appraiseSuccess getOrderInfo order not exist, orderCode is {}", orderCode);
throw new ServiceException(ServiceError.ORDER_NULL);
}
Integer dealUid=buyerOrder.getUid();
// 保存订单物流信息
saveExpress(dealUid,expressCompanyId,orderCode,wayBillCode,expressType);
// 更新买家订单状态
buyerOrder.setStatus(orderStatus.getCode());
buyerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
LOGGER.info("appraiseSuccess update buyer order {} ", buyerOrder);
buyerOrderMapper.updateByPrimaryKeySelective(buyerOrder);
// 发送mq获取物流信息
sendExpressMQ(dealUid,expressCompanyId,orderCode,wayBillCode);
LOGGER.info("appraiseSuccess end ! send express to erp ");
}
/**
* 保存物流信息
* @param uid 卖家到鉴定中心和鉴定失败时,记录卖家的uid,鉴定成功记录买家uid
* @param expressCompanyId
* @param orderCode
* @param wayBillCode
* @param expressType
*/
private void saveExpress(Integer uid,Integer expressCompanyId, Long orderCode, String wayBillCode,Integer expressType ){
ExpressInfo expressInfo=new ExpressInfo();
expressInfo.setUid(uid);/// 存卖家的uid
expressInfo.setOrderCode(orderCode);
expressInfo.setWaybillCode(wayBillCode);
expressInfo.setLogisticsType(expressCompanyId);
expressInfo.setCreateTime(DateUtil.getCurrentTimeSecond());
expressInfo.setExpressType(expressType.byteValue());
expressInfo.setState(0);
LOGGER.info("deliverToDepot save express info {} ", expressInfo);
expressInfoMapper.insert(expressInfo);
}
/**
... ... @@ -148,8 +214,8 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
* @return
*/
@Override
public ExpressInfoRespBo queryExpressDetailInfo(Long orderCode) {
LOGGER.info("queryExpressDetailInfo orderCode = {}", orderCode);
public ExpressInfoRespBo queryExpressDetailInfo(Integer uid,Long orderCode) {
LOGGER.info("queryExpressDetailInfo uid={}, orderCode = {}",uid, orderCode);
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
if (buyerOrder == null){
... ... @@ -157,9 +223,8 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
throw new ServiceException(ServiceError.ORDER_NULL);
}
Integer uid=buyerOrder.getUid();
ExpressInfoRespBo expressInfoRespBo = new ExpressInfoRespBo();
Integer expressType = getExpressType(orderCode);
Integer expressType = getExpressType(buyerOrder);
LOGGER.info("getExpressType result = {}", expressType);
List<ExpressInfo> expressInfoList = expressInfoMapper.queryExpressInfo(uid, orderCode, expressType);
processExpressInfo(expressInfoList, expressInfoRespBo);
... ... @@ -192,9 +257,20 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
}
}
@Override
public Integer getExpressType(Long orderCode) {
Integer uid = null;
/**
* orderCode 一定是买家订单号
* @return
*/
private Integer getExpressType(BuyerOrder buyerOrder) {
if(OrderStatus.SELLER_SEND_OUT.getCode()==buyerOrder.getStatus()||OrderStatus.PLATFORM_CHECKING.getCode()==buyerOrder.getStatus()){
return ExpressInfoConstant.EXPRESS_TYPE_1;
}else if(OrderStatus.CHECKING_FAKE.getCode()==buyerOrder.getStatus()){
return ExpressInfoConstant.EXPRESS_TYPE_3;
}else if(OrderStatus.WAITING_RECEIVE.getCode()==buyerOrder.getStatus()||OrderStatus.DONE.getCode()==buyerOrder.getStatus()){
return ExpressInfoConstant.EXPRESS_TYPE_2;
}
return 0;
/*Integer uid = null;
boolean buyer = true;
//根据订单号判断是买家还是卖家
CodeMeta codeMeta = orderCodeGenerator.expId(orderCode);
... ... @@ -224,6 +300,6 @@ public class ExpressInfoServiceImpl implements IExpressInfoService {
return ExpressInfoConstant.EXPRESS_TYPE_3;
}
}
return 0;
return 0;*/
}
}
... ...
... ... @@ -245,7 +245,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
throw new GatewayException(400, "售价错误");
}
int addressId = AddressUtil.getDecryptStr(req.getAddressId());
int addressId = AddressUtil.getDecryptStr("");
if (addressId < 0){
log.warn("seller submit order addressId invalidate, uid {}, storageId {}, addressId is {}",
uid, storageId, req.getAddressId());
... ...
... ... @@ -75,14 +75,15 @@
$(function() {
var productId = getUrlParam('id');
var ajaxUrl = location.pathname.indexOf('ufo-gateway') > -1 ? '/ufo-gateway' : '/';
$('.download-go').attr('href', 'https://union.yoho.cn/union/app-downloads.html?openby:yohobuy={action":"go.ufo","params":{"isnavhidden":true,"pagename":"productDetail","productId":' + productId + '}}')
$('.download-go').attr('href', 'https://union.yoho.cn/union/app-downloads.html?openby:yohobuy={"action":"go.ufo","params":{"isnavhidden":1,"pagename":"productDetail","productId":' + productId + '}}')
$('.download-close').on('click', function() {
$('.top-downloadbar').hide();
});
$.get('/', {
$.get(ajaxUrl, {
method: 'ufo.product.data',
product_id: productId
}, function(ret) {
... ...