记得上下班打卡 | git大法好,push需谨慎

Commit a0de4a46 authored by 胡佳晨's avatar 胡佳晨

提交 partner列表

parent ea801a09
......@@ -31,13 +31,6 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-api-feign-sequence</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
......
package com.liquidnet.service.kylin.dto.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class PerformanceListParam {
@ApiModelProperty(value = "演出名称", example = "")
private String title;
@ApiModelProperty(value = "-2全部(不包括未提交)0未发布演出列表;3审核通过;6上线;7下架;8已结束;", example = "0")
private int status;
@ApiModelProperty(value = "-2全部,-1未提交审核,0审核中,1审核通过,2审核拒绝", example = "0")
private int auditStatus;
@ApiModelProperty(value = "演出开始时间", example = "2000-01-01 12:00:00")
private String timeStart;
@ApiModelProperty(value = "演出结束时间", example = "2000-01-01 12:00:00")
private String timeEnd;
@ApiModelProperty(value = "排序类型 1创建时间倒序 2创建时间正序 3演出时间倒序 4演出时间正序", example = "0")
private int orderType;
@ApiModelProperty(value = "停售时间", example = "2000-01-01 12:00:00")
private String stopSellTime;
@ApiModelProperty(value = "页数", example = "0")
private int page;
@ApiModelProperty(value = "数量", example = "20")
private int size;
@ApiModelProperty(value = "排序字段", hidden = true)
private String orderItem;
@ApiModelProperty(value = "排序方式", hidden = true)
private String orderSc;
public void setOrderType(int orderType) {
this.orderType = orderType;
switch (orderType) {
case 1: {
orderItem = "created_at";
orderSc = "desc";
}
case 2: {
orderItem = "created_at";
orderSc = "asc";
}
case 3: {
orderItem = "time_start";
orderSc = "desc";
}
case 4: {
orderItem = "time_start";
orderSc = "asc";
}
}
}
}
......@@ -16,6 +16,9 @@ public class PerformanceStep1Param implements Serializable {
@ApiModelProperty(value = "封面图", example = "https://img.zhengzai.tv/partner/2019/05/14/5cda2d0520177.png")
private String imgPoster;
@ApiModelProperty(value = "第三方id", example = "0")
private String merchantId;
@ApiModelProperty(value = "演出名称", example = "测试演出")
private String title;
......
......@@ -23,9 +23,6 @@ public class PerformanceStep2Param implements Serializable {
@ApiModelProperty(value = "是否提交 1提交 0不提交(不验证参数)", example = "0")
private int isSubmit;
@ApiModelProperty(value = "第三方id", example = "0")
private String merchantId;
@ApiModelProperty(value = "场次数据",hidden = true)
private List<TicketTimesTicketCreatePartnerVo> ticketTimes;
}
package com.liquidnet.service.kylin.dto.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -17,6 +18,7 @@ import java.util.List;
*/
@Data
@ApiModel
public class BannersVo implements Serializable {
@ApiModelProperty(value = "Banner主键ID")
private String bannersId;
......
package com.liquidnet.service.kylin.dto.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel
public class PagerVo<T> {
@ApiModelProperty(value = "返回记录集合")
......
......@@ -3,15 +3,16 @@ package com.liquidnet.service.kylin.dto.vo;
import com.liquidnet.service.kylin.entity.KylinPerformanceRelations;
import com.liquidnet.service.kylin.entity.KylinPerformanceStatus;
import com.liquidnet.service.kylin.entity.KylinPerformances;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
@ApiModel
@Data
public class PerformanceVo {
......@@ -29,7 +30,6 @@ public class PerformanceVo {
private String price;
@ApiModelProperty(value = "开售时间")
private String sellTime;
@ApiModelProperty(value = "城市id")
private String cityId;
@ApiModelProperty(value = "场地id")
......
package com.liquidnet.service.kylin.dto.vo;
import com.liquidnet.service.kylin.entity.KylinTicketTimes;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -8,6 +9,7 @@ import java.time.format.DateTimeFormatter;
import java.util.List;
@Data
@ApiModel
public class TicketTimesVo {
@ApiModelProperty(value = "主键")
......
......@@ -3,6 +3,7 @@ package com.liquidnet.service.kylin.dto.vo;
import com.liquidnet.service.kylin.entity.KylinTicketRelations;
import com.liquidnet.service.kylin.entity.KylinTicketStatus;
import com.liquidnet.service.kylin.entity.KylinTickets;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -10,6 +11,7 @@ import java.math.BigDecimal;
import java.time.format.DateTimeFormatter;
@Data
@ApiModel
public class TicketVo {
@ApiModelProperty(value = "主键")
......
package com.liquidnet.service.kylin.dto.vo.partner;
import com.liquidnet.service.kylin.dto.param.PerformanceCreateParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class PerformancePartnerListVo {
//演出数据
@ApiModelProperty(value = "主键id")
private String performancesId;
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "开演时间")
private String timeStart;
@ApiModelProperty(value = "结束时间")
private String timeEnd;
@ApiModelProperty(value = "总库存")
private int totalGeneral;
@ApiModelProperty(value = "销售库存")
private int saleGeneral;
@ApiModelProperty(value = "总销售金额")
private int totalSalePrice;
@ApiModelProperty(value = "剩余库存")
private int surplusGeneral;
@ApiModelProperty(value = "演出状态")
private int status;
@ApiModelProperty(value = "提交审核状态 -1未提交审核,0提交审核,1审核通过,2审核拒绝")
private int auditStatus;
@ApiModelProperty(value = "拒绝理由")
private String rejectTxt;
@ApiModelProperty(value = "创建时间")
private String createdAt;
@ApiModelProperty(value = "返回数据赋值",hidden = true)
public void setStatus0Data(PerformanceCreateParam item){
this.performancesId=item.getPerformancesId();
this.title=item.getTitle();
this.timeStart=item.getTimeStart();
this.timeEnd=item.getTimeEnd();
this.totalGeneral=0;
this.saleGeneral=0;
this.totalSalePrice=0;
this.status=0;
this.auditStatus=-1;
this.rejectTxt="";
this.createdAt=item.getCreatedAt();
}
}
package com.liquidnet.service.kylin.service.partner;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.PageInfo;
import com.liquidnet.service.kylin.dao.PerformancePartnerListDao;
import com.liquidnet.service.kylin.dto.param.PerformanceCreateParam;
import com.liquidnet.service.kylin.dto.param.PerformanceListParam;
import com.liquidnet.service.kylin.dto.param.PerformanceStep1Param;
import com.liquidnet.service.kylin.dto.param.PerformanceStep2Param;
import com.liquidnet.service.kylin.dto.vo.PerformanceVo;
import com.liquidnet.service.kylin.dto.vo.partner.PerformancePartnerListVo;
import com.liquidnet.service.kylin.entity.KylinPerformances;
import java.util.HashMap;
import java.util.List;
/**
* <p>
* 演出 服务类
......@@ -20,11 +28,13 @@ public interface IKylinPerformancesPartnerService extends IService<KylinPerforma
boolean createStep2(PerformanceStep2Param step1Param);
PerformanceStep1Param getStep1(String performancesId);
PerformanceCreateParam getStep1(String performancesId);
PerformanceStep2Param getStep2(String performancesId);
boolean onLinePerformance(String performancesId);
boolean outLinePerformance(String performancesId);
PageInfo<PerformancePartnerListDao> getList(PerformanceListParam performanceListParam);
}
package com.liquidnet.service.kylin.dao;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class PerformancePartnerListDao {
//演出数据
@ApiModelProperty(value = "主键id")
private String performancesId;
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "开演时间")
private String timeStart;
@ApiModelProperty(value = "结束时间")
private String timeEnd;
@ApiModelProperty(value = "总库存")
private int totalGeneral;
@ApiModelProperty(value = "销售库存")
private int saleGeneral;
@ApiModelProperty(value = "总销售金额")
private int totalSalePrice;
@ApiModelProperty(value = "总销售金额")
private int surplusGeneral;
@ApiModelProperty(value = "演出状态")
private int status;
@ApiModelProperty(value = "提交审核状态 -1未提交审核,0提交审核,1审核通过,2审核拒绝")
private int auditStatus;
@ApiModelProperty(value = "拒绝理由")
private String rejectTxt;
@ApiModelProperty(value = "创建时间")
private String createdAt;
}
package com.liquidnet.service.kylin.mapper;
import com.liquidnet.service.kylin.dao.FieldMisListDao;
import com.liquidnet.service.kylin.dao.PerformancePartnerListDao;
import com.liquidnet.service.kylin.entity.KylinPerformances;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import java.util.Map;
/**
* <p>
* 演出 Mapper 接口
......@@ -13,4 +18,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface KylinPerformancesMapper extends BaseMapper<KylinPerformances> {
//列表
List<PerformancePartnerListDao> partnerPerformanceList(Map<String,Object> map);
}
......@@ -2,4 +2,90 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liquidnet.service.kylin.mapper.KylinPerformancesMapper">
<resultMap id="partnerPerformanceListResult" type="com.liquidnet.service.kylin.dao.PerformancePartnerListDao">
<result column="performances_id" property="performancesId"/>
<result column="title" property="title"/>
<result column="time_start" property="timeStart"/>
<result column="time_end" property="timeEnd"/>
<result column="total_general" property="totalGeneral"/>
<result column="sale_general" property="saleGeneral"/>
<result column="total_sale_price" property="totalSalePrice"/>
<result column="surplus_general" property="surplusGeneral"/>
<result column="status" property="status"/>
<result column="audit_status" property="auditStatus"/>
<result column="reject_txt" property="rejectTxt"/>
<result column="created_at" property="createdAt"/>
</resultMap>
<!-- 列表封装 -->
<sql id="partner_performance_list_Column">
</sql>
<!-- 第三方演出列表 (不包含退票信息) -->
<select id="partnerPerformanceList" parameterType="java.util.Map" resultMap="partnerPerformanceListResult">
SELECT
p.performances_id ,
p.title ,
p.time_start ,
p.time_end ,
t.total_general ,
IFNULL(ot.sale_general , 0) AS 'sale_general' ,
IFNULL(ot.total_sale_price , 0) AS 'total_sale_price' ,
IFNULL(
(
t.total_general - ot.sale_general
) ,
0
) AS 'surplus_general' ,
ps.`status` ,
ps.audit_status ,
p.reject_txt ,
p.created_at
FROM
kylin_performances AS p
LEFT JOIN kylin_performance_status AS ps ON p.performances_id = ps.performance_id
LEFT JOIN kylin_performance_relations AS pr ON p.performances_id = pr.performance_id
LEFT JOIN(
SELECT
ttr.performance_id ,
ts.ticket_id ,
sum(ts.total_general) AS 'total_general'
FROM
kylin_ticket_status AS ts
LEFT JOIN kylin_ticket_relations AS tr ON tr.ticket_id = ts.ticket_id
LEFT JOIN kylin_ticket_time_relation AS ttr ON tr.times_id = ttr.times_id
) AS t ON p.performances_id = t.performance_id
LEFT JOIN(
SELECT
sum(ot.number) AS 'sale_general' ,
sum(ot.price_actual) AS 'total_sale_price' ,
ote.performance_id AS 'performance_id'
FROM
kylin_order_tickets AS ot
LEFT JOIN kylin_order_ticket_status AS ots ON ots.order_id = ot.order_tickets_id
LEFT JOIN kylin_order_ticket_entities AS ote ON ote.order_id = ot.order_tickets_id
WHERE
ots.`status` = 0
OR ots.`status` = 1
) AS ot ON ot.performance_id = p.performances_id
<where>
<if test="title!=''">
AND title LIKE LIKE concat('%', #{title}, '%')
</if>
<if test="status!='-2'">
AND ps.STATUS = #{status}
</if>
<if test="auditStatus!='-2'">
AND ps.audit_status = #{auditStatus}
</if>
<if test="timeStart!=''">
AND p.time_start BETWEEN #{timeStart} AND #{timeEnd}
</if>
<if test="stopSellTime!=''">
AND p.time_end LIKE concat('%', #{stopSellTime}, '%')
</if>
</where>
ORDER BY #{orderItem} #{orderSc}
</select>
</mapper>
......@@ -18,14 +18,6 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- api -->
<dependency>
<groupId>com.liquidnet</groupId>
<artifactId>liquidnet-api-feign-sequence</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- common -->
<dependency>
<groupId>com.liquidnet</groupId>
......
package com.liquidnet.service.kylin.controller.partner;
import com.github.pagehelper.PageInfo;
import com.liquidnet.service.ResponseDto;
import com.liquidnet.service.kylin.dao.PerformancePartnerListDao;
import com.liquidnet.service.kylin.dto.param.PerformanceCreateParam;
import com.liquidnet.service.kylin.dto.param.PerformanceListParam;
import com.liquidnet.service.kylin.dto.param.PerformanceStep1Param;
import com.liquidnet.service.kylin.dto.param.PerformanceStep2Param;
import com.liquidnet.service.kylin.dto.vo.partner.PerformancePartnerListVo;
import com.liquidnet.service.kylin.service.impl.partner.KylinPerformancesPartnerServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -10,6 +15,8 @@ import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
@Api(tags = "第三方-演出")
@RestController
@RequestMapping("partner/performance")
......@@ -18,6 +25,19 @@ public class PerformancePartnerController {
@Autowired
private KylinPerformancesPartnerServiceImpl performancesPartnerService;
@PostMapping(value = "list")
@ApiOperation(value = "演出列表")
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<PageInfo<PerformancePartnerListDao>> getList(@RequestBody PerformanceListParam performanceListParam) {
PageInfo<PerformancePartnerListDao> result = null;
result = performancesPartnerService.getList(performanceListParam);
if (null == result) {
return ResponseDto.failure("列表获取失败");
} else {
return ResponseDto.success(result);
}
}
@PostMapping(value = "step1")
@ApiOperation(value = "创建演出第一步")
@ApiResponse(code = 200, message = "接口返回对象参数")
......@@ -45,8 +65,8 @@ public class PerformancePartnerController {
@GetMapping(value = "step1")
@ApiOperation(value = "获取演出第一步数据")
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<PerformanceStep1Param> createStep1(@RequestParam("performancesId") String performancesId) {
PerformanceStep1Param result = performancesPartnerService.getStep1(performancesId);
public ResponseDto<PerformanceCreateParam> createStep1(@RequestParam("performancesId") String performancesId) {
PerformanceCreateParam result = performancesPartnerService.getStep1(performancesId);
if (result==null) {
return ResponseDto.failure("获取数据失败");
} else {
......
package com.liquidnet.service.kylin.service.impl.admin;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.DateUtil;
......@@ -15,6 +16,7 @@ import com.liquidnet.service.kylin.mapper.*;
import com.liquidnet.service.kylin.service.admin.IKylinPerformancesAdminService;
import com.liquidnet.service.kylin.service.impl.partner.KylinTicketTimesPartnerServiceImpl;
import com.liquidnet.service.kylin.service.impl.partner.KylinTicketsPartnerServiceImpl;
import com.liquidnet.service.kylin.timerTask.PerformanceVoTask;
import com.mongodb.BasicDBObject;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.ReturnDocument;
......@@ -50,6 +52,9 @@ public class KylinPerformancesAdminServiceImpl extends ServiceImpl<KylinPerforma
@Autowired
private MongoConverter mongoConverter;
@Autowired
private PerformanceVoTask performanceVoTask;
@Autowired
private RedisUtil redisUtil;
......@@ -85,184 +90,76 @@ public class KylinPerformancesAdminServiceImpl extends ServiceImpl<KylinPerforma
@Override
public PerformanceCreatePartnerVo performanceDetails(String performancesId) {
PerformanceCreateParam performanceData = mongoTemplate.findOne(Query.query(Criteria.where("performancesId").is(performancesId)), PerformanceCreateParam.class, PerformanceCreateParam.class.getSimpleName());
List<TicketTimesCreatePartnerVo> ticketTimesCreatePartnerVos = ticketTimesPartnerService.getTimesMongoList(performancesId);
List<TicketTimesTicketCreatePartnerVo> ticketTimesTicketCreatePartnerVoList = new ArrayList<TicketTimesTicketCreatePartnerVo>();
ArrayList<BigDecimal> floatList = new ArrayList<>();
ArrayList<String> StringList = new ArrayList<>();
for (TicketTimesCreatePartnerVo ticketTimes : ticketTimesCreatePartnerVos) {
TicketTimesTicketCreatePartnerVo ticketTimesTicketCreatePartnerVo = new TicketTimesTicketCreatePartnerVo();
BeanUtils.copyProperties(ticketTimes, ticketTimesTicketCreatePartnerVo);
List<TicketCreatePartnerVo> ticketCreatePartnerVos = ticketsPartnerService.getTicketMongoList(ticketTimes.getTicketTimesId());
ticketTimesTicketCreatePartnerVo.setTicket(ticketCreatePartnerVos);
ticketTimesTicketCreatePartnerVoList.add(ticketTimesTicketCreatePartnerVo);
for (TicketCreatePartnerVo ticketCreatePartnerVoItem : ticketCreatePartnerVos) {
floatList.add(ticketCreatePartnerVoItem.getPrice());
StringList.add(ticketCreatePartnerVoItem.getTimeEnd());
}
}
PerformanceCreatePartnerVo performanceCreatePartnerVo = new PerformanceCreatePartnerVo();
BeanUtils.copyProperties(performanceData, performanceCreatePartnerVo);
floatList.sort(Comparator.reverseOrder());
StringList.sort(Comparator.naturalOrder());
performanceCreatePartnerVo.setPrice(floatList.get(0) + "起");
performanceCreatePartnerVo.setStopSellTime(StringList.get(0));
performanceCreatePartnerVo.setTicketTimes(ticketTimesTicketCreatePartnerVoList);
performanceCreatePartnerVo.setStatus(1);
performanceCreatePartnerVo.setStatusSell(1);
performanceCreatePartnerVo.setRejectTxt("");
performanceCreatePartnerVo.setIsShow(1);
performanceCreatePartnerVo.setIsDistribution(0);
performanceCreatePartnerVo.setSyncAgent(0);
performanceCreatePartnerVo.setAuditStatus(0);
boolean exists = mongoTemplate.exists(Query.query(Criteria.where("performancesId").is(performancesId)), PerformanceCreatePartnerVo.class, PerformanceCreatePartnerVo.class.getSimpleName());
if (!exists) {
PerformanceCreatePartnerVo data = mongoTemplate.insert(
performanceCreatePartnerVo, PerformanceCreatePartnerVo.class.getSimpleName()
);
}
return performanceCreatePartnerVo;
return mongoTemplate.findOne(
Query.query(Criteria.where("performancesId").is(performancesId)),
PerformanceCreatePartnerVo.class,
PerformanceCreatePartnerVo.class.getSimpleName()
);
}
@Override
public boolean performanceAudit(String performancesId, int status, String rejectTxt) {
try {
LocalDateTime updatedAt = LocalDateTime.now();
HashMap<String, Object> map = new HashMap<>();
int auditStatus=0;
if (status == 3) {
rejectTxt="";
auditStatus=1;
//修改演出
HashMap<String, Object> map = new HashMap<>();
map.put("rejectTxt", "");
map.put("rejectTxt", rejectTxt);
map.put("status", status);
map.put("auditStatus", auditStatus);
map.put("updatedAt", updatedAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
BasicDBObject objectPerformanceVo = new BasicDBObject("$set", mongoConverter.convertToMongoType(map));
Document docPerformance = mongoTemplate.getCollection(PerformanceCreatePartnerVo.class.getSimpleName()).findOneAndUpdate(
mongoTemplate.getCollection(PerformanceCreatePartnerVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("performancesId").is(performancesId)).getQueryObject(),
objectPerformanceVo,
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
objectPerformanceVo
);
PerformanceCreatePartnerVo performanceCreatePartnerVo = JsonUtils.fromJson(docPerformance.toJson(), PerformanceCreatePartnerVo.class);
//创建演出
KylinPerformances performances = new KylinPerformances();
BeanUtils.copyProperties(performanceCreatePartnerVo, performances);
KylinPerformanceStatus performanceStatus = new KylinPerformanceStatus();
BeanUtils.copyProperties(performanceCreatePartnerVo, performanceStatus);
KylinPerformanceRelations performanceRelations = new KylinPerformanceRelations();
BeanUtils.copyProperties(performanceCreatePartnerVo, performanceRelations);
performances.setCreatedAt(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(performanceCreatePartnerVo.getCreatedAt())));
performances.setTimeStart(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(performanceCreatePartnerVo.getTimeStart())));
performances.setTimeEnd(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(performanceCreatePartnerVo.getTimeEnd())));
performances.setUpdatedAt(updatedAt);
performanceStatus.setPerformanceId(performances.getPerformancesId());
performanceStatus.setPerformanceStatusId(IDGenerator.nextSnowId().toString());
performanceStatus.setCreatedAt(performances.getCreatedAt());
performanceStatus.setUpdatedAt(updatedAt);
performanceRelations.setPerformanceId(performances.getPerformancesId());
performanceRelations.setPerformanceRelationsId(IDGenerator.nextSnowId().toString());
performanceRelations.setCreatedAt(performances.getCreatedAt());
performanceRelations.setUpdatedAt(updatedAt);
performancesMapper.insert(performances);
performanceStatusMapper.insert(performanceStatus);
performanceRelationsMapper.insert(performanceRelations);
//场次数据
List<TicketTimesCreatePartnerVo> ticketTimesCreatePartnerVos = ticketTimesPartnerService.getTimesMongoList(performancesId);
for (TicketTimesCreatePartnerVo ticketTimeItem : ticketTimesCreatePartnerVos) {
//创建场次
KylinTicketTimes ticketTimes = new KylinTicketTimes();
BeanUtils.copyProperties(ticketTimeItem, ticketTimes);
KylinTicketTimeRelation ticketTimeRelation = new KylinTicketTimeRelation();
BeanUtils.copyProperties(ticketTimeItem, ticketTimeRelation);
ticketTimes.setUseStart(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketTimeItem.getUseStart())));
ticketTimes.setUseEnd(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketTimeItem.getUseEnd())));
ticketTimes.setCreatedAt(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketTimeItem.getCreatedAt())));
ticketTimes.setUpdatedAt(updatedAt);
ticketTimeRelation.setPerformanceId(performancesId);
ticketTimeRelation.setTicketTimeRelationId(IDGenerator.nextSnowId().toString());
ticketTimeRelation.setTimesId(ticketTimes.getTicketTimesId());
ticketTimeRelation.setCreatedAt(ticketTimes.getCreatedAt());
ticketTimeRelation.setUpdatedAt(updatedAt);
ticketTimesMapper.insert(ticketTimes);
ticketTimeRelationMapper.insert(ticketTimeRelation);
//修改票
for (TicketCreatePartnerVo ticketItem : ticketsPartnerService.getTicketMongoList(ticketTimeItem.getTicketTimesId())) {
BasicDBObject objectTicketVo = new BasicDBObject("$set", mongoConverter.convertToMongoType(map));
Document docTicket = mongoTemplate.getCollection(TicketCreatePartnerVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("ticketsId").is(ticketItem.getTicketsId())).getQueryObject(),
objectTicketVo,
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
);
TicketCreatePartnerVo ticketCreatePartnerVo = JsonUtils.fromJson(docTicket.toJson(), TicketCreatePartnerVo.class);
//创建演出
KylinTickets tickets = new KylinTickets();
BeanUtils.copyProperties(ticketCreatePartnerVo, tickets);
KylinTicketStatus ticketStatus = new KylinTicketStatus();
BeanUtils.copyProperties(ticketCreatePartnerVo, ticketStatus);
KylinTicketRelations ticketRelations = new KylinTicketRelations();
BeanUtils.copyProperties(ticketCreatePartnerVo, ticketRelations);
tickets.setPriceExpress(new BigDecimal(0.00));
tickets.setPriceDiscountMember(new BigDecimal(0.00));
tickets.setPriceDiscount(new BigDecimal(0.00));
tickets.setTimeStart(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketItem.getTimeStart())));
tickets.setTimeEnd(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketItem.getTimeEnd())));
tickets.setTimeEndExpress(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketItem.getTimeEndExpress())));
tickets.setUseStart(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketTimeItem.getUseStart())));
tickets.setUseEnd(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketTimeItem.getUseEnd())));
tickets.setSaleRemindMinute(60);
tickets.setCreatedAt(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketItem.getCreatedAt())));
tickets.setUpdatedAt(updatedAt);
ticketStatus.setTicketStatusId(IDGenerator.nextSnowId().toString());
ticketStatus.setTicketId(tickets.getTicketsId());
ticketStatus.setCounts(1);
ticketStatus.setIsMember(1);
ticketStatus.setStatusExchange(7);
ticketStatus.setQrCodeShowTime(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketItem.getQrCodeShowTime())));
ticketRelations.setCreatedAt(tickets.getCreatedAt());
ticketRelations.setUpdatedAt(updatedAt);
ticketRelations.setTicketRelationsId(IDGenerator.nextSnowId().toString());
ticketRelations.setTicketId(tickets.getTicketsId());
ticketRelations.setCreatedAt(tickets.getCreatedAt());
ticketRelations.setUpdatedAt(updatedAt);
ticketsMapper.insert(tickets);
ticketStatusMapper.insert(ticketStatus);
ticketRelationsMapper.insert(ticketRelations);
}
}
} else if (status == 4) {
HashMap<String, Object> map = new HashMap<>();
auditStatus=2;
map.put("rejectTxt", rejectTxt);
map.put("auditStatus", auditStatus);
map.put("status", status);
map.put("updatedAt", updatedAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
BasicDBObject object = new BasicDBObject("$set", mongoConverter.convertToMongoType(map));
mongoTemplate.getCollection(PerformanceCreatePartnerVo.class.getSimpleName()).updateMany(
mongoTemplate.getCollection(PerformanceCreatePartnerVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("performancesId").is(performancesId)).getQueryObject(),
object
);
} else {
return false;
}
//修改
KylinPerformanceStatus performanceStatus = new KylinPerformanceStatus();
performanceStatus.setStatus(status);
performanceStatus.setAuditStatus(auditStatus);
performanceStatus.setUpdatedAt(updatedAt);
performanceStatusMapper.update(performanceStatus, new UpdateWrapper<KylinPerformanceStatus>().eq("performance_id", performancesId));
KylinPerformances performances = new KylinPerformances();
performances.setUpdatedAt(updatedAt);
performances.setRejectTxt(rejectTxt);
performancesMapper.update(performances, new UpdateWrapper<KylinPerformances>().eq("performances_id", performancesId));
List<TicketTimesCreatePartnerVo> ticketTimesCreatePartnerVos = ticketTimesPartnerService.getTimesMongoList(performancesId);
for (TicketTimesCreatePartnerVo ticketTimeItem : ticketTimesCreatePartnerVos) {
for (TicketCreatePartnerVo ticketItem : ticketsPartnerService.getTicketMongoList(ticketTimeItem.getTicketTimesId())) {
BasicDBObject objectTicketVo = new BasicDBObject("$set", mongoConverter.convertToMongoType(map));
mongoTemplate.getCollection(TicketCreatePartnerVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("ticketsId").is(ticketItem.getTicketsId())).getQueryObject(),
objectTicketVo
);
KylinTickets tickets = new KylinTickets();
tickets.setUpdatedAt(updatedAt);
ticketsMapper.update(tickets,new UpdateWrapper<KylinTickets>().eq("tickets_id", ticketItem.getTicketsId()));
KylinTicketStatus ticketStatus = new KylinTicketStatus();
ticketStatus.setUpdatedAt(updatedAt);
ticketStatus.setStatus(status);
ticketStatusMapper.update(ticketStatus,new UpdateWrapper<KylinTicketStatus>().eq("ticket_id", ticketItem.getTicketsId()));
}
}
return true;
} catch (Exception e) {
System.out.println("ERROR DATA = " + e.getMessage());
......
......@@ -2,30 +2,36 @@ package com.liquidnet.service.kylin.service.impl.partner;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.BeanUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.kylin.constant.KylinRedisConst;
import com.liquidnet.service.kylin.dao.PerformancePartnerListDao;
import com.liquidnet.service.kylin.dto.TicketInventoryDto;
import com.liquidnet.service.kylin.dto.param.PerformanceCreateParam;
import com.liquidnet.service.kylin.dto.param.PerformanceListParam;
import com.liquidnet.service.kylin.dto.param.PerformanceStep1Param;
import com.liquidnet.service.kylin.dto.param.PerformanceStep2Param;
import com.liquidnet.service.kylin.dto.vo.FieldsVo;
import com.liquidnet.service.kylin.dto.vo.PerformanceVo;
import com.liquidnet.service.kylin.dto.vo.TicketTimesVo;
import com.liquidnet.service.kylin.dto.vo.TicketVo;
import com.liquidnet.service.kylin.dto.vo.ignore.PerformanceIgnoreVo;
import com.liquidnet.service.kylin.dto.vo.ignore.TicketIgnoreVo;
import com.liquidnet.service.kylin.dto.vo.ignore.TicketTimesIgnoreVo;
import com.liquidnet.service.kylin.dto.vo.partner.PerformanceCreatePartnerVo;
import com.liquidnet.service.kylin.dto.vo.partner.TicketCreatePartnerVo;
import com.liquidnet.service.kylin.dto.vo.partner.TicketTimesCreatePartnerVo;
import com.liquidnet.service.kylin.dto.vo.partner.TicketTimesTicketCreatePartnerVo;
import com.liquidnet.service.kylin.dto.vo.partner.*;
import com.liquidnet.service.kylin.entity.*;
import com.liquidnet.service.kylin.mapper.*;
import com.liquidnet.service.kylin.service.partner.IKylinPerformancesPartnerService;
import com.liquidnet.service.kylin.service.impl.PerformanceVoTask;
import com.liquidnet.service.kylin.timerTask.PerformanceVoTask;
import com.mongodb.BasicDBObject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.MongoConverter;
import org.springframework.data.mongodb.core.query.Criteria;
......@@ -103,9 +109,18 @@ public class KylinPerformancesPartnerServiceImpl extends ServiceImpl<KylinPerfor
try {
step1Param.setCreatedAt(createdAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
step1Param.setPerformancesId(performanceId);
PerformanceStep1Param data = mongoTemplate.insert(
step1Param, PerformanceStep1Param.class.getSimpleName()
PerformanceCreateParam performanceCreateParam = new PerformanceCreateParam();
BeanUtils.copyProperties(step1Param, performanceCreateParam);
performanceCreateParam.setIsTrueName(0);
performanceCreateParam.setLimitCount(0);
performanceCreateParam.setCreatedAt(createdAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
performanceCreateParam.setIsSubmit(0);
performanceCreateParam.setStatus(0);
performanceCreateParam.setStatusSell(1);
mongoTemplate.insert(
performanceCreateParam, PerformanceCreateParam.class.getSimpleName()
);
return performanceId;
} catch (Exception e) {
return "";
......@@ -120,14 +135,6 @@ public class KylinPerformancesPartnerServiceImpl extends ServiceImpl<KylinPerfor
// 获取 当前时间 -> 创建时间
LocalDateTime createdAt = LocalDateTime.now();
PerformanceStep1Param info = mongoTemplate.findOne(Query.query(Criteria.where("performancesId").is(performanceId)),
PerformanceStep1Param.class,
PerformanceStep1Param.class.getSimpleName());
boolean isExists = mongoTemplate.exists(Query.query(Criteria.where("performancesId").is(performanceId).and("status").is(0)),
PerformanceCreateParam.class,
PerformanceCreateParam.class.getSimpleName());
boolean isExistsSubmit = mongoTemplate.exists(Query.query(Criteria.where("performancesId").is(performanceId).and("status").is(1)),
PerformanceCreateParam.class,
PerformanceCreateParam.class.getSimpleName());
......@@ -142,36 +149,16 @@ public class KylinPerformancesPartnerServiceImpl extends ServiceImpl<KylinPerfor
map.put("limitCount", step2Param.getLimitCount());
map.put("createdAt", createdAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
map.put("isSubmit", step2Param.getIsSubmit());
map.put("merchantId", step2Param.getMerchantId());
map.put("statuSell", 1);
//演出新增数据
PerformanceCreateParam performanceCreateParam = new PerformanceCreateParam();
BeanUtils.copyProperties(info, performanceCreateParam);
performanceCreateParam.setIsTrueName(step2Param.getIsTrueName());
performanceCreateParam.setLimitCount(step2Param.getLimitCount());
performanceCreateParam.setCreatedAt(createdAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
performanceCreateParam.setIsSubmit(step2Param.getIsSubmit());
performanceCreateParam.setMerchantId(step2Param.getMerchantId());
map.put("statusSell", 1);
// 获取第一步数据
if (step2Param.getIsSubmit() == 1) { // 提交
if (isExists) {
map.put("status", 1);
BasicDBObject object = new BasicDBObject("$set", mongoConverter.convertToMongoType(map));
mongoTemplate.getCollection(PerformanceCreateParam.class.getSimpleName()).updateOne(
Query.query(Criteria.where("performancesId").is(performanceId)).getQueryObject(),
object
);
} else {
// 提交 演出
performanceCreateParam.setStatus(1);
PerformanceCreateParam data = mongoTemplate.insert(
performanceCreateParam, PerformanceCreateParam.class.getSimpleName()
);
}
map.put("status", 1);
BasicDBObject object = new BasicDBObject("$set", mongoConverter.convertToMongoType(map));
mongoTemplate.getCollection(PerformanceCreateParam.class.getSimpleName()).updateOne(
Query.query(Criteria.where("performancesId").is(performanceId)).getQueryObject(),
object
);
//提交 票
List<TicketTimesCreatePartnerVo> ticketTimesCreatePartnerVoList = ticketTimesPartnerService.getTimesMongoList(performanceId);
for (TicketTimesCreatePartnerVo ticketTimes : ticketTimesCreatePartnerVoList) {
......@@ -182,34 +169,34 @@ public class KylinPerformancesPartnerServiceImpl extends ServiceImpl<KylinPerfor
}
if (ticketTimesCreatePartnerVoList.size() <= 0) {
return false;
}
} else { //保存
if (isExists) {
map.put("status", 0);
BasicDBObject object = new BasicDBObject("$set", mongoConverter.convertToMongoType(map));
mongoTemplate.getCollection(PerformanceCreateParam.class.getSimpleName()).updateMany(
Query.query(Criteria.where("performancesId").is(performanceId)).getQueryObject(),
object
);
} else {
// 保存 演出
performanceCreateParam.setStatus(0);
PerformanceCreateParam data = mongoTemplate.insert(
performanceCreateParam, PerformanceCreateParam.class.getSimpleName()
);
PerformanceCreatePartnerVo performanceCreatePartnerVo = performanceVoTask.createPerformanceCreateParam(performanceId);
HashMap<String, Object> mapSql = new HashMap<>();
mapSql.put("rejectTxt", "");
mapSql.put("status", 1);
mapSql.put("updatedAt", createdAt.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
performanceVoTask.createPerformanceMySql(performanceId, mapSql, performanceCreatePartnerVo, createdAt);
}
} else { //保存
map.put("status", 0);
BasicDBObject object = new BasicDBObject("$set", mongoConverter.convertToMongoType(map));
mongoTemplate.getCollection(PerformanceCreateParam.class.getSimpleName()).updateMany(
Query.query(Criteria.where("performancesId").is(performanceId)).getQueryObject(),
object
);
}
return true;
}
@Override
public PerformanceStep1Param getStep1(String performancesId) {
PerformanceStep1Param data = mongoTemplate.findOne(
Query.query(Criteria.where("performancesId").is(performancesId)), PerformanceStep1Param.class, PerformanceStep1Param.class.getSimpleName()
public PerformanceCreateParam getStep1(String performancesId) {
PerformanceCreateParam data = mongoTemplate.findOne(
Query.query(Criteria.where("performancesId").is(performancesId)), PerformanceCreateParam.class, PerformanceCreateParam.class.getSimpleName()
);
if (data == null) {
return new PerformanceStep1Param();
return new PerformanceCreateParam();
}
return data;
}
......@@ -382,25 +369,28 @@ public class KylinPerformancesPartnerServiceImpl extends ServiceImpl<KylinPerfor
//mongoVo 迁移 演出数据迁移
PerformanceVo performanceVo = mongoTemplate.findOne(Query.query(Criteria.where("performancesId").is(performancesId)), PerformanceVo.class, PerformanceVo.class.getSimpleName());
PerformanceIgnoreVo performanceIgnoreVo = new PerformanceIgnoreVo();
BeanUtils.copyProperties(performanceVo,performanceIgnoreVo);
BeanUtils.copyProperties(performanceVo, performanceIgnoreVo);
performanceIgnoreVo.setAppStatus(7);
mongoTemplate.insert(performanceIgnoreVo,PerformanceIgnoreVo.class.getSimpleName());
mongoTemplate.remove(Query.query(Criteria.where("performancesId").is(performancesId)),PerformanceVo.class, PerformanceVo.class.getSimpleName());
mongoTemplate.remove(Query.query(Criteria.where("performancesId").is(performancesId)), PerformanceIgnoreVo.class, PerformanceIgnoreVo.class.getSimpleName());
mongoTemplate.insert(performanceIgnoreVo, PerformanceIgnoreVo.class.getSimpleName());
mongoTemplate.remove(Query.query(Criteria.where("performancesId").is(performancesId)), PerformanceVo.class, PerformanceVo.class.getSimpleName());
List<TicketTimesVo> ticketTimesVoList = mongoTemplate.find(Query.query(Criteria.where("performanceId").is(performancesId)), TicketTimesVo.class, TicketTimesVo.class.getSimpleName());
for (TicketTimesVo ticketTimesVoItem : ticketTimesVoList) {
//场次数据迁移
TicketTimesIgnoreVo ticketTimesIgnoreVo = new TicketTimesIgnoreVo();
BeanUtils.copyProperties(ticketTimesVoItem,ticketTimesIgnoreVo);
mongoTemplate.insert(ticketTimesIgnoreVo,TicketTimesIgnoreVo.class.getSimpleName());
BeanUtils.copyProperties(ticketTimesVoItem, ticketTimesIgnoreVo);
mongoTemplate.remove(Query.query(Criteria.where("ticketTimesId").is(ticketTimesVoItem.getTicketTimesId())), TicketTimesIgnoreVo.class, TicketTimesIgnoreVo.class.getSimpleName());
mongoTemplate.insert(ticketTimesIgnoreVo, TicketTimesIgnoreVo.class.getSimpleName());
mongoTemplate.remove(Query.query(Criteria.where("ticketTimesId").is(ticketTimesVoItem.getTicketTimesId())), TicketTimesVo.class, TicketTimesVo.class.getSimpleName());
List<TicketVo> ticketVoList = mongoTemplate.find(Query.query(Criteria.where("timeId").is(ticketTimesVoItem.getTicketTimesId())), TicketVo.class, TicketVo.class.getSimpleName());
for (TicketVo ticketVoItem : ticketVoList) {
// 票 迁移
TicketIgnoreVo ticketIgnoreVo = new TicketIgnoreVo();
BeanUtils.copyProperties(ticketVoItem,ticketIgnoreVo);
mongoTemplate.insert(ticketIgnoreVo,TicketIgnoreVo.class.getSimpleName());
BeanUtils.copyProperties(ticketVoItem, ticketIgnoreVo);
mongoTemplate.remove(Query.query(Criteria.where("ticketsId").is(ticketVoItem.getTicketsId())), TicketIgnoreVo.class, TicketIgnoreVo.class.getSimpleName());
mongoTemplate.insert(ticketIgnoreVo, TicketIgnoreVo.class.getSimpleName());
mongoTemplate.remove(Query.query(Criteria.where("ticketsId").is(ticketVoItem.getTicketsId())), TicketVo.class, TicketVo.class.getSimpleName());
}
}
......@@ -409,4 +399,46 @@ public class KylinPerformancesPartnerServiceImpl extends ServiceImpl<KylinPerfor
return false;
}
}
@Override
public PageInfo<PerformancePartnerListDao> getList(PerformanceListParam performanceListParam) {
HashMap<String, Object> info = new HashMap<>();
int status = performanceListParam.getStatus();
int page = performanceListParam.getPage() - 1;
int size = performanceListParam.getSize();
PageInfo<PerformancePartnerListDao> pageInfoTmp = null;
if (status == 0) {//未发布演出
// 排序 分页
Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "createdAt"));
//条件
Criteria criteria = Criteria.where("status").is(status);
if (!performanceListParam.getTitle().isEmpty()) {
criteria.and("title").regex(".*?\\" + performanceListParam.getTitle());
}
Query query = Query.query(criteria);
// 查询总数
long count = mongoTemplate.count(query, PerformanceCreateParam.class, PerformanceCreateParam.class.getSimpleName());
List<PerformanceCreateParam> performanceCreateParam = mongoTemplate.find(query, PerformanceCreateParam.class, PerformanceCreateParam.class.getSimpleName());
query.with(pageable);
//处理Vo
List<PerformancePartnerListVo> voList = new ArrayList<>();
for (PerformanceCreateParam item : performanceCreateParam) {
PerformancePartnerListVo voData = new PerformancePartnerListVo();
voData.setStatus0Data(item);
voList.add(voData);
}
pageInfoTmp = new PageInfo(voList);
pageInfoTmp.setTotal(count);
} else {//演出列表
try {
PageHelper.startPage(performanceListParam.getPage(), performanceListParam.getSize());
List<PerformancePartnerListDao> voList = performancesMapper.partnerPerformanceList(BeanUtil.convertBeanToMap(performanceListParam));
pageInfoTmp = new PageInfo(voList);
return pageInfoTmp;
} catch (Exception e) {
return null;
}
}
return pageInfoTmp;
}
}
package com.liquidnet.service.kylin.service.impl;
package com.liquidnet.service.kylin.timerTask;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.kylin.constant.KylinRedisConst;
import com.liquidnet.service.kylin.dto.TicketInventoryDto;
import com.liquidnet.service.kylin.dto.param.PerformanceCreateParam;
import com.liquidnet.service.kylin.dto.vo.PerformanceVo;
import com.liquidnet.service.kylin.dto.vo.TicketTimesVo;
import com.liquidnet.service.kylin.dto.vo.TicketVo;
import com.liquidnet.service.kylin.dto.vo.partner.PerformanceCreatePartnerVo;
import com.liquidnet.service.kylin.dto.vo.partner.TicketCreatePartnerVo;
import com.liquidnet.service.kylin.dto.vo.partner.TicketTimesCreatePartnerVo;
import com.liquidnet.service.kylin.dto.vo.partner.TicketTimesTicketCreatePartnerVo;
import com.liquidnet.service.kylin.entity.*;
import com.liquidnet.service.kylin.mapper.*;
import com.liquidnet.service.kylin.service.impl.partner.KylinTicketTimesPartnerServiceImpl;
import com.liquidnet.service.kylin.service.impl.partner.KylinTicketsPartnerServiceImpl;
import com.mongodb.BasicDBObject;
import com.mongodb.client.model.FindOneAndUpdateOptions;
import com.mongodb.client.model.ReturnDocument;
import org.bson.Document;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.MongoConverter;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
......@@ -33,6 +51,36 @@ public class PerformanceVoTask {
@Autowired
private RedisUtil redisUtil;
@Autowired
private KylinPerformancesMapper performancesMapper;
@Autowired
private KylinPerformanceStatusMapper performanceStatusMapper;
@Autowired
private KylinPerformanceRelationsMapper performanceRelationsMapper;
@Autowired
private KylinTicketTimesPartnerServiceImpl ticketTimesPartnerService;
@Autowired
private KylinTicketsMapper ticketsMapper;
@Autowired
private KylinTicketStatusMapper ticketStatusMapper;
@Autowired
private KylinTicketRelationsMapper ticketRelationsMapper;
@Autowired
private KylinTicketTimesMapper ticketTimesMapper;
@Autowired
private KylinTicketTimeRelationMapper ticketTimeRelationMapper;
@Autowired
private KylinTicketsPartnerServiceImpl ticketsPartnerService;
public void performanceVoStatus(String performanceSingleId) {
......@@ -131,4 +179,165 @@ public class PerformanceVoTask {
}
}
/**
* 生成 PerformanceCreatePartnerVo(用于审核第一次提交数据)
* @param performancesId
* @return
*/
public PerformanceCreatePartnerVo createPerformanceCreateParam(String performancesId){
PerformanceCreateParam performanceData = mongoTemplate.findOne(Query.query(Criteria.where("performancesId").is(performancesId)), PerformanceCreateParam.class, PerformanceCreateParam.class.getSimpleName());
List<TicketTimesCreatePartnerVo> ticketTimesCreatePartnerVos = ticketTimesPartnerService.getTimesMongoList(performancesId);
List<TicketTimesTicketCreatePartnerVo> ticketTimesTicketCreatePartnerVoList = new ArrayList<TicketTimesTicketCreatePartnerVo>();
ArrayList<BigDecimal> floatList = new ArrayList<>();
ArrayList<String> StringList = new ArrayList<>();
for (TicketTimesCreatePartnerVo ticketTimes : ticketTimesCreatePartnerVos) {
TicketTimesTicketCreatePartnerVo ticketTimesTicketCreatePartnerVo = new TicketTimesTicketCreatePartnerVo();
BeanUtils.copyProperties(ticketTimes, ticketTimesTicketCreatePartnerVo);
List<TicketCreatePartnerVo> ticketCreatePartnerVos = ticketsPartnerService.getTicketMongoList(ticketTimes.getTicketTimesId());
ticketTimesTicketCreatePartnerVo.setTicket(ticketCreatePartnerVos);
ticketTimesTicketCreatePartnerVoList.add(ticketTimesTicketCreatePartnerVo);
for (TicketCreatePartnerVo ticketCreatePartnerVoItem : ticketCreatePartnerVos) {
floatList.add(ticketCreatePartnerVoItem.getPrice());
StringList.add(ticketCreatePartnerVoItem.getTimeEnd());
}
}
PerformanceCreatePartnerVo performanceCreatePartnerVo = new PerformanceCreatePartnerVo();
BeanUtils.copyProperties(performanceData, performanceCreatePartnerVo);
floatList.sort(Comparator.reverseOrder());
StringList.sort(Comparator.naturalOrder());
performanceCreatePartnerVo.setPrice(floatList.get(0) + "起");
performanceCreatePartnerVo.setStopSellTime(StringList.get(0));
performanceCreatePartnerVo.setTicketTimes(ticketTimesTicketCreatePartnerVoList);
performanceCreatePartnerVo.setStatus(1);
performanceCreatePartnerVo.setStatusSell(1);
performanceCreatePartnerVo.setRejectTxt("");
performanceCreatePartnerVo.setIsShow(1);
performanceCreatePartnerVo.setIsDistribution(0);
performanceCreatePartnerVo.setSyncAgent(0);
performanceCreatePartnerVo.setAuditStatus(0);
boolean exists = mongoTemplate.exists(Query.query(Criteria.where("performancesId").is(performancesId)), PerformanceCreatePartnerVo.class, PerformanceCreatePartnerVo.class.getSimpleName());
if (!exists) {
PerformanceCreatePartnerVo data = mongoTemplate.insert(
performanceCreatePartnerVo, PerformanceCreatePartnerVo.class.getSimpleName()
);
}
return performanceCreatePartnerVo;
}
public void createPerformanceMySql(String performancesId,HashMap<String, Object> map,PerformanceCreatePartnerVo performanceCreatePartnerVo,LocalDateTime updatedAt){
try {
//创建演出
KylinPerformances performances = new KylinPerformances();
BeanUtils.copyProperties(performanceCreatePartnerVo, performances);
KylinPerformanceStatus performanceStatus = new KylinPerformanceStatus();
BeanUtils.copyProperties(performanceCreatePartnerVo, performanceStatus);
KylinPerformanceRelations performanceRelations = new KylinPerformanceRelations();
BeanUtils.copyProperties(performanceCreatePartnerVo, performanceRelations);
performances.setCreatedAt(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(performanceCreatePartnerVo.getCreatedAt())));
performances.setTimeStart(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(performanceCreatePartnerVo.getTimeStart())));
performances.setTimeEnd(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(performanceCreatePartnerVo.getTimeEnd())));
performances.setUpdatedAt(updatedAt);
performanceStatus.setPerformanceId(performances.getPerformancesId());
performanceStatus.setPerformanceStatusId(IDGenerator.nextSnowId().toString());
performanceStatus.setCreatedAt(performances.getCreatedAt());
performanceStatus.setAuditStatus(0);
performanceStatus.setUpdatedAt(updatedAt);
performanceRelations.setPerformanceId(performances.getPerformancesId());
performanceRelations.setPerformanceRelationsId(IDGenerator.nextSnowId().toString());
performanceRelations.setCreatedAt(performances.getCreatedAt());
performanceRelations.setUpdatedAt(updatedAt);
performancesMapper.insert(performances);
performanceStatusMapper.insert(performanceStatus);
performanceRelationsMapper.insert(performanceRelations);
//场次数据
List<TicketTimesCreatePartnerVo> ticketTimesCreatePartnerVos = ticketTimesPartnerService.getTimesMongoList(performancesId);
for (TicketTimesCreatePartnerVo ticketTimeItem : ticketTimesCreatePartnerVos) {
//创建场次
KylinTicketTimes ticketTimes = new KylinTicketTimes();
BeanUtils.copyProperties(ticketTimeItem, ticketTimes);
KylinTicketTimeRelation ticketTimeRelation = new KylinTicketTimeRelation();
BeanUtils.copyProperties(ticketTimeItem, ticketTimeRelation);
ticketTimes.setUseStart(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketTimeItem.getUseStart())));
ticketTimes.setUseEnd(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketTimeItem.getUseEnd())));
ticketTimes.setCreatedAt(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketTimeItem.getCreatedAt())));
ticketTimes.setUpdatedAt(updatedAt);
ticketTimeRelation.setPerformanceId(performancesId);
ticketTimeRelation.setTicketTimeRelationId(IDGenerator.nextSnowId().toString());
ticketTimeRelation.setTimesId(ticketTimes.getTicketTimesId());
ticketTimeRelation.setCreatedAt(ticketTimes.getCreatedAt());
ticketTimeRelation.setUpdatedAt(updatedAt);
ticketTimesMapper.insert(ticketTimes);
ticketTimeRelationMapper.insert(ticketTimeRelation);
//修改票
for (TicketCreatePartnerVo ticketItem : ticketsPartnerService.getTicketMongoList(ticketTimeItem.getTicketTimesId())) {
BasicDBObject objectTicketVo = new BasicDBObject("$set", mongoConverter.convertToMongoType(map));
Document docTicket = mongoTemplate.getCollection(TicketCreatePartnerVo.class.getSimpleName()).findOneAndUpdate(
Query.query(Criteria.where("ticketsId").is(ticketItem.getTicketsId())).getQueryObject(),
objectTicketVo,
new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER)
);
TicketCreatePartnerVo ticketCreatePartnerVo = JsonUtils.fromJson(docTicket.toJson(), TicketCreatePartnerVo.class);
//创建演出
KylinTickets tickets = new KylinTickets();
BeanUtils.copyProperties(ticketCreatePartnerVo, tickets);
KylinTicketStatus ticketStatus = new KylinTicketStatus();
BeanUtils.copyProperties(ticketCreatePartnerVo, ticketStatus);
KylinTicketRelations ticketRelations = new KylinTicketRelations();
BeanUtils.copyProperties(ticketCreatePartnerVo, ticketRelations);
tickets.setPriceExpress(new BigDecimal("0.00"));
tickets.setPriceDiscountMember(new BigDecimal("0.00"));
tickets.setPriceDiscount(new BigDecimal("0.00"));
tickets.setTimeStart(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketItem.getTimeStart())));
tickets.setTimeEnd(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketItem.getTimeEnd())));
tickets.setTimeEndExpress(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketItem.getTimeEndExpress())));
tickets.setUseStart(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketTimeItem.getUseStart())));
tickets.setUseEnd(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketTimeItem.getUseEnd())));
tickets.setSaleRemindMinute(60);
tickets.setCreatedAt(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketItem.getCreatedAt())));
tickets.setUpdatedAt(updatedAt);
ticketStatus.setTicketStatusId(IDGenerator.nextSnowId().toString());
ticketStatus.setTicketId(tickets.getTicketsId());
ticketStatus.setCounts(1);
ticketStatus.setIsMember(1);
ticketStatus.setStatusExchange(7);
ticketStatus.setQrCodeShowTime(DateUtil.asLocalDateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(ticketItem.getQrCodeShowTime())));
ticketRelations.setCreatedAt(tickets.getCreatedAt());
ticketRelations.setUpdatedAt(updatedAt);
ticketRelations.setTicketRelationsId(IDGenerator.nextSnowId().toString());
ticketRelations.setTicketId(tickets.getTicketsId());
ticketRelations.setCreatedAt(tickets.getCreatedAt());
ticketRelations.setUpdatedAt(updatedAt);
ticketsMapper.insert(tickets);
ticketStatusMapper.insert(ticketStatus);
ticketRelationsMapper.insert(ticketRelations);
}
}
}catch (Exception e){
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment