Commit 44a6ce7b authored by zhangfeng's avatar zhangfeng

订单V值触发

parent fd7d53f8
......@@ -12,7 +12,11 @@ public enum ScoreSourceTypeEnum {
SYSTEM_EXPIRED(3, "系统失效", ScoreOperateTypeEnum.REDUCE, null),
EXCHANGE_REWARD_CANCEL(4, "兑换礼品撤销", ScoreOperateTypeEnum.ADD, EXCHANGE_REWARD),
;
ORDER_V(5, "订单V值", ScoreOperateTypeEnum.ADD, null),
REGISTER(6, "注册", ScoreOperateTypeEnum.ADD, null),
RECOMMEND(7, "推荐", ScoreOperateTypeEnum.ADD, null),
SHARE(8, "分享活动", ScoreOperateTypeEnum.ADD, null);
private final int value;
......@@ -21,6 +25,7 @@ public enum ScoreSourceTypeEnum {
private final ScoreOperateTypeEnum operateType;
private final ScoreSourceTypeEnum reverseSource;
ScoreSourceTypeEnum(int value, String name, ScoreOperateTypeEnum operateType, ScoreSourceTypeEnum reverseSource) {
this.value = value;
this.name = name;
......
......@@ -49,10 +49,10 @@
<artifactId>yudao-module-depository-core</artifactId>
<version>${revision}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>cn.iocoder.boot</groupId>-->
<!-- <artifactId>yudao-module-order-core</artifactId>-->
<!-- <version>${revision}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-order-api</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</project>
......@@ -40,7 +40,7 @@ import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
@Slf4j
@Service
public class MemberUserScoreApiImpl implements MemberUserScoreApi{
public class MemberUserScoreApiImpl implements MemberUserScoreApi {
@Resource
private MemberUserScoreLogService logService;
......@@ -75,7 +75,7 @@ public class MemberUserScoreApiImpl implements MemberUserScoreApi{
List<ScoreDetailChangeDto> detailInfos = saveScoreDetail(req, logId);
saveScoreDetailReleation(req, detailInfos);
updateUserScore(req);
publishDetailExpireEvent(req,detailInfos);
publishDetailExpireEvent(req, detailInfos);
} catch (InterruptedException e) {
throw exception(GET_LOCK_FAILED);
} finally {
......@@ -85,7 +85,7 @@ public class MemberUserScoreApiImpl implements MemberUserScoreApi{
}
private void publishDetailExpireEvent(MemberUserScoreOperateReqDTO req, List<ScoreDetailChangeDto> detailInfos) {
if (req.getSourceType().getReverseSource() == null || req.getOperateType() ==ScoreOperateTypeEnum.REDUCE) {
if (req.getSourceType().getReverseSource() == null || req.getOperateType() == ScoreOperateTypeEnum.REDUCE) {
return;
}
//判断回退流程,回退的积分是否过期.如果过期再走正常的过期扣积分流程
......@@ -122,12 +122,12 @@ public class MemberUserScoreApiImpl implements MemberUserScoreApi{
}
}
return req.getMemberIds().stream().map(memberId -> operateScore(MemberUserScoreOperateReqDTO.builder()
.memberId(memberId)
.scoreCount(req.getScoreCount())
.operateType(req.getOperateType())
.sourceType(req.getSourceType())
.extParam(req.getExtParam())
.build()))
.memberId(memberId)
.scoreCount(req.getScoreCount())
.operateType(req.getOperateType())
.sourceType(req.getSourceType())
.extParam(req.getExtParam())
.build()))
.collect(Collectors.toList());
}
......@@ -158,24 +158,24 @@ public class MemberUserScoreApiImpl implements MemberUserScoreApi{
private void updateUserScore(MemberUserScoreOperateReqDTO req) {
memberUserScoreService.updateUserScore(MemberUserScoreUpdateReqDTO.builder()
.memberId(req.getMemberId())
.scoreCount(req.getScoreCount())
.operateType(req.getSourceType() == ScoreSourceTypeEnum.MANUAL_OPERATE ?
req.getOperateType() : req.getSourceType().getOperateType())
.sourceType(req.getSourceType())
.memberId(req.getMemberId())
.scoreCount(req.getScoreCount())
.operateType(req.getSourceType() == ScoreSourceTypeEnum.MANUAL_OPERATE ?
req.getOperateType() : req.getSourceType().getOperateType())
.sourceType(req.getSourceType())
.build());
}
private List<ScoreDetailChangeDto> saveScoreDetail(MemberUserScoreOperateReqDTO req, Long scoreLogId) {
return scoreDetailService.updateScoreDetail(MemberUserScoreDetailUpdateReqDto.builder()
.memberId(req.getMemberId())
.scoreCount(req.getScoreCount())
.operateType(req.getSourceType() == ScoreSourceTypeEnum.MANUAL_OPERATE ?
req.getOperateType() : req.getSourceType().getOperateType())
.sourceType(req.getSourceType())
.scoreLogId(scoreLogId)
.expireDays(req.getExpireDays())
.releationId(req.getReleationId())
.memberId(req.getMemberId())
.scoreCount(req.getScoreCount())
.operateType(req.getSourceType() == ScoreSourceTypeEnum.MANUAL_OPERATE ?
req.getOperateType() : req.getSourceType().getOperateType())
.sourceType(req.getSourceType())
.scoreLogId(scoreLogId)
.expireDays(req.getExpireDays())
.releationId(req.getReleationId())
.build());
}
......@@ -183,6 +183,7 @@ public class MemberUserScoreApiImpl implements MemberUserScoreApi{
return logService.createScoreLog(MemberUserScoreLogCreateReq.builder()
.memberId(req.getMemberId())
.scoreCount(req.getScoreCount())
.ruleId(req.getRuleId())
.operateType(req.getSourceType() == ScoreSourceTypeEnum.MANUAL_OPERATE ?
req.getOperateType().getValue() : req.getSourceType().getOperateType().getValue())
.sourceType(req.getSourceType().getValue())
......
package cn.iocoder.yudao.module.member.controller.admin.scoreRule;
import cn.iocoder.yudao.framework.apollo.core.event.OrderInShippingEvent;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.util.ExcelUtils;
......@@ -15,6 +16,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.ListUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -41,6 +43,8 @@ public class ScoreRuleController {
private ScoreRuleService scoreRuleService;
@Resource
private WarehouseService warehouseService;
@Resource
private ApplicationContext applicationContext;
@PostMapping("/create")
@ApiOperation("创建积分规则")
......@@ -119,6 +123,13 @@ public class ScoreRuleController {
return success(list);
}
@GetMapping("/test-score-rule")
@ApiOperation("测试订单V值触发")
public CommonResult<Void> testScoreRule(@RequestParam Long orderId, @RequestParam String orderNo) {
applicationContext.publishEvent(new OrderInShippingEvent(orderId, orderNo));
return success(null);
}
@GetMapping("/export-excel")
......
......@@ -16,6 +16,7 @@
<modules>
<module>yudao-module-order-core</module>
<module>yudao-module-order-rest</module>
<module>yudao-module-order-api</module>
</modules>
<description>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-order</artifactId>
<version>${revision}</version>
</parent>
<artifactId>yudao-module-order-api</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-common</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package cn.iocoder.boot.module.order.api;
import cn.iocoder.boot.module.order.api.dto.OrderRespDTO;
/**
* 订单 api
*/
public interface OrderApi {
/**
* 根据订单id或编号获取订单
*/
OrderRespDTO getOrder(Long id, String orderNo);
/**
* 判断是否用户首单
*/
boolean isFirstOrder(Long userId);
}
package cn.iocoder.boot.module.order.api.dto;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
/**
* 订单目的仓库
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class OrderObjectiveApiDO extends BaseDO {
/**
* 主键ID
*/
private Long id;
/**
* 订单id
*/
private Long orderId;
/**
* 目的地id
*/
private Long objectiveId;
@ApiModelProperty(value = "目的国家id")
private Long objectiveCountryId;
@ApiModelProperty(value = "目的仓库id")
private Long objectiveWarehouseId;
/**
* 目的地详情
*/
private String objective;
/**
* 0调仓标志;1原始数据,实际的目的地仓库
*/
private Integer type;
/**
* 货到没到这个仓库:0未到;1已到
*/
private Boolean isThis;
}
package cn.iocoder.boot.module.order.api.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OrderRespDTO {
/**
* 主键ID
*/
private Long orderId;
/**
* 订单编号
*/
private String orderNo;
/**
* 快递单号
*/
private String number;
/**
* 运输方式id
*/
private Integer transportId;
/**
* 渠道ID
*/
private Long channelId;
/**
* 订单类型(可多选):1 集运服务 2 海外仓
*/
private String type;
/**
* 下单会员id
*/
private Long userId;
/**
* 客户经理ID
*/
private Long salesmanId;
/**
* 部门ID
*/
private Long deptId;
/**
* 唛头
*/
private String marks;
/**
* 订单状态详情见字典
*/
private Integer status;
/**
* 订单异常状态(字典 order_abnormal_state)
*/
private Integer abnormalState;
/**
* 订单入仓状态(字典 order_warehouse_in_status)
*/
private Integer inWarehouseState;
/**
* 订单出货状态(字典 order_shipment_state)
*/
private Integer shipmentState;
/**
* 上次订单主状态值
*/
private Integer oldStatus;
/**
* 上次订单入仓状态值
*/
private Integer oldInWarehouseState;
/**
* 上次订单出货状态值
*/
private Integer oldShipmentState;
/**
* 是否被删掉 1 删掉;0正常
*/
private Boolean isDel;
@ApiModelProperty(value = "代收金额")
private BigDecimal collectionProxy;
@ApiModelProperty(value = "代收货币ID")
private Integer collectionProxyCurrency;
/**
* 是否代收货款收款 0为否 1为是
*/
private Boolean isCollection;
/**
* 重货体积
*/
private BigDecimal wVolume;
/**
* 泡货重量
*/
private BigDecimal vWeight;
/**
* 原应收重货体积
*/
private BigDecimal orgWVolume;
/**
* 原应收泡货重量
*/
private BigDecimal orgVWeight;
@ApiModelProperty(value = "最小计量重量")
private BigDecimal minMeteringWeight = BigDecimal.ZERO;
@ApiModelProperty(value = "最小计量体积")
private BigDecimal minMeteringVolume = BigDecimal.ZERO;
@ApiModelProperty(value = "最小计量个数")
private BigDecimal minMeteringQuantity = BigDecimal.ZERO;
/**
* 重货标准基数
*/
private BigDecimal weightUnit;
/**
* 泡货标准基数
*/
private BigDecimal volumeUnit;
@ApiModelProperty(value = "原重货标准基数")
private BigDecimal orgWeightUnit;
@ApiModelProperty(value = "原泡货标准基数")
private BigDecimal orgVolumeUnit;
@ApiModelProperty(value = "计算使用的重货标准基数")
private BigDecimal useWeightUnit;
@ApiModelProperty(value = "计算使用的泡货标准基数")
private BigDecimal useVolumeUnit;
/**
* 入仓类型
*/
private Integer warehouseType;
/**
* 备注
*/
private String remarks;
/**
* 调仓始发仓
*/
private Long adjustToStartWarehouseId;
/**
* 调仓目的仓
*/
private Long adjustToDestWarehouseId;
/**
* 目的地调仓始发仓
*/
private Long destAdjustToStartWarehouseId;
/**
* 目的地调仓目的仓
*/
private Long destAdjustToDestWarehouseId;
@ApiModelProperty(value = "入仓数量", required = true)
private Integer sumQuantity;
/**
* 入仓件数
*/
private Integer sumNum;
/**
* 自定义入仓体积
*/
private BigDecimal customSumVolume;
/**
* 入仓体积
*/
private BigDecimal sumVolume;
/**
* 自定义入仓重量
*/
private BigDecimal customSumWeight;
/**
* 入仓重量
*/
private BigDecimal sumWeight;
/**
* 重货比
*/
private BigDecimal weightRatio;
/**
* 发货人的客户id
*/
private Long customerId;
/**
* 完成入仓的入仓体积
*/
private BigDecimal sumVolumeFinishedWarehouseIn;
/**
* 完成入仓的入仓重量
*/
private BigDecimal sumWeightFinishedWarehouseIn;
/**
* 完成入仓的箱/件数
*/
private Integer sumCartonsNumFinishedWarehouseIn;
/**
* 完成入仓的所有箱内总货物数量
*/
private Integer sumQuantityAllFinishedWarehouseIn;
/**
* 上次打包的入仓体积
*/
@ApiModelProperty(value = "上次打包的入仓体积")
private BigDecimal sumVolumePrevPacked;
/**
* 上次打包的入仓重量
*/
@ApiModelProperty(value = "上次打包的入仓重量")
private BigDecimal sumWeightPrevPacked;
/**
* 上次打包的箱/件数
*/
@ApiModelProperty(value = "上次打包的箱数")
private Integer sumCartonsNumPrevPacked;
/**
* 上次打包的所有箱内总货物数量
*/
@ApiModelProperty(value = "上次打包的所有箱内总货物数量")
private Integer sumQuantityAllPrevPacked;
@ApiModelProperty(value = "付款人: 1 发货人 2 收货人 3 自定义")
private Integer drawee;
@ApiModelProperty(value = "自定义付款人信息")
private String customDrawee;
@ApiModelProperty(value = "打包前入仓重量")
private BigDecimal weightBeforePack;
@ApiModelProperty(value = "打包后入仓重量")
private BigDecimal weightAfterPack;
@ApiModelProperty(value = "是否有收货人,1-是,0-否")
private Boolean hasConsignee = true;
@TableField(exist = false)
@ApiModelProperty(value = "目的地信息")
@NotNull(message = "目的地信息不能为空")
private OrderObjectiveApiDO orderObjectiveDO;
@TableField(exist = false)
@ApiModelProperty(value = "目的地ID")
private Long objectiveId;
@TableField(exist = false)
@ApiModelProperty(value = "目的地")
private String objectiveName;
}
package cn.iocoder.boot.module.order.enums;
import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.util.json.core.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
@AllArgsConstructor
@Getter
public enum OrderStatusApiEnum implements IntArrayValuable {
DRAFT(0, "草稿", "draft", "",""),
//1未使用
ORDER_PLACED(2, "已下单", "Order placed", "",""),
WAREHOUSING(3, "入仓中", "Warehousing in progress", "",""),
// SPECIAL_APPLY_PROGRESS(4, "特价申请中", "Special offer application in progress", "",""),
IN_WAREHOUSE(5, "已入仓", "Warehousing", "货物已入捷道%s","The shipment has been delivered to E&C %s"),
WITHDRAWN_EXPENSES_NOT_CLEARED(6, "已退仓-费用未清", "Withdrawn - expense not cleared", "",""),
WITHDRAWN(7, "已退仓", "Withdrawn", "",""),
WAREHOUSE_ADJUSTMENT(8, "调仓中", "Warehouse adjustment in progress", "",""),
MERGED_ORDER(9, "已合单", "Closed order", "",""),
SPLIT_ORDER(10, "已拆单", "Split order", "",""),
PRE_INSTALLED(11, "已预装", "Pre installed", "",""),
INSTALLED_CABINET(12, "已装柜", "Installed cabinet", "预计开船时间:","Estimated time of departure:"),
IN_SHIPPING(13, "航运中", "In shipping", "货物已出仓,预计到港时间:","The goods have been warehoused, and the estimated arrival time is:"),
ARRIVED(14, "已到目的港", "Arrived", "",""),
CLEARED(15, "已清关", "Cleared", "货物已清关","The shipment been cleared out"),
UNLOADED_CABINET(16, "已卸柜", "Unloaded cabinet", "",""),
TWP_WAY_TAKEOFF(17, "二程起飞", "Two way takeoff", "",""),
TWP_WAY_ARRIVAL(18, "二程到目的港", "Two way arrival", "",""),
// WRITTEN_OFF(19, "已核销", "Written off"),
PICKED_UP(20, "已提货", "Picked up", "提货时间:","Pickup time:"),
PART_PICKED_UP(21, "部分提货", "Part Picked up", "提货时间:","Pickup time:"),
//....预留定义
// TALLY(31, "理货", "tally", "", ""),
SHIPMENT(32, "出货", "shipment", "", ""),
// ORDER_UPDATE(50, "订单修改中", "Order update in progress", "",""),
CANCEL(88, "取消订单", "cancellation of order", "",""),
// 此状态为状态13的空运转义状态,当运输方式为空运时,状态13为已起飞
HAS_TAKEN_OFF(130, "已起飞", "Has taken off", "货物已起飞,预计在%s日期抵达%s机场","The shipment has departed China.ETA date to %s is %s"),
CUSTOMS_PASS_AIR(12421, "已报关", "Customs Declaration", "货物报关已放行,候机中","Shipment been released by China custom.waiting to departed China"),
CUSTOMS_PART_EXIT(12322, "已报关", "Customs Inspection", "报关查验退场,返回仓库中","Shipment been Inspected by China custom.waiting return to warehouse"),
CUSTOMS_FULL_EXIT(12323, "已报关", "Customs Inspection", "报关查验退场,返回仓库中","Shipment been Inspected by China custom.waiting return to warehouse"),
WAREHOUSED(32412,"出仓", "Sent out","",""),
UNLOADED_CABINET_AIR(16435,"到仓", "Location","货物已抵达捷道%s提货仓","The shipment been delivered at E&C %s branch"),
;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(OrderStatusApiEnum::getValue).toArray();
/**
* 类型
*/
private final Integer value;
/**
* 类型中文名
*/
private final String nameZh;
/**
* 类型英文名
*/
private final String nameEn;
/**
* 备注中文名
*/
private final String remarksZh;
/**
* 备注英文名
*/
private final String remarksEn;
public static OrderStatusApiEnum valueOf(Integer value) {
return ArrayUtil.firstMatch(orderStatus -> orderStatus.getValue().equals(value), OrderStatusApiEnum.values());
}
@Override
public int[] array() {
return ARRAYS;
}
}
......@@ -57,7 +57,11 @@
<artifactId>yudao-module-infra-impl</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-order-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
......
package cn.iocoder.yudao.module.order.api;
import cn.iocoder.boot.module.order.api.OrderApi;
import cn.iocoder.boot.module.order.api.dto.OrderObjectiveApiDO;
import cn.iocoder.boot.module.order.api.dto.OrderRespDTO;
import cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO;
import cn.iocoder.yudao.module.order.dal.dataobject.orderObjective.OrderObjectiveDO;
import cn.iocoder.yudao.module.order.service.order.OrderObjectiveService;
import cn.iocoder.yudao.module.order.service.order.OrderService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
@Service
@Validated
public class OrderApiImpl implements OrderApi {
@Resource
private OrderService orderService;
@Resource
private OrderObjectiveService objectiveService;
@Override
public OrderRespDTO getOrder(Long id, String orderNo) {
OrderDO orderDO;
if (id != null) {
orderDO = orderService.getById(id);
} else {
orderDO = orderService.selectOne(new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getOrderNo, orderNo).last("limit 1"));
}
if (orderDO == null) {
return null;
}
OrderRespDTO orderRespDTO = new OrderRespDTO();
BeanUtils.copyProperties(orderDO, orderRespDTO);
OrderObjectiveDO orderObjectiveDO = objectiveService.getByOrderId(id);
if (orderObjectiveDO == null) {
return orderRespDTO;
}
OrderObjectiveApiDO orderObjectiveApiDO = new OrderObjectiveApiDO();
BeanUtils.copyProperties(orderObjectiveDO, orderObjectiveApiDO);
orderRespDTO.setOrderObjectiveDO(orderObjectiveApiDO);
return orderRespDTO;
}
@Override
public boolean isFirstOrder(Long userId) {
Long count = orderService.selectCount(new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getUserId, userId));
return count <= 0;
}
}
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