From 2aae6068bbf1aff1ffb2813098553ac632d5002b Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期二, 10 九月 2024 16:24:20 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master-v2' into master-v2
---
src/main/java/com/mzl/flower/dto/response/payment/DeliveryOrderList4CheckDTO.java | 2
src/main/java/com/mzl/flower/web/payment/DeliveryOrderController.java | 16 ++++
src/main/java/com/mzl/flower/service/flower/FlowerService.java | 3
src/main/java/com/mzl/flower/service/point/PointGoodsService.java | 110 +++++++++++++++-----------
src/main/java/com/mzl/flower/service/point/CustomerPointService.java | 2
src/main/resources/mapper/payment/OrderMapper.xml | 4 +
src/main/java/com/mzl/flower/dto/request/payment/DeliveryOrderInfoSpQueryDTO.java | 7 +
src/main/java/com/mzl/flower/dto/response/payment/DeliveryOrderItem4CheckDTO.java | 2
src/main/java/com/mzl/flower/dto/request/payment/DeliveryOrderStationQueryDTO.java | 7 +
src/main/java/com/mzl/flower/dto/request/payment/OrderQueryDTO.java | 3
src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java | 4
src/main/resources/mapper/point/CustomerPointMapper.xml | 16 ++-
src/main/resources/mapper/payment/DeliveryOrderMapper.xml | 23 ++++-
src/main/java/com/mzl/flower/service/system/UserService.java | 2
14 files changed, 139 insertions(+), 62 deletions(-)
diff --git a/src/main/java/com/mzl/flower/dto/request/payment/DeliveryOrderInfoSpQueryDTO.java b/src/main/java/com/mzl/flower/dto/request/payment/DeliveryOrderInfoSpQueryDTO.java
index 04dc3fe..aeee9a5 100644
--- a/src/main/java/com/mzl/flower/dto/request/payment/DeliveryOrderInfoSpQueryDTO.java
+++ b/src/main/java/com/mzl/flower/dto/request/payment/DeliveryOrderInfoSpQueryDTO.java
@@ -4,6 +4,7 @@
import lombok.Data;
import java.time.LocalDateTime;
+import java.util.List;
@Data
public class DeliveryOrderInfoSpQueryDTO {
@@ -28,9 +29,15 @@
@ApiModelProperty(value = "库位名称")
private String warehouseLocationCode;
+ @ApiModelProperty(value = "日期")
+ private String date;
+
@ApiModelProperty(hidden = true)
private LocalDateTime startDate;
@ApiModelProperty(hidden = true)
private LocalDateTime endDate;
+
+ @ApiModelProperty(hidden = true)
+ private List<String> statusList;
}
diff --git a/src/main/java/com/mzl/flower/dto/request/payment/DeliveryOrderStationQueryDTO.java b/src/main/java/com/mzl/flower/dto/request/payment/DeliveryOrderStationQueryDTO.java
index e503680..19217da 100644
--- a/src/main/java/com/mzl/flower/dto/request/payment/DeliveryOrderStationQueryDTO.java
+++ b/src/main/java/com/mzl/flower/dto/request/payment/DeliveryOrderStationQueryDTO.java
@@ -4,6 +4,7 @@
import lombok.Data;
import java.time.LocalDateTime;
+import java.util.List;
@Data
public class DeliveryOrderStationQueryDTO {
@@ -34,9 +35,15 @@
@ApiModelProperty(value = "库位名称")
private String warehouseLocationCode;
+ @ApiModelProperty(value = "日期")
+ private String date;
+
@ApiModelProperty(hidden = true)
private LocalDateTime startDate;
@ApiModelProperty(hidden = true)
private LocalDateTime endDate;
+
+ @ApiModelProperty(hidden = true)
+ private List<String> statusList;
}
diff --git a/src/main/java/com/mzl/flower/dto/request/payment/OrderQueryDTO.java b/src/main/java/com/mzl/flower/dto/request/payment/OrderQueryDTO.java
index d271a9a..ca40541 100644
--- a/src/main/java/com/mzl/flower/dto/request/payment/OrderQueryDTO.java
+++ b/src/main/java/com/mzl/flower/dto/request/payment/OrderQueryDTO.java
@@ -70,4 +70,7 @@
@ApiModelProperty(hidden = true)
private List<String> idList;
+
+ @ApiModelProperty(value = "收货地址详细地址(拼接省市区地址)")
+ private String address;
}
diff --git a/src/main/java/com/mzl/flower/dto/response/payment/DeliveryOrderItem4CheckDTO.java b/src/main/java/com/mzl/flower/dto/response/payment/DeliveryOrderItem4CheckDTO.java
index 1e02cee..f0b2e4d 100644
--- a/src/main/java/com/mzl/flower/dto/response/payment/DeliveryOrderItem4CheckDTO.java
+++ b/src/main/java/com/mzl/flower/dto/response/payment/DeliveryOrderItem4CheckDTO.java
@@ -37,7 +37,7 @@
private String flowerLevelStr;
@ApiModelProperty(value = "订单商品状态")
- @DictTrans(target = "statusStr", codeType = "CHECK_OPERATE")
+ @DictTrans(target = "statusStr", codeType = "ORDER_ITEM_STATUS")
private String status;
private String statusStr;
diff --git a/src/main/java/com/mzl/flower/dto/response/payment/DeliveryOrderList4CheckDTO.java b/src/main/java/com/mzl/flower/dto/response/payment/DeliveryOrderList4CheckDTO.java
index ae7760f..a392344 100644
--- a/src/main/java/com/mzl/flower/dto/response/payment/DeliveryOrderList4CheckDTO.java
+++ b/src/main/java/com/mzl/flower/dto/response/payment/DeliveryOrderList4CheckDTO.java
@@ -25,4 +25,6 @@
@ApiModelProperty(value = "供应商总价")
private BigDecimal totalAmount;
+ @ApiModelProperty(value = "未完成质检订单数量")
+ private Integer uncheckedCount;
}
diff --git a/src/main/java/com/mzl/flower/service/flower/FlowerService.java b/src/main/java/com/mzl/flower/service/flower/FlowerService.java
index 4ad623e..221d4be 100644
--- a/src/main/java/com/mzl/flower/service/flower/FlowerService.java
+++ b/src/main/java/com/mzl/flower/service/flower/FlowerService.java
@@ -458,6 +458,9 @@
public void deleteFlower(Long id){
final Flower flower = flowerMapper.selectById(id);
+ if(flower == null){
+ throw new ValidationException("商品未找到");
+ }
flowerMapper.deleteById(id);
diff --git a/src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java b/src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java
index 154e9a9..92f7400 100644
--- a/src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java
+++ b/src/main/java/com/mzl/flower/service/payment/DeliveryOrderService.java
@@ -354,7 +354,7 @@
);
if (items != null && items.size() > 0) {
for (OrderItem i : items) {
- i.setStatus(Constants.CHECK_OPERATE.ok.name());
+ i.setStatus(Constants.ORDER_ITEM_STATUS.ok.name());
i.setCheckTime(LocalDateTime.now());
orderItemMapper.updateById(i);
}
@@ -463,6 +463,7 @@
//////////////////////////////////////////////////////////////新接口
public Page<DeliveryOrderList4CheckDTO> selectSupplierDoList4Check(Page page, DeliveryOrderStationQueryDTO dto) {
+ dto.setStatusList(splitParam(dto.getStatus()));
List<DeliveryOrderList4CheckDTO> ls = deliveryOrderMapper.selectSupplierDoList4Check(page, dto);
page.setRecords(ls);
@@ -473,6 +474,7 @@
if(dto.getSupplierId() == null){
throw new ValidationException("供应商id不能为空");
}
+ dto.setStatusList(splitParam(dto.getStatus()));
List<DeliveryOrder4CheckDTO> ls = deliveryOrderMapper.selectSupplierDoInfo4Check(page, dto);
if(ls != null && ls.size() > 0){
diff --git a/src/main/java/com/mzl/flower/service/point/CustomerPointService.java b/src/main/java/com/mzl/flower/service/point/CustomerPointService.java
index 3d225f9..05363d3 100644
--- a/src/main/java/com/mzl/flower/service/point/CustomerPointService.java
+++ b/src/main/java/com/mzl/flower/service/point/CustomerPointService.java
@@ -93,7 +93,7 @@
point.setDeductionPoint(point.getDeductionPoint() + detail.getPoint());
}else{
//积分不足,直接清0
- point.setDeductionPoint(point.getUsedPoint() + balancePoint);
+ point.setDeductionPoint(point.getDeductionPoint() + balancePoint);
detail.setPoint(balancePoint);
detail.setRemarks(detail.getRemarks()+",积分不足,扣除积分"+balancePoint);
}
diff --git a/src/main/java/com/mzl/flower/service/point/PointGoodsService.java b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java
index 4c2ab59..27ad4dc 100644
--- a/src/main/java/com/mzl/flower/service/point/PointGoodsService.java
+++ b/src/main/java/com/mzl/flower/service/point/PointGoodsService.java
@@ -18,6 +18,7 @@
import com.mzl.flower.mapper.point.PointGoodsMapper;
import com.mzl.flower.mapper.point.PointGoodsRecordMapper;
import com.mzl.flower.service.BaseService;
+import com.mzl.flower.service.payment.RedisLockService;
import com.mzl.flower.utils.UUIDGenerator;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +44,9 @@
@Autowired
private CustomerPointDetailMapper customerPointDetailMapper;
+
+ @Autowired
+ private RedisLockService lockService;
public Long addPointGoods(PointGoodsCreateDTO dto){
PointGoods p = new PointGoods();
@@ -117,57 +121,69 @@
}
}
- public synchronized void exchangeGoods(ExchangeGoodsDTO dto) {
- PointGoods p = pointGoodsMapper.selectById(dto.getGoodsId());
- if(p == null){
- throw new ValidationException("商品未找到");
+ public void exchangeGoods(ExchangeGoodsDTO dto) {
+ String key="EXCHANGE_GOODS:"+dto.getGoodsId()+":"+SecurityUtils.getUserId();
+ boolean lock = lockService.getObjectLock(key, "");
+ if(!lock){
+ throw new ValidationException("系统操作频繁,请稍后重试");
}
- if(!Constants.POINT_GOODS_STATUS.A.name().equals(p.getStatus())){
- throw new ValidationException("商品未上架");
- }
- if(p.getStock()< dto.getNum()){
- throw new ValidationException("商品库存不足");
- }
- CustomerPoint cp = customerPointMapper.selectOne(new LambdaQueryWrapper<CustomerPoint>()
- .eq(CustomerPoint::getUserId, SecurityUtils.getUserId()));
- if(cp == null || (cp.getTotalPoint()-cp.getUsedPoint()-cp.getExpiredPoint()) < p.getPoint() * dto.getNum()){
- throw new ValidationException("积分不足");
- }
- //记录兑换记录
- PointGoodsRecord record = new PointGoodsRecord();
- record.setUserId(SecurityUtils.getUserId());
- record.setCustomerId(getCustomerByUserId(SecurityUtils.getUserId()).getId());
- record.setGoodsId(dto.getGoodsId());
- record.setNum(dto.getNum());
- record.setPoint(p.getPoint());
- record.setName(p.getName());
- record.setPictures(p.getPictures());
- record.setDescription(p.getDescription());
- record.setTotalPoint(p.getPoint() * dto.getNum());
- record.setCover(p.getCover());
- record.setRedeemCode(UUIDGenerator.getUUID());
- record.setStatus(Constants.POINT_GOODS_RECORD_STATUS.A.name());//未使用
- pointGoodsRecordMapper.insert(record);
+ try {
+ PointGoods p = pointGoodsMapper.selectById(dto.getGoodsId());
+ if(p == null){
+ throw new ValidationException("商品未找到");
+ }
+ if(!Constants.POINT_GOODS_STATUS.A.name().equals(p.getStatus())){
+ throw new ValidationException("商品未上架");
+ }
+ if(p.getStock()< dto.getNum()){
+ throw new ValidationException("商品库存不足");
+ }
+ CustomerPoint cp = customerPointMapper.selectOne(new LambdaQueryWrapper<CustomerPoint>()
+ .eq(CustomerPoint::getUserId, SecurityUtils.getUserId()));
+ if(cp == null || (cp.getTotalPoint()-cp.getUsedPoint()-cp.getExpiredPoint()-cp.getDeductionPoint()) < p.getPoint() * dto.getNum()){
+ throw new ValidationException("积分不足");
+ }
+ //记录兑换记录
+ PointGoodsRecord record = new PointGoodsRecord();
+ record.setUserId(SecurityUtils.getUserId());
+ record.setCustomerId(getCustomerByUserId(SecurityUtils.getUserId()).getId());
+ record.setGoodsId(dto.getGoodsId());
+ record.setNum(dto.getNum());
+ record.setPoint(p.getPoint());
+ record.setName(p.getName());
+ record.setPictures(p.getCover());
+ record.setDescription(p.getDescription());
+ record.setTotalPoint(p.getPoint() * dto.getNum());
+ record.setCover(p.getCover());
+ record.setRedeemCode(UUIDGenerator.getUUID());
+ record.setStatus(Constants.POINT_GOODS_RECORD_STATUS.A.name());//未使用
+ pointGoodsRecordMapper.insert(record);
- //更新积分汇总
- cp.setUsedPoint(cp.getUsedPoint()+record.getTotalPoint());
- customerPointMapper.updateById(cp);
+ //更新积分汇总
+ cp.setUsedPoint(cp.getUsedPoint()+record.getTotalPoint());
+ customerPointMapper.updateById(cp);
- //记录积分明细
- CustomerPointDetail detail = new CustomerPointDetail();
- detail.setUserId(SecurityUtils.getUserId());
- detail.setCustomerId(record.getCustomerId());
- detail.setPoint(record.getTotalPoint());
- detail.setChangeType(Constants.POINT_CHANGE_TYPE.reduce.name());
- detail.setType(Constants.POINT_TYPE.exchange.name());
- detail.setRecordDate(LocalDate.now());
- detail.setRemarks(record.getName());
- detail.create(SecurityUtils.getUserId());
- customerPointDetailMapper.insert(detail);
+ //记录积分明细
+ CustomerPointDetail detail = new CustomerPointDetail();
+ detail.setUserId(SecurityUtils.getUserId());
+ detail.setCustomerId(record.getCustomerId());
+ detail.setPoint(record.getTotalPoint());
+ detail.setChangeType(Constants.POINT_CHANGE_TYPE.reduce.name());
+ detail.setType(Constants.POINT_TYPE.exchange.name());
+ detail.setRecordDate(LocalDate.now());
+ detail.setRemarks(record.getName());
+ detail.create(SecurityUtils.getUserId());
+ customerPointDetailMapper.insert(detail);
- //更新库存
- p.setStock(p.getStock()- dto.getNum());
- pointGoodsMapper.updateById(p);
+ //更新库存
+ p.setStock(p.getStock()- dto.getNum());
+ pointGoodsMapper.updateById(p);
+ }catch (Exception e){
+ throw new ValidationException("兑换失败");
+ }finally {
+ lockService.releaseObjectLock(key,"");
+ }
+
}
public Page<PointGoodsRecordDTO> myExchangeGoods(QueryExchangeGoodsDTO dto, Page page) {
diff --git a/src/main/java/com/mzl/flower/service/system/UserService.java b/src/main/java/com/mzl/flower/service/system/UserService.java
index 855ec56..3ddf79c 100644
--- a/src/main/java/com/mzl/flower/service/system/UserService.java
+++ b/src/main/java/com/mzl/flower/service/system/UserService.java
@@ -201,7 +201,7 @@
if(customerPoint == null){
result.setCurrentPoint(0);
}else{
- Integer currentPoint =customerPoint.getTotalPoint()-customerPoint.getUsedPoint()-customerPoint.getExpiredPoint();
+ Integer currentPoint =customerPoint.getTotalPoint()-customerPoint.getUsedPoint()-customerPoint.getExpiredPoint()-customerPoint.getDeductionPoint();
result.setCurrentPoint(currentPoint>=0?currentPoint:0);
}
}else if(Constants.USER_TYPE.supplier.name().equals(user.getType())){
diff --git a/src/main/java/com/mzl/flower/web/payment/DeliveryOrderController.java b/src/main/java/com/mzl/flower/web/payment/DeliveryOrderController.java
index 2af2b28..b176677 100644
--- a/src/main/java/com/mzl/flower/web/payment/DeliveryOrderController.java
+++ b/src/main/java/com/mzl/flower/web/payment/DeliveryOrderController.java
@@ -136,6 +136,14 @@
@ApiOperation(value = "查询集货站供应商配送列表")
public ResponseEntity<ReturnDataDTO<Page<DeliveryOrderList4CheckDTO>>> selectSupplierDoList4Check(Page page
, DeliveryOrderStationQueryDTO dto){
+ LocalDate localDate = deliveryOrderService.parseLocalDate(dto.getDate());
+ if(localDate != null){
+ LocalDateTime end = localDate.atTime(17, 0, 0);
+ LocalDateTime begin = end.plusDays(-1);
+ dto.setStartDate(begin);
+ dto.setEndDate(end);
+ }
+
return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectSupplierDoList4Check(page, dto));
}
@@ -179,6 +187,14 @@
@ApiOperation(value = "查询供应商配送单列表")
public ResponseEntity<ReturnDataDTO<Page<DeliveryOrder4CheckDTO>>> selectSupplierDoInfo4Check(Page page
, DeliveryOrderInfoSpQueryDTO dto){
+ LocalDate localDate = deliveryOrderService.parseLocalDate(dto.getDate());
+ if(localDate != null){
+ LocalDateTime end = localDate.atTime(17, 0, 0);
+ LocalDateTime begin = end.plusDays(-1);
+ dto.setStartDate(begin);
+ dto.setEndDate(end);
+ }
+
return returnData(R.SUCCESS.getCode(), deliveryOrderService.selectSupplierDoInfo4Check(page, dto));
}
diff --git a/src/main/resources/mapper/payment/DeliveryOrderMapper.xml b/src/main/resources/mapper/payment/DeliveryOrderMapper.xml
index dbfd143..34f3909 100644
--- a/src/main/resources/mapper/payment/DeliveryOrderMapper.xml
+++ b/src/main/resources/mapper/payment/DeliveryOrderMapper.xml
@@ -79,13 +79,16 @@
</select>
<select id="selectSupplierDoList4Check" resultType="com.mzl.flower.dto.response.payment.DeliveryOrderList4CheckDTO">
- SELECT tt.id, tt.supplierName, tt.supplierTel, tt.stationName, sum(tt.num) totalNum, sum(tt.amount) totalAmount
+ SELECT tt.id, tt.supplierName, tt.supplierTel, tt.stationName, sum(tt.num) totalNum
+ , sum(tt.amount) totalAmount, sum(tt.uncheckedCount) uncheckedCount
from (
select s.id, s.name supplierName, s.contact_tel supplierTel, st.name stationName
, (select sum(num) from t_order_item oi
where oi.supplier_id = q.supplier_id and oi.order_id = q.order_id) num
- , (select sum(oi.supplier_price * oi.num) from t_order_item oi
+ , (select sum(oi.supplier_price * oi.num) from t_order_item oi
where oi.supplier_id = q.supplier_id and oi.order_id = q.order_id) amount
+ , (select count(1) from t_delivery_order dor
+ where dor.id = q.id and dor.status != 'CHECKED') uncheckedCount
from t_supplier_info s
join t_station st on st.id = s.station_id
join t_delivery_order q on s.id = q.supplier_id
@@ -98,8 +101,12 @@
<if test="condition.orderNo != null and condition.orderNo != ''">
AND q.order_no LIKE concat('%', #{condition.orderNo},'%')
</if>
- <if test="condition.status != null and condition.status != ''">
- AND q.status = #{condition.status}
+
+ <if test="condition.statusList != null and condition.statusList.size > 0">
+ AND q.status in
+ <foreach collection="condition.statusList" item="status" open="(" separator="," close=")">
+ #{status}
+ </foreach>
</if>
<if test="condition.supplierId != null">
@@ -148,8 +155,12 @@
<if test="condition.orderNo != null and condition.orderNo != ''">
AND q.order_no LIKE concat('%', #{condition.orderNo},'%')
</if>
- <if test="condition.status != null and condition.status != ''">
- AND q.status = #{condition.status}
+
+ <if test="condition.statusList != null and condition.statusList.size > 0">
+ AND q.status in
+ <foreach collection="condition.statusList" item="status" open="(" separator="," close=")">
+ #{status}
+ </foreach>
</if>
<if test="condition.warehouseId != null">
diff --git a/src/main/resources/mapper/payment/OrderMapper.xml b/src/main/resources/mapper/payment/OrderMapper.xml
index 880740c..8bcdc82 100644
--- a/src/main/resources/mapper/payment/OrderMapper.xml
+++ b/src/main/resources/mapper/payment/OrderMapper.xml
@@ -90,6 +90,10 @@
<if test="condition.customerAddress != null and condition.customerAddress != ''">
AND q.customer_address LIKE concat('%', #{condition.customerAddress},'%')
</if>
+ <if test="condition.address != null and condition.address != ''">
+ AND CONCAT(q.customer_province, q.customer_city, q.customer_region, q.customer_address) LIKE concat('%',
+ #{condition.address},'%')
+ </if>
<if test="condition.customer != null and condition.customer != ''">
AND (q.customer LIKE concat('%', #{condition.customer},'%')
or q.customer_tel LIKE concat('%', #{condition.customer},'%')
diff --git a/src/main/resources/mapper/point/CustomerPointMapper.xml b/src/main/resources/mapper/point/CustomerPointMapper.xml
index 91c18e8..9514779 100644
--- a/src/main/resources/mapper/point/CustomerPointMapper.xml
+++ b/src/main/resources/mapper/point/CustomerPointMapper.xml
@@ -3,15 +3,21 @@
<mapper namespace="com.mzl.flower.mapper.point.CustomerPointMapper">
<select id="queryPage" resultType="com.mzl.flower.dto.response.point.CustomerPointDTO">
SELECT
- p.*,
c.`name` as customerName,
+ c.user_id as userId,
+ p.id as id,
+ c.id as customerId,
+ IFNULL(p.total_point, 0) as totalPoint,
+ IFNULL(p.used_point, 0) as usedPoint,
+ IFNULL(p.expired_point, 0) as expiredPoint,
+ IFNULL(p.deduction_point, 0) as deductionPoint,
t.tel as customerTel
FROM
- t_customer_point p
- LEFT JOIN t_customer_info c ON c.id = p.customer_id
- LEFT JOIN t_user t on p.user_id = t.id
+ t_customer_info c
+ LEFT JOIN t_customer_point p ON c.id = p.customer_id
+ LEFT JOIN t_user t on c.user_id = t.id
WHERE
- p.deleted = 0
+ c.deleted = 0
<if test="dto.customerName!= null and dto.customerName != ''">
AND c.`name` LIKE CONCAT('%',#{dto.customerName},'%')
</if>
--
Gitblit v1.9.3