关联关系修改

This commit is contained in:
Jerry Yan 2024-12-30 14:37:27 +08:00
parent fd7511ad55
commit aa7d1fab52
17 changed files with 154 additions and 71 deletions

View File

@ -38,4 +38,6 @@ public interface OrderMapper {
OrderAppRespVO appDetail(Long id);
List<OrderRespVO> refundList(OrderReqQuery query);
List<OrderItemEntity> listOrderItemByOrderId(Long orderId);
}

View File

@ -51,4 +51,8 @@ public interface SourceMapper {
List<SourceRespVO> listUser(SourceReqQuery sourceReqQuery);
int addRelations(List<MemberSourceEntity> list);
int updateRelation(MemberSourceEntity memberSourceEntity);
List<SourceRespVO> queryByRelation(SourceReqQuery sourceReqQuery);
}

View File

@ -1,8 +1,6 @@
package com.ycwl.basic.mapper;
import com.ycwl.basic.model.pc.template.entity.TemplateEntity;
import com.ycwl.basic.model.pc.template.req.TemplateReqQuery;
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
import com.ycwl.basic.model.pc.video.entity.VideoEntity;
import com.ycwl.basic.model.pc.video.req.VideoReqQuery;
import com.ycwl.basic.model.pc.video.resp.VideoRespVO;
@ -25,4 +23,11 @@ public interface VideoMapper {
int update(VideoEntity task);
VideoEntity findByTaskId(@NonNull Long taskId);
int addRelation(MemberVideoEntity source);
int addRelations(List<MemberVideoEntity> list);
int updateRelation(MemberVideoEntity memberVideoEntity);
List<VideoRespVO> queryByRelation(VideoReqQuery videoReqQuery);
}

View File

