Authored by mali

Merge branch 'gray' into test6.9.5

package com.yoho.order.dal;
import com.yoho.order.model.PhoneUidDepot;
public interface PhoneUidDepotMapper {
int insert(PhoneUidDepot record);
PhoneUidDepot selectByphoneUid(String phoneUid);
}
\ No newline at end of file
... ...
package com.yoho.order.model;
import lombok.Data;
/**
* 质检手机和鉴定中心绑定关系
*/
@Data
public class PhoneUidDepot {
private Integer id;
private String phoneUid;
private Integer depotNo;
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.order.dal.PhoneUidDepotMapper" >
<resultMap id="BaseResultMap" type="com.yoho.order.model.PhoneUidDepot" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="phone_uid" property="phoneUid" jdbcType="VARCHAR" />
<result column="depot_no" property="depotNo" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, phone_uid, depot_no
</sql>
<select id="selectByphoneUid" resultMap="BaseResultMap" parameterType="java.lang.String" >
select <include refid="Base_Column_List" /> from phone_uid_depot
where phone_uid = #{phoneUid,jdbcType=VARCHAR} limit 1
</select>
<insert id="insert" parameterType="com.yoho.order.model.PhoneUidDepot" >
insert into phone_uid_depot (phone_uid, depot_no) values (#{phoneUid,jdbcType=VARCHAR}, #{depotNo,jdbcType=INTEGER})
</insert>
</mapper>
\ No newline at end of file
... ...
package com.yoho.ufo.order.controller;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yoho.order.model.Area;
import com.yoho.order.model.BuyerOrderReq;
import com.yoho.order.model.QiniuLiveRecord;
import com.yoho.ufo.exception.PlatformException;
import com.yoho.ufo.order.service.impl.AsynVideoLiveService;
import com.yoho.ufo.order.service.impl.PhoneUidCameraService;
import com.yoho.ufo.order.service.impl.PhoneUidDepotService;
import com.yoho.ufo.order.service.impl.UfoLiveService;
import com.yoho.ufo.service.model.ApiResponse;
import com.yohobuy.ufo.model.order.bo.PhoneUidCameraBo;
import com.yohobuy.ufo.model.order.bo.PhoneUidDepotBo;
import com.yohobuy.ufo.model.order.req.QNliveReq;
import com.yohobuy.ufo.model.order.resp.CameraRecordResp;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* Created by li.ma on 2018/12/13.
... ... @@ -36,6 +40,9 @@ public class UfoLiveController {
@Autowired
private PhoneUidCameraService phoneUidCameraService;
@Autowired
private PhoneUidDepotService phoneUidDepotService;
@RequestMapping(value = "/generateMp4Vedio")
public ApiResponse generateMp4Vedio(BuyerOrderReq req) {
... ... @@ -199,4 +206,21 @@ public class UfoLiveController {
int reslut = phoneUidCameraService.insertArea(area);
return new ApiResponse.ApiResponseBuilder().code(200).data(reslut).message("更新成功").build();
}
@RequestMapping(value = "/savePhoneDepotRecord")
public ApiResponse savePhoneDepotRecord(PhoneUidDepotBo phoneUidDepotBo) {
LOGGER.info("savePhoneDepotRecord in. phoneUidDepotBo is {}", phoneUidDepotBo);
Boolean reslut = phoneUidDepotService.insert(phoneUidDepotBo);
return new ApiResponse.ApiResponseBuilder().code(reslut ? 200 : 400).data(reslut).message(reslut ? "保存成功" : "保存失败").build();
}
@RequestMapping(value = "/queryPhoneUidDepot")
public ApiResponse queryPhoneUidDepot(PhoneUidDepotBo phoneUidDepotBo) {
LOGGER.info("queryPhoneUidDepot in. ");
PhoneUidDepotBo reslut = phoneUidDepotService.selectByphoneUid(phoneUidDepotBo.getPhoneUid());
if(reslut == null){
return new ApiResponse.ApiResponseBuilder().code(400).data("").message("查询无鉴定中心信息").build();
}
return new ApiResponse.ApiResponseBuilder().code(200).data(reslut).message("查询成功").build();
}
}
... ...
... ... @@ -43,6 +43,9 @@ public class LiveEventsListener implements ApplicationListener<QiniuLiveRecordEv
@Autowired
private UfoLiveService ufoLiveService;
@Autowired
private LiveRecordHelper liveRecordHelper;
/**
* seller_order_code = #{sellerOrderCode,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=INTEGER},
... ... @@ -61,6 +64,10 @@ public class LiveEventsListener implements ApplicationListener<QiniuLiveRecordEv
return;
}
if (liveRecordHelper.noNeddGenerate(record.getOrderCode(), record.getStartTime())) {
return;
}
if (record.getEndTime() - record.getStartTime() > 300) {
record.setEndTime(record.getStartTime() + 300);
}
... ...
package com.yoho.ufo.order.service.event;
import com.google.common.collect.Lists;
import com.yoho.order.dal.QiniuLiveRecordMapper;
import com.yoho.order.model.QiniuLiveRecord;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
/**
* Created by li.ma on 2019/5/20.
*/
@Service
public class LiveRecordHelper {
private static final Logger LOGGER = LoggerFactory.getLogger(LiveRecordHelper.class);
@Autowired
private QiniuLiveRecordMapper qiniuLiveRecordMapper;
/**
* 如果已经存在视频,且开始时间一致,则无需再生成视频
* @param orderCode
* @param startTime
* @return true 无需再次生成
*/
public boolean noNeddGenerate(Long orderCode, Integer startTime) {
if (null == startTime || null == orderCode) {
LOGGER.error("method noNeddGenerate wrong, orderCode is {}, startTime is {}", orderCode, startTime);
return false;
}
boolean reslut = false;
List<QiniuLiveRecord> qiniuLiveRecords = qiniuLiveRecordMapper.selectByOrderCodes(Lists.newArrayList(orderCode));
if (CollectionUtils.isNotEmpty(qiniuLiveRecords) && startTime.equals(qiniuLiveRecords.get(0).getStartTime())) {
reslut = true;
}
LOGGER.info("method noNeddGenerate run. reslut is {}, orderCode is {}, startTime is {}", orderCode, startTime, reslut);
return reslut;
}
}
... ...
package com.yoho.ufo.order.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.collect.Maps;
import org.elasticsearch.common.netty.util.internal.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Splitter;
... ... @@ -9,8 +39,45 @@ import com.yoho.core.redis.cluster.operations.nosync.YHValueOperations;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.core.rest.client.ServiceCaller;
import com.yoho.error.exception.ServiceException;
import com.yoho.order.dal.*;
import com.yoho.order.model.*;
import com.yoho.order.dal.AppraiseAddressMapper;
import com.yoho.order.dal.BuyerOrderGoodsMapper;
import com.yoho.order.dal.BuyerOrderMapper;
import com.yoho.order.dal.BuyerOrderMetaMapper;
import com.yoho.order.dal.ExpressCompanyMapper;
import com.yoho.order.dal.ExpressInfoMapper;
import com.yoho.order.dal.ExpressRecordMapper;
import com.yoho.order.dal.OrderConfigMapper;
import com.yoho.order.dal.OrderOperateRecordMapper;
import com.yoho.order.dal.OrdersPayMapper;
import com.yoho.order.dal.PhoneUidDepotMapper;
import com.yoho.order.dal.QiniuLiveRecordMapper;
import com.yoho.order.dal.QualityCheckMapper;
import com.yoho.order.dal.SellerOrderGoodsMapper;
import com.yoho.order.dal.SellerOrderMapper;
import com.yoho.order.dal.SellerOrderMetaMapper;
import com.yoho.order.dal.SignForPackageMapper;
import com.yoho.order.dal.StoredSellerMapper;
import com.yoho.order.model.AppraiseAddress;
import com.yoho.order.model.BuyerOrder;
import com.yoho.order.model.BuyerOrderFeedback;
import com.yoho.order.model.BuyerOrderGoods;
import com.yoho.order.model.BuyerOrderMeta;
import com.yoho.order.model.BuyerOrderReq;
import com.yoho.order.model.ExpressCompany;
import com.yoho.order.model.ExpressInfo;
import com.yoho.order.model.ExpressRecord;
import com.yoho.order.model.OrderConfig;
import com.yoho.order.model.OrderOperateRecord;
import com.yoho.order.model.OrdersPay;
import com.yoho.order.model.PhoneUidDepot;
import com.yoho.order.model.QiniuLiveRecord;
import com.yoho.order.model.QualityCheck;
import com.yoho.order.model.QualityCheckResp;
import com.yoho.order.model.SellerOrder;
import com.yoho.order.model.SellerOrderGoods;
import com.yoho.order.model.SellerOrderMeta;
import com.yoho.order.model.SignForPackage;
import com.yoho.order.model.StoredSeller;
import com.yoho.service.model.order.request.OrderRequest;
import com.yoho.ufo.constants.PlatformConstant;
import com.yoho.ufo.constants.RedisKeyConstants;
... ... @@ -26,34 +93,26 @@ import com.yoho.ufo.order.service.IBuyerOrderService;
import com.yoho.ufo.service.impl.UfoServiceCaller;
import com.yoho.ufo.service.impl.UserHelper;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yoho.ufo.util.*;
import com.yohobuy.ufo.model.enums.ProductSkupStatusEnum;
import com.yoho.ufo.util.DateUtil;
import com.yoho.ufo.util.ImagesConstant;
import com.yoho.ufo.util.ImagesHelper;
import com.yoho.ufo.util.MobileHelper;
import com.yoho.ufo.util.OrderVideoUrlUtil;
import com.yohobuy.ufo.model.order.bo.AppraiseExpressInfoBo;
import com.yohobuy.ufo.model.order.common.*;
import com.yohobuy.ufo.model.order.common.EnumExpressType;
import com.yohobuy.ufo.model.order.common.EnumQualityCheckStatus;
import com.yohobuy.ufo.model.order.common.EnumQualityCheckType;
import com.yohobuy.ufo.model.order.common.OperateTypeEnum;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.req.BuyerOrderMetaUpdateReq;
import com.yohobuy.ufo.model.order.resp.*;
import com.yohobuy.ufo.model.order.resp.BuyerOrderResp;
import com.yohobuy.ufo.model.order.resp.ExpressInfoResp;
import com.yohobuy.ufo.model.order.resp.OrderDetailResp;
import com.yohobuy.ufo.model.order.resp.OrderOperateRecordResp;
import com.yohobuy.ufo.model.order.resp.QcOrderDetailResp;
import com.yohobuy.ufo.model.order.resp.SkupImageInfo;
import com.yohobuy.ufo.model.resp.product.SecondDetailResp;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.collect.Maps;
import org.elasticsearch.common.netty.util.internal.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* @author caoyan
... ... @@ -135,6 +194,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Autowired
private UfoServiceCaller ufoServiceCaller;
@Autowired
private PhoneUidDepotMapper phoneUidDepotMapper;
private static final String BUYER_ORDER_META_KEY_DELIVERY_ADDRESS = "delivery_address";
... ... @@ -1747,7 +1809,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
String url = erpDomain + PlatformConstant.ERP_GET_SF_WAYBILLCODE;
JSONObject jsonReqObj = getStringHttpEntity(buyerOrder, sellerGoods, appraiseAddress.getAddress(), skup, req.getPayMethod());
JSONObject jsonReqObj = getStringHttpEntity(buyerOrder, sellerGoods, appraiseAddress.getAddress(), skup, req);
HttpEntity<String> formEntity = new HttpEntity<>(jsonReqObj.toString(), getHttpHeaders());
LOGGER.info("getSfWaybillCode formEntity is {}, url is {}", formEntity.toString(), url);
... ... @@ -1846,7 +1908,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return RedisKeyBuilder.newInstance().appendFixed(RedisKeyConstants.SF_WAYBILL_CODE).appendVar(orderCode);
}
private JSONObject getStringHttpEntity(BuyerOrder buyerOrder, SellerOrderGoods sellerGoods, String appraiseAddress, Integer skup, Integer payMethod) {
private JSONObject getStringHttpEntity(BuyerOrder buyerOrder, SellerOrderGoods sellerGoods, String appraiseAddress, Integer skup, BuyerOrderReq req) {
JSONObject jsonObj = new JSONObject();
jsonObj.put("orderCode", buyerOrder.getOrderCode());
jsonObj.put("uid", buyerOrder.getUid());
... ... @@ -1864,9 +1926,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
jsonObj.put("jDistrict", addressMap.get("district"));
jsonObj.put("jAddress", addressMap.get("address"));
jsonObj.put("expressType", 2);//快件产品类型 1:标准快递 2:顺丰特惠(便宜,全程陆运)
jsonObj.put("payMethod", payMethod);//1:寄方付 2:收方付 3:第三方付
jsonObj.put("payMethod", req.getPayMethod());//1:寄方付 2:收方付 3:第三方付
jsonObj.put("businessCode", "UFO");
jsonObj.put("custid", sellerGoods.getDepotNo().intValue() == 0 ? beijingCustid : nanjingCustid);
jsonObj.put("custid", getCustId(req.getPhoneUid(), sellerGoods.getDepotNo()));
//收件人信息
if(buyerOrder.getStatus().equals(Constant.BUYER_ORDER_STATUS_JUDGE_PASS.getByteVal())
... ... @@ -1892,6 +1954,17 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return jsonObj;
}
private String getCustId(String phoneUid, Integer depotNo) {
if(StringUtils.isNotEmpty(phoneUid)) {
PhoneUidDepot record = phoneUidDepotMapper.selectByphoneUid(phoneUid);
if(null != record) {
depotNo = record.getDepotNo();
}
}
return depotNo.intValue() == 0 ? beijingCustid : nanjingCustid;
}
private void buildAddressInfo(JSONObject metaValue, JSONObject jsonObj, Integer uid) {
// jsonObj.put("dCompany", "");
jsonObj.put("dContact", metaValue.getString("consignee"));
... ...
package com.yoho.ufo.order.service.impl;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yoho.error.exception.ServiceException;
import com.yoho.order.dal.PhoneUidDepotMapper;
import com.yoho.order.model.PhoneUidDepot;
import com.yohobuy.ufo.model.order.bo.PhoneUidDepotBo;
/**
* Created by caoyan.
*/
@Service
public class PhoneUidDepotService {
private static final Logger LOGGER = LoggerFactory.getLogger(PhoneUidDepotService.class);
@Autowired
private PhoneUidDepotMapper phoneUidDepotMapper;
public boolean insert(PhoneUidDepotBo record) {
if (StringUtils.isEmpty(record.getPhoneUid()) || null == record.getDepotNo()) {
return false;
}
if (null != phoneUidDepotMapper.selectByphoneUid(record.getPhoneUid())) {
return false; //已存在
}
PhoneUidDepot phoneUidDepot = new PhoneUidDepot();
try {
BeanUtils.copyProperties(phoneUidDepot, record);
} catch (Exception e) {
LOGGER.error("insert method copyProperties find wrong params is " + record, e);
throw new ServiceException(500, "更新失败");
}
return phoneUidDepotMapper.insert(phoneUidDepot) > 0 ? true : false;
}
public PhoneUidDepotBo selectByphoneUid(String phoneUid) {
if (StringUtils.isEmpty(phoneUid)) {
return null;
}
PhoneUidDepot phoneUidDepot = phoneUidDepotMapper.selectByphoneUid(phoneUid);
if (null == phoneUidDepot) {
return null;
}
PhoneUidDepotBo bo = new PhoneUidDepotBo();
bo.setDepotNo(phoneUidDepot.getDepotNo());
bo.setPhoneUid(phoneUidDepot.getPhoneUid());
return bo;
}
}
... ...
... ... @@ -51,6 +51,7 @@ datasources:
- com.yoho.order.dal.SignForPackageMapper
- com.yoho.order.dal.OrderConfigMapper
- com.yoho.order.dal.PhoneUidCameraMapper
- com.yoho.order.dal.PhoneUidDepotMapper
ufo_resource:
servers:
... ...
... ... @@ -51,6 +51,7 @@ datasources:
- com.yoho.order.dal.SignForPackageMapper
- com.yoho.order.dal.OrderConfigMapper
- com.yoho.order.dal.PhoneUidCameraMapper
- com.yoho.order.dal.PhoneUidDepotMapper
ufo_resource:
servers:
... ...