Authored by caoyan

Merge branch 'test6.9.2' of http://git.yoho.cn/ufo/ufo-platform into test6.9.2

... ... @@ -281,10 +281,12 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{
}
private ApiResponse sendCouponByMQ(String couponToken, List<Integer> uidList){
UserHelper operator = new UserHelper();
LOGGER.info("sendCoupon with couponToken is {}, uidList is {}, operateUserId is {}, operateUserName is {}", couponToken, uidList, operator.getUserId(), operator.getUserName());
// ufo券校验 1.是否有效 2.可用数量是否大于所需发送人数
Coupon coupon = couponMapper.selectValidByToken(couponToken);
if(coupon == null){
LOGGER.info("sendCoupon failed with coupon isn't exist or isn't valid, token is {}", couponToken);
LOGGER.info("sendCoupon failed with coupon isn't exist or isn't valid, couponToken is {}", couponToken);
return new ApiResponse(201, "优惠券未在使用中!", null);
}
if(coupon.getEndTime() < DateUtil.getCurrentTimeSecond()){
... ... @@ -293,7 +295,7 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{
}
int availableNum = coupon.getCouponNum() - coupon.getSendNum();
if(uidList.size() > availableNum){
LOGGER.info("sendCoupon failed with couponNum isn't enough, uidSize is {}, availableCouponNum is {}", uidList.size(), availableNum);
LOGGER.info("sendCoupon failed with couponNum isn't enough,token is{}, uidSize is {}, availableCouponNum is {}",couponToken, uidList.size(), availableNum);
return new ApiResponse(201, "uid数量大于当前券可用数量:"+ availableNum + "!" , null);
}
// 发券
... ... @@ -305,6 +307,7 @@ public class CouponServiceImpl implements ICouponService,IBusinessExportService{
sendCouponParam.put("couponTokens", Collections.singletonList(coupon.getCouponToken()));
sendCouponParam.put("sendType", "1");//sendType 为1时, 若这张券已经领过,则仍然可以领
yhProducer.send("ufo.couponSendWithTradeMqNotify", sendCouponParam, null);
LOGGER.info("sendCoupon by mq, token is {}, uid is {}, operateUserId is {}, operateUserName is {}", couponToken, uid, operator.getUserId(), operator.getUserName());
Thread.sleep(5);
}catch (Exception e){
failUidList.add(uid);
... ...
package com.yoho.order.dal;
import com.yoho.order.model.PhoneUidCamera;
public interface PhoneUidCameraMapper {
int insert(PhoneUidCamera record);
PhoneUidCamera selectByphoneUid(String phoneUid);
int updateByphoneUid(PhoneUidCamera record);
}
\ No newline at end of file
... ...
... ... @@ -118,4 +118,6 @@ public class BuyerOrderReq extends PageRequestBO{
private Integer sellerDeliveryStatus ;
private Integer currentSecondMinus24Hours;
private String phoneUid;
}
... ...
package com.yoho.order.model;
import lombok.Data;
/**
* 手机唯一标识与摄像头编号的关系
*/
@Data
public class PhoneUidCamera {
private Integer id;
private Integer cameraCode;
private String phoneUid;
}
\ No newline at end of file
... ...
... ... @@ -43,6 +43,16 @@ public class QiniuLiveRecord {
private String vedioUrl; // 新方式生成的视频文件链接
private String phoneUid; // 手机唯一标识
public String getPhoneUid() {
return phoneUid;
}
public void setPhoneUid(String phoneUid) {
this.phoneUid = phoneUid;
}
public String getVedioUrl() {
return vedioUrl;
}
... ... @@ -243,6 +253,16 @@ public class QiniuLiveRecord {
private Integer cameraCode;
private String phoneUid; // 手机唯一标识
public String getPhoneUid() {
return phoneUid;
}
public void setPhoneUid(String phoneUid) {
this.phoneUid = phoneUid;
}
public Integer getCameraCode() {
return cameraCode;
}
... ... @@ -435,6 +455,7 @@ public class QiniuLiveRecord {
record.setShowFlag(this.getShowFlag());
record.setVedioFileUrl(this.getVedioFileUrl());
record.setUpdateTime(this.getUpdateTime());
record.setPhoneUid(this.getPhoneUid());
return record;
}
... ...
<?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.PhoneUidCameraMapper" >
<resultMap id="BaseResultMap" type="com.yoho.order.model.PhoneUidCamera" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="camera_code" property="cameraCode" jdbcType="INTEGER" />
<result column="phone_uid" property="phoneUid" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, camera_code, phone_uid
</sql>
<select id="selectByphoneUid" resultMap="BaseResultMap" parameterType="java.lang.String" >
select <include refid="Base_Column_List" /> from phone_uid_camera
where phone_uid = #{phoneUid,jdbcType=VARCHAR}
</select>
<insert id="insert" parameterType="com.yoho.order.model.PhoneUidCamera" >
insert into phone_uid_camera (camera_code, phone_uid) values (#{cameraCode,jdbcType=INTEGER}, #{phoneUid,jdbcType=VARCHAR})
</insert>
<update id="updateByphoneUid" parameterType="com.yoho.order.model.PhoneUidCamera" >
update phone_uid_camera set camera_code = #{cameraCode,jdbcType=INTEGER}
where phone_uid = #{phoneUid,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
... ...
... ... @@ -4,8 +4,10 @@ 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.UfoLiveService;
import com.yoho.ufo.service.model.ApiResponse;
import com.yohobuy.ufo.model.order.bo.PhoneUidCameraBo;
import com.yohobuy.ufo.model.order.req.QNliveReq;
import com.yohobuy.ufo.model.order.resp.CameraRecordResp;
import org.apache.commons.lang3.StringUtils;
... ... @@ -31,6 +33,9 @@ public class UfoLiveController {
@Autowired
private AsynVideoLiveService asynVideoLiveService;
@Autowired
private PhoneUidCameraService phoneUidCameraService;
@RequestMapping(value = "/generateMp4Vedio")
public ApiResponse generateMp4Vedio(BuyerOrderReq req) {
LOGGER.info("generateMp4Vedio in. req is {}", req);
... ... @@ -158,4 +163,33 @@ public class UfoLiveController {
List<QiniuLiveRecord> result = ufoLiveService.queryVideoInfo(req.getStartTime(), req.getEndTime());
return new ApiResponse.ApiResponseBuilder().code(200).data(result).build();
}
/**
* 当前手机标识的摄像头
* @return
*/
@RequestMapping(value = "/queryPhoneCurrentCamera")
public ApiResponse queryPhoneCurrentCamera(PhoneUidCameraBo phoneUidCameraBo) {
LOGGER.info("queryPhoneCurrentCamera in. ");
PhoneUidCameraBo reslut = phoneUidCameraService.selectByphoneUid(phoneUidCameraBo.getPhoneUid());
if(reslut == null){
return new ApiResponse.ApiResponseBuilder().code(400).data("").message("查询无摄像头信息").build();
}
return new ApiResponse.ApiResponseBuilder().code(200).data(reslut).message("查询成功").build();
}
@RequestMapping(value = "/savePhoneCameraRecord")
public ApiResponse savePhoneCameraRecord(PhoneUidCameraBo phoneUidCameraBo) {
LOGGER.info("savePhoneCameraRecord in. phoneUidCameraBo is {}", phoneUidCameraBo);
Boolean reslut = phoneUidCameraService.insert(phoneUidCameraBo);
return new ApiResponse.ApiResponseBuilder().code(200).data(reslut).message("查询成功").build();
}
@RequestMapping(value = "/updatePhoneCameraRecord")
public ApiResponse updatePhoneCameraRecord(PhoneUidCameraBo phoneUidCameraBo) {
LOGGER.info("updatePhoneCameraRecord in. phoneUidCameraBo is {}", phoneUidCameraBo);
int reslut = phoneUidCameraService.updateByphoneUid(phoneUidCameraBo);
return new ApiResponse.ApiResponseBuilder().code(200).data(reslut).message("更新成功").build();
}
}
... ...
... ... @@ -114,6 +114,7 @@ public class LiveEventsListener implements ApplicationListener<QiniuLiveRecordEv
result.setOrderCode(Long.valueOf(record.getOrderCode()));
result.setEndTime(null == record.getEndTime() ? DateUtil.getCurrentTimeSeconds() : record.getEndTime()); // 鉴定通过和不通过的时候,默认视频结束
result.setCameraCode(record.getCameraCode());
result.setPhoneUid(record.getPhoneUid());
return result;
}
}
... ...
package com.yoho.ufo.order.service.impl;
import com.yoho.error.exception.ServiceException;
import com.yoho.order.dal.PhoneUidCameraMapper;
import com.yoho.order.model.PhoneUidCamera;
import com.yoho.ufo.exception.PlatformException;
import com.yohobuy.ufo.model.order.bo.PhoneUidCameraBo;
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 java.lang.reflect.InvocationTargetException;
/**
* Created by li.ma on 2019/4/29.
*/
@Service
public class PhoneUidCameraService {
private static final Logger LOGGER = LoggerFactory.getLogger(PhoneUidCameraService.class);
@Autowired
private PhoneUidCameraMapper phoneUidCameraMapper;
public boolean insert(PhoneUidCameraBo record) {
if (StringUtils.isEmpty(record.getPhoneUid()) || null == record.getCameraCode()) {
return false;
}
PhoneUidCamera phoneUidCamera = new PhoneUidCamera();
try {
BeanUtils.copyProperties(phoneUidCamera, record);
} catch (Exception e) {
LOGGER.error("insert method copyProperties find wrong params is " + record, e);
throw new ServiceException(500, "更新失败");
}
return phoneUidCameraMapper.insert(phoneUidCamera) > 0 ? true : false;
}
public PhoneUidCameraBo selectByphoneUid(String phoneUid) {
if (StringUtils.isEmpty(phoneUid)) {
return null;
}
PhoneUidCamera phoneUidCamera = phoneUidCameraMapper.selectByphoneUid(phoneUid);
if (null == phoneUidCamera) {
return null;
}
PhoneUidCameraBo bo = new PhoneUidCameraBo();
bo.setCameraCode(phoneUidCamera.getCameraCode());
bo.setPhoneUid(phoneUidCamera.getPhoneUid());
return bo;
}
public int updateByphoneUid(PhoneUidCameraBo record) {
if (StringUtils.isEmpty(record.getPhoneUid()) || null == record.getCameraCode()) {
return 0;
}
PhoneUidCamera phoneUidCamera = new PhoneUidCamera();
try {
BeanUtils.copyProperties(phoneUidCamera, record);
} catch (Exception e) {
LOGGER.error("updateByphoneUid method copyProperties find wrong params is " + record, e);
throw new ServiceException(500, "更新失败");
}
return phoneUidCameraMapper.updateByphoneUid(phoneUidCamera);
}
}
... ...
... ... @@ -28,6 +28,7 @@ import com.yoho.ufo.service.impl.QNLiveUtilService;
import com.yoho.ufo.service.impl.UserHelper;
import com.yoho.ufo.util.DateUtil;
import com.yoho.ufo.util.OrderVideoUrlUtil;
import com.yohobuy.ufo.model.order.bo.PhoneUidCameraBo;
import com.yohobuy.ufo.model.order.constants.QNliveConstants;
import com.yohobuy.ufo.model.order.req.QNliveReq;
... ... @@ -79,6 +80,9 @@ public class UfoLiveService {
@Autowired
private OrderConfigConstant orderConfigConstant;
@Autowired
private PhoneUidCameraService phoneUidCameraService;
@Database(ForceMaster = true)
public void generateMp4(QiniuLiveRecord req) throws PlatformException {
LOGGER.info("method UfoLiveService.generateMp4 in, QNliveReq is {}", req);
... ... @@ -206,6 +210,13 @@ public class UfoLiveService {
// 查询当前登录用户默认的摄像头设备
public Integer queryInitCameraCode(QiniuLiveRecord req) {
// UserCameraRecord userCameraRecord = userCameraRecordMapper.selectUserCameraRecord(new UserHelper().getUserId());
Optional<Integer> phoneCamera = Optional.ofNullable(req.getPhoneUid()).map(phoneUidCameraService::selectByphoneUid).map(PhoneUidCameraBo::getCameraCode);
if (phoneCamera.isPresent()) { // 优先获取手机唯一标识对应的摄像头编号
return phoneCamera.get();
}
LOGGER.info("method queryInitCameraCode from getRedisKey, req is {}", req);
String cameraCode = yhValueOperations.get(getRedisKey(req.getPid()));
... ...
... ... @@ -50,6 +50,7 @@ datasources:
- com.yoho.order.dal.LiveRecordTimeMapper
- com.yoho.order.dal.SignForPackageMapper
- com.yoho.order.dal.OrderConfigMapper
- com.yoho.order.dal.PhoneUidCameraMapper
ufo_resource:
servers:
... ...
... ... @@ -50,6 +50,7 @@ datasources:
- com.yoho.order.dal.LiveRecordTimeMapper
- com.yoho.order.dal.SignForPackageMapper
- com.yoho.order.dal.OrderConfigMapper
- com.yoho.order.dal.PhoneUidCameraMapper
ufo_resource:
servers:
... ...