From dcb96821f905f3fd93c059d8703517bdcac4d336 Mon Sep 17 00:00:00 2001
From: 刘帅 <rr.iii@qq.com>
Date: 星期二, 29 九月 2026 20:02:02 +0800
Subject: [PATCH] 排序问题及门店手机号展示问题
---
cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java | 716 +++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 543 insertions(+), 173 deletions(-)
diff --git a/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java b/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
index fc40208..63ef586 100644
--- a/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
+++ b/cloud-server-activity/src/main/java/com/dsh/activity/controller/PointMercharsController.java
@@ -1,6 +1,7 @@
package com.dsh.activity.controller;
+import com.alipay.api.domain.ArrangementVORes;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.activity.entity.*;
@@ -10,11 +11,9 @@
import com.dsh.activity.feignclient.course.model.CoursePackagePaymentConfig;
import com.dsh.activity.feignclient.model.*;
import com.dsh.activity.feignclient.other.OperatorClient;
+import com.dsh.activity.feignclient.other.SiteClient;
import com.dsh.activity.feignclient.other.StoreClient;
-import com.dsh.activity.feignclient.other.model.Store;
-import com.dsh.activity.feignclient.other.model.StoreDetailOfCourse;
-import com.dsh.activity.feignclient.other.model.StoreInfoDto;
-import com.dsh.activity.feignclient.other.model.TOperatorCity;
+import com.dsh.activity.feignclient.other.model.*;
import com.dsh.activity.model.CoachChangeStateVO;
import com.dsh.activity.model.PointMerchandiseIncomeVo;
import com.dsh.activity.model.PointMerchandiseVo;
@@ -27,10 +26,12 @@
import com.dsh.activity.util.*;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.xml.crypto.Data;
+import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
@@ -78,6 +79,8 @@
@Resource
private CouponCityService ccityService;
+ @Autowired
+ private SiteClient siteClient;
@Resource
@@ -91,9 +94,13 @@
*/
@RequestMapping("/base/pointMerchars/changeState")
public void changeState(@RequestBody CoachChangeStateVO dto) {
-
-
pmdsService.changeState(dto);
+ }
+
+ @ResponseBody
+ @PostMapping("/base/pointMerchars/goodsList")
+ public List<PointsMerchandise> goodsList() {
+ return pmdsService.list();
}
/**
@@ -118,13 +125,37 @@
@RequestMapping("/base/pointMerchars/writeOff")
public Object writeOff(@RequestBody WriteOffDTO dto) {
- UserPointsMerchandise byId = userPointsMerchandiseService.getById(dto.getId());
- byId.setStoreId(dto.getVerifiStoreId());
- byId.setStatus(2);
- byId.setVerificationTime(new Date());
- byId.setUserId(null);
- byId.setVerificationUserId(dto.getVerificationUserId());
- return userPointsMerchandiseService.updateById(byId);
+ if (dto == null || dto.getId() == null) {
+ throw new IllegalArgumentException("门票记录不能为空");
+ }
+ if (!Integer.valueOf(1).equals(dto.getGoType()) && !Integer.valueOf(2).equals(dto.getGoType())) {
+ throw new IllegalArgumentException("入园方式参数不正确");
+ }
+
+ UserPointsMerchandise ticket = userPointsMerchandiseService.getById(dto.getId());
+ if (ticket == null) {
+ throw new IllegalArgumentException("门票记录不存在");
+ }
+ if (!Integer.valueOf(1).equals(ticket.getStatus())) {
+ throw new IllegalStateException("该门票已核销");
+ }
+
+ // 以待核销状态作为更新条件,避免并发请求重复核销同一张门票。
+ UserPointsMerchandise updatedTicket = new UserPointsMerchandise();
+ updatedTicket.setId(ticket.getId());
+ updatedTicket.setVerifiStoreId(dto.getVerifiStoreId());
+ updatedTicket.setStatus(2);
+ updatedTicket.setVerificationTime(new Date());
+ updatedTicket.setVerificationUserId(dto.getVerificationUserId());
+ updatedTicket.setGoType(dto.getGoType());
+ boolean updated = userPointsMerchandiseService.update(updatedTicket,
+ new LambdaQueryWrapper<UserPointsMerchandise>()
+ .eq(UserPointsMerchandise::getId, ticket.getId())
+ .eq(UserPointsMerchandise::getStatus, 1));
+ if (!updated) {
+ throw new IllegalStateException("该门票已核销");
+ }
+ return true;
}
@Autowired
@@ -205,7 +236,7 @@
List<Integer> storeIds = ofSearch.getStoreIds();
// 优惠券指定的门店
List<Integer> collect5 = cstoreService.list(new QueryWrapper<CouponStore>().eq("couponId", id3)
- .in("storeId", storeIds)).stream().map(CouponStore::getStoreId)
+ .in("storeId", storeIds)).stream().map(CouponStore::getStoreId)
.collect(Collectors.toList());
// 判断两个集合是否相交
// 比较两个集合中是否有相同的元素;当两个集合中没有相同元素时返回true,
@@ -225,10 +256,12 @@
String endTime = (String) stringObjectMap.get("endTime");
stringObjectMap.put("timeValue", startTime + "至" + endTime);
int count1 = upmseService.count(new LambdaQueryWrapper<UserPointsMerchandise>()
- .eq(UserPointsMerchandise::getPointsMerchandiseId, o));
+ .eq(UserPointsMerchandise::getPointsMerchandiseId, o)
+ .eq(UserPointsMerchandise::getPayStatus, 2).eq(UserPointsMerchandise::getState, 1));
int count2 = upmseService.count(new LambdaQueryWrapper<UserPointsMerchandise>()
.eq(UserPointsMerchandise::getPointsMerchandiseId, o)
- .eq(UserPointsMerchandise::getStatus, 2));
+ .eq(UserPointsMerchandise::getStatus, 2)
+ .eq(UserPointsMerchandise::getPayStatus, 2).eq(UserPointsMerchandise::getState, 1));
stringObjectMap.put("hasExchangeQty", count1);
stringObjectMap.put("hasPickQty", count2);
@@ -276,8 +309,8 @@
*/
@ResponseBody
@RequestMapping("/base/pointMerchars/getAmount")
- public List<PointMerchandiseIncomeVo> getAmount() {
- return userPointsMerchandiseService.getAmount();
+ public List<PointMerchandiseIncomeVo> getAmount(@RequestBody List<Integer> storeIds) {
+ return userPointsMerchandiseService.getAmount(storeIds);
}
@@ -297,12 +330,11 @@
List<IntegralCommodity> commodity = new ArrayList<>();
Map<String, String> geocode = gdMapGeocodingUtil.geocode(location.getLon(), location.getLat());
+ if (null == geocode) {
+ return new ArrayList<>();
+ }
String provinceCode = geocode.get("provinceCode");
String cityCode = geocode.get("cityCode");
-
-
-// if(null != geocode) {
-
List<Store> stores = storeClient.queryStoreList(new QueryStoreList(provinceCode, cityCode));
Store s = null;
Double d = 0D;
@@ -314,14 +346,7 @@
d = wgs84;
}
}
-// }
-
-// List<PointsMerchandiseCity> cityCode1 = pmdsCityService.list(new QueryWrapper<PointsMerchandiseCity>().eq("cityCode", cityCode));
List<Integer> cIds = new ArrayList<>();
-// for (PointsMerchandiseCity pointsMerchandiseCity : cityCode1) {
-// cIds.add(pointsMerchandiseCity.getPointsMerchandiseId());
-// }
-
List<PointsMerchandiseStore> storesids = pointsMerchandiseStoreService.list(new QueryWrapper<PointsMerchandiseStore>().eq("storeId", s.getId()));
for (PointsMerchandiseStore storesid : storesids) {
cIds.add(storesid.getPointsMerchandiseId());
@@ -331,8 +356,9 @@
QueryWrapper<PointsMerchandise> wrapper = new QueryWrapper<PointsMerchandise>()
.eq("state", 1)
.eq("shelves", 1)
- .gt("endTime", new Date());
- if(cIds.size() > 0){
+ .gt("endTime", new Date())
+ .eq("status", 1);
+ if (cIds.size() > 0) {
wrapper.in("id", cIds);
}
List<PointsMerchandise> merchandises = pmdsService.list(wrapper.last("ORDER BY sort desc,insertTime desc"));
@@ -342,7 +368,17 @@
integralCommodity.setCommodityId(merchandise.getId());
integralCommodity.setCommodityImg(merchandise.getCover());
integralCommodity.setCommodityName(merchandise.getName());
- integralCommodity.setCommodityPrice(merchandise.getPrice());
+ if (merchandise.getRedemptionMethod() == 1) {
+ integralCommodity.setIntegral(merchandise.getIntegral());
+ }
+ if (merchandise.getRedemptionMethod() == 2) {
+ integralCommodity.setCommodityPrice(merchandise.getPrice());
+ integralCommodity.setIntegral(merchandise.getIntegral());
+ }
+ if (merchandise.getRedemptionMethod() == 3) {
+ integralCommodity.setCommodityPrice(merchandise.getPrice());
+ }
+ integralCommodity.setRedemptionMethod(merchandise.getRedemptionMethod());
integralCommodity.setGoodsType(merchandise.getType());
integralCommodity.setSort(merchandise.getSort());
commodity.add(integralCommodity);
@@ -355,27 +391,30 @@
storeCoupons.add(couponStore.getCouponId());
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- QueryWrapper<Coupon> queryWrapper = new QueryWrapper<Coupon>().eq("state", 1).gt("endTime", sdf.format(new Date()));
- if(storeCoupons.size() > 0){
+ QueryWrapper<Coupon> queryWrapper = new QueryWrapper<Coupon>()
+ .eq("state", 1).gt("endTime", sdf.format(new Date()));
+ if (storeCoupons.size() > 0) {
queryWrapper.in("id", storeCoupons);
}
List<Coupon> list = couponService.list(queryWrapper.last(" ORDER BY insertTime desc"));
- if (!list.isEmpty()){
+ if (!list.isEmpty()) {
for (Coupon coupon : list) {
- IntegralCommodity integralCommodity = new IntegralCommodity();
- integralCommodity.setCommodityId(coupon.getId());
- integralCommodity.setCommodityImg(coupon.getCover());
- integralCommodity.setCommodityName(coupon.getName());
- integralCommodity.setCommodityPrice(coupon.getIntegral());
- integralCommodity.setGoodsType(coupon.getType());
-// integralCommodity.setSort(coupon.getSort());
- commodity.add(integralCommodity);
+ IntegralCommodity integralCommodity = new IntegralCommodity();
+ integralCommodity.setCommodityId(coupon.getId());
+ integralCommodity.setCommodityImg(coupon.getCover());
+ integralCommodity.setCommodityName(coupon.getName());
+ if (coupon.getRedemptionMethod() == 1) {
+ integralCommodity.setIntegral(coupon.getIntegral().intValue());
+ }
+ if (coupon.getRedemptionMethod() == 2) {
+ integralCommodity.setCommodityPrice(coupon.getCash());
+ integralCommodity.setIntegral(coupon.getIntegral().intValue());
+ }
+ integralCommodity.setRedemptionMethod(coupon.getRedemptionMethod());
+ integralCommodity.setGoodsType(4);
+ commodity.add(integralCommodity);
}
-
}
-
-
- System.out.println(commodity);
return commodity;
}
@@ -384,24 +423,56 @@
@PostMapping("/base/pointMerchars/getCommoditys")
public PointMerchandiseVo getVicinityGoods(@RequestBody CommodityRequest request) {
+ System.err.println("积分商城请求参数"+request);
PointMerchandiseVo pointMerchandiseVo = new PointMerchandiseVo();
List<PointsMerchandise> list = new ArrayList<>();
String provinceCode = "";
String cityCode = "";
if (ToolUtil.isEmpty(request.getLon()) && ToolUtil.isEmpty(request.getLat())) {
- return pointMerchandiseVo;
+ }else{
+ try {
+ Map<String, String> geocode = gdMapGeocodingUtil.geocode(request.getLon(), request.getLat());
+ provinceCode = geocode.get("provinceCode");
+ cityCode = geocode.get("cityCode");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
- try {
- Map<String, String> geocode = gdMapGeocodingUtil.geocode(request.getLon(), request.getLat());
- provinceCode = geocode.get("provinceCode");
- cityCode = geocode.get("cityCode");
- } catch (Exception e) {
- e.printStackTrace();
- }
+
list = pmdsService.list(new QueryWrapper<PointsMerchandise>()
.eq("state", 1)
- .eq("shelves", 1).le("startTime", new Date()).ge("endTime", new Date()));
+ .eq("shelves", 1)
+ .le("startTime", new Date())
+ .ge("endTime", new Date())
+ .eq("status", 1)
+ .orderByDesc("insertTime", "id")
+ );
+ if (request.getShopId()!=null){
+ List<Integer> storeId = new ArrayList<>();
+ storeId.add(request.getShopId());
+ List<Store> stores = storeClient.queryStoreByIds(storeId);
+ Store store = stores.get(0);
+ provinceCode = store.getProvinceCode();
+ cityCode = store.getCityCode();
+ List<Integer> pointsMerchandiseIds = pmdstoService.lambdaQuery().eq(PointsMerchandiseStore::getStoreId, request.getShopId()).list()
+ .stream().map(PointsMerchandiseStore::getPointsMerchandiseId)
+ .collect(Collectors.toList());
+ if (pointsMerchandiseIds.isEmpty()){
+ pointMerchandiseVo.setMerchandises(list);
+ return pointMerchandiseVo;
+ }else{
+ List<PointsMerchandise> pointsMerchandiseList = pmdsService.lambdaQuery()
+ .eq(PointsMerchandise::getState, 1)
+ .eq(PointsMerchandise::getShelves,1)
+ .in(PointsMerchandise::getId, pointsMerchandiseIds)
+ .orderByDesc(PointsMerchandise::getInsertTime, PointsMerchandise::getId)
+ .list();
+
+ list = pointsMerchandiseList;
+ }
+ }
+ list = list.stream().distinct().collect(Collectors.toList());
if (list.size() > 0) {
Iterator<PointsMerchandise> iterator = list.iterator();
while (iterator.hasNext()) {
@@ -449,7 +520,7 @@
detailsVo.setGoodName(coursePackage.getName());
detailsVo.setBelongsScope(merchandise.getUserPopulation());
int coursePackageNums = upmseService.count(new QueryWrapper<UserPointsMerchandise>()
- .eq("pointsMerchandiseId", merchandise.getId()));
+ .eq("pointsMerchandiseId", merchandise.getId()).eq("payStatus", 2).eq("state", 1));
detailsVo.setRedeemedNum(coursePackageNums);
detailsVo.setResidueNum(Math.max(merchandise.getQuantityIssued() - coursePackageNums, 0));
detailsVo.setPerLimit(merchandise.getPickUpQuantity());
@@ -512,7 +583,7 @@
detailsVo.setGoodName(merchandise.getName());
detailsVo.setBelongsScope(merchandise.getUserPopulation());
int count = upmseService.count(new QueryWrapper<UserPointsMerchandise>()
- .eq("pointsMerchandiseId", merchandise.getId()));
+ .eq("pointsMerchandiseId", merchandise.getId()).eq("payStatus", 2).eq("state", 1));
detailsVo.setRedeemedNum(count);
detailsVo.setResidueNum(Math.max(merchandise.getQuantityIssued() - count, 0));
detailsVo.setPerLimit(merchandise.getPickUpQuantity());
@@ -567,7 +638,7 @@
detailsVo.setGoodName(coupon.getName());
detailsVo.setBelongsScope(coupon.getUserPopulation());
int couponNums = upmseService.count(new QueryWrapper<UserPointsMerchandise>()
- .eq("pointsMerchandiseId", merchandise.getId()));
+ .eq("pointsMerchandiseId", merchandise.getId()).eq("payStatus", 2).eq("state", 1));
detailsVo.setRedeemedNum(couponNums);
detailsVo.setResidueNum(Math.max(coupon.getQuantityIssued() - couponNums, 0));
detailsVo.setPerLimit(coupon.getPickUpQuantity());
@@ -610,6 +681,8 @@
@Autowired
private UserCouponService userCouponService;
+ @Autowired
+ private VipDetailService vipDetailService;
@PostMapping("/base/pointMerchars/getGoodDetails")
public ProductDetailsVo getGoodDetailsWithId(@RequestBody ProductDetailRequest detailRequest) {
@@ -647,7 +720,7 @@
detailsVo.setGoodName(coursePackage.getName());
detailsVo.setBelongsScope(merchandise.getUserPopulation());
int coursePackageNums = upmseService.count(new QueryWrapper<UserPointsMerchandise>()
- .eq("pointsMerchandiseId", merchandise.getId()));
+ .eq("pointsMerchandiseId", merchandise.getId()).eq("payStatus", 2).eq("state", 1));
detailsVo.setRedeemedNum(coursePackageNums);
detailsVo.setResidueNum(Math.max(merchandise.getQuantityIssued() - coursePackageNums, 0));
detailsVo.setPerLimit(merchandise.getPickUpQuantity());
@@ -710,7 +783,7 @@
detailsVo.setGoodName(merchandise.getName());
detailsVo.setBelongsScope(merchandise.getUserPopulation());
int count = upmseService.count(new QueryWrapper<UserPointsMerchandise>()
- .eq("pointsMerchandiseId", merchandise.getId()));
+ .eq("pointsMerchandiseId", merchandise.getId()).eq("payStatus", 2).eq("state", 1));
detailsVo.setRedeemedNum(count);
detailsVo.setResidueNum(Math.max(merchandise.getQuantityIssued() - count, 0));
detailsVo.setPerLimit(merchandise.getPickUpQuantity());
@@ -818,13 +891,16 @@
@ResponseBody
@PostMapping("/base/pointMerchars/getDetailsOfExchange")
- public ExchangeDetailsVo getIntegralExchangeDetails(@RequestBody Integer appUserId) {
+ public ExchangeDetailsVo getIntegralExchangeDetails(@RequestBody Integer appUserId) throws ParseException {
ExchangeDetailsVo detailsVo = new ExchangeDetailsVo();
List<ExchangeDetailsResponse> responses = new ArrayList<>();
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ SimpleDateFormat simpleDateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
List<UserPointsMerchandise> pointsMerchandises = upmseService.list(new QueryWrapper<UserPointsMerchandise>()
- .eq("userId", appUserId).eq("payStatus", 2));
-
+ .eq("userId", appUserId).eq("payStatus", 2)
+ .orderByDesc("insertTime", "id"));
+ List<PointsMerchandiseStore> pointsMerchandiseStoreList = pointsMerchandiseStoreService.list();
+ Map<Integer, List<PointsMerchandiseStore>> pointsMerchandiseStoreMap = pointsMerchandiseStoreList.stream().collect(Collectors.groupingBy(PointsMerchandiseStore::getPointsMerchandiseId));
List<Coupon> list1 = couponService.list();
List<Integer> ids = new ArrayList<>();
@@ -835,7 +911,9 @@
}
List<UserCoupon> userCoupons = new ArrayList<>();
if (ids.size() > 0) {
- userCoupons = userCouponService.list(new QueryWrapper<UserCoupon>().eq("userId", appUserId).in("couponId", ids));
+ userCoupons = userCouponService.list(new QueryWrapper<UserCoupon>().eq("userId", appUserId).in("couponId", ids)
+ .ne("status", 3)
+ .orderByDesc("insertTime", "id"));
}
if (pointsMerchandises.size() > 0) {
for (UserPointsMerchandise pointsMerchandise : pointsMerchandises) {
@@ -843,6 +921,7 @@
if (merchandise == null) {
continue;
}
+
ExchangeDetailsResponse detailsResponse = new ExchangeDetailsResponse();
detailsResponse.setDetailsId(pointsMerchandise.getId());
detailsResponse.setGoodName(merchandise.getName());
@@ -862,6 +941,8 @@
detailsResponse.setUseStatus(pointsMerchandise.getStatus() == 1 ? 2 : 1);
detailsResponse.setGoodType(merchandise.getType());
if (merchandise.getType() == 3) {
+ detailsResponse.setCodeType(3);
+ detailsResponse.setDataId(pointsMerchandise.getId()+"");
detailsResponse.setCardType(merchandise.getCardType());
List<Integer> sids = new ArrayList<>();
detailsResponse.setUserId(appUserId);
@@ -900,64 +981,94 @@
// 以下代码均为临时代码===============================
for (Integer integer : collect) {
ArrayList<Integer> list2 = new ArrayList<>();
- if (integer==2024){
+ if (integer == 2024) {
list2.add(32);
detailsResponse.setRid(list2);
}
// 临时 根据门票id 指定的区域
- if (integer==9919){
- if (pointsMerchandise.getPointsMerchandiseId()==196||pointsMerchandise.getPointsMerchandiseId()==198){
+ if (integer == 9919) {
+ if (pointsMerchandise.getPointsMerchandiseId() == 196 || pointsMerchandise.getPointsMerchandiseId() == 198) {
// 返回儿童区id
ArrayList<Integer> list3 = new ArrayList<>();
list3.add(44);
detailsResponse.setRid(list3);
- }else if(pointsMerchandise.getPointsMerchandiseId()==197) {
+ } else if (pointsMerchandise.getPointsMerchandiseId() == 197) {
ArrayList<Integer> list4 = new ArrayList<>();
list4.add(43);
detailsResponse.setRid(list4);
}
-
}
+ }
+ if (detailsResponse.getRid() == null) {
+ List<Integer> integers = stoClient.querySiteIdById(collect);
+ detailsResponse.setRid(integers);
}
//======================================================
}
+ } else {
+ // todo 返回门店id 和场地id
+ // 查询指定场地
+ List<PointsMerchandiseStore> list = pmdstoService.list(new LambdaQueryWrapper<PointsMerchandiseStore>()
+ .eq(PointsMerchandiseStore::getPointsMerchandiseId, merchandise.getId()));
+ // 门店
+ ArrayList<Integer> list3 = new ArrayList<>();
+ // 场地
+ ArrayList<Integer> list4 = new ArrayList<>();
+ for (PointsMerchandiseStore temp : list) {
+ Integer storeId = temp.getStoreId();
+ Integer siteId = temp.getSiteId();
+ list3.add(storeId);
+ list4.add(siteId);
+ }
+ detailsResponse.setRid(list4);
+ detailsResponse.setSid(list3);
+ System.err.println("门票rid" + list4);
+ System.err.println("门票sid" + list3);
}
if (merchandise.getCardType() == 1) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(pointsMerchandise.getInsertTime());
- calendar.add(Calendar.DAY_OF_MONTH, 1);
- Date end = calendar.getTime();
- String startDate = dateFormat.format(pointsMerchandise.getInsertTime());
- String endDate = dateFormat.format(end);
- detailsResponse.setStartTime(startDate);
- detailsResponse.setEndTime(startDate);
+ // 日卡开始时间和结束时间根据门店营业时间来
+ // 查询门店
+ List<Integer> storeIds = pointsMerchandiseStoreMap.get(merchandise.getId()).stream().map(PointsMerchandiseStore::getStoreId)
+ .collect(Collectors.toList());
+ List<Store> stores = storeClient.queryStoreByIds(storeIds);
+ String startTime = "";
+ String endTime = "";
- Date now = new Date();
- Calendar cal1 = Calendar.getInstance();
- cal1.setTime(pointsMerchandise.getInsertTime());
+ if (stores != null && !stores.isEmpty()) {
+ // 初始化为第一个门店的时间
+ startTime = stores.get(0).getStartTime();
+ endTime = stores.get(0).getEndTime();
+ // 遍历所有门店,找出最早的开始时间和最晚的结束时间
+ for (Store store : stores) {
+ String storeStartTime = store.getStartTime();
+ String storeEndTime = store.getEndTime();
- Calendar cal2 = Calendar.getInstance();
- cal2.setTime(now);
+ if (storeStartTime != null && startTime != null) {
+ // 比较开始时间,找出最早的
+ if (storeStartTime.compareTo(startTime) < 0) {
+ startTime = storeStartTime;
+ }
+ }
- // Compare the year, month, and day of the two Calendar instances
- boolean isSameDate = cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
- cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) &&
- cal1.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH);
-
- // Print the result
- if (isSameDate) {
- } else {
- System.out.println("The two dates do not have the same date.");
- detailsResponse.setUseStatus(3);
-
+ if (storeEndTime != null && endTime != null) {
+ // 比较结束时间,找出最晚的
+ if (storeEndTime.compareTo(endTime) > 0) {
+ endTime = storeEndTime;
+ }
+ }
+ }
}
-
-
+ String format = simpleDateFormat1.format(pointsMerchandise.getInsertTime());
+ detailsResponse.setStartTime(format + " " + startTime + ":00");
+ detailsResponse.setEndTime(format + " " + endTime + ":00");
+ if (simpleDateFormat.parse(format + " " + endTime + ":00").before(new Date()) &&detailsResponse.getUseStatus()==2) {
+ System.err.println("过期了,当前门店中最晚营业时间为" + format + " " + endTime + ":00");
+ detailsResponse.setUseStatus(3);
+ }
} else if (merchandise.getCardType() == 2) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTime(pointsMerchandise.getInsertTime());
calendar.add(Calendar.DAY_OF_MONTH, 31);
@@ -968,15 +1079,22 @@
detailsResponse.setEndTime(endDate);
Date now = new Date();
- if (now.after(end)) {
+ if (now.after(end)&&detailsResponse.getUseStatus()==2) {
detailsResponse.setUseStatus(3);
}
+// if (detailsResponse.getUseStatus()!=3){
+// if (detailsResponse.getUseStatus()==1 &&now.after(end)){
+// detailsResponse.setUseStatus(2);
+// }else{
+// detailsResponse.setUseStatus(2);
+// }
+// }
} else if (merchandise.getCardType() == 3) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTime(pointsMerchandise.getInsertTime());
- calendar.add(Calendar.DAY_OF_MONTH, 93);
+ calendar.add(Calendar.DAY_OF_MONTH, 90);
Date end = calendar.getTime();
String startDate = dateFormat.format(pointsMerchandise.getInsertTime());
String endDate = dateFormat.format(end);
@@ -984,15 +1102,22 @@
detailsResponse.setEndTime(endDate);
Date now = new Date();
- if (now.after(end)) {
+ if (now.after(end)&&detailsResponse.getUseStatus()==2) {
detailsResponse.setUseStatus(3);
}
+// if (detailsResponse.getUseStatus()!=3){
+// if (detailsResponse.getUseStatus()==1 &&now.after(end)){
+// detailsResponse.setUseStatus(2);
+// }else{
+// detailsResponse.setUseStatus(2);
+// }
+// }
} else if (merchandise.getCardType() == 4) {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTime(pointsMerchandise.getInsertTime());
- calendar.add(Calendar.DAY_OF_MONTH, 372);
+ calendar.add(Calendar.DAY_OF_MONTH, 365);
Date end = calendar.getTime();
String startDate = dateFormat.format(pointsMerchandise.getInsertTime());
String endDate = dateFormat.format(end);
@@ -1000,9 +1125,16 @@
detailsResponse.setEndTime(endDate);
Date now = new Date();
- if (now.after(end)) {
+ if (now.after(end)&&detailsResponse.getUseStatus()==2) {
detailsResponse.setUseStatus(3);
}
+// if (detailsResponse.getUseStatus()!=3){
+// if (detailsResponse.getUseStatus()==1 &&now.after(end)){
+// detailsResponse.setUseStatus(2);
+// }else{
+// detailsResponse.setUseStatus(2);
+// }
+// }
}
@@ -1013,6 +1145,34 @@
detailsVo.setDetailsResponses(responses);
}
+ // 2.0新增会员权益赠送门票
+ List<VipDetail> list = vipDetailService.lambdaQuery()
+ .eq(VipDetail::getAppUserId, appUserId)
+ .eq(VipDetail::getType, 2)
+ .orderByDesc(VipDetail::getInsertTime, VipDetail::getId)
+ .list();
+ for (VipDetail vipDetail : list) {
+ ExchangeDetailsResponse detailsResponse = new ExchangeDetailsResponse();
+ // 添加-用于区分会员权益门票
+ detailsResponse.setDetailsId(Long.valueOf("-" + vipDetail.getId()));
+ detailsResponse.setGoodName(vipDetail.getTicketName());
+ detailsResponse.setStartTime(simpleDateFormat.format(vipDetail.getStartTime()));
+ detailsResponse.setEndTime(simpleDateFormat.format(vipDetail.getEndTime()));
+ detailsResponse.setUseStatus(vipDetail.getStatus() == 1 ? 2 : 1);
+ detailsResponse.setGoodType(3);
+ detailsResponse.setCardType(3);
+ detailsResponse.setDataId(vipDetail.getId()+"");
+ // 表明是会员赠送的门票
+ detailsResponse.setExchangeType(4);
+ // 全国通用
+ detailsResponse.setRid(Collections.singletonList(0));
+ detailsResponse.setSid(Collections.singletonList(0));
+ Date now = new Date();
+ if (now.after(vipDetail.getEndTime())&&detailsResponse.getUseStatus()==2) {
+ detailsResponse.setUseStatus(3);
+ }
+ responses.add(detailsResponse);
+ }
if (userCoupons.size() > 0) {
for (UserCoupon userCoupon : userCoupons) {
@@ -1032,19 +1192,24 @@
detailsResponse.setIntegral(c.getIntegral().intValue());
detailsResponse.setCash(c.getCash());
}
+ if (userCoupon.getIsVipGrant() != null && userCoupon.getIsVipGrant() == 1) {
+ detailsResponse.setExchangeType(4);
+ }
detailsResponse.setStartTime(simpleDateFormat.format(c.getStartTime()));
detailsResponse.setEndTime(simpleDateFormat.format(c.getEndTime()));
detailsResponse.setUseStatus(userCoupon.getStatus() == 1 ? 2 : 1);
detailsResponse.setGoodType(4);
+ Date now = new Date();
+ if (now.after(c.getEndTime())&&detailsResponse.getUseStatus()==2) {
+ detailsResponse.setUseStatus(3);
+ }
responses.add(detailsResponse);
-
-
}
- Comparator<ExchangeDetailsResponse> comparator = Comparator.comparing(ExchangeDetailsResponse::getStartTime).reversed();
- Collections.sort(responses, comparator);
- detailsVo.setDetailsResponses(responses);
-
}
+ responses.sort(Comparator.comparing(ExchangeDetailsResponse::getStartTime,
+ Comparator.nullsLast(Comparator.reverseOrder()))
+ .thenComparing(ExchangeDetailsResponse::getDetailsId, Comparator.reverseOrder()));
+ detailsVo.setDetailsResponses(responses);
return detailsVo;
}
@@ -1057,9 +1222,95 @@
public PointDetailsVo getSpecificsOfGoods(@RequestBody Long speMercharsId) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
PointDetailsVo detailsVo = new PointDetailsVo();
+
+ if (speMercharsId.toString().contains("-1")) {
+ // 会员优惠券
+ VipDetail vipDetail = vipDetailService.getById(Math.abs(speMercharsId));
+ if (vipDetail.getType() == 1) {
+ Coupon coupon = iCouponService.getById(vipDetail.getCouponId());
+ detailsVo.setDetailsId(Long.valueOf(coupon.getId()));
+ List<String> list3 = new ArrayList<>();
+ list3.add(ToolUtil.isEmpty(coupon.getCover()) ? "" : coupon.getCover());
+ if (ToolUtil.isNotEmpty(coupon.getProductImages())) {
+ list3.addAll(Arrays.asList(StrUtils.splitStr2StrArr(coupon.getProductImages(), ",")));
+ }
+ detailsVo.setPics(list3);
+ Collections.sort(detailsVo.getPics(), (s1, s2) -> {
+ if (s1.equals(coupon.getCover())) {
+ return -1; // s1排在前面
+ } else if (s2.equals(coupon.getCover())) {
+ return 1; // s2排在前面
+ } else {
+ return 0; // 保持原顺序
+ }
+ });
+ detailsVo.setGoodName(coupon.getName());
+ detailsVo.setExchangeType(coupon.getRedemptionMethod());
+ if (coupon.getRedemptionMethod() == 1) {
+ detailsVo.setIntegral(coupon.getIntegral().intValue());
+ } else {
+ detailsVo.setIntegral(coupon.getIntegral().intValue());
+ detailsVo.setCash(coupon.getCash());
+ }
+ if (coupon.getUseScope() == 1) {
+ detailsVo.setExchangeAddrType(1);
+ detailsVo.setBelongs("全国通用");
+ } else if (coupon.getUseScope() == 2) {
+ detailsVo.setExchangeAddrType(2);
+ List<CouponCity> list = ccityService.list(new LambdaQueryWrapper<CouponCity>()
+ .eq(CouponCity::getCouponId, coupon.getId()));
+ if (list.size() > 0) {
+ detailsVo.setBelongs(list.get(0).getProvince() + "|" + list.get(0).getCity() + "用户可用");
+ }
+ } else {
+ detailsVo.setExchangeAddrType(3);
+ List<CouponStore> list = cstoreService.list(new QueryWrapper<CouponStore>()
+ .eq("couponId", coupon.getId()));
+ StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(list.get(0).getStoreId());
+ detailsVo.setBelongs(courseOfStore.getStoreName() + "可用");
+ }
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+ detailsVo.setStartTime(format.format(coupon.getStartTime()));
+ detailsVo.setEndTime(format.format(coupon.getEndTime()));
+
+ detailsVo.setContents(coupon.getIllustrate());
+ detailsVo.setGoodType(4);
+ } else {
+
+ // 门票
+ detailsVo.setDetailsId(Long.valueOf("-" + vipDetail.getId()));
+ detailsVo.setGoodName(vipDetail.getTicketName());
+ switch (vipDetail.getStatus()) {
+ case 1:
+ detailsVo.setUseType(2);
+ break;
+ case 2:
+ detailsVo.setUseType(1);
+ break;
+ case 3:
+ detailsVo.setUseType(3);
+ break;
+ }
+ detailsVo.setStartTime(simpleDateFormat.format(vipDetail.getStartTime()));
+ detailsVo.setEndTime(simpleDateFormat.format(vipDetail.getEndTime()));
+ detailsVo.setOrderTime(simpleDateFormat.format(vipDetail.getInsertTime()));
+ if (vipDetail.getUseTime() != null) {
+ detailsVo.setWriteOffTime(simpleDateFormat.format(vipDetail.getUseTime()));
+ }
+ if (vipDetail.getUseStoreId() != null) {
+ StoreDetailOfCourse courseOfStore = stoClient.getCourseOfStore(vipDetail.getUseStoreId());
+ detailsVo.setWriteOffName(courseOfStore.getStoreName());
+ }
+
+ detailsVo.setBelongs("全国通用");
+ detailsVo.setGoodType(3);
+ detailsVo.setCardType(1);
+ detailsVo.setExchangeAddrType(1);
+ }
+ detailsVo.setDetailsId(Long.valueOf("-" + vipDetail.getId()));
+ return detailsVo;
+ }
UserPointsMerchandise byId = upmseService.getById(speMercharsId);
-
-
if (ToolUtil.isNotEmpty(byId)) {
List<PointsMerchandiseStore> stores = storeService.list(new QueryWrapper<PointsMerchandiseStore>().eq("pointsMerchandiseId", byId.getPointsMerchandiseId()));
@@ -1202,7 +1453,7 @@
list1.add(coursePackage.getCoverDrawing());
detailsVo.setPics(list1);
detailsVo.setClassHours(0);
- if(coursePackage.getType() != 3){
+ if (coursePackage.getType() != 3) {
CoursePackagePaymentConfig coursePackagePaymentConfig = cpClient.queryConfigCoursePackData(pmdsServiceById.getCoursePackageConfigId());
detailsVo.setClassHours(coursePackagePaymentConfig.getClassHours());
}
@@ -1351,11 +1602,19 @@
return merchandise.getId();
}
+ @PostMapping("/base/pointMerchars/saveDetailsUserPointMercaseList")
+ public Boolean saveDetailsUserPointMercaseList(@RequestBody List<UserPointsMerchandise> merchandises) {
+ for (UserPointsMerchandise merchandise : merchandises) {
+ merchandise.setInsertTime(new Date());
+ }
+
+ return upmseService.saveBatch(merchandises);
+ }
+
@PostMapping("/base/pointMerchars/updateDetailsUserPointMercase")
public void updateDetailsUserPointMercase(@RequestBody UserPointsMerchandise merchandise) {
merchandise.setUserId(null);
- merchandise.setPointsMerchandiseId(null);
upmseService.updateById(merchandise);
}
@@ -1392,7 +1651,8 @@
public int queryUserHasGoodsNums(@RequestBody AppUserGoodResp goodResp) {
int count = upmseService.count(new LambdaQueryWrapper<UserPointsMerchandise>()
.eq(UserPointsMerchandise::getUserId, goodResp.getAppUserId())
- .eq(UserPointsMerchandise::getPointsMerchandiseId, goodResp.getGoodId()));
+ .eq(UserPointsMerchandise::getPointsMerchandiseId, goodResp.getGoodId())
+ .eq(UserPointsMerchandise::getPayStatus, 2).eq(UserPointsMerchandise::getState, 1));
System.out.println(count);
return count;
}
@@ -1401,7 +1661,8 @@
@PostMapping("/base/pointMerchars/queryUserHasGoodsNums1")
public int queryUserHasGoodsNums1(@RequestBody AppUserGoodResp goodResp) {
int count = upmseService.count(new LambdaQueryWrapper<UserPointsMerchandise>()
- .eq(UserPointsMerchandise::getPointsMerchandiseId, goodResp.getGoodId()));
+ .eq(UserPointsMerchandise::getPointsMerchandiseId, goodResp.getGoodId())
+ .eq(UserPointsMerchandise::getPayStatus, 2).eq(UserPointsMerchandise::getState, 1));
System.out.println(count);
return count;
}
@@ -1432,8 +1693,6 @@
@PostMapping("/base/pointMerchars/getConsumeDetails")
public List<ConsumeDetail> getConsumeDetails(@RequestBody BillingDataRequestVo requestVo) {
return upmseService.getConsumeDetails(requestVo);
-
-
}
@@ -1539,17 +1798,23 @@
List<Map<String, Object>> mapList = new ArrayList<>();
LambdaQueryWrapper<UserPointsMerchandise> userPointsMerchandiseLambdaQueryWrapper = new LambdaQueryWrapper<>();
userPointsMerchandiseLambdaQueryWrapper.eq(UserPointsMerchandise::getPointsMerchandiseId, pointMercharsPayedVo.getId());
+ userPointsMerchandiseLambdaQueryWrapper.eq(UserPointsMerchandise::getPayStatus, 2).eq(UserPointsMerchandise::getState, 1);
if (ToolUtil.isNotEmpty(pointMercharsPayedVo.getStatus())) {
userPointsMerchandiseLambdaQueryWrapper.eq(UserPointsMerchandise::getStatus, pointMercharsPayedVo.getStatus());
}
- List<UserPointsMerchandise> list = upmseService.list(userPointsMerchandiseLambdaQueryWrapper);
+ List<UserPointsMerchandise> list = upmseService.list(userPointsMerchandiseLambdaQueryWrapper.orderByDesc(UserPointsMerchandise::getPaymentTime)
+ .isNotNull(UserPointsMerchandise::getPaymentTime));
System.out.println(list);
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (list.size() > 0) {
for (UserPointsMerchandise pointsMerchandise : list) {
Map<String, Object> map = new HashMap<>();
map.put("id", pointsMerchandise.getId());
map.put("userId", pointsMerchandise.getUserId());
map.put("status", pointsMerchandise.getStatus());
+ map.put("goType", pointsMerchandise.getGoType());
+ map.put("payTime", sdf.format(pointsMerchandise.getPaymentTime()));
+ map.put("orderNumber", pointsMerchandise.getOrderNumber());
mapList.add(map);
}
}
@@ -1633,6 +1898,9 @@
case 3:
infoOneVo.setExchangeArea("指定门店");
break;
+ case 4:
+ infoOneVo.setExchangeArea("指定场地");
+ break;
default:
break;
}
@@ -1670,24 +1938,69 @@
List<StoreVos> storeVos = new ArrayList<>();
List<PointsMerchandiseStore> list = pmdstoService.list(new QueryWrapper<PointsMerchandiseStore>()
.eq("pointsMerchandiseId", id));
- if (list.size() > 0) {
- List<Integer> collect = list.stream().map(PointsMerchandiseStore::getStoreId).collect(Collectors.toList());
- List<Store> stores = stoClient.queryStoreByIds(collect);
- if (stores.size() > 0) {
- for (Store store : stores) {
- StoreVos storeVos1 = new StoreVos();
- storeVos1.setNum1(store.getProvince() + "省" + store.getCity() + "市");
- if (store.getOperatorId() == 0) {
- storeVos1.setNum2("平台");
- } else {
+ PointsMerchandise byId = pmdsService.getById(id);
- storeVos1.setNum2(store.getOName());
+ if (list.size() > 0) {
+
+ if (byId.getUseScope() == 3) {
+ // 如果是指定门店
+ List<Integer> collect = list.stream().map(PointsMerchandiseStore::getStoreId).collect(Collectors.toList());
+
+ List<Store> stores = stoClient.queryStoreByIds(collect);
+ if (stores.size() > 0) {
+ int a = 0;
+ for (Store store : stores) {
+ StoreVos storeVos1 = new StoreVos();
+ storeVos1.setNum1(store.getProvince() + "省" + store.getCity() + "市");
+ if (store.getOperatorId() == null) {
+ storeVos1.setNum2("平台");
+ } else if (store.getOperatorId() == 0) {
+ storeVos1.setNum2("平台");
+ } else {
+ storeVos1.setNum2(store.getOName());
+ }
+ storeVos1.setNum3(store.getName());
+ storeVos1.setNum4(store.getIds());
+ storeVos.add(storeVos1);
}
- storeVos1.setNum3(store.getName());
- storeVos1.setNum4(store.getIds());
- storeVos.add(storeVos1);
}
+ } else if (byId.getUseScope() == 4) {
+ // 如果是指定场地
+ List<Integer> collect1 = list.stream().map(PointsMerchandiseStore::getSiteId).distinct().collect(Collectors.toList());
+ int temp = 0;
+ List<Integer> collect = list.stream().map(PointsMerchandiseStore::getStoreId).collect(Collectors.toList());
+ List<Store> stores1 = new ArrayList<>();
+ for (Integer integer : collect) {
+ List<Integer> list1 = new ArrayList<>();
+ list1.add(integer);
+ List<Store> stores = stoClient.queryStoreByIds(list1);
+ stores1.addAll(stores);
+ }
+ List<Store> stores = stoClient.queryStoreByIds(collect);
+ while (temp != collect1.size()) {
+ for (Store store : stores1) {
+ Integer integer = collect1.get(temp);
+ Site site = siteClient.querySiteById(integer);
+ StoreVos storeVos1 = new StoreVos();
+ storeVos1.setNum5(site.getName());
+ storeVos1.setNum1(store.getProvince() + "省" + store.getCity() + "市");
+ if (store.getOperatorId() == null) {
+ storeVos1.setNum2("平台");
+ } else if (store.getOperatorId() == 0) {
+ storeVos1.setNum2("平台");
+ } else {
+ storeVos1.setNum2(store.getOName());
+ }
+ storeVos1.setNum3(store.getName());
+ storeVos1.setNum4(store.getIds());
+ storeVos.add(storeVos1);
+ temp++;
+ }
+ }
+
+
}
+
}
return storeVos;
}
@@ -1697,10 +2010,14 @@
@PostMapping("/base/pointMerchars/updateGoodsDetail")
public boolean updateGoodsDetail(@RequestBody Map<String, Object> map) {
try {
+ String name = (String) map.get("name");
Integer pointMerchandiseId = (Integer) map.get("pointMerchandiseId");
PointsMerchandise byId1 = pmdsService.getById(pointMerchandiseId);
if (Integer.valueOf(map.get("type").toString()) != 1) {
byId1.setStatus(2);
+ }
+ if (StringUtils.hasLength(name)) {
+ byId1.setName(name);
}
Integer quantityIssued = (Integer) map.get("quantityIssued");
Integer pickUpQuantity = (Integer) map.get("pickUpQuantity");
@@ -1753,6 +2070,20 @@
public Boolean addOther(@RequestBody String pam) {
Boolean save = false;
String[] split = pam.split("_");
+ if (split.length > 2) {
+ if (StringUtils.hasLength(split[2])) {
+ for (String s : split[2].split(",")) {
+ PointsMerchandiseStore pointsMerchandiseStore = new PointsMerchandiseStore();
+ pointsMerchandiseStore.setPointsMerchandiseId(Integer.valueOf(split[0]));
+ pointsMerchandiseStore.setSiteId(Integer.valueOf(s));
+ Site site = siteClient.querySiteById(Integer.valueOf(s));
+ pointsMerchandiseStore.setStoreId(site.getStoreId());
+ save = pmdstoService.save(pointsMerchandiseStore);
+ }
+ // 这个门票是选择的场地
+ return save;
+ }
+ }
for (String s : split[1].split(",")) {
PointsMerchandiseStore pointsMerchandiseStore = new PointsMerchandiseStore();
pointsMerchandiseStore.setPointsMerchandiseId(Integer.valueOf(split[0]));
@@ -1761,6 +2092,7 @@
}
return save;
}
+
@PostMapping("/base/pointMerchars/addCitys")
public Boolean addCitys(@RequestBody ArrayList<Map<String, String>> objects) {
@@ -1849,62 +2181,100 @@
@PostMapping("/base/pointMerchars/queryFee")
@ResponseBody
public HashMap<String, Object> queryFee(@RequestBody QueryDataFee queryDataFee) {
+ return queryTicketFee(queryDataFee, false);
+ }
+
+ /**
+ * 按购买记录的 storeId 统计门票收入。购买表按 userId 分片,未带 userId 条件时
+ * ShardingSphere 会读取各分表,确保 t_user_points_merchandise1-5 的记录都参与统计。
+ */
+ @PostMapping("/base/pointMerchars/queryTicketFee")
+ @ResponseBody
+ public HashMap<String, Object> queryTicketFee(@RequestBody QueryDataFee queryDataFee) {
+ return queryTicketFee(queryDataFee, true);
+ }
+
+ private HashMap<String, Object> queryTicketFee(QueryDataFee queryDataFee, boolean scopeByStore) {
HashMap<String, Object> map = new HashMap<>();
String data = queryDataFee.getData();
- List<Integer> ids = queryDataFee.getIds();
- if (ids.size() == 0) {
- ids.add(-1);
- }
- List<PointsMerchandise> list1 = pmdsService.list(new LambdaQueryWrapper<PointsMerchandise>().eq(PointsMerchandise::getRedemptionMethod, 3));
+ List<Integer> ids = queryDataFee.getIds() == null
+ ? new ArrayList<>() : new ArrayList<>(queryDataFee.getIds());
+ // cardType 是门票卡种的唯一分类依据:1 日卡、2 月卡、3 季卡、4 年卡。
+ // 不能额外依赖历史商品的 type/redemptionMethod,避免有效门票记录被遗漏。
+ List<PointsMerchandise> tickets = pmdsService.list(new LambdaQueryWrapper<PointsMerchandise>()
+ .in(PointsMerchandise::getCardType, 1, 2, 3, 4));
LambdaQueryWrapper<UserPointsMerchandise> vipPaymentLambdaQueryWrapper = new LambdaQueryWrapper<>();
if (ToolUtil.isNotEmpty(data)) {
String stime = data.split(" - ")[0] + " 00:00:00";
String etime = data.split(" - ")[1] + " 23:59:59";
- vipPaymentLambdaQueryWrapper.between(UserPointsMerchandise::getInsertTime, stime, etime);
+ // 实收以支付时间归属;没有支付时间的历史数据才回退到创建时间。
+ vipPaymentLambdaQueryWrapper.and(wrapper -> wrapper
+ .between(UserPointsMerchandise::getPaymentTime, stime, etime)
+ .or(item -> item.isNull(UserPointsMerchandise::getPaymentTime)
+ .between(UserPointsMerchandise::getInsertTime, stime, etime)));
}
- vipPaymentLambdaQueryWrapper.in(UserPointsMerchandise::getUserId, ids);
- List<Integer> collect = list1.stream().map(PointsMerchandise::getId).collect(Collectors.toList());
+ if (!ids.isEmpty()) {
+ if (scopeByStore) {
+ // 门票记录通常写入 storeId;全国/城市通用等历史记录可能未写该字段,
+ // 此时按商品配置的门店关系归属到运营商/门店统计范围。
+ List<Integer> scopedTicketIds = pmdstoService.list(new LambdaQueryWrapper<PointsMerchandiseStore>()
+ .in(PointsMerchandiseStore::getStoreId, ids))
+ .stream().map(PointsMerchandiseStore::getPointsMerchandiseId)
+ .filter(Objects::nonNull).distinct().collect(Collectors.toList());
+ vipPaymentLambdaQueryWrapper.and(wrapper -> {
+ wrapper.in(UserPointsMerchandise::getStoreId, ids);
+ if (!scopedTicketIds.isEmpty()) {
+ wrapper.or().in(UserPointsMerchandise::getPointsMerchandiseId, scopedTicketIds);
+ }
+ });
+ } else {
+ vipPaymentLambdaQueryWrapper.in(UserPointsMerchandise::getUserId, ids);
+ }
+ }
+ List<Integer> collect = tickets.stream().map(PointsMerchandise::getId).collect(Collectors.toList());
if (collect.size() == 0) {
collect.add(-1);
}
vipPaymentLambdaQueryWrapper.in(UserPointsMerchandise::getPointsMerchandiseId, collect);
+ // payStatus=2 才表示支付成功;payType 是兑换/支付方式,不能固定为 2,
+ // 否则会把其它已支付门票记录错误排除。
vipPaymentLambdaQueryWrapper.eq(UserPointsMerchandise::getPayStatus, 2);
- ArrayList<Integer> objects = new ArrayList<>();
+ vipPaymentLambdaQueryWrapper.and(wrapper -> wrapper.isNull(UserPointsMerchandise::getState)
+ .or().eq(UserPointsMerchandise::getState, 1));
List<UserPointsMerchandise> list = upmseService.list(vipPaymentLambdaQueryWrapper);
- double a = 0;
- double d = 0;
- double m = 0;
- double j = 0;
- double y = 0;
+ Map<Integer, PointsMerchandise> ticketMap = tickets.stream()
+ .collect(Collectors.toMap(PointsMerchandise::getId, ticket -> ticket, (first, ignored) -> first));
+ BigDecimal all = BigDecimal.ZERO;
+ BigDecimal day = BigDecimal.ZERO;
+ BigDecimal month = BigDecimal.ZERO;
+ BigDecimal quarter = BigDecimal.ZERO;
+ BigDecimal year = BigDecimal.ZERO;
for (UserPointsMerchandise userPointsMerchandise : list) {
- for (PointsMerchandise pointsMerchandise : list1) {
- if (pointsMerchandise.getId() == userPointsMerchandise.getPointsMerchandiseId()) {
- a += pointsMerchandise.getCash().doubleValue();
- }
- if (pointsMerchandise.getType() == 3) {
- if (pointsMerchandise.getCardType() == 1) {
- d += pointsMerchandise.getCash().doubleValue();
- }
- if (pointsMerchandise.getCardType() == 2) {
- m += pointsMerchandise.getCash().doubleValue();
- }
- if (pointsMerchandise.getCardType() == 3) {
- j += pointsMerchandise.getCash().doubleValue();
- }
- if (pointsMerchandise.getCardType() == 4) {
- y += pointsMerchandise.getCash().doubleValue();
- }
- }
+ PointsMerchandise ticket = ticketMap.get(userPointsMerchandise.getPointsMerchandiseId());
+ if (ticket == null || userPointsMerchandise.getCash() == null) {
+ continue;
}
-
+ // 以 t_user_points_merchandise1-5 中实际支付的 cash 为准,
+ // 不使用商品当前价格,避免商品改价影响历史营收。
+ BigDecimal ticketAmount = userPointsMerchandise.getCash();
+ all = all.add(ticketAmount);
+ if (Integer.valueOf(1).equals(ticket.getCardType())) {
+ day = day.add(ticketAmount);
+ } else if (Integer.valueOf(2).equals(ticket.getCardType())) {
+ month = month.add(ticketAmount);
+ } else if (Integer.valueOf(3).equals(ticket.getCardType())) {
+ quarter = quarter.add(ticketAmount);
+ } else if (Integer.valueOf(4).equals(ticket.getCardType())) {
+ year = year.add(ticketAmount);
+ }
}
- map.put("all", a);
- map.put("day", d);
- map.put("month", m);
- map.put("quarter", j);
- map.put("year", y);
+ map.put("all", all);
+ map.put("day", day);
+ map.put("month", month);
+ map.put("quarter", quarter);
+ map.put("year", year);
return map;
--
Gitblit v1.7.1