胡锐 1 week ago
commit d7a62a2d09
  1. 78
      bweb/src/main/java/com/hfkj/controller/order/BsOrderController.java
  2. 180
      cweb/src/main/java/com/hfkj/controller/order/BsOrderController.java
  3. 4
      service/src/main/java/com/hfkj/model/BsOrderModel.java
  4. 11
      service/src/main/java/com/hfkj/service/order/BsOrderService.java
  5. 28
      service/src/main/java/com/hfkj/service/order/Impl/BsOrderServiceImpl.java

@ -4,7 +4,9 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.entity.BsOrder;
import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.service.order.BsOrderService;
@ -20,8 +22,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Controller
@RequestMapping(value="/order")
@ -66,4 +69,75 @@ public class BsOrderController {
}
}
@RequestMapping(value="/statisticsOrder",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "统计订单")
public ResponseData statisticsOrder() {
// 今日时间
Map<String, Date> todayTime = DateUtil.getTodayTimeObj();
// 昨日时间
Map<String, Date> yesterdayTime = DateUtil.getYesterdayTimeObj();
// 本月时间
Map<String, Date> thisMonthTime = DateUtil.getThisMonthTimeObj();
// 上月时间
Map<String, Date> lastMonthTime = DateUtil.getLastMonthTimeObj();
// 创建一个Calendar对象,并设置为2024年2月0日,即2024年1月最后一天
Calendar timeS = new GregorianCalendar();
timeS.set(Calendar.YEAR, 2024);
timeS.set(Calendar.MONTH, 1);
timeS.set(Calendar.DAY_OF_MONTH, 0);
// 设置时间为23点59分59秒
timeS.set(Calendar.HOUR_OF_DAY, 23);
timeS.set(Calendar.MINUTE, 59);
timeS.set(Calendar.SECOND, 59);
// 调用bsOrderService的getOrderList方法,传入一个空的HashMap,获取订单列表
List<BsOrder> orderList = orderService.getOrderList(new HashMap<>());
Map<String,Object> map = new HashMap<>();
// 平台总订单数
Map<String , Object> platformOrder = new HashMap<>();
// 获取今天订单数量
platformOrder.put("todayOrder", (int) orderList.stream().filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
// 获取昨天订单数量
platformOrder.put("yesterdayOrder", (int) orderList.stream().filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
// 获取本月订单数量
platformOrder.put("thisMonthOrder", (int) orderList.stream().filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
// 获取上月订单数量
platformOrder.put("lastMonthOrder", (int) orderList.stream().filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
// 将订单数量放入map中
map.put("platformOrder", platformOrder);
// 新增订单数
Map<String , Object> newAddOrder = new HashMap<>();
// 获取今天新增订单数量
newAddOrder.put("todayNewAddOrder", (int) orderList.stream().filter(s->s.getStatus().equals(1)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
// 获取昨天新增订单数量
newAddOrder.put("yesterdayNewAddOrder", (int) orderList.stream().filter(s->s.getStatus().equals(1)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
// 获取本月新增订单数量
newAddOrder.put("thisMonthNewAddOrder", (int) orderList.stream().filter(s->s.getStatus().equals(1)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
// 获取上月新增订单数量
newAddOrder.put("lastMonthNewAddOrder", (int) orderList.stream().filter(s->s.getStatus().equals(1)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
// 将新增订单数放入map中
map.put("newAddOrder", newAddOrder);
// 预估金额
Map<String , Object> estimatedAmount = new HashMap<>();
// 获取今天预估金额
estimatedAmount.put("todayEstimatedAmount", orderList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
// 获取昨天预估金额
estimatedAmount.put("yesterdayEstimatedAmount", orderList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
// 获取本月预估金额
estimatedAmount.put("thisMonthEstimatedAmount", orderList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
// 获取上月预估金额
estimatedAmount.put("lastMonthEstimatedAmount", orderList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
// 将预估金额放入map中
map.put("estimatedAmount", estimatedAmount);
return ResponseMsgUtil.success(map);
}
}

@ -8,24 +8,31 @@ import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.SessionObject;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.model.ResponseData;
import com.hfkj.model.SecUserSessionObject;
import com.hfkj.model.UserSessionObject;
import com.hfkj.entity.BsOrder;
import com.hfkj.model.*;
import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.order.Impl.BsOrderServiceImpl;
import com.hfkj.service.promotion.PromotionBusinessService;
import com.hfkj.service.promotion.PromotionService;
import com.hfkj.service.sec.SecDictionaryService;
import com.hfkj.service.user.BsUserAccountRecordService;
import com.hfkj.service.user.BsUserParentRelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Controller
@RequestMapping(value="/order")
@ -39,6 +46,12 @@ public class BsOrderController {
@Resource
private UserCenter userCenter;
@Resource
private BsUserParentRelService userParentRelService;
@Resource
private BsUserAccountRecordService userAccountRecordService;
@Resource
private SecDictionaryService secDictionaryService;
@RequestMapping(value="/getOrderList",method = RequestMethod.GET)
@ -94,6 +107,163 @@ public class BsOrderController {
}
}
@RequestMapping(value="/statisticsOrder",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "统计订单")
public ResponseData statisticsOrder() {
// 用户session
UserSessionObject session = userCenter.getSessionModel(UserSessionObject.class);
// 今日时间
Map<String, Date> todayTime = DateUtil.getTodayTimeObj();
// 昨日时间
Map<String, Date> yesterdayTime = DateUtil.getYesterdayTimeObj();
// 本月时间
Map<String, Date> thisMonthTime = DateUtil.getThisMonthTimeObj();
// 上月时间
Map<String, Date> lastMonthTime = DateUtil.getLastMonthTimeObj();
// 创建一个Calendar对象,并设置为2024年2月0日,即2024年1月最后一天
Calendar timeS = new GregorianCalendar();
timeS.set(Calendar.YEAR, 2024);
timeS.set(Calendar.MONTH, 1);
timeS.set(Calendar.DAY_OF_MONTH, 0);
// 设置时间为23点59分59秒
timeS.set(Calendar.HOUR_OF_DAY, 23);
timeS.set(Calendar.MINUTE, 59);
timeS.set(Calendar.SECOND, 59);
List<BsOrder> list = orderService.getOrderList(new HashMap<>());
// 查询个人订单
List<BsOrder> orderUserList = list.stream().filter(s->s.getUserId().equals(session.getUser().getId())).collect(Collectors.toList());
//查询团队
// 查询团队用户
Map<String,Object> param = new HashMap<>();
param.put("parentUserId", session.getUser().getId());
// 查询下级数据
List<UserTeamModel> subList = userParentRelService.getTeamSubList(param);
List<BsOrder> teamOrderList = new ArrayList<>();
// 遍历下级数据
for (UserTeamModel userTeamModel : subList) {
List<BsOrder> teamList = list.stream().filter(bsOrder -> bsOrder.getUserId().equals(userTeamModel.getUserId())).collect(Collectors.toList());
teamOrderList.addAll(teamList);
}
// 所有订单
List<BsOrder> allOrderList = new ArrayList<>();
allOrderList.addAll(orderUserList);
allOrderList.addAll(teamOrderList);
Map<String,Object> map = new HashMap<>();
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue());
map.put("cumulative" , userAccountRecordService.getUserTotalProfit(session.getUser().getId() , null , null));
map.put("unliquidated" , allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
// 今日收益报表
Map<String , Object> todayReport = new HashMap<>();
JSONObject object;
// 获取今天新增订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
todayReport.put("todayAddOrder", object);
// 获取今天我的订单
object = new JSONObject();
object.put("orderNum", (int) orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
object.put("orderMoney", orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
todayReport.put("todayUserOrder", object);
// 团队订单
object = new JSONObject();
object.put("orderTeamNum", (int) teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
object.put("orderTeamMoney", teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
todayReport.put("teamOrderList", object);
// 获取今天失效订单
object = new JSONObject();
object.put("orderFailureNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).count());
object.put("orderFailureMoney", allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(todayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(todayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
todayReport.put("todayFailureOrder", object);
map.put("todayReport" ,todayReport);
// 昨天收益报表
Map<String , Object> yesterdayReport = new HashMap<>();
// 获取昨天新增订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
yesterdayReport.put("yesterdayAddOrder", object);
// 获取昨天我的订单
object = new JSONObject();
object.put("orderNum", (int) orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
object.put("orderMoney", orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
yesterdayReport.put("yesterdayUserOrder", object);
// 团队订单
object = new JSONObject();
object.put("orderNum", (int) teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
object.put("orderMoney", teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
yesterdayReport.put("yesterdayOrderList", object);
// 获取昨天失效订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(yesterdayTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(yesterdayTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
yesterdayReport.put("yesterdayFailureOrder", object);
map.put("yesterdayReport" ,yesterdayReport);
// 本月收益报表
Map<String , Object> thisMonthReport = new HashMap<>();
// 获取本月新增订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
thisMonthReport.put("thisMonthAddOrder", object);
// 获取本月我的订单
object = new JSONObject();
object.put("orderNum", (int) orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
thisMonthReport.put("thisMonthUserOrder", object);
// 团队订单
object = new JSONObject();
object.put("orderNum", (int) teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
thisMonthReport.put("thisMonthOrderList", object);
// 获取本月失效订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(thisMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(thisMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
thisMonthReport.put("thisMonthFailureOrder", object);
map.put("thisMonthReport" ,thisMonthReport);
// 上月收益报表
Map<String , Object> lastMonthReport = new HashMap<>();
// 获取本月新增订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
lastMonthReport.put("lastMonthAddOrder", object);
// 获取本月我的订单
object = new JSONObject();
object.put("orderNum", (int) orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", orderUserList.stream().filter(s->s.getStatus().equals(1) || s.getStatus().equals(2) || s.getStatus().equals(3)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
lastMonthReport.put("lastMonthUserOrder", object);
// 团队订单
object = new JSONObject();
object.put("orderNum", (int) teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", teamOrderList.stream().filter(s->s.getStatus().equals(5)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
lastMonthReport.put("lastMonthOrderList", object);
// 获取本月失效订单
object = new JSONObject();
object.put("orderNum", (int) allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).count());
object.put("orderMoney", allOrderList.stream().filter(s -> s.getStatus().equals(6)).filter(s -> s.getCreateTime().toInstant().isAfter(lastMonthTime.get("timeS").toInstant()) && s.getCreateTime().toInstant().isBefore(lastMonthTime.get("timeE").toInstant())).map(BsOrder::getPromotionAmount).reduce(BigDecimal.ZERO, BigDecimal::add).multiply(goldCoinExchangeRate));
lastMonthReport.put("lastMonthFailureOrder", object);
map.put("lastMonthReport" ,lastMonthReport);
return ResponseMsgUtil.success(map);
}
}

@ -3,6 +3,8 @@ package com.hfkj.model;
import com.hfkj.entity.BsOrder;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class BsOrderModel extends BsOrder {
@ -21,4 +23,6 @@ public class BsOrderModel extends BsOrder {
* 名称
*/
private String name;
private BigDecimal gold;
}

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.hfkj.entity.BsOrder;
import com.hfkj.model.BsOrderModel;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@ -75,6 +76,16 @@ public interface BsOrderService {
*/
List<BsOrderModel> getOrderListParent(Map<String , Object> map);
/**
* @MethodName orderRebate
* @Description: 订单返利
* @param orderNo 订单号
* @param gold 返利金额
* @return: void
* @Author: Sum1Dream
* @Date: 2024/10/24 下午3:03
*/
void orderRebate(String orderNo , BigDecimal gold) throws Exception;
}

@ -15,6 +15,8 @@ import com.hfkj.service.order.BsOrderService;
import com.hfkj.service.order.OrderBusinessService;
import com.hfkj.service.pdd.PddService;
import com.hfkj.service.promotion.PromotionBusinessService;
import com.hfkj.service.sec.SecDictionaryService;
import com.hfkj.service.user.BsUserContributeService;
import com.hfkj.service.user.BsUserParentRelService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
@ -24,6 +26,7 @@ import org.springframework.core.annotation.OrderUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@ -44,6 +47,11 @@ public class BsOrderServiceImpl implements BsOrderService {
@Resource
private BsUserParentRelService userParentRelService;
@Resource
private BsUserContributeService userContributeService;
@Resource
private SecDictionaryService secDictionaryService;
@Override
public BsOrder editData(BsOrder order) {
bsOrderMapper.updateByPrimaryKey(order);
@ -112,7 +120,7 @@ public class BsOrderServiceImpl implements BsOrderService {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(map, "createTimeE")));
}
if (MapUtils.getInteger(map , "status") != null) {
criteria.andTypeEqualTo(MapUtils.getInteger(map , "status"));
criteria.andStatusEqualTo(MapUtils.getInteger(map , "status"));
}
if (MapUtils.getLong(map , "userId") != null) {
criteria.andUserIdEqualTo(MapUtils.getLong(map , "userId"));
@ -135,7 +143,7 @@ public class BsOrderServiceImpl implements BsOrderService {
// 创建一个BsOrderModel类型的列表
List<BsOrderModel> orderModels = new ArrayList<>();
BigDecimal goldCoinExchangeRate = new BigDecimal(secDictionaryService.getDictionary("GOLD_COIN_EXCHANGE_RATE").get(0).getCodeValue());
// 查询用户订单
if (MapUtils.getInteger(map , "orderType").equals(1)) {
// 获取订单列表
@ -146,6 +154,7 @@ public class BsOrderServiceImpl implements BsOrderService {
BsOrderModel orderModel = new BsOrderModel();
// 将订单属性复制到订单模型中
BeanUtils.copyProperties(order, orderModel);
orderModel.setGold(order.getPromotionAmount().multiply(goldCoinExchangeRate));
// 将订单模型添加到订单模型列表中
orderModels.add(orderModel);
}
@ -179,4 +188,19 @@ public class BsOrderServiceImpl implements BsOrderService {
return null;
}
@Override
public void orderRebate(String orderNo, BigDecimal gold) throws Exception {
BsOrder bsOrder = findByOrderNo(orderNo);
// 判断订单状态是否为4或5
if (bsOrder.getStatus().equals(4) || bsOrder.getStatus().equals(5)) {
// 如果是,则抛出异常,提示订单状态不可返利
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态不可返利");
}
Map<String,Object> otherParam = new HashMap<>();
otherParam.put("sourceId", bsOrder.getId());
otherParam.put("sourceOrderNo", bsOrder.getOrderNo());
userContributeService.purchase(bsOrder.getPromotionAmount(), bsOrder.getUserId(), otherParam);
}
}

Loading…
Cancel
Save