推客直接收益,调整顺序
This commit is contained in:
parent
34924ad351
commit
553ef3a2cd
@ -19,6 +19,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@ -80,32 +81,40 @@ public class BrokerBiz {
|
||||
brokerRecord.setBrokerRate(broker.getBrokerRate());
|
||||
BigDecimal brokerRate = brokerRecord.getBrokerRate();
|
||||
BigDecimal brokerPrice = order.getPayPrice().multiply(brokerRate).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN);
|
||||
brokerRecord.setDirectPrice(order.getPayPrice());
|
||||
brokerRecord.setBrokerPrice(brokerPrice);
|
||||
reason += "金额:" + order.getPayPrice() + "元,提成比例:" + brokerRate + ",提成金额:" + brokerPrice + "元";
|
||||
reason += "金额:" + order.getPayPrice() + "元,提成比例:" + brokerRate + "%,提成金额:" + brokerPrice + "元";
|
||||
brokerRecord.setReason(reason);
|
||||
brokerRecordList.add(brokerRecord);
|
||||
} else {
|
||||
BigDecimal totalRate = brokerInfoList.stream().map(BrokerRespVO::getBrokerRate).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BrokerRespVO broker = brokerInfoList.get(0);
|
||||
BigDecimal firstRate = broker.getBrokerRate();
|
||||
BigDecimal brokerPrice = order.getPayPrice().multiply(firstRate).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN);
|
||||
BigDecimal realRate = broker.getBrokerRate();
|
||||
BigDecimal brokerPrice = order.getPayPrice().multiply(realRate).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN);
|
||||
AtomicBoolean isFirst = new AtomicBoolean(true);
|
||||
// todo 需要计算实际提成比例
|
||||
BigDecimal firstRate = BigDecimal.valueOf(50);
|
||||
BigDecimal secondRate = BigDecimal.valueOf(100).subtract(firstRate).divide(BigDecimal.valueOf(brokerInfoList.size() - 1), 2, RoundingMode.HALF_DOWN);
|
||||
brokerInfoList.forEach(item -> {
|
||||
String reason = "多人提成:支付金额:" + order.getPayPrice() + "元,可提成比例:" + firstRate + ",可提成金额:" + brokerPrice + ":";
|
||||
String reason = "多人提成:支付金额:" + order.getPayPrice() + "元,可提成比例:" + realRate + "%,可提成金额:" + brokerPrice + ":";
|
||||
BrokerRecord brokerRecord = new BrokerRecord();
|
||||
brokerRecord.setBrokerId(item.getId());
|
||||
brokerRecord.setOrderId(orderId);
|
||||
if (item.getBrokerRate() == null) {
|
||||
reason += "提成比例为空!";
|
||||
brokerRecord.setBrokerRate(BigDecimal.ZERO);
|
||||
BigDecimal interBrokerRate;
|
||||
if (isFirst.get()) {
|
||||
interBrokerRate = firstRate;
|
||||
brokerRecord.setDirectPrice(order.getPayPrice());
|
||||
} else {
|
||||
interBrokerRate = secondRate;
|
||||
brokerRecord.setDirectPrice(BigDecimal.ZERO);
|
||||
}
|
||||
brokerRecord.setOrderPrice(order.getPayPrice());
|
||||
BigDecimal interBrokerRate = item.getBrokerRate().divide(totalRate, 2, RoundingMode.HALF_DOWN);
|
||||
brokerRecord.setBrokerRate(interBrokerRate);
|
||||
BigDecimal interBrokerPrice = order.getPayPrice().multiply(interBrokerRate).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN);
|
||||
brokerRecord.setBrokerPrice(interBrokerPrice);
|
||||
reason += "提成比例:" + item.getBrokerRate() + ",实际提成比例:" + interBrokerRate + ",提成金额:" + interBrokerPrice + "元";
|
||||
reason += "二次提成比例:" + interBrokerRate + "%,提成金额:" + interBrokerPrice + "元";
|
||||
brokerRecord.setReason(reason);
|
||||
brokerRecordList.add(brokerRecord);
|
||||
isFirst.set(false);
|
||||
});
|
||||
}
|
||||
revokeOrder(orderId);
|
||||
|
@ -0,0 +1,5 @@
|
||||
package com.ycwl.basic.constant;
|
||||
|
||||
public class StorageConstant {
|
||||
public static final String VLOG_PATH = "vlog";
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.controller.extern;
|
||||
|
||||
import com.ycwl.basic.annotation.IgnoreToken;
|
||||
import com.ycwl.basic.mapper.FaceMapper;
|
||||
import com.ycwl.basic.mapper.MemberMapper;
|
||||
import com.ycwl.basic.mapper.VideoMapper;
|
||||
@ -23,7 +24,9 @@ import com.ycwl.basic.utils.ApiResponse;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -36,7 +39,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController("/ly")
|
||||
@RestController
|
||||
@RequestMapping("/ly")
|
||||
public class LyCompatibleController {
|
||||
@Autowired
|
||||
private FaceService faceService;
|
||||
@ -57,6 +61,7 @@ public class LyCompatibleController {
|
||||
private TaskTaskServiceImpl taskTaskServiceImpl;
|
||||
|
||||
@PostMapping("sendPhoto")
|
||||
@IgnoreToken
|
||||
public R sendPhoto(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request) {
|
||||
Map<String, String> headersMap = new HashMap<String, String>();
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
@ -72,12 +77,14 @@ public class LyCompatibleController {
|
||||
return R.error("请传入秘钥!");
|
||||
}
|
||||
String scid = request.getParameter("scid");
|
||||
Long scenicId = 0L;
|
||||
long scenicId;
|
||||
if (StringUtils.isBlank(scid)) {
|
||||
return R.error("景区ID为空!");
|
||||
}
|
||||
if (StringUtils.equals("288",scid)) {
|
||||
// 正式景区
|
||||
scenicId = 3955650120997015552L;
|
||||
} else {
|
||||
scenicId = 3946669713328836608L;
|
||||
}
|
||||
String openId = headersMap.get("client");
|
||||
MemberRespVO member = memberMapper.getByOpenId(openId);
|
||||
@ -104,7 +111,8 @@ public class LyCompatibleController {
|
||||
return R.ok().put("data", resp);
|
||||
}
|
||||
|
||||
@PostMapping("getIsVideo")
|
||||
@RequestMapping("getIsVideo")
|
||||
@IgnoreToken
|
||||
public R getIsVideo(HttpServletRequest request) {
|
||||
Map<String, String> headersMap = new HashMap<String, String>();
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
@ -140,7 +148,8 @@ public class LyCompatibleController {
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("getNewVideo")
|
||||
@RequestMapping("getNewVideo")
|
||||
@IgnoreToken
|
||||
public R getNewVideo(HttpServletRequest request) {
|
||||
Map<String, String> headersMap = new HashMap<String, String>();
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
|
@ -99,11 +99,11 @@ public class BrokerController {
|
||||
}
|
||||
|
||||
@ApiOperation("根据brokerId和时间范围查询每天的记录数量和orderPrice汇总")
|
||||
@GetMapping("/record/dailySummary")
|
||||
@GetMapping("/{id}/record/summary")
|
||||
public ApiResponse<List<DailySummaryRespVO>> getDailySummaryByBrokerId(
|
||||
@RequestParam Long brokerId,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date startTime,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime) {
|
||||
@PathVariable("id") Long brokerId,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) {
|
||||
return ApiResponse.success(brokerRecordService.getDailySummaryByBrokerId(brokerId, startTime, endTime));
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ public class BrokerRecord {
|
||||
private BigDecimal orderPrice;
|
||||
private BigDecimal brokerRate;
|
||||
private BigDecimal brokerPrice;
|
||||
private BigDecimal directPrice;
|
||||
private String reason;
|
||||
private Date createTime;
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.ycwl.basic.model.pc.broker.req;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@ -18,7 +19,9 @@ public class BrokerRecordReqQuery extends BaseQueryParameterReq {
|
||||
private Long brokerId;
|
||||
private Long orderId;
|
||||
@ApiModelProperty("开始时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date startTime;
|
||||
@ApiModelProperty("结束时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date endTime;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.model.pc.broker.resp;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -11,7 +12,10 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
public class DailySummaryRespVO {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private Date date;
|
||||
private Long recordCount;
|
||||
private Long scanCount;
|
||||
private Long orderCount;
|
||||
private BigDecimal totalOrderPrice;
|
||||
private BigDecimal totalBrokerPrice;
|
||||
}
|
@ -3,6 +3,7 @@ package com.ycwl.basic.model.pc.scenic.entity;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ycwl.basic.storage.enums.StorageType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -65,4 +66,7 @@ public class ScenicConfigEntity {
|
||||
* 人脸识别阈值,是0~100的数值
|
||||
*/
|
||||
private Float faceScoreThreshold;
|
||||
private StorageType storeType;
|
||||
private String storeConfigJson;
|
||||
private BigDecimal brokerDirectRate;
|
||||
}
|
||||
|
@ -164,17 +164,6 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
sourceVideoContent.setLockType(1);
|
||||
sourceImageContent.setLockType(1);
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(faceRespVO.getScenicId());
|
||||
if (!Integer.valueOf(1).equals(scenicConfig.getDisableSourceVideo())) {
|
||||
IsBuyRespVO isBuyRespVO = orderBiz.isBuy(userId, faceRespVO.getScenicId(), 1, faceId);
|
||||
sourceVideoContent.setSourceType(isBuyRespVO.getGoodsType());
|
||||
sourceVideoContent.setContentId(isBuyRespVO.getGoodsId());
|
||||
if (isBuyRespVO.isBuy()) {
|
||||
sourceVideoContent.setIsBuy(1);
|
||||
} else {
|
||||
sourceVideoContent.setIsBuy(0);
|
||||
}
|
||||
contentList.add(sourceVideoContent);
|
||||
}
|
||||
if (!Integer.valueOf(1).equals(scenicConfig.getDisableSourceImage())) {
|
||||
IsBuyRespVO isBuyRespVO = orderBiz.isBuy(userId, faceRespVO.getScenicId(), 2, faceId);
|
||||
sourceImageContent.setSourceType(isBuyRespVO.getGoodsType());
|
||||
@ -186,7 +175,17 @@ public class AppScenicServiceImpl implements AppScenicService {
|
||||
}
|
||||
contentList.add(sourceImageContent);
|
||||
}
|
||||
|
||||
if (!Integer.valueOf(1).equals(scenicConfig.getDisableSourceVideo())) {
|
||||
IsBuyRespVO isBuyRespVO = orderBiz.isBuy(userId, faceRespVO.getScenicId(), 1, faceId);
|
||||
sourceVideoContent.setSourceType(isBuyRespVO.getGoodsType());
|
||||
sourceVideoContent.setContentId(isBuyRespVO.getGoodsId());
|
||||
if (isBuyRespVO.isBuy()) {
|
||||
sourceVideoContent.setIsBuy(1);
|
||||
} else {
|
||||
sourceVideoContent.setIsBuy(0);
|
||||
}
|
||||
contentList.add(sourceVideoContent);
|
||||
}
|
||||
sourceList.stream().collect(Collectors.groupingBy(SourceRespVO::getType)).forEach((type, list) -> {
|
||||
ContentPageVO contentPageVO = new ContentPageVO();
|
||||
if (type == 1) {
|
||||
|
@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.ycwl.basic.biz.OrderBiz;
|
||||
import com.ycwl.basic.biz.TaskStatusBiz;
|
||||
import com.ycwl.basic.biz.TemplateBiz;
|
||||
import com.ycwl.basic.constant.StorageConstant;
|
||||
import com.ycwl.basic.constant.TaskConstant;
|
||||
import com.ycwl.basic.mapper.FaceMapper;
|
||||
import com.ycwl.basic.mapper.FaceSampleMapper;
|
||||
@ -51,6 +52,7 @@ import com.ycwl.basic.repository.VideoTaskRepository;
|
||||
import com.ycwl.basic.service.task.TaskService;
|
||||
import com.ycwl.basic.storage.StorageFactory;
|
||||
import com.ycwl.basic.storage.adapters.IStorageAdapter;
|
||||
import com.ycwl.basic.storage.utils.StorageUtil;
|
||||
import com.ycwl.basic.task.VideoPieceGetter;
|
||||
import com.ycwl.basic.repository.TemplateRepository;
|
||||
import com.ycwl.basic.utils.SnowFlakeUtil;
|
||||
@ -635,8 +637,15 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
if (task == null) {
|
||||
return null;
|
||||
}
|
||||
IStorageAdapter adapter = StorageFactory.use("video");
|
||||
String filename = task.getId() + "_" + task.getScenicId() + ".mp4";
|
||||
IStorageAdapter adapter;
|
||||
ScenicConfigEntity scenicConfig = scenicRepository.getScenicConfig(task.getScenicId());
|
||||
if (scenicConfig != null && scenicConfig.getStoreType() != null) {
|
||||
adapter = StorageFactory.get(scenicConfig.getStoreType());
|
||||
adapter.loadConfig(JSONObject.parseObject(scenicConfig.getStoreConfigJson(), Map.class));
|
||||
} else {
|
||||
adapter = StorageFactory.use("video");
|
||||
}
|
||||
String filename = StorageUtil.joinPath(StorageConstant.VLOG_PATH, task.getId() + "_" + task.getScenicId() + ".mp4");
|
||||
if (StringUtils.isBlank(task.getVideoUrl())) {
|
||||
// 生成
|
||||
String url = adapter.getUrl(filename);
|
||||
|
@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ycwl.basic.mapper.BrokerMapper">
|
||||
<insert id="add">
|
||||
insert into broker(scenic_id, `name`, phone, status, broker_enable, broker_rate, create_at, update_at) values (#{scenicId}, #{name}, #{phone}, 0, #{brokerEnable}, #{brokerRate}, now(), now())
|
||||
insert into broker(scenic_id, `name`, phone, status, broker_enable, broker_rate, create_at, update_at) values (#{scenicId}, #{name}, #{phone}, 1, #{brokerEnable}, #{brokerRate}, now(), now())
|
||||
</insert>
|
||||
<update id="update">
|
||||
update broker set `name` = #{name}, phone = #{phone}, broker_enable = #{brokerEnable}, broker_rate = #{brokerRate}, update_at = now() where id = #{id}
|
||||
@ -35,11 +35,13 @@
|
||||
delete from broker where id = #{id}
|
||||
</delete>
|
||||
<select id="list" resultType="com.ycwl.basic.model.pc.broker.resp.BrokerRespVO">
|
||||
select b.id, scenic_id, s.name as scenicName, b.`name`, b.phone, b.broker_enable, b.broker_rate, b.status, b.create_at, b.update_at,
|
||||
select b.id, scenic_id, s.name as scenicName, b.`name`, b.phone, b.broker_enable, b.broker_rate, b.status,
|
||||
(select count(1) from statistics s where s.type = 20 and s.morph_id = b.id) as broker_scan_count,
|
||||
(select count(1) from broker_record r where r.broker_id = b.id) as broker_order_count,
|
||||
(select sum(order_price) from broker_record r where r.broker_id = b.id) as broker_order_amount,
|
||||
create_at, update_at
|
||||
(select min(r.create_time) from broker_record r where r.broker_id = b.id) as first_broker_date,
|
||||
(select max(r.create_time) from broker_record r where r.broker_id = b.id) as last_broker_date,
|
||||
b.create_at, b.update_at
|
||||
from broker b left join scenic s on b.scenic_id = s.id
|
||||
<where>
|
||||
<if test="scenicId!= null">
|
||||
|
@ -31,23 +31,26 @@
|
||||
|
||||
<select id="getDailySummaryByBrokerId" resultType="com.ycwl.basic.model.pc.broker.resp.DailySummaryRespVO">
|
||||
SELECT date_series.date AS date,
|
||||
COALESCE(COUNT(br.id), 0) AS recordCount,
|
||||
COALESCE(SUM(br.order_price), 0) AS totalOrderPrice
|
||||
COALESCE(COUNT(s.id), 0) AS scanCount,
|
||||
COALESCE(COUNT(br.id), 0) AS orderCount,
|
||||
COALESCE(SUM(br.order_price), 0) AS totalOrderPrice,
|
||||
COALESCE(SUM(br.broker_price), 0) AS totalBrokerPrice
|
||||
FROM (
|
||||
SELECT DATE_ADD(#{startTime}, INTERVAL (units.i + tens.i * 10 + hundreds.i * 100) DAY) AS date
|
||||
FROM (SELECT 0 AS i UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) units
|
||||
CROSS JOIN (SELECT 0 AS i UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) tens
|
||||
CROSS JOIN (SELECT 0 AS i UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) hundreds
|
||||
WHERE DATE_ADD(#{startTime}, INTERVAL (units.i + tens.i * 10) DAY) <= #{endTime}
|
||||
WHERE DATE_ADD(#{startTime}, INTERVAL (units.i + tens.i * 10 + hundreds.i * 100) DAY) <= #{endTime}
|
||||
) date_series
|
||||
LEFT JOIN broker_record br ON DATE(br.create_time) = date_series.date AND br.broker_id = #{brokerId}
|
||||
LEFT JOIN statistics s ON s.type = 20 and DATE(s.create_time) = date_series.date and s.morph_id = #{brokerId}
|
||||
GROUP BY date_series.date
|
||||
ORDER BY date_series.date
|
||||
</select>
|
||||
|
||||
<insert id="add">
|
||||
insert into broker_record(broker_id, order_id, order_price, broker_rate, broker_price, reason, create_time)
|
||||
values (#{brokerId}, #{orderId}, #{orderPrice}, #{brokerRate}, #{brokerPrice}, #{reason}, now())
|
||||
insert into broker_record(broker_id, order_id, order_price, broker_rate, broker_price, direct_price, reason, create_time)
|
||||
values (#{brokerId}, #{orderId}, #{orderPrice}, #{brokerRate}, #{brokerPrice}, #{directPrice}, #{reason}, now())
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById">
|
||||
|
@ -103,7 +103,10 @@
|
||||
image_source_store_day=#{imageSourceStoreDay},
|
||||
user_source_expire_day=#{userSourceExpireDay},
|
||||
face_score_threshold=#{faceScoreThreshold},
|
||||
force_finish_time=#{forceFinishTime}
|
||||
force_finish_time=#{forceFinishTime},
|
||||
store_type=#{storeType},
|
||||
store_config_json=#{storeConfigJson},
|
||||
broker_direct_rate=#{brokerDirectRate}
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
Loading…
x
Reference in New Issue
Block a user