|
@@ -1,6 +1,6 @@
|
|
|
package com.ruoyi.app.pay;
|
|
package com.ruoyi.app.pay;
|
|
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -8,37 +8,36 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ruoyi.app.order.ZaloPayCommonService;
|
|
import com.ruoyi.app.order.ZaloPayCommonService;
|
|
|
|
|
+import com.ruoyi.app.pay.dto.QsBillingDto;
|
|
|
|
|
+import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
|
|
+import com.ruoyi.common.utils.DictUtils;
|
|
|
|
|
+import com.ruoyi.system.domain.vo.ShBillingDto;
|
|
|
import com.ruoyi.app.utils.DateUtil;
|
|
import com.ruoyi.app.utils.DateUtil;
|
|
|
-import com.ruoyi.app.utils.IpUtils;
|
|
|
|
|
-import com.ruoyi.app.utils.Md5Pay;
|
|
|
|
|
import com.ruoyi.app.utils.zaloPay.ZaloPay;
|
|
import com.ruoyi.app.utils.zaloPay.ZaloPay;
|
|
|
import com.ruoyi.app.utils.zaloPay.ZaloPayConfig;
|
|
import com.ruoyi.app.utils.zaloPay.ZaloPayConfig;
|
|
|
-import com.ruoyi.app.utils.zaloPay.ZaloPayCreateOrderResponse;
|
|
|
|
|
import com.ruoyi.common.annotation.Anonymous;
|
|
import com.ruoyi.common.annotation.Anonymous;
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
-import com.ruoyi.common.annotation.RepeatSubmit;
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
import com.ruoyi.common.utils.MessageUtils;
|
|
import com.ruoyi.common.utils.MessageUtils;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
-import com.ruoyi.system.domain.PosOrder;
|
|
|
|
|
-import com.ruoyi.system.domain.UserBilling;
|
|
|
|
|
|
|
+import com.ruoyi.system.domain.*;
|
|
|
import com.ruoyi.system.domain.vo.BillDTO;
|
|
import com.ruoyi.system.domain.vo.BillDTO;
|
|
|
import com.ruoyi.system.mapper.UserBillingMapper;
|
|
import com.ruoyi.system.mapper.UserBillingMapper;
|
|
|
-import com.ruoyi.system.service.IInfoUserService;
|
|
|
|
|
-import com.ruoyi.system.service.IPosOrderService;
|
|
|
|
|
-import com.ruoyi.system.service.IUserBillingService;
|
|
|
|
|
|
|
+import com.ruoyi.system.service.*;
|
|
|
import com.ruoyi.system.utils.Auth;
|
|
import com.ruoyi.system.utils.Auth;
|
|
|
import com.ruoyi.system.utils.JwtUtil;
|
|
import com.ruoyi.system.utils.JwtUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
-import jakarta.servlet.http.HttpServletRequest;
|
|
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
|
+
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -50,8 +49,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
*/
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/Billing/billing")
|
|
@RequestMapping("/Billing/billing")
|
|
|
-public class UserBillingController extends BaseController
|
|
|
|
|
-{
|
|
|
|
|
|
|
+public class UserBillingController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IUserBillingService userBillingService;
|
|
private IUserBillingService userBillingService;
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -66,9 +64,14 @@ public class UserBillingController extends BaseController
|
|
|
private ZaloPayConfig zaloPayConfig;
|
|
private ZaloPayConfig zaloPayConfig;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ZaloPay zaloPay;
|
|
private ZaloPay zaloPay;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IPosOrderRatingService posOrderRatingService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICommissionRatesService commissionRatesService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 商家日账单数据
|
|
* 商家日账单数据
|
|
|
|
|
+ *
|
|
|
* @param token
|
|
* @param token
|
|
|
* @param page
|
|
* @param page
|
|
|
* @param size
|
|
* @param size
|
|
@@ -79,24 +82,61 @@ public class UserBillingController extends BaseController
|
|
|
@Auth
|
|
@Auth
|
|
|
@GetMapping("/getzddaylist")
|
|
@GetMapping("/getzddaylist")
|
|
|
public AjaxResult getzddaylist(@RequestHeader String token,
|
|
public AjaxResult getzddaylist(@RequestHeader String token,
|
|
|
- @RequestParam Long page,
|
|
|
|
|
- @RequestParam Long size,
|
|
|
|
|
- @RequestParam String riqi)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ @RequestParam Long page,
|
|
|
|
|
+ @RequestParam Long size,
|
|
|
|
|
+ @RequestParam String riqi,
|
|
|
|
|
+ @RequestParam(required = false) Boolean isCancel
|
|
|
|
|
+ ) {
|
|
|
JwtUtil jwtUtil = new JwtUtil();
|
|
JwtUtil jwtUtil = new JwtUtil();
|
|
|
Long id = Long.valueOf(jwtUtil.getusid(token));
|
|
Long id = Long.valueOf(jwtUtil.getusid(token));
|
|
|
- List<UserBilling> list = userBillingMapper.getdaylist(id,riqi,(page-1)*size,size);
|
|
|
|
|
|
|
+ InfoUser user = infoUserService.getById(id);
|
|
|
|
|
+ //获取日的取消订单列表
|
|
|
|
|
+ if (isCancel != null && isCancel) {
|
|
|
|
|
+ return getDayCancleOrderList(page, size, riqi, user);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<UserBilling> list = userBillingMapper.getdaylist(id, riqi, (page - 1) * size, size);
|
|
|
setYhInfo(list);
|
|
setYhInfo(list);
|
|
|
- BillDTO sum = userBillingMapper.getdaysum(id,riqi);
|
|
|
|
|
|
|
+ BillDTO sum = userBillingMapper.getdaysum(id, riqi);
|
|
|
JSONObject org = new JSONObject();
|
|
JSONObject org = new JSONObject();
|
|
|
- org.put("shul",sum.getSul());
|
|
|
|
|
- org.put("sum",sum.getShouru());
|
|
|
|
|
- org.put("list",list);
|
|
|
|
|
|
|
+ org.put("shul", sum.getSul());
|
|
|
|
|
+ org.put("sum", sum.getShouru());
|
|
|
|
|
+ org.put("commission", sum.getCommission());
|
|
|
|
|
+ org.put("tax", sum.getTax());
|
|
|
|
|
+ org.put("behalfAmount", sum.getBehalfAmount());
|
|
|
|
|
+ LambdaQueryWrapper<PosOrder> queryWrapper = new LambdaQueryWrapper<PosOrder>()
|
|
|
|
|
+ .in(PosOrder::getState, new ArrayList<Long>(Arrays.asList(9L, 10L)))
|
|
|
|
|
+ .apply("(sh_id=" + id + " or qs_id=" + id + ") and date_format (cretim,'%Y-%m-%d %H:%i:%s') >= date_format ('" + riqi + " 00:00:00','%Y-%m-%d %H:%i:%s') and date_format (cretim,'%Y-%m-%d %H:%i:%s') <= date_format ('" + riqi + " 23:59:59','%Y-%m-%d %H:%i:%s')");
|
|
|
|
|
+ // 取消总数 ,作废、客服介入的数据
|
|
|
|
|
+ long cancleCount = posOrderService.count(queryWrapper);
|
|
|
|
|
+ org.put("cancelCount", cancleCount);
|
|
|
|
|
+
|
|
|
|
|
+ if ("2".equals(user.getUserType())) {
|
|
|
|
|
+ setQsList(list, org);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ShBillingDto shBillingDto = userBillingMapper.getShDaysum(id, riqi);
|
|
|
|
|
+ org.put("foodAmount", shBillingDto.getFoodAmount());
|
|
|
|
|
+ org.put("shYh", shBillingDto.getShYh());
|
|
|
|
|
+ setShList(list, org, user);
|
|
|
|
|
+ }
|
|
|
|
|
+ return success(MessageUtils.message("no.success"), org);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //按日获取取消订单列表
|
|
|
|
|
+ public AjaxResult getDayCancleOrderList(Long page, Long size, String riqi, InfoUser user) {
|
|
|
|
|
+ JSONObject org = new JSONObject();
|
|
|
|
|
+ Page<PosOrder> pageInput = new Page<>(page, size);
|
|
|
|
|
+ LambdaQueryWrapper<PosOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.in(PosOrder::getState, new ArrayList<Long>(Arrays.asList(9L, 10L)));
|
|
|
|
|
+ queryWrapper.apply("(sh_id=" + user.getUserId() + " or qs_id=" + user.getUserId() + ") and date_format (cretim,'%Y-%m-%d %H:%i:%s') >= date_format ('" + riqi + " 00:00:00','%Y-%m-%d %H:%i:%s') and date_format (cretim,'%Y-%m-%d %H:%i:%s') <= date_format ('" + riqi + " 23:59:59','%Y-%m-%d %H:%i:%s')");
|
|
|
|
|
+ queryWrapper.orderByDesc(PosOrder::getCretim);
|
|
|
|
|
+ IPage<PosOrder> datas = posOrderService.page(pageInput, queryWrapper);
|
|
|
|
|
+ org.put("list", datas.getRecords());
|
|
|
return success(MessageUtils.message("no.success"), org);
|
|
return success(MessageUtils.message("no.success"), org);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 商家周账单数据
|
|
* 商家周账单数据
|
|
|
|
|
+ *
|
|
|
* @param token
|
|
* @param token
|
|
|
* @param page
|
|
* @param page
|
|
|
* @param size
|
|
* @param size
|
|
@@ -107,27 +147,119 @@ public class UserBillingController extends BaseController
|
|
|
@Auth
|
|
@Auth
|
|
|
@GetMapping("/getzdmeeklist")
|
|
@GetMapping("/getzdmeeklist")
|
|
|
public AjaxResult getzdmeeklist(@RequestHeader String token,
|
|
public AjaxResult getzdmeeklist(@RequestHeader String token,
|
|
|
- @RequestParam Long page,
|
|
|
|
|
- @RequestParam Long size,
|
|
|
|
|
- @RequestParam String riqi)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ @RequestParam Long page,
|
|
|
|
|
+ @RequestParam Long size,
|
|
|
|
|
+ @RequestParam String riqi,
|
|
|
|
|
+ @RequestParam(required = false) Boolean isCancel) {
|
|
|
JwtUtil jwtUtil = new JwtUtil();
|
|
JwtUtil jwtUtil = new JwtUtil();
|
|
|
Long id = Long.valueOf(jwtUtil.getusid(token));
|
|
Long id = Long.valueOf(jwtUtil.getusid(token));
|
|
|
- List<UserBilling> list = userBillingMapper.getmeeklist(id,riqi,(page-1)*size,size);
|
|
|
|
|
|
|
+ InfoUser user = infoUserService.getById(id);
|
|
|
|
|
+ //获取日的取消订单列表
|
|
|
|
|
+ if (isCancel != null && isCancel) {
|
|
|
|
|
+ return getWeekCancleOrderList(page, size, riqi, user);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<UserBilling> list = userBillingMapper.getmeeklist(id, riqi, (page - 1) * size, size);
|
|
|
setYhInfo(list);
|
|
setYhInfo(list);
|
|
|
- BillDTO sum = userBillingMapper.getmeeksum(id,riqi);
|
|
|
|
|
|
|
+ BillDTO sum = userBillingMapper.getmeeksum(id, riqi);
|
|
|
|
|
+ JSONObject org = new JSONObject();
|
|
|
|
|
+ org.put("shul", sum.getSul()); //数量
|
|
|
|
|
+ org.put("sum", sum.getShouru());
|
|
|
|
|
+ org.put("commission", sum.getCommission());
|
|
|
|
|
+ org.put("tax", sum.getTax());
|
|
|
|
|
+ org.put("behalfAmount", sum.getBehalfAmount());
|
|
|
|
|
+ LambdaQueryWrapper<PosOrder> queryWrapper = new LambdaQueryWrapper<PosOrder>()
|
|
|
|
|
+ .in(PosOrder::getState, new ArrayList<Long>(Arrays.asList(9L, 10L)))
|
|
|
|
|
+ .apply("(sh_id=" + id + " or qs_id=" + id + ") and WEEK(cretim) = WEEK(" + riqi + ") and YEAR(cretim) = YEAR(" + riqi + ")");
|
|
|
|
|
+ // 取消总数 ,作废、客服介入的数据
|
|
|
|
|
+ long cancleCount = posOrderService.count(queryWrapper);
|
|
|
|
|
+ org.put("cancelCount", cancleCount);
|
|
|
|
|
+ if ("2".equals(user.getUserType())) {
|
|
|
|
|
+ setQsList(list, org);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ShBillingDto shBillingDto = userBillingMapper.getShMeeksum(id, riqi);
|
|
|
|
|
+ org.put("foodAmount", shBillingDto.getFoodAmount());
|
|
|
|
|
+ org.put("shYh", shBillingDto.getShYh());
|
|
|
|
|
+ setShList(list, org, user);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return success(MessageUtils.message("no.success"), org);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //按周获取取消订单列表
|
|
|
|
|
+ public AjaxResult getWeekCancleOrderList(Long page, Long size, String riqi, InfoUser user) {
|
|
|
JSONObject org = new JSONObject();
|
|
JSONObject org = new JSONObject();
|
|
|
- org.put("shul",sum.getSul());
|
|
|
|
|
- org.put("sum",sum.getShouru());
|
|
|
|
|
- org.put("list",list);
|
|
|
|
|
|
|
+ Page<PosOrder> pageInput = new Page<>(page, size);
|
|
|
|
|
+ LambdaQueryWrapper<PosOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.in(PosOrder::getState, new ArrayList<Long>(Arrays.asList(9L, 10L)));
|
|
|
|
|
+ queryWrapper.apply("(sh_id=" + user.getUserId() + " or qs_id=" + user.getUserId() + ") and WEEK(cretim) = WEEK(" + riqi + ") and YEAR(cretim) = YEAR(" + riqi + ")");
|
|
|
|
|
+ queryWrapper.orderByDesc(PosOrder::getCretim);
|
|
|
|
|
+ IPage<PosOrder> datas = posOrderService.page(pageInput, queryWrapper);
|
|
|
|
|
+ org.put("list", datas.getRecords());
|
|
|
return success(MessageUtils.message("no.success"), org);
|
|
return success(MessageUtils.message("no.success"), org);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //返回商户账单信息
|
|
|
|
|
+ private void setShList(List<UserBilling> list, JSONObject org, InfoUser user) {
|
|
|
|
|
+ List<ShBillingDto> result = new ArrayList<>();
|
|
|
|
|
+ if (!list.isEmpty()) {
|
|
|
|
|
+ List<Long> ddIds = list.stream().map(x -> Long.valueOf(x.getDdId())).collect(Collectors.toList());
|
|
|
|
|
+ List<PosOrder> orders = posOrderService.list(new LambdaQueryWrapper<PosOrder>().in(PosOrder::getDdId, ddIds));
|
|
|
|
|
+ List<PosOrderRating> ratings = posOrderRatingService.list(new LambdaQueryWrapper<PosOrderRating>().in(PosOrderRating::getDdId, ddIds));
|
|
|
|
|
+ list.forEach(x -> {
|
|
|
|
|
+ ShBillingDto dto = Convert.convert(ShBillingDto.class, x);
|
|
|
|
|
+ //货到付款的订单金额
|
|
|
|
|
+ orders.stream().filter(o -> o.getDdId().equals(Long.valueOf(x.getDdId()))).findFirst().ifPresent(o -> {
|
|
|
|
|
+ dto.setFoodAmount(o.getFoodAmount());
|
|
|
|
|
+ int shYh = (o.getMdDiscountAmount() == null ? 0 : o.getMdDiscountAmount()) + (o.getMdSalesReduction() == null ? 0 : o.getMdSalesReduction());
|
|
|
|
|
+ dto.setShYh((double) shYh);
|
|
|
|
|
+ });
|
|
|
|
|
+ ratings.stream().filter(r -> r.getDdId().equals(Long.valueOf(x.getDdId()))).findFirst().ifPresent(r -> dto.setShStarts(r.getQsStars()));
|
|
|
|
|
+ result.add(dto);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ double bl = user.getCommission() == null ? 0.00 : user.getCommission();
|
|
|
|
|
+ bl = commissionRatesService.getShCommissionRate(bl, user.getUserId());
|
|
|
|
|
+ org.put("commissionRate", bl);
|
|
|
|
|
+ org.put("list", result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //骑手返回骑手账单信息
|
|
|
|
|
+ private void setQsList(List<UserBilling> list, JSONObject org) {
|
|
|
|
|
+ List<QsBillingDto> result = new ArrayList<>();
|
|
|
|
|
+ if (!list.isEmpty()) {
|
|
|
|
|
+ List<Long> ddIds = list.stream().map(x -> Long.valueOf(x.getDdId())).collect(Collectors.toList());
|
|
|
|
|
+ List<PosOrder> orders = posOrderService.list(new LambdaQueryWrapper<PosOrder>().in(PosOrder::getDdId, ddIds));
|
|
|
|
|
+ List<PosOrderRating> ratings = posOrderRatingService.list(new LambdaQueryWrapper<PosOrderRating>().in(PosOrderRating::getDdId, ddIds));
|
|
|
|
|
+ list.forEach(x -> {
|
|
|
|
|
+ QsBillingDto dto = Convert.convert(QsBillingDto.class, x);
|
|
|
|
|
+ //货到付款的订单金额
|
|
|
|
|
+ orders.stream().filter(o -> o.getDdId().equals(Long.valueOf(x.getDdId()))).findFirst().ifPresent(o -> {
|
|
|
|
|
+ if ("1".equals(o.getCollectPayment())) {
|
|
|
|
|
+ dto.setOrderAmount(o.getAmount());
|
|
|
|
|
+ }
|
|
|
|
|
+ dto.setFreight(o.getFreight());
|
|
|
|
|
+ dto.setJvli(o.getJvli());
|
|
|
|
|
+ });
|
|
|
|
|
+ ratings.stream().filter(r -> r.getDdId().equals(Long.valueOf(x.getDdId()))).findFirst().ifPresent(r -> dto.setQsStarts(r.getQsStars()));
|
|
|
|
|
+ result.add(dto);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ String taxRate="0";
|
|
|
|
|
+ List<SysDictData> taxBlData = DictUtils.getDictCache("sys_qs_freight_bl");
|
|
|
|
|
+
|
|
|
|
|
+ if (taxBlData != null && taxBlData.get(0) != null) {
|
|
|
|
|
+ taxRate = taxBlData.get(0).getDictValue();
|
|
|
|
|
+ }
|
|
|
|
|
+ org.put("taxRate", taxRate);
|
|
|
|
|
+ org.put("list", result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
private void setYhInfo(List<UserBilling> list) {
|
|
private void setYhInfo(List<UserBilling> list) {
|
|
|
- if(!list.isEmpty()){
|
|
|
|
|
- List<String> orderIds=list.stream().map(UserBilling::getDdId).collect(Collectors.toList());
|
|
|
|
|
|
|
+ if (!list.isEmpty()) {
|
|
|
|
|
+ List<String> orderIds = list.stream().map(UserBilling::getDdId).collect(Collectors.toList());
|
|
|
LambdaQueryWrapper<PosOrder> query = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<PosOrder> query = new LambdaQueryWrapper<>();
|
|
|
- query.in(PosOrder::getDdId,orderIds);
|
|
|
|
|
|
|
+ query.in(PosOrder::getDdId, orderIds);
|
|
|
List<PosOrder> orders = posOrderService.list(query);
|
|
List<PosOrder> orders = posOrderService.list(query);
|
|
|
list.forEach(billing -> {
|
|
list.forEach(billing -> {
|
|
|
orders.stream().filter(o -> o.getDdId().toString().equals(billing.getDdId())).findFirst().ifPresent(o -> {
|
|
orders.stream().filter(o -> o.getDdId().toString().equals(billing.getDdId())).findFirst().ifPresent(o -> {
|
|
@@ -153,6 +285,7 @@ public class UserBillingController extends BaseController
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 商家月账单数据
|
|
* 商家月账单数据
|
|
|
|
|
+ *
|
|
|
* @param token
|
|
* @param token
|
|
|
* @param page
|
|
* @param page
|
|
|
* @param size
|
|
* @param size
|
|
@@ -163,94 +296,55 @@ public class UserBillingController extends BaseController
|
|
|
@Auth
|
|
@Auth
|
|
|
@GetMapping("/getzdmatlist")
|
|
@GetMapping("/getzdmatlist")
|
|
|
public AjaxResult getzdmatlist(@RequestHeader String token,
|
|
public AjaxResult getzdmatlist(@RequestHeader String token,
|
|
|
- @RequestParam Long page,
|
|
|
|
|
- @RequestParam Long size,
|
|
|
|
|
- @RequestParam String riqi)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ @RequestParam Long page,
|
|
|
|
|
+ @RequestParam Long size,
|
|
|
|
|
+ @RequestParam String riqi,
|
|
|
|
|
+ @RequestParam(required = false) Boolean isCancel) {
|
|
|
JwtUtil jwtUtil = new JwtUtil();
|
|
JwtUtil jwtUtil = new JwtUtil();
|
|
|
Long id = Long.valueOf(jwtUtil.getusid(token));
|
|
Long id = Long.valueOf(jwtUtil.getusid(token));
|
|
|
- List<UserBilling> list = userBillingMapper.getmatlist(id,riqi,(page-1)*size,size);
|
|
|
|
|
|
|
+ InfoUser user = infoUserService.getById(id);
|
|
|
|
|
+ if (isCancel != null && isCancel) {
|
|
|
|
|
+ return getMonthCancleOrderList(page, size, riqi, user);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<UserBilling> list = userBillingMapper.getmatlist(id, riqi, (page - 1) * size, size);
|
|
|
setYhInfo(list);
|
|
setYhInfo(list);
|
|
|
- BillDTO sum = userBillingMapper.getmatsum(id,riqi);
|
|
|
|
|
|
|
+ BillDTO sum = userBillingMapper.getmatsum(id, riqi);
|
|
|
JSONObject org = new JSONObject();
|
|
JSONObject org = new JSONObject();
|
|
|
- org.put("shul",sum.getSul());
|
|
|
|
|
- org.put("sum",sum.getShouru());
|
|
|
|
|
- org.put("list",list);
|
|
|
|
|
- return success(MessageUtils.message("no.success"), org);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //充值
|
|
|
|
|
- @Anonymous
|
|
|
|
|
- @Auth
|
|
|
|
|
- @RepeatSubmit(interval = 1000, message = "请求过于频繁")
|
|
|
|
|
- @RequestMapping(value = "/userRecharge", method = {RequestMethod.GET,RequestMethod.POST})
|
|
|
|
|
- public AjaxResult userRecharge(@RequestHeader String token, @RequestParam String language, @RequestParam Long amount, HttpServletRequest request)
|
|
|
|
|
- {
|
|
|
|
|
- JwtUtil jwtUtil = new JwtUtil();
|
|
|
|
|
- IpUtils ipUtils = new IpUtils();
|
|
|
|
|
- String ip = ipUtils.getIpAddr(request);
|
|
|
|
|
- String id = jwtUtil.getusid(token);
|
|
|
|
|
- Long timeLong = System.currentTimeMillis();
|
|
|
|
|
- Md5Pay md5Pay = new Md5Pay();
|
|
|
|
|
- String orderid = "CZ"+timeLong;
|
|
|
|
|
- System.out.println("orderid:"+orderid);
|
|
|
|
|
- String obj = md5Pay.VNPay(language,orderid,String.valueOf(amount),ip);
|
|
|
|
|
- UserBilling billing = new UserBilling();
|
|
|
|
|
- billing.setUserId(Long.valueOf(id));
|
|
|
|
|
- billing.setType(String.valueOf(1));
|
|
|
|
|
- billing.setDdId(orderid);
|
|
|
|
|
- billing.setAmount(Double.valueOf(amount));
|
|
|
|
|
- billing.setState(String.valueOf(3));
|
|
|
|
|
- billing.setIllustrate("用户充值");
|
|
|
|
|
- billing.setPaymentMethod("app线上充值");
|
|
|
|
|
- billing.setUrl(obj);
|
|
|
|
|
- Boolean reg = userBillingService.saveOrUpdate(billing);
|
|
|
|
|
- if(reg){
|
|
|
|
|
- return success(MessageUtils.message("no.order.create.success"), obj);
|
|
|
|
|
- }else {
|
|
|
|
|
- return error();
|
|
|
|
|
|
|
+ org.put("shul", sum.getSul());
|
|
|
|
|
+ org.put("sum", sum.getShouru());
|
|
|
|
|
+ org.put("commission", sum.getCommission());
|
|
|
|
|
+ org.put("tax", sum.getTax());
|
|
|
|
|
+ org.put("behalfAmount", sum.getBehalfAmount());
|
|
|
|
|
+ LambdaQueryWrapper<PosOrder> queryWrapper = new LambdaQueryWrapper<PosOrder>()
|
|
|
|
|
+ .in(PosOrder::getState, new ArrayList<Long>(Arrays.asList(9L, 10L)))
|
|
|
|
|
+ .apply("(sh_id=" + id + " or qs_id=" + id + ") and DATE_FORMAT(cretim, '%Y-%m') = " + riqi);
|
|
|
|
|
+ // 取消总数 ,作废、客服介入的数据
|
|
|
|
|
+ long cancleCount = posOrderService.count(queryWrapper);
|
|
|
|
|
+ org.put("cancelCount", cancleCount);
|
|
|
|
|
+ if ("2".equals(user.getUserType())) {
|
|
|
|
|
+ setQsList(list, org);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ShBillingDto shBillingDto = userBillingMapper.getshMonthsum(id, riqi);
|
|
|
|
|
+ org.put("foodAmount", shBillingDto.getFoodAmount());
|
|
|
|
|
+ org.put("shYh", shBillingDto.getShYh());
|
|
|
|
|
+ setShList(list, org, user);
|
|
|
}
|
|
}
|
|
|
|
|
+ return success(MessageUtils.message("no.success"), org);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * 充值使用ZaloPay
|
|
|
|
|
- * @param token
|
|
|
|
|
- * @param language
|
|
|
|
|
- * @param amount
|
|
|
|
|
- * @param request
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- @Anonymous
|
|
|
|
|
- @Auth
|
|
|
|
|
- @RepeatSubmit(interval = 1000, message = "请求过于频繁")
|
|
|
|
|
- @RequestMapping(value = "/userRechargeZaloPay", method = {RequestMethod.GET,RequestMethod.POST})
|
|
|
|
|
- public AjaxResult userRechargeZaloPay(@RequestHeader String token, @RequestParam String language, @RequestParam Long amount,@RequestParam String payType, HttpServletRequest request) throws Exception {
|
|
|
|
|
- JwtUtil jwtUtil = new JwtUtil();
|
|
|
|
|
- String userId = jwtUtil.getusid(token);
|
|
|
|
|
- Long timeLong = System.currentTimeMillis();
|
|
|
|
|
- String orderid = "CZ"+timeLong;
|
|
|
|
|
- System.out.println("orderid:"+orderid);
|
|
|
|
|
- ZaloPayCreateOrderResponse obj = zaloPay.createOrder(userId,orderid,amount,"user recharch by zalopay",zaloPayConfig.getZaloPayConfig(payType));
|
|
|
|
|
- zaloPayCommonService.setZaloPayOrder(orderid, JSON.toJSONString(obj),null,null,null,payType);
|
|
|
|
|
- UserBilling billing = new UserBilling();
|
|
|
|
|
- billing.setUserId(Long.valueOf(userId));
|
|
|
|
|
- billing.setType(String.valueOf(1));
|
|
|
|
|
- billing.setDdId(orderid);
|
|
|
|
|
- billing.setAmount(Double.valueOf(amount));
|
|
|
|
|
- billing.setState(String.valueOf(3));
|
|
|
|
|
- billing.setIllustrate("用户充值");
|
|
|
|
|
- billing.setPaymentMethod("zalopay线上充值");
|
|
|
|
|
- billing.setUrl(JSONObject.toJSONString(obj));
|
|
|
|
|
- Boolean reg = userBillingService.saveOrUpdate(billing);
|
|
|
|
|
- if(reg){
|
|
|
|
|
- return success(MessageUtils.message("no.order.create.success"), obj);
|
|
|
|
|
- }else {
|
|
|
|
|
- return error();
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ //按周获取取消订单列表
|
|
|
|
|
+ public AjaxResult getMonthCancleOrderList(Long page, Long size, String riqi, InfoUser user) {
|
|
|
|
|
+ JSONObject org = new JSONObject();
|
|
|
|
|
+ Page<PosOrder> pageInput = new Page<>(page, size);
|
|
|
|
|
+ LambdaQueryWrapper<PosOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper.in(PosOrder::getState, new ArrayList<Long>(Arrays.asList(9L, 10L)));
|
|
|
|
|
+ queryWrapper.apply("(sh_id=" + user.getUserId() + " or qs_id=" + user.getUserId() + ") and DATE_FORMAT(cretim, '%Y-%m') = " + riqi);
|
|
|
|
|
+ queryWrapper.orderByDesc(PosOrder::getCretim);
|
|
|
|
|
+ IPage<PosOrder> datas = posOrderService.page(pageInput, queryWrapper);
|
|
|
|
|
+ org.put("list", datas.getRecords());
|
|
|
|
|
+ return success(MessageUtils.message("no.success"), org);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
//查询用户账户及余额
|
|
//查询用户账户及余额
|
|
|
@Anonymous
|
|
@Anonymous
|
|
|
@Auth
|
|
@Auth
|
|
@@ -332,15 +426,33 @@ public class UserBillingController extends BaseController
|
|
|
return success(MessageUtils.message("no.success"), org);
|
|
return success(MessageUtils.message("no.success"), org);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询Billing列表
|
|
* 查询Billing列表
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:list')")
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:list')")
|
|
|
@GetMapping("/list")
|
|
@GetMapping("/list")
|
|
|
- public TableDataInfo list(UserBilling userBilling)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public TableDataInfo list(UserBilling userBilling) {
|
|
|
startPage();
|
|
startPage();
|
|
|
|
|
+ String[] dr = userBilling.getDateRange();
|
|
|
|
|
+ if (dr != null && dr.length == 2) {
|
|
|
|
|
+ userBilling.setCretimStart(dr[0]);
|
|
|
|
|
+ userBilling.setCretimEnd(dr[1]);
|
|
|
|
|
+ }
|
|
|
List<UserBilling> list = userBillingService.selectUserBillingList(userBilling);
|
|
List<UserBilling> list = userBillingService.selectUserBillingList(userBilling);
|
|
|
|
|
+ if (!list.isEmpty()) {
|
|
|
|
|
+ List<Long> userIds = list.stream().map(UserBilling::getUserId).collect(Collectors.toList());
|
|
|
|
|
+ List<InfoUser> users = infoUserService.list(new LambdaQueryWrapper<InfoUser>().in(InfoUser::getUserId, userIds));
|
|
|
|
|
+ list.forEach(x -> {
|
|
|
|
|
+ users.stream().filter(u -> u.getUserId().equals(x.getUserId())).findFirst().ifPresent(y -> {
|
|
|
|
|
+ x.setUserName(y.getUserName());
|
|
|
|
|
+ if ("0".equals(y.getUserType())) {
|
|
|
|
|
+ x.setUserName(y.getPhone());
|
|
|
|
|
+ }
|
|
|
|
|
+ x.setUserType(y.getUserType());
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -350,9 +462,26 @@ public class UserBillingController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:export')")
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:export')")
|
|
|
@Log(title = "Billing", businessType = BusinessType.EXPORT)
|
|
@Log(title = "Billing", businessType = BusinessType.EXPORT)
|
|
|
@PostMapping("/export")
|
|
@PostMapping("/export")
|
|
|
- public void export(HttpServletResponse response, UserBilling userBilling)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public void export(HttpServletResponse response, UserBilling userBilling) {
|
|
|
|
|
+ String[] dr = userBilling.getDateRange();
|
|
|
|
|
+ if (dr != null && dr.length == 2) {
|
|
|
|
|
+ userBilling.setCretimStart(dr[0]);
|
|
|
|
|
+ userBilling.setCretimEnd(dr[1]);
|
|
|
|
|
+ }
|
|
|
List<UserBilling> list = userBillingService.selectUserBillingList(userBilling);
|
|
List<UserBilling> list = userBillingService.selectUserBillingList(userBilling);
|
|
|
|
|
+ if (!list.isEmpty()) {
|
|
|
|
|
+ List<Long> userIds = list.stream().map(UserBilling::getUserId).collect(Collectors.toList());
|
|
|
|
|
+ List<InfoUser> users = infoUserService.list(new LambdaQueryWrapper<InfoUser>().in(InfoUser::getUserId, userIds));
|
|
|
|
|
+ list.forEach(x -> {
|
|
|
|
|
+ users.stream().filter(u -> u.getUserId().equals(x.getUserId())).findFirst().ifPresent(y -> {
|
|
|
|
|
+ x.setUserName(y.getUserName());
|
|
|
|
|
+ if ("0".equals(y.getUserType())) {
|
|
|
|
|
+ x.setUserName(y.getPhone());
|
|
|
|
|
+ }
|
|
|
|
|
+ x.setUserType(y.getUserType());
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
ExcelUtil<UserBilling> util = new ExcelUtil<UserBilling>(UserBilling.class);
|
|
ExcelUtil<UserBilling> util = new ExcelUtil<UserBilling>(UserBilling.class);
|
|
|
util.exportExcel(response, list, MessageUtils.message("no.export.excel.billing"));
|
|
util.exportExcel(response, list, MessageUtils.message("no.export.excel.billing"));
|
|
|
}
|
|
}
|
|
@@ -362,9 +491,17 @@ public class UserBillingController extends BaseController
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:query')")
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:query')")
|
|
|
@GetMapping(value = "/{id}")
|
|
@GetMapping(value = "/{id}")
|
|
|
- public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
|
- {
|
|
|
|
|
- return success(userBillingService.selectUserBillingById(id));
|
|
|
|
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
|
|
+ UserBilling result = userBillingService.selectUserBillingById(id);
|
|
|
|
|
+ if (result != null) {
|
|
|
|
|
+ InfoUser user = infoUserService.getById(result.getUserId());
|
|
|
|
|
+ result.setUserName(user.getUserName());
|
|
|
|
|
+ if ("0".equals(user.getUserType())) {
|
|
|
|
|
+ result.setUserName(user.getPhone());
|
|
|
|
|
+ }
|
|
|
|
|
+ result.setUserType(user.getUserType());
|
|
|
|
|
+ }
|
|
|
|
|
+ return success(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -373,8 +510,7 @@ public class UserBillingController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:add')")
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:add')")
|
|
|
@Log(title = "Billing", businessType = BusinessType.INSERT)
|
|
@Log(title = "Billing", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
- public AjaxResult add(@RequestBody UserBilling userBilling)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public AjaxResult add(@RequestBody UserBilling userBilling) {
|
|
|
return toAjax(userBillingService.insertUserBilling(userBilling));
|
|
return toAjax(userBillingService.insertUserBilling(userBilling));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -384,8 +520,7 @@ public class UserBillingController extends BaseController
|
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:edit')")
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:edit')")
|
|
|
@Log(title = "Billing", businessType = BusinessType.UPDATE)
|
|
@Log(title = "Billing", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
@PutMapping
|
|
|
- public AjaxResult edit(@RequestBody UserBilling userBilling)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public AjaxResult edit(@RequestBody UserBilling userBilling) {
|
|
|
return toAjax(userBillingService.updateUserBilling(userBilling));
|
|
return toAjax(userBillingService.updateUserBilling(userBilling));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -394,9 +529,8 @@ public class UserBillingController extends BaseController
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:remove')")
|
|
@PreAuthorize("@ss.hasPermi('Billing:billing:remove')")
|
|
|
@Log(title = "Billing", businessType = BusinessType.DELETE)
|
|
@Log(title = "Billing", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
|
|
- public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
return toAjax(userBillingService.deleteUserBillingByIds(ids));
|
|
return toAjax(userBillingService.deleteUserBillingByIds(ids));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|