@ -19,10 +19,6 @@ public class GoodsPageVO {
private Long scenicId;
@ApiModelProperty("景区名称")
private String scenicName;
@ApiModelProperty("经度")
private BigDecimal longitude;
@ApiModelProperty("纬度")
private BigDecimal latitude;
@ApiModelProperty("商品类型 1:成片视频 2:源素材")
private Integer goodsType;
@ApiModelProperty("源素材类型 1:视频 2:图片")

View File

@ -13,6 +13,4 @@ import lombok.Data;
public class ScenicDeviceCountVO {
@ApiModelProperty("景区设备总数")
private Integer totalDeviceCount;
@ApiModelProperty("拍摄到用户的设备数量")
private Integer shotDeviceCount;
}

View File

@ -11,4 +11,5 @@ public class MemberSourceEntity {
private Integer type;
private Long sourceId;
private Integer isBuy;
private Long orderId;
}

View File

@ -35,11 +35,6 @@ public class SourceRespVO {
*/
@ApiModelProperty("来源设备id")
private Long deviceId;
/**
* 所属用户
*/
@ApiModelProperty("所属用户")
private Long memberId;
@ApiModelProperty("原素材类型1视频2图像")
private Integer type;
/**

View File

@ -0,0 +1,13 @@
package com.ycwl.basic.model.pc.video.entity;
import lombok.Data;
@Data
public class MemberVideoEntity {
private Long id;
private Long memberId;
private Long taskId;
private Long videoId;
private Integer isBuy;
private Long orderId;
}

View File

@ -41,10 +41,6 @@ public class VideoRespVO {
private BigDecimal slashPrice;
@ApiModelProperty("模版封面图片")
private String templateCoverUrl;
@ApiModelProperty("经度")
private BigDecimal longitude;
@ApiModelProperty("纬度")
private BigDecimal latitude;
/**
* 任务id
*/

View File

@ -26,6 +26,7 @@ import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Authorlongbinbin
@ -54,14 +55,12 @@ public class GoodsServiceImpl implements GoodsService {
videoReqQuery.setIsBuy(query.getIsBuy());
videoReqQuery.setMemberId(Long.valueOf(BaseContextHandler.getUserId()));
//查询成片vlog
List<VideoRespVO> videoList = videoMapper.list(videoReqQuery);
List<VideoRespVO> videoList = videoMapper.queryByRelation(videoReqQuery);
videoList.forEach(videoRespVO -> {
GoodsPageVO goodsPageVO = new GoodsPageVO();
goodsPageVO.setGoodsName(videoRespVO.getTemplateName());
goodsPageVO.setScenicId(videoRespVO.getScenicId());
goodsPageVO.setScenicName(videoRespVO.getScenicName());
goodsPageVO.setLongitude(videoRespVO.getLongitude());
goodsPageVO.setLatitude(videoRespVO.getLatitude());
goodsPageVO.setGoodsType(1);
goodsPageVO.setGoodsId(videoRespVO.getId());
goodsPageVO.setTemplateName(videoRespVO.getTemplateName());
@ -73,21 +72,17 @@ public class GoodsServiceImpl implements GoodsService {
SourceReqQuery sourceReqQuery = new SourceReqQuery();
sourceReqQuery.setScenicId(query.getScenicId());
sourceReqQuery.setIsBuy(query.getIsBuy());
sourceReqQuery.setMemberId(query.getMemberId());
sourceReqQuery.setMemberId(Long.valueOf(BaseContextHandler.getUserId()));
//查询源素材
List<SourceRespVO> sourceList = sourceMapper.listGroupByType(sourceReqQuery);
sourceList.forEach(sourceRespVO -> {
List<SourceRespVO> sourceList = sourceMapper.queryByRelation(sourceReqQuery);
sourceList.stream().collect(Collectors.groupingBy(SourceRespVO::getType)).forEach((type, value) -> {
GoodsPageVO goodsPageVO = new GoodsPageVO();
Integer type = sourceRespVO.getType();
if(type==1){
if (type == 1) {
goodsPageVO.setGoodsName("原片集");
}else {
} else {
goodsPageVO.setGoodsName("照片集");
}
goodsPageVO.setScenicId(sourceRespVO.getScenicId());
goodsPageVO.setScenicName(sourceRespVO.getScenicName());
goodsPageVO.setLongitude(sourceRespVO.getLongitude());
goodsPageVO.setLatitude(sourceRespVO.getLatitude());
goodsPageVO.setScenicId(query.getScenicId());
goodsPageVO.setGoodsType(2);
goodsPageVO.setSourceType(type);
goodsList.add(goodsPageVO);
@ -187,8 +182,6 @@ public class GoodsServiceImpl implements GoodsService {
goodsDetailVO.setGoodsName(videoRespVO.getTemplateName());
goodsDetailVO.setScenicId(videoRespVO.getScenicId());
goodsDetailVO.setScenicName(videoRespVO.getScenicName());
goodsDetailVO.setLongitude(videoRespVO.getLongitude());
goodsDetailVO.setLatitude(videoRespVO.getLatitude());
goodsDetailVO.setGoodsType(1);
goodsDetailVO.setGoodsId(videoRespVO.getId());
goodsDetailVO.setVideoUrl(videoRespVO.getVideoUrl());

View File

@ -27,11 +27,17 @@ import com.ycwl.basic.enums.BizCodeEnum;
import com.ycwl.basic.enums.OrderStateEnum;
import com.ycwl.basic.enums.StatisticEnum;
import com.ycwl.basic.exception.AppException;
import com.ycwl.basic.mapper.OrderMapper;
import com.ycwl.basic.mapper.PaymentMapper;
import com.ycwl.basic.mapper.SourceMapper;
import com.ycwl.basic.mapper.StatisticsMapper;
import com.ycwl.basic.mapper.VideoMapper;
import com.ycwl.basic.model.mobile.statistic.req.StatisticsRecordAddReq;
import com.ycwl.basic.model.pc.order.entity.OrderItemEntity;
import com.ycwl.basic.model.pc.order.resp.OrderRespVO;
import com.ycwl.basic.model.pc.payment.entity.PaymentEntity;
import com.ycwl.basic.model.pc.source.entity.MemberSourceEntity;
import com.ycwl.basic.model.pc.video.entity.MemberVideoEntity;
import com.ycwl.basic.model.wx.WXPayOrderReqVO;
import com.ycwl.basic.model.wx.WxPayRespVO;
import com.ycwl.basic.model.wx.WxchatCallbackSuccessData;
@ -88,6 +94,12 @@ public class WxPayServiceImpl implements WxPayService {
private PaymentMapper paymentMapper;
@Autowired
private StatisticsMapper statisticsMapper;
@Autowired
private OrderMapper orderMapper;
@Autowired
private SourceMapper sourceMapper;
@Autowired
private VideoMapper videoMapper;
@Override
public WxPayRespVO createOrder(WXPayOrderReqVO req) {
@ -196,7 +208,31 @@ public class WxPayServiceImpl implements WxPayService {
}catch (Exception e) {
log.error("[微信支付回调]更新订单状态失败", e);
}
OrderRespVO byId = orderMapper.getById(orderId);
List<OrderItemEntity> orderItemList = orderMapper.listOrderItemByOrderId(orderId);
orderItemList.forEach(orderItemVO -> {
switch (orderItemVO.getGoodsType()) {
case 1: // 成片
MemberVideoEntity memberVideoEntity = new MemberVideoEntity();
memberVideoEntity.setMemberId(byId.getMemberId());
memberVideoEntity.setVideoId(orderItemVO.getGoodsId());
memberVideoEntity.setIsBuy(1);
memberVideoEntity.setOrderId(orderId);
videoMapper.updateRelation(memberVideoEntity);
break;
case 2: // 源素材
MemberSourceEntity memberSourceEntity = new MemberSourceEntity();
memberSourceEntity.setMemberId(byId.getMemberId());
memberSourceEntity.setSourceId(orderItemVO.getGoodsId());
memberSourceEntity.setType(orderItemVO.getGoodsType());
memberSourceEntity.setIsBuy(1);
memberSourceEntity.setOrderId(orderId);
sourceMapper.updateRelation(memberSourceEntity);
break;
default:
break;
}
});
}
}).start();

View File

@ -128,19 +128,6 @@ public class OrderServiceImpl implements OrderService {
orderItemEntity.setGoodsType(goodsType);
orderItemEntity.setGoodsId(goodsId);
orderItems.add(orderItemEntity);
//修改商品状态
// if (Objects.equals(goodsType, GoodsTypeEnum.VIDEO.code)) {
// VideoEntity videoEntity = new VideoEntity();
// videoEntity.setId(goodsId);
// videoEntity.setIsBuy(1);
// videoMapper.update(videoEntity);
// }else if (Objects.equals(goodsType, GoodsTypeEnum.SOURCE.code)) {
// SourceEntity sourceEntity = new SourceEntity();
// sourceEntity.setId(goodsId);
// sourceEntity.setIsBuy(1);
// sourceMapper.update(sourceEntity);
// }
});
int addOrderItems = orderMapper.addOrderItems(orderItems);
if (addOrderItems == NumberConstant.ZERO) {

View File

@ -17,6 +17,7 @@ import com.ycwl.basic.model.pc.source.resp.SourceRespVO;
import com.ycwl.basic.model.pc.task.entity.TaskEntity;
import com.ycwl.basic.model.pc.task.req.TaskReqQuery;
import com.ycwl.basic.model.pc.task.resp.TaskRespVO;
import com.ycwl.basic.model.pc.template.entity.TemplateConfigEntity;
import com.ycwl.basic.model.pc.template.entity.TemplateEntity;
import com.ycwl.basic.model.pc.template.resp.TemplateRespVO;
import com.ycwl.basic.model.pc.video.entity.VideoEntity;
@ -130,6 +131,7 @@ public class TaskTaskServiceImpl implements TaskService {
if (faceId == null) {
return;
}
TemplateConfigEntity config = templateMapper.getConfig(templateId);
FaceRespVO faceRespVO = faceMapper.getById(faceId);
if (faceRespVO == null) {
return;
@ -141,6 +143,11 @@ public class TaskTaskServiceImpl implements TaskService {
.map(FaceSampleRespVO::getSourceId)
.map(sourceId -> sourceMapper.getById(sourceId))
.collect(Collectors.groupingBy(item -> item.getDeviceId().toString()));
if (config != null) {
if (config.getMinimalPlaceholderFill() > sourcesMap.size()) {
throw new RuntimeException("请先游玩后在来生成吧~");
}
}
TaskEntity taskEntity = new TaskEntity();
taskEntity.setId(SnowFlakeUtil.getLongId());
taskEntity.setFaceId(faceId);

View File

@ -88,18 +88,9 @@
where d.scenic_id = #{scenicId}
</select>
<select id="deviceCountByScenicId" resultType="com.ycwl.basic.model.mobile.scenic.ScenicDeviceCountVO">
select ifnull(a.totalDeviceCount,0) as totalDeviceCount,ifnull(b.shotDeviceCount,0) as shotDeviceCount
from (
select count(1) totalDeviceCount,scenic_id
select count(1) totalDeviceCount
from device
where scenic_id = #{scenicId} and status = 1
)a
left join (
select count(1) shotDeviceCount,scenic_id
from source
where scenic_id = #{scenicId} and member_id=#{userId}
group by device_id
)b on a.scenic_id = b.scenic_id
</select>
<select id="getConfigByDeviceId" resultType="com.ycwl.basic.model.pc.device.entity.DeviceConfigEntity">
select *

View File

@ -209,10 +209,6 @@
from `order` o
left join member m on m.id = o.member_id
left join scenic s on o.scenic_id = s.id
left join order_item oi on o.id = oi.order_id
left join template t on o.goods_type='3' and oi.goods_id = t.id
left join source sr on o.goods_type='2' and oi.goods_id = sr.id
left join video vd on o.goods_type='1' and oi.goods_id = vd.id
where o.id = #{id}
</select>
<select id="getOrderCount" resultType="java.lang.Integer">
@ -395,4 +391,7 @@
</where>
order by o.create_at desc
</select>
<select id="listOrderItemByOrderId" resultType="com.ycwl.basic.model.pc.order.entity.OrderItemEntity">
select * from order_item where order_id = #{orderId}
</select>
</mapper>

View File

@ -6,14 +6,14 @@
values (#{id}, #{scenicId}, #{deviceId}, #{url}, #{videoUrl}, #{type}, #{faceSampleId}, #{posJson})
</insert>
<insert id="addRelation">
replace member_source(member_id, source_id, is_buy, type)
values (#{memberId}, #{sourceId}, #{isBuy}, #{type})
replace member_source(member_id, source_id, is_buy, type, order_id)
values (#{memberId}, #{sourceId}, #{isBuy}, #{type}, #{orderId})
</insert>
<insert id="addRelations">
replace member_source(member_id, source_id, is_buy, type)
replace member_source(member_id, source_id, is_buy, type, order_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.memberId}, #{item.sourceId}, #{item.isBuy}, #{item.type})
(#{item.memberId}, #{item.sourceId}, #{item.isBuy}, #{item.type}, #{orderId})
</foreach>
</insert>
<update id="update">
@ -30,12 +30,20 @@
</set>
where id = #{id}
</update>
<update id="updateRelation">
update member_source
<set>
<if test="isBuy!=null">is_buy = #{isBuy}, </if>
<if test="orderId!=null">order_id = #{orderId}, </if>
</set>
where member_id = #{memberId} and source_id = #{sourceId} and type = #{type}
</update>
<delete id="deleteById">
delete from source where id = #{id}
</delete>
<select id="list" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, scenic_id, device_id, member_id, url, so.create_time, so.update_time,sc.`name` as scenicName, so.video_url, so.`type`, so.face_sample_id
select so.id, scenic_id, device_id, url, so.create_time, so.update_time,sc.`name` as scenicName, so.video_url, so.`type`, so.face_sample_id
from source so
left join scenic sc on sc.id = so.scenic_id
<where>
@ -104,17 +112,27 @@
limit 1
</select>
<select id="listUser" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, scenic_id, device_id, url, so.create_time, so.update_time,sc.`name` as scenicName
select so.id, ms.scenic_id, device_id, url, so.create_time, so.update_time,sc.`name` as scenicName
from member_source ms
left join source so on ms.source_id = so.id
left join scenic sc on sc.id = so.scenic_id
where
ms.member_id = #{memberId}
<if test="scenicId!= null">and so.scenic_id = #{scenicId} </if>
<if test="deviceId!= null">and so.device_id = #{deviceId} </if>
<if test="scenicId!= null">and ms.scenic_id = #{scenicId} </if>
<if test="isBuy!=null">and ms.is_buy = #{isBuy}</if>
<if test="type!=null">and ms.type = #{type} </if>
<if test="faceId!=null">and FIND_IN_SET(so.face_sample_id, (select face.match_sample_ids from face where id = #{faceId})) </if>
order by so.create_time desc
</select>
<select id="queryByRelation" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
select so.id, ms.scenic_id, ms.type, so.url, so.create_time, so.update_time,sc.`name` as scenicName
from member_source ms
left join source so on ms.source_id = so.id
left join scenic sc on sc.id = so.scenic_id
where
ms.member_id = #{memberId}
<if test="type!=null">and ms.type = #{type} </if>
<if test="scenicId!= null">and ms.scenic_id = #{scenicId} </if>
<if test="isBuy!=null">and ms.is_buy = #{isBuy}</if>
</select>
</mapper>

View File

@ -5,6 +5,17 @@
insert into video(id, scenic_id, member_id, template_id, task_id, worker_id, video_url)
values (#{id}, #{scenicId}, #{memberId}, #{templateId}, #{taskId}, #{workerId}, #{videoUrl})
</insert>
<insert id="addRelation">
replace member_video(member_id, task_id, video_id, is_buy, order_id)
values (#{memberId}, #{taskId}, #{videoId}, #{isBuy}, #{orderId})
</insert>
<insert id="addRelations">
replace member_video(member_id, task_id, video_id, is_buy, order_id)
values
<foreach collection="list" item="item" separator=",">
(#{item.memberId}, #{item.taskId}, #{item.videoId}, #{item.isBuy}, #{orderId})
</foreach>
</insert>
<update id="update">
update video
<set>
@ -18,6 +29,14 @@
</set>
where id = #{id}
</update>
<update id="updateRelation">
update member_video
<set>
<if test="isBuy!= null">is_buy = #{isBuy}, </if>
<if test="orderId!= null">order_id = #{orderId}, </if>
</set>
where member_id = #{memberId} and video_id = #{videoId}
</update>
<delete id="deleteById">
delete from video where id = #{id}
</delete>
@ -60,4 +79,27 @@
<select id="findByTaskId" resultType="com.ycwl.basic.model.pc.video.entity.VideoEntity">
select * from video where task_id = #{taskId} limit 1
</select>
<select id="queryByRelation" resultType="com.ycwl.basic.model.pc.video.resp.VideoRespVO">
select v.id, mv.scenic_id, v.template_id, mv.task_id, worker_id, video_url, v.create_time, v.update_time,
s.name scenicName, t.name templateName, t.price templatePrice,t.cover_url templateCoverUrl,mv.is_buy
from member_video mv
left join video v on mv.video_id = v.id
left join scenic s on s.id = v.scenic_id
left join template t on v.template_id = t.id
<where>
<if test="scenicId!= null">and mv.scenic_id = #{scenicId} </if>
<if test="memberId!= null">and mv.member_id = #{memberId} </if>
<if test="templateId!= null">and template_id = #{templateId} </if>
<if test="taskId!=null">and mv.task_id = #{taskId} </if>
<if test="isBuy!=null">and mv.is_buy = #{isBuy}</if>
<if test="startTime!= null">and v.create_time &gt;= #{startTime} </if>
<if test="endTime!= null">and v.create_time &lt;= #{endTime} </if>
<if test="faceId!= null">
and mv.task_id in (
select id from task where face_id = #{faceId}
)
</if>
</where>
order by v.create_time desc
</select>
</mapper>