Compare commits
61 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe7b4a9754 | ||
|
|
4bd912cd89 | ||
|
|
8270ffdc44 | ||
|
|
2528ce8317 | ||
|
|
b7293ca099 | ||
|
|
4fa9644ce2 | ||
|
|
9371c2b85a | ||
|
|
1eb2c70ea7 | ||
|
|
e1a0698883 | ||
|
|
0e5ac1ceb5 | ||
|
|
8fe450dd70 | ||
|
|
5cd84c91fa | ||
|
|
004b3294c4 | ||
|
|
df92ad6179 | ||
|
|
ce108efa97 | ||
|
|
6c940850cb | ||
|
|
5557b2b360 | ||
|
|
51d03bbe54 | ||
|
|
ba813d268e | ||
|
|
569a465850 | ||
|
|
71de503e22 | ||
|
|
570c94450b | ||
|
|
5100cfa1be | ||
|
|
dcc60f5841 | ||
|
|
59bd4110e5 | ||
|
|
a0fa4bb531 | ||
|
|
cd66a1b268 | ||
|
|
21ae260976 | ||
|
|
255ce6a491 | ||
|
|
0767fe5e0f | ||
|
|
96247fab7d | ||
|
|
30c62c9a71 | ||
|
|
a3d6cc105a | ||
|
|
2a48cfa63f | ||
|
|
f47038bbe5 | ||
|
|
5f0950f17f | ||
|
|
6f89b2eb3d | ||
|
|
b13db23b90 | ||
|
|
0a89b6d67c | ||
|
|
2231792463 | ||
|
|
929a694284 | ||
|
|
cff2c0e38a | ||
|
|
4955db3333 | ||
|
|
9320f400df | ||
|
|
89e202fa15 | ||
|
|
1212fc1cc0 | ||
|
|
9543878cd1 | ||
|
|
0c6c96eacb | ||
|
|
b9b6a90dee | ||
|
|
331e1ddc00 | ||
|
|
c17da7d4b3 | ||
|
|
0bd6ed40a2 | ||
|
|
0756092e4d | ||
|
|
496df13b1e | ||
|
|
a9ebf37fc5 | ||
|
|
72ee726ccb | ||
|
|
b1a9894a33 | ||
|
|
04f428198a | ||
|
|
f7d89c8dba | ||
|
|
eea45c05d8 | ||
|
|
84971187ca |
16
pom.xml
16
pom.xml
@@ -21,7 +21,17 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.aliyun.oss</groupId>
|
||||||
|
<artifactId>aliyun-sdk-oss</artifactId>
|
||||||
|
<version>2.8.3</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- zxing生成二维码 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.zxing</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>3.5.3</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
@@ -205,10 +215,6 @@
|
|||||||
<groupId>org.mybatis</groupId>
|
<groupId>org.mybatis</groupId>
|
||||||
<artifactId>mybatis-spring</artifactId>
|
<artifactId>mybatis-spring</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
<exclusion>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class MyBatisPlusConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public PaginationInterceptor paginationInterceptor() {
|
||||||
|
return new PaginationInterceptor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -139,7 +139,15 @@ public class OrderController {
|
|||||||
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||||
String userId = jsonObject.getString("accountId");
|
String userId = jsonObject.getString("accountId");
|
||||||
orderVo.setMerchantId(Integer.valueOf(userId));
|
orderVo.setMerchantId(Integer.valueOf(userId));
|
||||||
return orderService.createOrder(orderVo, clientType, token, null);
|
return orderService.createOrder(orderVo, clientType, token, null, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转台并台
|
||||||
|
*/
|
||||||
|
@PutMapping("/switch")
|
||||||
|
public Result switchTable(@Validated @RequestBody SwitchTableDTO switchTableDTO, @RequestHeader("token") String token) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, orderService.switchTable(switchTableDTO, token));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/createBackOrder")
|
@PostMapping("/createBackOrder")
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
|
|||||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
|
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
|
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.CreditDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnOrderDTO;
|
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnOrderDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.VipPayDTO;
|
import com.chaozhanggui.system.cashierservice.entity.dto.VipPayDTO;
|
||||||
@@ -25,6 +26,7 @@ import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
|||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.chaozhanggui.system.cashierservice.util.IpUtil;
|
import com.chaozhanggui.system.cashierservice.util.IpUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.Utils;
|
||||||
import com.chaozhanggui.system.cashierservice.util.WechatUtil;
|
import com.chaozhanggui.system.cashierservice.util.WechatUtil;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -214,12 +216,20 @@ public class PayController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((vipPayDTO.getPayAmount() != null && vipPayDTO.getPayAmount().compareTo(BigDecimal.ZERO) <= 0) ||
|
if ((vipPayDTO.getPayAmount() != null && vipPayDTO.getPayAmount().compareTo(BigDecimal.ZERO) <= 0) ||
|
||||||
(vipPayDTO.getDiscountAmount() != null && vipPayDTO.getDiscountAmount().compareTo(BigDecimal.ZERO) <= 0)) {
|
(vipPayDTO.getDiscountAmount() != null && vipPayDTO.getDiscountAmount().compareTo(BigDecimal.ZERO) <= 0)) {
|
||||||
return Result.fail("折扣金额必须大于0");
|
return Result.fail("折扣金额必须大于0");
|
||||||
}
|
}
|
||||||
return payService.vipPay(vipPayDTO.getOrderId(), token, vipPayDTO.getVipUserId(), vipPayDTO.getPayAmount(), vipPayDTO.getDiscountAmount());
|
return payService.vipPay(vipPayDTO.getOrderId(), token, vipPayDTO.getVipUserId(), vipPayDTO.getPayAmount(), vipPayDTO.getDiscountAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账支付
|
||||||
|
*/
|
||||||
|
@PostMapping("creditPay")
|
||||||
|
public Result creditPay(@RequestHeader("token") String token, @RequestBody CreditDTO creditDTO) {
|
||||||
|
return payService.creditPay(creditDTO, token);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 银行卡支付
|
* 银行卡支付
|
||||||
*
|
*
|
||||||
@@ -315,11 +325,11 @@ public class PayController {
|
|||||||
|
|
||||||
@GetMapping("/noToken/queryOrderInfo")
|
@GetMapping("/noToken/queryOrderInfo")
|
||||||
public Result noTokenQueryOrderInfo(String orderId) {
|
public Result noTokenQueryOrderInfo(String orderId) {
|
||||||
if(StrUtil.isBlank(orderId)){
|
if (StrUtil.isBlank(orderId)) {
|
||||||
return Result.fail("订单id不能为空");
|
return Result.fail("订单id不能为空");
|
||||||
}
|
}
|
||||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(Integer.valueOf(orderId));
|
||||||
if(orderInfo == null){
|
if (orderInfo == null) {
|
||||||
return Result.fail("订单不存在");
|
return Result.fail("订单不存在");
|
||||||
}
|
}
|
||||||
Map<String, Object> data = new HashMap<>(4);
|
Map<String, Object> data = new HashMap<>(4);
|
||||||
|
|||||||
@@ -5,9 +5,13 @@ import com.chaozhanggui.system.cashierservice.entity.dto.ClearTableDTO;
|
|||||||
import com.chaozhanggui.system.cashierservice.service.ShopInfoService;
|
import com.chaozhanggui.system.cashierservice.service.ShopInfoService;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.AliUploadUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
@CrossOrigin(origins = "*")
|
@CrossOrigin(origins = "*")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -78,4 +82,9 @@ public class ShopInfoController {
|
|||||||
public Result queryPwdInfo(@RequestParam("shopId") String shopId) {
|
public Result queryPwdInfo(@RequestParam("shopId") String shopId) {
|
||||||
return shopInfoService.queryShopPwdInfo(shopId);
|
return shopInfoService.queryShopPwdInfo(shopId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("upload")
|
||||||
|
public Result upload(@RequestParam("file") MultipartFile file) throws Exception {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, AliUploadUtils.uploadSuffix(file.getInputStream(), file.getOriginalFilename()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.controller;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.calltable.*;
|
||||||
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCallService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 叫号
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/callTable")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class TbCallTableController {
|
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(TbCallTableController.class);
|
||||||
|
private final TbCallService tbCallService;
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public Result get(@RequestParam(required = false) Integer callTableId, @RequestParam Integer shopId,
|
||||||
|
@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size,
|
||||||
|
@RequestParam(required = false) Integer state) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.get(page, size, shopId, callTableId, state));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public Result add(@Validated @RequestBody CallTableDTO addCallTableDTO) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.add(addCallTableDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
public Result update(@Validated @RequestBody UpdateCallTableDTO callTableDTO) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.update(callTableDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
public Result delete(@Validated @RequestBody BaseCallTableDTO baseCallTableDTO) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.delete(baseCallTableDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("takeNumber")
|
||||||
|
public Result takeNumber(@Validated @RequestBody TakeNumberDTO takeNumberDTO) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.takeNumber(takeNumberDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("takeNumberCode")
|
||||||
|
public Result takeNumberCode(@RequestParam Integer shopId, @RequestParam Integer callTableId) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.takeNumberCode(shopId, callTableId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("call")
|
||||||
|
public Result call(@Validated @RequestBody CallQueueDTO callQueueDTO) {
|
||||||
|
try {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.call(callQueueDTO));
|
||||||
|
} catch (MsgException e) {
|
||||||
|
log.error("异常", e);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, new HashMap<String, Object>() {{
|
||||||
|
put("state", "0");
|
||||||
|
put("message", e.getMessage());
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PutMapping("updateState")
|
||||||
|
public Result confirm(@Validated @RequestBody UpdateCallQueueDTO updateCallQueueDTO) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.updateInfo(updateCallQueueDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("queue")
|
||||||
|
public Result getQueue(@RequestParam Integer shopId, @RequestParam(required = false) Integer callTableId,
|
||||||
|
@RequestParam(required = false) Integer state, @RequestParam(defaultValue = "1") Integer page,
|
||||||
|
@RequestParam(defaultValue = "10") Integer size) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.getQueue(shopId, callTableId, state, page, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("callRecord")
|
||||||
|
public Result getCallRecord(@RequestParam Integer shopId, @RequestParam(required = false) Integer callTableId,
|
||||||
|
@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.getCallRecord(shopId, callTableId, page, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("config")
|
||||||
|
public Result getConfig(@RequestParam Integer shopId) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.getConfig(shopId));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PutMapping("config")
|
||||||
|
public Result updateConfig(@RequestBody UpdateConfigDTO configDTO) {
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbCallService.updateConfig(configDTO));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.controller;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditBuyer;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCreditBuyerService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账人
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/credit/buyer")
|
||||||
|
public class TbCreditBuyerController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbCreditBuyerService tbCreditBuyerService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("page")
|
||||||
|
public Result page(@RequestParam Map<String, Object> params) {
|
||||||
|
PageInfo<TbCreditBuyer> page = tbCreditBuyerService.page(params);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 信息
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("{id}")
|
||||||
|
public Result get(@PathVariable("id") String id) {
|
||||||
|
TbCreditBuyer data = tbCreditBuyerService.getById(id);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
public Result save(@RequestBody TbCreditBuyer entity) {
|
||||||
|
boolean ret = tbCreditBuyerService.save(entity);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改
|
||||||
|
*
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PutMapping
|
||||||
|
public Result update(@RequestBody TbCreditBuyer dto) {
|
||||||
|
boolean ret = tbCreditBuyerService.update(dto);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DeleteMapping("{id}")
|
||||||
|
public Result delete(@PathVariable("id") String id) {
|
||||||
|
tbCreditBuyerService.delete(id);
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 还款
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("repayment")
|
||||||
|
public Result repayment(@RequestBody Map<String, Object> params) {
|
||||||
|
Map<String, Object> data = tbCreditBuyerService.repayment(params);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.controller;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditPaymentRecord;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.CreditBuyerOrderDTO;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCreditBuyerOrderService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账账单
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/credit/buyer-order")
|
||||||
|
public class TbCreditBuyerOrderController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbCreditBuyerOrderService tbCreditBuyerOrderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("page")
|
||||||
|
public Result page(@RequestParam Map<String, Object> params) {
|
||||||
|
PageInfo<CreditBuyerOrderDTO> page = tbCreditBuyerOrderService.page(params);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 付款
|
||||||
|
*
|
||||||
|
* @param record
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("pay")
|
||||||
|
public Result pay(@RequestBody TbCreditPaymentRecord record) {
|
||||||
|
tbCreditBuyerOrderService.pay(record);
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("summary")
|
||||||
|
public Result summary(@RequestParam Map<String, Object> params) {
|
||||||
|
Map<String, Object> data = tbCreditBuyerOrderService.summary(params);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.controller;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditPaymentRecord;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCreditPaymentRecordService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账账单付款记录
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/credit/payment-record")
|
||||||
|
public class TbCreditPaymentRecordController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbCreditPaymentRecordService tbCreditPaymentRecordService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param params
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("page")
|
||||||
|
public Result page(@RequestParam Map<String, Object> params) {
|
||||||
|
PageInfo<TbCreditPaymentRecord> page = tbCreditPaymentRecordService.page(params);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -40,7 +40,7 @@ public interface TbActivateMapper {
|
|||||||
* @param tbActivate 实例对象
|
* @param tbActivate 实例对象
|
||||||
* @return 影响行数
|
* @return 影响行数
|
||||||
*/
|
*/
|
||||||
int insert(TbActivate tbActivate);
|
Integer insert(TbActivate tbActivate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量新增数据(MyBatis原生foreach方法)
|
* 批量新增数据(MyBatis原生foreach方法)
|
||||||
@@ -48,7 +48,7 @@ public interface TbActivateMapper {
|
|||||||
* @param entities List<TbActivate> 实例对象列表
|
* @param entities List<TbActivate> 实例对象列表
|
||||||
* @return 影响行数
|
* @return 影响行数
|
||||||
*/
|
*/
|
||||||
int insertBatch(@Param("entities") List<TbActivate> entities);
|
Integer insertBatch(@Param("entities") List<TbActivate> entities);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改数据
|
* 修改数据
|
||||||
@@ -56,7 +56,7 @@ public interface TbActivateMapper {
|
|||||||
* @param tbActivate 实例对象
|
* @param tbActivate 实例对象
|
||||||
* @return 影响行数
|
* @return 影响行数
|
||||||
*/
|
*/
|
||||||
int update(TbActivate tbActivate);
|
Integer update(TbActivate tbActivate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过主键删除数据
|
* 通过主键删除数据
|
||||||
@@ -64,14 +64,14 @@ public interface TbActivateMapper {
|
|||||||
* @param id 主键
|
* @param id 主键
|
||||||
* @return 影响行数
|
* @return 影响行数
|
||||||
*/
|
*/
|
||||||
int deleteById(Integer id);
|
Integer deleteById(Integer id);
|
||||||
|
|
||||||
TbActivate selectByAmount(@Param("shopId") String shopId, @Param("amount") BigDecimal amount);
|
TbActivate selectByAmount(@Param("shopId") String shopId, @Param("amount") BigDecimal amount);
|
||||||
|
|
||||||
TbActivate selectByAmountScope(@Param("shopId") String shopId,@Param("amount") BigDecimal amount);
|
TbActivate selectByAmountScope(@Param("shopId") String shopId,@Param("amount") BigDecimal amount);
|
||||||
|
|
||||||
int updateMemberPoints(@Param("memberId") Long memberId,@Param("points") Integer points);
|
Integer updateMemberPoints(@Param("memberId") Long memberId,@Param("points") Integer points);
|
||||||
|
|
||||||
int insertMemberPointsLog(Map<String,Object> params);
|
Integer insertMemberPointsLog(Map<String,Object> params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ public interface TbProductMapper {
|
|||||||
List<TbProduct> selectByShopIdAndShopTypeCheckGrounding(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName);
|
List<TbProduct> selectByShopIdAndShopTypeCheckGrounding(@Param("shopId") String shopId, @Param("categoryId") String categoryId,@Param("commdityName") String commdityName);
|
||||||
List<TbProduct> selectByShopIdAndShopTypeUnGrounding(@Param("shopId") String shopId,@Param("commdityName") String commdityName);
|
List<TbProduct> selectByShopIdAndShopTypeUnGrounding(@Param("shopId") String shopId,@Param("commdityName") String commdityName);
|
||||||
|
|
||||||
Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId, @Param("masterId") String masterId,@Param("day") String day, @Param("tableId") String tableId);
|
Integer countOrderByshopIdAndProductId(@Param("shopId") String shopId, @Param("productId") String productId,
|
||||||
|
@Param("masterId") String masterId,@Param("day") String day,
|
||||||
|
@Param("tableId") String tableId, @Param("useType") String useType);
|
||||||
@Update("update tb_product set stock_number = stock_number - #{num,jdbcType=INTEGER} where id = #{productId}")
|
@Update("update tb_product set stock_number = stock_number - #{num,jdbcType=INTEGER} where id = #{productId}")
|
||||||
void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num);
|
void updateStockById(@Param("productId")Integer productId, @Param("num")Integer num);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.io.Serializable;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* 叫号配置表
|
||||||
* @TableName tb_call_config
|
* @TableName tb_call_config
|
||||||
*/
|
*/
|
||||||
@TableName(value ="tb_call_config")
|
@TableName(value ="tb_call_config")
|
||||||
@@ -65,14 +65,9 @@ public class TbCallConfig implements Serializable {
|
|||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否过号顺延
|
* 临近几桌提醒
|
||||||
*/
|
*/
|
||||||
private Integer isPostpone;
|
private Integer nearNum;
|
||||||
|
|
||||||
/**
|
|
||||||
* 顺延号码数量
|
|
||||||
*/
|
|
||||||
private Integer postponeNum;
|
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -218,31 +213,17 @@ public class TbCallConfig implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否过号顺延
|
* 临近几桌提醒
|
||||||
*/
|
*/
|
||||||
public Integer getIsPostpone() {
|
public Integer getNearNum() {
|
||||||
return isPostpone;
|
return nearNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否过号顺延
|
* 临近几桌提醒
|
||||||
*/
|
*/
|
||||||
public void setIsPostpone(Integer isPostpone) {
|
public void setNearNum(Integer nearNum) {
|
||||||
this.isPostpone = isPostpone;
|
this.nearNum = nearNum;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 顺延号码数量
|
|
||||||
*/
|
|
||||||
public Integer getPostponeNum() {
|
|
||||||
return postponeNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 顺延号码数量
|
|
||||||
*/
|
|
||||||
public void setPostponeNum(Integer postponeNum) {
|
|
||||||
this.postponeNum = postponeNum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -267,8 +248,7 @@ public class TbCallConfig implements Serializable {
|
|||||||
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
|
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
|
||||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
|
||||||
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
|
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
|
||||||
&& (this.getIsPostpone() == null ? other.getIsPostpone() == null : this.getIsPostpone().equals(other.getIsPostpone()))
|
&& (this.getNearNum() == null ? other.getNearNum() == null : this.getNearNum().equals(other.getNearNum()));
|
||||||
&& (this.getPostponeNum() == null ? other.getPostponeNum() == null : this.getPostponeNum().equals(other.getPostponeNum()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -285,8 +265,7 @@ public class TbCallConfig implements Serializable {
|
|||||||
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
|
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
|
||||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||||
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
|
||||||
result = prime * result + ((getIsPostpone() == null) ? 0 : getIsPostpone().hashCode());
|
result = prime * result + ((getNearNum() == null) ? 0 : getNearNum().hashCode());
|
||||||
result = prime * result + ((getPostponeNum() == null) ? 0 : getPostponeNum().hashCode());
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,8 +285,7 @@ public class TbCallConfig implements Serializable {
|
|||||||
sb.append(", shopId=").append(shopId);
|
sb.append(", shopId=").append(shopId);
|
||||||
sb.append(", createTime=").append(createTime);
|
sb.append(", createTime=").append(createTime);
|
||||||
sb.append(", updateTime=").append(updateTime);
|
sb.append(", updateTime=").append(updateTime);
|
||||||
sb.append(", isPostpone=").append(isPostpone);
|
sb.append(", nearNum=").append(nearNum);
|
||||||
sb.append(", postponeNum=").append(postponeNum);
|
|
||||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||||
sb.append("]");
|
sb.append("]");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.io.Serializable;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* 叫号排号表
|
||||||
* @TableName tb_call_queue
|
* @TableName tb_call_queue
|
||||||
*/
|
*/
|
||||||
@TableName(value ="tb_call_queue")
|
@TableName(value ="tb_call_queue")
|
||||||
@@ -109,6 +109,11 @@ public class TbCallQueue implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String createDay;
|
private String createDay;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否已经顺延 0 未顺延 1已顺延一次 2顺延一次仍然过号
|
||||||
|
*/
|
||||||
|
private Integer isPostpone;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -378,6 +383,20 @@ public class TbCallQueue implements Serializable {
|
|||||||
this.createDay = createDay;
|
this.createDay = createDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否已经顺延 0 未顺延 1已顺延一次 2顺延一次仍然过号
|
||||||
|
*/
|
||||||
|
public Integer getIsPostpone() {
|
||||||
|
return isPostpone;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否已经顺延 0 未顺延 1已顺延一次 2顺延一次仍然过号
|
||||||
|
*/
|
||||||
|
public void setIsPostpone(Integer isPostpone) {
|
||||||
|
this.isPostpone = isPostpone;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object that) {
|
public boolean equals(Object that) {
|
||||||
if (this == that) {
|
if (this == that) {
|
||||||
@@ -408,7 +427,8 @@ public class TbCallQueue implements Serializable {
|
|||||||
&& (this.getSubState() == null ? other.getSubState() == null : this.getSubState().equals(other.getSubState()))
|
&& (this.getSubState() == null ? other.getSubState() == null : this.getSubState().equals(other.getSubState()))
|
||||||
&& (this.getConfirmTime() == null ? other.getConfirmTime() == null : this.getConfirmTime().equals(other.getConfirmTime()))
|
&& (this.getConfirmTime() == null ? other.getConfirmTime() == null : this.getConfirmTime().equals(other.getConfirmTime()))
|
||||||
&& (this.getCallNum() == null ? other.getCallNum() == null : this.getCallNum().equals(other.getCallNum()))
|
&& (this.getCallNum() == null ? other.getCallNum() == null : this.getCallNum().equals(other.getCallNum()))
|
||||||
&& (this.getCreateDay() == null ? other.getCreateDay() == null : this.getCreateDay().equals(other.getCreateDay()));
|
&& (this.getCreateDay() == null ? other.getCreateDay() == null : this.getCreateDay().equals(other.getCreateDay()))
|
||||||
|
&& (this.getIsPostpone() == null ? other.getIsPostpone() == null : this.getIsPostpone().equals(other.getIsPostpone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -434,6 +454,7 @@ public class TbCallQueue implements Serializable {
|
|||||||
result = prime * result + ((getConfirmTime() == null) ? 0 : getConfirmTime().hashCode());
|
result = prime * result + ((getConfirmTime() == null) ? 0 : getConfirmTime().hashCode());
|
||||||
result = prime * result + ((getCallNum() == null) ? 0 : getCallNum().hashCode());
|
result = prime * result + ((getCallNum() == null) ? 0 : getCallNum().hashCode());
|
||||||
result = prime * result + ((getCreateDay() == null) ? 0 : getCreateDay().hashCode());
|
result = prime * result + ((getCreateDay() == null) ? 0 : getCreateDay().hashCode());
|
||||||
|
result = prime * result + ((getIsPostpone() == null) ? 0 : getIsPostpone().hashCode());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,6 +483,7 @@ public class TbCallQueue implements Serializable {
|
|||||||
sb.append(", confirmTime=").append(confirmTime);
|
sb.append(", confirmTime=").append(confirmTime);
|
||||||
sb.append(", callNum=").append(callNum);
|
sb.append(", callNum=").append(callNum);
|
||||||
sb.append(", createDay=").append(createDay);
|
sb.append(", createDay=").append(createDay);
|
||||||
|
sb.append(", isPostpone=").append(isPostpone);
|
||||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||||
sb.append("]");
|
sb.append("]");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public class TbCashierCart implements Serializable {
|
|||||||
private String proGroupInfo;
|
private String proGroupInfo;
|
||||||
private String typeEnum;
|
private String typeEnum;
|
||||||
private Integer groupType;
|
private Integer groupType;
|
||||||
|
private int isWeight;
|
||||||
|
|
||||||
public void copy(TbCashierCart source) {
|
public void copy(TbCashierCart source) {
|
||||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账人
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("tb_credit_buyer")
|
||||||
|
public class TbCreditBuyer {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账编码
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 店铺id
|
||||||
|
*/
|
||||||
|
private Integer shopId;
|
||||||
|
/**
|
||||||
|
* 状态 1-启用 0-停用
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 挂账人
|
||||||
|
*/
|
||||||
|
private String debtor;
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String mobile;
|
||||||
|
/**
|
||||||
|
* 职务
|
||||||
|
*/
|
||||||
|
private String position;
|
||||||
|
/**
|
||||||
|
* 挂账额度
|
||||||
|
*/
|
||||||
|
private BigDecimal creditAmount;
|
||||||
|
/**
|
||||||
|
* 账户余额
|
||||||
|
*/
|
||||||
|
private BigDecimal accountBalance;
|
||||||
|
/**
|
||||||
|
* 还款方式 total-按总金额还款 order-按订单还款
|
||||||
|
*/
|
||||||
|
private String repaymentMethod;
|
||||||
|
/**
|
||||||
|
* 支付方式
|
||||||
|
*/
|
||||||
|
private String paymentMethod;
|
||||||
|
/**
|
||||||
|
* 责任人
|
||||||
|
*/
|
||||||
|
private String responsiblePerson;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
/**
|
||||||
|
* 删除标志 0-正常 1-删除
|
||||||
|
*/
|
||||||
|
private Integer delFlag;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已挂账金额
|
||||||
|
*/
|
||||||
|
@TableField(value = "(select ifnull(sum(unpaid_amount),0) from view_credit_buyer_order where credit_buyer_id = tb_credit_buyer.id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||||
|
private BigDecimal owedAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 剩余挂账额度
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private BigDecimal remainingAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 累计挂账金额
|
||||||
|
*/
|
||||||
|
@TableField(value = "(select ifnull(sum(pay_amount),0) from view_credit_buyer_order where credit_buyer_id = tb_credit_buyer.id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||||
|
private BigDecimal accumulateAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 适用门店
|
||||||
|
*/
|
||||||
|
@TableField(value = "(select shop_name from tb_shop_info where id = tb_credit_buyer.shop_id)", select = false, insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER)
|
||||||
|
private String shopName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 剩余挂账额度
|
||||||
|
*/
|
||||||
|
public BigDecimal getRemainingAmount() {
|
||||||
|
return NumberUtil.sub(creditAmount, NumberUtil.null2Zero(owedAmount));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账账单
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("tb_credit_buyer_order")
|
||||||
|
public class TbCreditBuyerOrder {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 订单id
|
||||||
|
*/
|
||||||
|
private Long orderId;
|
||||||
|
/**
|
||||||
|
* 挂账人编码
|
||||||
|
*/
|
||||||
|
private String creditBuyerId;
|
||||||
|
/**
|
||||||
|
* 已付金额
|
||||||
|
*/
|
||||||
|
private BigDecimal paidAmount;
|
||||||
|
/**
|
||||||
|
* 状态 unpaid-未付款 partial-部分支付 paid-已付款
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
|
* 最近一次付款时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date lastPaymentTime;
|
||||||
|
/**
|
||||||
|
* 最近一次付款方式
|
||||||
|
*/
|
||||||
|
private String lastPaymentMethod;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@TableField(value = "remark", updateStrategy = FieldStrategy.NEVER)
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账账单付款记录
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
@TableName("tb_credit_payment_record")
|
||||||
|
public class TbCreditPaymentRecord {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 订单id
|
||||||
|
*/
|
||||||
|
private Long orderId;
|
||||||
|
/**
|
||||||
|
* 挂账人编码
|
||||||
|
*/
|
||||||
|
private String creditBuyerId;
|
||||||
|
/**
|
||||||
|
* 还款金额
|
||||||
|
*/
|
||||||
|
private BigDecimal repaymentAmount;
|
||||||
|
/**
|
||||||
|
* 支付方式
|
||||||
|
*/
|
||||||
|
private String paymentMethod;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
/**
|
||||||
|
* 还款时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date paymentTime;
|
||||||
|
/**
|
||||||
|
* 操作时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.entity;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.data.annotation.Transient;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -59,9 +60,12 @@ public class TbOrderDetail implements Serializable {
|
|||||||
private BigDecimal canReturnAmount;
|
private BigDecimal canReturnAmount;
|
||||||
private BigDecimal returnAmount;
|
private BigDecimal returnAmount;
|
||||||
private Integer isPrint;
|
private Integer isPrint;
|
||||||
|
@Transient
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Integer isGift;
|
||||||
|
|
||||||
private BigDecimal discountSaleAmount;
|
private BigDecimal discountSaleAmount;
|
||||||
private String discountSaleNote;
|
private String discountSaleNote;
|
||||||
private String proGroupInfo;
|
private String proGroupInfo;
|
||||||
|
private int isWeight;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ public class TbOrderInfo implements Serializable {
|
|||||||
private BigDecimal pointsDiscountAmount;
|
private BigDecimal pointsDiscountAmount;
|
||||||
private String refundRemark;
|
private String refundRemark;
|
||||||
private Integer pointsNum;
|
private Integer pointsNum;
|
||||||
|
private String creditBuyerId;
|
||||||
|
|
||||||
public TbOrderInfo(){
|
public TbOrderInfo(){
|
||||||
super();
|
super();
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class TbShopPermission extends Model<TbShopPermission> {
|
|||||||
* @return 主键值
|
* @return 主键值
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Serializable pkVal() {
|
public Serializable pkVal() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class TbShopStaffPermission extends Model<TbShopStaffPermission> {
|
|||||||
* @return 主键值
|
* @return 主键值
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Serializable pkVal() {
|
public Serializable pkVal() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账账单
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CreditBuyerOrderDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 订单id
|
||||||
|
*/
|
||||||
|
private Long orderId;
|
||||||
|
/**
|
||||||
|
* 挂账人编码
|
||||||
|
*/
|
||||||
|
private String creditBuyerId;
|
||||||
|
/**
|
||||||
|
* 应付金额
|
||||||
|
*/
|
||||||
|
private BigDecimal payAmount;
|
||||||
|
/**
|
||||||
|
* 已付金额
|
||||||
|
*/
|
||||||
|
private BigDecimal paidAmount;
|
||||||
|
/**
|
||||||
|
* 未付金额
|
||||||
|
*/
|
||||||
|
private BigDecimal unpaidAmount;
|
||||||
|
/**
|
||||||
|
* 状态 unpaid-未付款 partial-部分支付 paid-已付款
|
||||||
|
*/
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
|
* 最近一次付款时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date lastPaymentTime;
|
||||||
|
/**
|
||||||
|
* 最近一次付款方式
|
||||||
|
*/
|
||||||
|
private String lastPaymentMethod;
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
private String remark;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.DecimalMin;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CreditDTO {
|
||||||
|
@NotNull
|
||||||
|
private Integer orderId;
|
||||||
|
@NotEmpty
|
||||||
|
private String creditBuyerId;
|
||||||
|
@DecimalMin("0.00")
|
||||||
|
private BigDecimal payAmount;
|
||||||
|
@DecimalMin("0.00")
|
||||||
|
private BigDecimal discountAmount;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SwitchTableDTO {
|
||||||
|
@NotNull
|
||||||
|
private Integer shopId;
|
||||||
|
@NotEmpty(message = "取餐码不为空")
|
||||||
|
private String masterId;
|
||||||
|
private Integer orderId;
|
||||||
|
private List<Integer> cartIds;
|
||||||
|
private Boolean isFull;
|
||||||
|
@NotEmpty(message = "当前台桌id不为空")
|
||||||
|
private String currentTableId;
|
||||||
|
@NotEmpty(message = "目标台桌id不为空")
|
||||||
|
private String targetTableId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto.calltable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BaseCallTableDTO {
|
||||||
|
@NotNull
|
||||||
|
private Integer callTableId;
|
||||||
|
@NotNull
|
||||||
|
private Integer shopId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto.calltable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CallQueueDTO{
|
||||||
|
@NotNull
|
||||||
|
private Integer callQueueId;
|
||||||
|
@NotNull
|
||||||
|
private Integer shopId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto.calltable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CallTableDTO {
|
||||||
|
@NotNull
|
||||||
|
private Integer shopId;
|
||||||
|
@NotEmpty
|
||||||
|
private String name;
|
||||||
|
private String note;
|
||||||
|
@NotNull
|
||||||
|
@Min(1)
|
||||||
|
private Integer waitTime;
|
||||||
|
@NotBlank
|
||||||
|
private String prefix;
|
||||||
|
@NotNull
|
||||||
|
@Min(1)
|
||||||
|
private Integer start;
|
||||||
|
@Min(1)
|
||||||
|
private Integer nearNum;
|
||||||
|
private Integer isPostpone;
|
||||||
|
private Integer postponeNum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto.calltable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class TakeNumberDTO extends BaseCallTableDTO{
|
||||||
|
private Integer userId;
|
||||||
|
@NotEmpty
|
||||||
|
@Pattern(regexp = "^1\\d{10}$|^(0\\d{2,3}-?|\\(0\\d{2,3}\\))?[1-9]\\d{4,7}(-\\d{1,8})?$",message = "手机号码格式错误")
|
||||||
|
private String phone;
|
||||||
|
private String note;
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto.calltable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@Getter
|
||||||
|
public class UpdateCallQueueDTO extends CallQueueDTO{
|
||||||
|
@NotNull
|
||||||
|
private Integer state;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto.calltable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UpdateCallTableDTO{
|
||||||
|
@NotNull
|
||||||
|
private Integer callTableId;
|
||||||
|
@NotNull
|
||||||
|
private Integer shopId;
|
||||||
|
private String name;
|
||||||
|
private String note;
|
||||||
|
@Min(1)
|
||||||
|
private Integer waitTime;
|
||||||
|
private String prefix;
|
||||||
|
@Min(1)
|
||||||
|
private Integer start;
|
||||||
|
@Min(1)
|
||||||
|
private Integer nearNum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.dto.calltable;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UpdateConfigDTO {
|
||||||
|
@NotNull
|
||||||
|
private Integer shopId;
|
||||||
|
private Integer isOnline;
|
||||||
|
private String bgCover;
|
||||||
|
private Integer isPostpone;
|
||||||
|
private Integer postponeNum;
|
||||||
|
private Integer nearNum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity.vo;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCallQueue;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class CallRecordVO extends TbCallQueue {
|
||||||
|
private String tableNote;
|
||||||
|
private Long sinceAt;
|
||||||
|
}
|
||||||
@@ -16,12 +16,15 @@ public class CustomFilter implements Filter {
|
|||||||
public void init(FilterConfig filterConfig) throws ServletException {
|
public void init(FilterConfig filterConfig) throws ServletException {
|
||||||
log.info(">>>> customFilter init <<<<");
|
log.info(">>>> customFilter init <<<<");
|
||||||
}
|
}
|
||||||
|
public boolean isMultipartRequest(HttpServletRequest request) {
|
||||||
|
String contentType = request.getContentType();
|
||||||
|
return contentType != null && contentType.toLowerCase().startsWith("multipart/form-data");
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
|
||||||
log.info(">>>> customFilter doFilter start <<<<");
|
log.info(">>>> customFilter doFilter start <<<<");
|
||||||
RequestWrapper requestWapper = null;
|
RequestWrapper requestWapper = null;
|
||||||
if (servletRequest instanceof HttpServletRequest) {
|
if (servletRequest instanceof HttpServletRequest && !isMultipartRequest((HttpServletRequest)servletRequest)) {
|
||||||
requestWapper = new RequestWrapper((HttpServletRequest) servletRequest);
|
requestWapper = new RequestWrapper((HttpServletRequest) servletRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.interceptor;
|
package com.chaozhanggui.system.cashierservice.interceptor;
|
||||||
|
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
import javax.servlet.ReadListener;
|
import javax.servlet.ReadListener;
|
||||||
import javax.servlet.ServletInputStream;
|
import javax.servlet.ServletInputStream;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -9,73 +11,70 @@ import java.io.*;
|
|||||||
public class RequestWrapper extends HttpServletRequestWrapper {
|
public class RequestWrapper extends HttpServletRequestWrapper {
|
||||||
private final String body;
|
private final String body;
|
||||||
|
|
||||||
public RequestWrapper(HttpServletRequest request) {
|
public RequestWrapper(HttpServletRequest request) throws IOException {
|
||||||
super(request);
|
super(request);
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
BufferedReader bufferedReader = null;
|
BufferedReader bufferedReader = null;
|
||||||
InputStream inputStream = null;
|
InputStream inputStream = null;
|
||||||
try {
|
|
||||||
|
// 仅处理普通请求体,不影响multipart请求
|
||||||
|
if (!(request instanceof MultipartHttpServletRequest)) {
|
||||||
inputStream = request.getInputStream();
|
inputStream = request.getInputStream();
|
||||||
if (inputStream != null) {
|
if (inputStream != null) {
|
||||||
bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
char[] charBuffer = new char[128];
|
char[] charBuffer = new char[128];
|
||||||
int bytesRead = -1;
|
int bytesRead;
|
||||||
while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
|
while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
|
||||||
stringBuilder.append(charBuffer, 0, bytesRead);
|
stringBuilder.append(charBuffer, 0, bytesRead);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stringBuilder.append("");
|
stringBuilder.append("");
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
body = stringBuilder.toString();
|
||||||
ex.printStackTrace();
|
} else {
|
||||||
} finally {
|
// 如果是Multipart请求,不做处理,直接返回
|
||||||
if (inputStream != null) {
|
body = null;
|
||||||
try {
|
|
||||||
inputStream.close();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (bufferedReader != null) {
|
|
||||||
try {
|
|
||||||
bufferedReader.close();
|
|
||||||
}
|
|
||||||
catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
body = stringBuilder.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServletInputStream getInputStream() throws IOException {
|
public ServletInputStream getInputStream() throws IOException {
|
||||||
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes());
|
if (body != null) {
|
||||||
ServletInputStream servletInputStream = new ServletInputStream() {
|
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes());
|
||||||
@Override
|
return new ServletInputStream() {
|
||||||
public boolean isFinished() {
|
@Override
|
||||||
return false;
|
public boolean isFinished() {
|
||||||
}
|
return byteArrayInputStream.available() == 0;
|
||||||
@Override
|
}
|
||||||
public boolean isReady() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void setReadListener(ReadListener readListener) {
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public int read() throws IOException {
|
|
||||||
return byteArrayInputStream.read();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return servletInputStream;
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isReady() {
|
||||||
|
return byteArrayInputStream.available() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setReadListener(ReadListener readListener) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int read() throws IOException {
|
||||||
|
return byteArrayInputStream.read();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// 如果是Multipart请求,返回空的输入流,交给Spring处理
|
||||||
|
return super.getInputStream();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BufferedReader getReader() throws IOException {
|
public BufferedReader getReader() throws IOException {
|
||||||
return new BufferedReader(new InputStreamReader(this.getInputStream()));
|
if (body != null) {
|
||||||
|
return new BufferedReader(new InputStreamReader(this.getInputStream()));
|
||||||
|
} else {
|
||||||
|
// 如果是Multipart请求,返回空的reader
|
||||||
|
return super.getReader();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBody() {
|
public String getBody() {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.springframework.web.servlet.HandlerInterceptor;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ public class SignInterceptor implements HandlerInterceptor {
|
|||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> getParameterMap(HttpServletRequest request) {
|
private Map<String, Object> getParameterMap(HttpServletRequest request) throws IOException {
|
||||||
RequestWrapper requestWrapper = new RequestWrapper(request);
|
RequestWrapper requestWrapper = new RequestWrapper(request);
|
||||||
String body = requestWrapper.getBody();
|
String body = requestWrapper.getBody();
|
||||||
if (ObjectUtil.isNotEmpty(body)) {
|
if (ObjectUtil.isNotEmpty(body)) {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
* @description 针对表【tb_call_config】的数据库操作Mapper
|
* @description 针对表【tb_call_config(叫号配置表)】的数据库操作Mapper
|
||||||
* @createDate 2024-09-19 14:35:05
|
* @createDate 2024-12-10 10:12:45
|
||||||
* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallConfig
|
* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallConfig
|
||||||
*/
|
*/
|
||||||
public interface TbCallConfigMapper extends BaseMapper<TbCallConfig> {
|
public interface TbCallConfigMapper extends BaseMapper<TbCallConfig> {
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.mapper;
|
package com.chaozhanggui.system.cashierservice.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbCallQueue;
|
import com.chaozhanggui.system.cashierservice.entity.TbCallQueue;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.vo.CallRecordVO;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
* @description 针对表【tb_call_queue】的数据库操作Mapper
|
* @description 针对表【tb_call_queue(叫号排号表)】的数据库操作Mapper
|
||||||
* @createDate 2024-09-19 14:35:05
|
* @createDate 2024-12-10 10:12:45
|
||||||
* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue
|
* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallQueue
|
||||||
*/
|
*/
|
||||||
public interface TbCallQueueMapper extends BaseMapper<TbCallQueue> {
|
public interface TbCallQueueMapper extends BaseMapper<TbCallQueue> {
|
||||||
|
|
||||||
|
@Select("select a.*, b.note as tableNote, TIMESTAMPDIFF(SECOND, a.create_time, NOW()) as since_at from tb_call_queue a " +
|
||||||
|
"left join tb_call_table b on a.call_table_id=b.id " +
|
||||||
|
"where a.shop_id=#{shopId} and a.state in (3, 2, 1) order by a.create_time desc")
|
||||||
|
Page<CallRecordVO> selectCallRecord(Integer shopId, Integer callTableId, Page<Object> objectPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
* @description 针对表【tb_call_table】的数据库操作Mapper
|
* @description 针对表【tb_call_table(叫号桌型表)】的数据库操作Mapper
|
||||||
* @createDate 2024-09-19 14:35:05
|
* @createDate 2024-12-10 10:12:45
|
||||||
* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallTable
|
* @Entity com.chaozhanggui.system.cashierservice.entity.TbCallTable
|
||||||
*/
|
*/
|
||||||
public interface TbCallTableMapper extends BaseMapper<TbCallTable> {
|
public interface TbCallTableMapper extends BaseMapper<TbCallTable> {
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditBuyer;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账人
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface TbCreditBuyerMapper extends BaseMapper<TbCreditBuyer> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditBuyerOrder;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.CreditBuyerOrderDTO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账账单
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface TbCreditBuyerOrderMapper extends BaseMapper<TbCreditBuyerOrder> {
|
||||||
|
|
||||||
|
List<CreditBuyerOrderDTO> getList(Map<String, Object> params);
|
||||||
|
|
||||||
|
long getCount(Map<String, Object> params);
|
||||||
|
|
||||||
|
BigDecimal getSumPayAmount(Map<String, Object> params);
|
||||||
|
|
||||||
|
BigDecimal getSumPaidAmount(Map<String, Object> params);
|
||||||
|
|
||||||
|
BigDecimal getSumUnpaidAmount(Map<String, Object> params);
|
||||||
|
|
||||||
|
CreditBuyerOrderDTO getOne(Map<String, Object> params);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditPaymentRecord;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账账单付款记录
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface TbCreditPaymentRecordMapper extends BaseMapper<TbCreditPaymentRecord> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.rabbit;
|
package com.chaozhanggui.system.cashierservice.rabbit;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
import cn.hutool.core.thread.ThreadUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
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;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.TbOrderDetailMapper;
|
import com.chaozhanggui.system.cashierservice.dao.TbOrderDetailMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.TbOrderInfoMapper;
|
import com.chaozhanggui.system.cashierservice.dao.TbOrderInfoMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
|
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
|
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
|
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
|
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO;
|
import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mybatis.MPCashierCartMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mybatis.MPOrderDetailMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
|
import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.rabbit.print.PrinterHandler;
|
import com.chaozhanggui.system.cashierservice.rabbit.print.PrinterHandler;
|
||||||
import com.chaozhanggui.system.cashierservice.util.Utils;
|
import com.chaozhanggui.system.cashierservice.util.Utils;
|
||||||
@@ -24,6 +25,8 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@@ -31,14 +34,18 @@ public class PrintConsumer {
|
|||||||
private final TbOrderInfoMapper tbOrderInfoMapper;
|
private final TbOrderInfoMapper tbOrderInfoMapper;
|
||||||
private final TbShopInfoMapper tbShopInfoMapper;
|
private final TbShopInfoMapper tbShopInfoMapper;
|
||||||
private final TbOrderDetailMapper tbOrderDetailMapper;
|
private final TbOrderDetailMapper tbOrderDetailMapper;
|
||||||
|
private final MPOrderDetailMapper mpOrderDetailMapper;
|
||||||
|
private final MPCashierCartMapper mpCashierCartMapper;
|
||||||
private final MpPrintMachineMapper mpPrintMachineMapper;
|
private final MpPrintMachineMapper mpPrintMachineMapper;
|
||||||
|
|
||||||
private final PrinterHandler printerHandler;
|
private final PrinterHandler printerHandler;
|
||||||
|
|
||||||
public PrintConsumer(TbOrderInfoMapper tbOrderInfoMapper, TbShopInfoMapper tbShopInfoMapper, TbOrderDetailMapper tbOrderDetailMapper, MpPrintMachineMapper mpPrintMachineMapper, PrinterHandler printerHandler) {
|
public PrintConsumer(TbOrderInfoMapper tbOrderInfoMapper, TbShopInfoMapper tbShopInfoMapper, TbOrderDetailMapper tbOrderDetailMapper, MPOrderDetailMapper mpOrderDetailMapper, MPCashierCartMapper mpCashierCartMapper, MpPrintMachineMapper mpPrintMachineMapper, PrinterHandler printerHandler) {
|
||||||
this.tbOrderInfoMapper = tbOrderInfoMapper;
|
this.tbOrderInfoMapper = tbOrderInfoMapper;
|
||||||
this.tbShopInfoMapper = tbShopInfoMapper;
|
this.tbShopInfoMapper = tbShopInfoMapper;
|
||||||
this.tbOrderDetailMapper = tbOrderDetailMapper;
|
this.tbOrderDetailMapper = tbOrderDetailMapper;
|
||||||
|
this.mpOrderDetailMapper = mpOrderDetailMapper;
|
||||||
|
this.mpCashierCartMapper = mpCashierCartMapper;
|
||||||
this.mpPrintMachineMapper = mpPrintMachineMapper;
|
this.mpPrintMachineMapper = mpPrintMachineMapper;
|
||||||
this.printerHandler = printerHandler;
|
this.printerHandler = printerHandler;
|
||||||
}
|
}
|
||||||
@@ -65,10 +72,27 @@ public class PrintConsumer {
|
|||||||
for (Object orderDetail : orderDetailIds) {
|
for (Object orderDetail : orderDetailIds) {
|
||||||
orderDetails.add(JSONObject.parseObject(orderDetail.toString(), TbOrderDetail.class));
|
orderDetails.add(JSONObject.parseObject(orderDetail.toString(), TbOrderDetail.class));
|
||||||
}
|
}
|
||||||
|
if (CollUtil.isEmpty(orderDetails)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Integer> ids = orderDetails.stream().map(TbOrderDetail::getId).collect(Collectors.toList());
|
||||||
|
List<TbOrderDetail> detailList = mpOrderDetailMapper.selectList(Wrappers.<TbOrderDetail>lambdaQuery().in(TbOrderDetail::getId, ids));
|
||||||
|
if (CollUtil.isEmpty(detailList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<Integer, Integer> isPrintMap = detailList.stream().collect(Collectors.toMap(TbOrderDetail::getId, TbOrderDetail::getIsPrint));
|
||||||
|
for (TbOrderDetail detail : orderDetails) {
|
||||||
|
detail.setIsPrint(isPrintMap.get(detail.getId()));
|
||||||
|
}
|
||||||
|
List<TbCashierCart> cartList = mpCashierCartMapper.selectList(Wrappers.<TbCashierCart>lambdaQuery().eq(TbCashierCart::getOrderId, orderInfo.getId()));
|
||||||
|
Map<Integer, String> map = cartList.stream().collect(Collectors.toMap(TbCashierCart::getId, TbCashierCart::getIsGift));
|
||||||
|
orderDetails.parallelStream().forEach(item->{
|
||||||
|
int isGift = "true".equals(map.get(item.getCartId())) ? 1 : 0;
|
||||||
|
item.setIsGift(isGift);
|
||||||
|
});
|
||||||
if (orderDetails.isEmpty()) {
|
if (orderDetails.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 菜品票
|
// 菜品票
|
||||||
getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "cash", "one", null).forEach(machine -> {
|
getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "cash", "one", null).forEach(machine -> {
|
||||||
log.info("打印机信息: {}", machine);
|
log.info("打印机信息: {}", machine);
|
||||||
@@ -109,6 +133,13 @@ public class PrintConsumer {
|
|||||||
|
|
||||||
getPrintMachine(shopInfo.getId(), "cash", "normal", null).forEach(machine -> {
|
getPrintMachine(shopInfo.getId(), "cash", "normal", null).forEach(machine -> {
|
||||||
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
|
List<TbOrderDetail> tbOrderDetails = tbOrderDetailMapper.selectAllByOrderId(orderInfo.getId());
|
||||||
|
tbOrderDetails = tbOrderDetails.stream().filter(item -> !"return".equals(item.getStatus())).collect(Collectors.toList());
|
||||||
|
List<TbCashierCart> cartList = mpCashierCartMapper.selectList(Wrappers.<TbCashierCart>lambdaQuery().eq(TbCashierCart::getOrderId, orderInfo.getId()));
|
||||||
|
Map<Integer, String> map = cartList.stream().collect(Collectors.toMap(TbCashierCart::getId, TbCashierCart::getIsGift));
|
||||||
|
tbOrderDetails.parallelStream().forEach(item->{
|
||||||
|
int isGift = "true".equals(map.get(item.getCartId())) ? 1 : 0;
|
||||||
|
item.setIsGift(isGift);
|
||||||
|
});
|
||||||
printerHandler.handleRequest(machine, isReturn, orderInfo, tbOrderDetails, null);
|
printerHandler.handleRequest(machine, isReturn, orderInfo, tbOrderDetails, null);
|
||||||
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
|
// printPlaceTicket(isReturn, machine, orderInfo, shopInfo);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -243,6 +243,9 @@ public class PrintMechineConsumer {
|
|||||||
if (it.getIsMember() == 1) {
|
if (it.getIsMember() == 1) {
|
||||||
unitPrice = it.getMemberPrice();
|
unitPrice = it.getMemberPrice();
|
||||||
}
|
}
|
||||||
|
if (it.getIsGift() == 1) {
|
||||||
|
unitPrice = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
||||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
||||||
detailList.add(detail);
|
detailList.add(detail);
|
||||||
@@ -324,6 +327,10 @@ public class PrintMechineConsumer {
|
|||||||
c.getId().toString().equals(categoryId)
|
c.getId().toString().equals(categoryId)
|
||||||
).count();
|
).count();
|
||||||
}
|
}
|
||||||
|
Integer isGift = ObjectUtil.defaultIfNull(it.getIsGift(), 0);
|
||||||
|
if (isGift == 1) {
|
||||||
|
it.setProductName("【赠】" + it.getProductName());
|
||||||
|
}
|
||||||
log.info("获取当前类别是否未打印类别:{}", count);
|
log.info("获取当前类别是否未打印类别:{}", count);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
// 统计已打数量
|
// 统计已打数量
|
||||||
@@ -545,6 +552,10 @@ public class PrintMechineConsumer {
|
|||||||
c.getId().toString().equals(categoryId)
|
c.getId().toString().equals(categoryId)
|
||||||
).count();
|
).count();
|
||||||
}
|
}
|
||||||
|
Integer isGift = ObjectUtil.defaultIfNull(it.getIsGift(), 0);
|
||||||
|
if (isGift == 1) {
|
||||||
|
it.setProductName("【赠】" + it.getProductName());
|
||||||
|
}
|
||||||
String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
|
String classifyPrint = tbPrintMachineWithBLOBs.getClassifyPrint();
|
||||||
// 如果是部分打印,并且所属分类不在设置的列表中,则不打印
|
// 如果是部分打印,并且所属分类不在设置的列表中,则不打印
|
||||||
if ("1".equals(classifyPrint) && count == 0) {
|
if ("1".equals(classifyPrint) && count == 0) {
|
||||||
@@ -603,6 +614,9 @@ public class PrintMechineConsumer {
|
|||||||
if (it.getIsMember() == 1) {
|
if (it.getIsMember() == 1) {
|
||||||
unitPrice = it.getMemberPrice();
|
unitPrice = it.getMemberPrice();
|
||||||
}
|
}
|
||||||
|
if (it.getIsGift() == 1) {
|
||||||
|
unitPrice = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
||||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
||||||
detailList.add(detail);
|
detailList.add(detail);
|
||||||
@@ -671,6 +685,9 @@ public class PrintMechineConsumer {
|
|||||||
if (it.getIsMember() == 1) {
|
if (it.getIsMember() == 1) {
|
||||||
unitPrice = it.getMemberPrice();
|
unitPrice = it.getMemberPrice();
|
||||||
}
|
}
|
||||||
|
if ("true".equals(it.getIsGift())) {
|
||||||
|
unitPrice = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
BigDecimal subTotal = NumberUtil.mul(it.getNumber(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
BigDecimal subTotal = NumberUtil.mul(it.getNumber(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
||||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
||||||
detailList.add(detail);
|
detailList.add(detail);
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ public abstract class PrinterHandler {
|
|||||||
log.info("开始打印退单菜品,商品名:{}", item.getProductName());
|
log.info("开始打印退单菜品,商品名:{}", item.getProductName());
|
||||||
Integer isWaitCall = ObjectUtil.defaultIfNull(item.getIsWaitCall(), 0);
|
Integer isWaitCall = ObjectUtil.defaultIfNull(item.getIsWaitCall(), 0);
|
||||||
if (isWaitCall == 1) {
|
if (isWaitCall == 1) {
|
||||||
if (!item.getProductName().startsWith("【等叫】")) {
|
if (!item.getProductName().contains("【等叫】")) {
|
||||||
item.setProductName("【等叫】" + item.getProductName());
|
item.setProductName("【等叫】" + item.getProductName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -97,10 +97,14 @@ public abstract class PrinterHandler {
|
|||||||
if (isTemporary == 1) {
|
if (isTemporary == 1) {
|
||||||
item.setProductId(0);
|
item.setProductId(0);
|
||||||
item.setProductSkuId(0);
|
item.setProductSkuId(0);
|
||||||
if (!item.getProductName().startsWith("【临】")) {
|
if (!item.getProductName().contains("【临】")) {
|
||||||
item.setProductName("【临】" + item.getProductName());
|
item.setProductName("【临】" + item.getProductName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Integer isGift = ObjectUtil.defaultIfNull(item.getIsGift(), 0);
|
||||||
|
if (isGift == 1 && !item.getProductName().contains("【赠】")) {
|
||||||
|
item.setProductName("【赠】" + item.getProductName());
|
||||||
|
}
|
||||||
// 台位费不打印
|
// 台位费不打印
|
||||||
if (item.getProductId().equals(-999)) {
|
if (item.getProductId().equals(-999)) {
|
||||||
log.info("台位费商品,不打印");
|
log.info("台位费商品,不打印");
|
||||||
@@ -131,9 +135,9 @@ public abstract class PrinterHandler {
|
|||||||
}
|
}
|
||||||
String classifyPrint = machine.getClassifyPrint();
|
String classifyPrint = machine.getClassifyPrint();
|
||||||
// 如果是部分打印,并且所属分类不在设置的列表中,则不打印
|
// 如果是部分打印,并且所属分类不在设置的列表中,则不打印
|
||||||
if("1".equals(classifyPrint) && count == 0) {
|
if ("1".equals(classifyPrint) && count == 0) {
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
|
String remark = StrUtil.isNotBlank(sku.getSpecSnap()) ? sku.getSpecSnap() : "";
|
||||||
item.setRemark(remark);
|
item.setRemark(remark);
|
||||||
if (isReturn) {
|
if (isReturn) {
|
||||||
@@ -170,10 +174,17 @@ public abstract class PrinterHandler {
|
|||||||
if (isTemporary == 1) {
|
if (isTemporary == 1) {
|
||||||
it.setProductName("【临】" + it.getProductName());
|
it.setProductName("【临】" + it.getProductName());
|
||||||
}
|
}
|
||||||
|
Integer isGift = ObjectUtil.defaultIfNull(it.getIsGift(), 0);
|
||||||
|
if (isGift == 1) {
|
||||||
|
it.setProductName("【赠】" + it.getProductName());
|
||||||
|
}
|
||||||
BigDecimal unitPrice = it.getPrice();
|
BigDecimal unitPrice = it.getPrice();
|
||||||
if(it.getIsMember() == 1){
|
if (it.getIsMember() == 1) {
|
||||||
unitPrice = it.getMemberPrice();
|
unitPrice = it.getMemberPrice();
|
||||||
}
|
}
|
||||||
|
if (it.getIsGift() == 1) {
|
||||||
|
unitPrice = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
||||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
||||||
detailList.add(detail);
|
detailList.add(detail);
|
||||||
@@ -227,4 +238,17 @@ public abstract class PrinterHandler {
|
|||||||
Utils.checkValueUnReturn(printerBrand, "打印机品牌未赋值");
|
Utils.checkValueUnReturn(printerBrand, "打印机品牌未赋值");
|
||||||
return printerBrand.equals(currentBrand) && "network".equals(connectType);
|
return printerBrand.equals(currentBrand) && "network".equals(connectType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String a = "1【赠1】1【临1】1【等叫1】1";
|
||||||
|
if (!a.contains("【赠】")) {
|
||||||
|
System.out.println("不包含");
|
||||||
|
}
|
||||||
|
if (a.indexOf("【临】") != -1) {
|
||||||
|
System.out.println("包含");
|
||||||
|
}
|
||||||
|
if (a.indexOf("【等叫】") != -1) {
|
||||||
|
System.out.println("包含");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -281,6 +281,9 @@ public class CloudPrinterService {
|
|||||||
if (it.getIsMember() == 1) {
|
if (it.getIsMember() == 1) {
|
||||||
unitPrice = it.getMemberPrice();
|
unitPrice = it.getMemberPrice();
|
||||||
}
|
}
|
||||||
|
if (it.getIsGift() == 1) {
|
||||||
|
unitPrice = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
||||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
||||||
detailList.add(detail);
|
detailList.add(detail);
|
||||||
@@ -355,6 +358,9 @@ public class CloudPrinterService {
|
|||||||
if (it.getIsMember() == 1) {
|
if (it.getIsMember() == 1) {
|
||||||
unitPrice = it.getMemberPrice();
|
unitPrice = it.getMemberPrice();
|
||||||
}
|
}
|
||||||
|
if ("true".equals(it.getIsGift())) {
|
||||||
|
unitPrice = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
BigDecimal subTotal = NumberUtil.mul(it.getNumber(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
BigDecimal subTotal = NumberUtil.mul(it.getNumber(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
||||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
||||||
detailList.add(detail);
|
detailList.add(detail);
|
||||||
@@ -428,6 +434,9 @@ public class CloudPrinterService {
|
|||||||
if (it.getIsMember() == 1) {
|
if (it.getIsMember() == 1) {
|
||||||
unitPrice = it.getMemberPrice();
|
unitPrice = it.getMemberPrice();
|
||||||
}
|
}
|
||||||
|
if (it.getIsGift() == 1) {
|
||||||
|
unitPrice = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
BigDecimal subTotal = NumberUtil.mul(it.getNum(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
||||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getProductName(), it.getNum().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
||||||
detailList.add(detail);
|
detailList.add(detail);
|
||||||
@@ -484,6 +493,9 @@ public class CloudPrinterService {
|
|||||||
if (it.getIsMember() == 1) {
|
if (it.getIsMember() == 1) {
|
||||||
unitPrice = it.getMemberPrice();
|
unitPrice = it.getMemberPrice();
|
||||||
}
|
}
|
||||||
|
if ("true".equals(it.getIsGift())) {
|
||||||
|
unitPrice = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
BigDecimal subTotal = NumberUtil.mul(it.getNumber(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
BigDecimal subTotal = NumberUtil.mul(it.getNumber(), unitPrice.subtract(NumberUtil.null2Zero(it.getDiscountSaleAmount())));
|
||||||
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
OrderDetailPO.Detail detail = new OrderDetailPO.Detail(it.getName(), it.getNumber().toString(), subTotal.toPlainString(), remark, it.getProGroupInfo());
|
||||||
detailList.add(detail);
|
detailList.add(detail);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.service;
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.comparator.CompareUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -11,7 +13,10 @@ import com.chaozhanggui.system.cashierservice.mybatis.TbVersionMapper;
|
|||||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.chaozhanggui.system.cashierservice.util.*;
|
import com.chaozhanggui.system.cashierservice.util.MD5Util;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.RedisCst;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.RedisUtil;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -62,7 +67,6 @@ public class LoginService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(loginReq.getSerialNumber())) {
|
if (ObjectUtil.isEmpty(loginReq.getSerialNumber())) {
|
||||||
return Result.fail(CodeEnum.SERIALNUMBER);
|
return Result.fail(CodeEnum.SERIALNUMBER);
|
||||||
}
|
}
|
||||||
@@ -92,7 +96,7 @@ public class LoginService {
|
|||||||
return Result.fail(CodeEnum.MERCHANTEIXST);
|
return Result.fail(CodeEnum.MERCHANTEIXST);
|
||||||
}
|
}
|
||||||
|
|
||||||
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffMapper.selectByAccountAndShopId(loginReq.getLoginName(),account.getShopId());
|
TbPlussShopStaff tbPlussShopStaff = tbPlussShopStaffMapper.selectByAccountAndShopId(loginReq.getLoginName(), account.getShopId());
|
||||||
if (ObjectUtil.isEmpty(tbPlussShopStaff)) {
|
if (ObjectUtil.isEmpty(tbPlussShopStaff)) {
|
||||||
return Result.fail(CodeEnum.ACCOUNTEIXST);
|
return Result.fail(CodeEnum.ACCOUNTEIXST);
|
||||||
} else if (!tbPlussShopStaff.getStatus()) {
|
} else if (!tbPlussShopStaff.getStatus()) {
|
||||||
@@ -120,7 +124,13 @@ public class LoginService {
|
|||||||
tbTokenMapper.insert(tbToken);
|
tbTokenMapper.insert(tbToken);
|
||||||
|
|
||||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(account.getShopId()));
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(account.getShopId()));
|
||||||
|
if (shopInfo.getExpireAt() != null) {
|
||||||
|
Long expireAt = shopInfo.getExpireAt();
|
||||||
|
Date time = DateUtil.calendar(expireAt).getTime();
|
||||||
|
if (CompareUtil.compare(time, new Date()) < 0) {
|
||||||
|
return Result.fail("店铺已到期,请联系区域经理续费");
|
||||||
|
}
|
||||||
|
}
|
||||||
redisUtil.saveMessage(key, token, 365 * 24 * 60 * 60);
|
redisUtil.saveMessage(key, token, 365 * 24 * 60 * 60);
|
||||||
|
|
||||||
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
@@ -129,15 +139,21 @@ public class LoginService {
|
|||||||
accountMap.put("accountId", account.getId());
|
accountMap.put("accountId", account.getId());
|
||||||
accountMap.put("merchantName", account.getAccount());
|
accountMap.put("merchantName", account.getAccount());
|
||||||
accountMap.put("loginName", tbPlussShopStaff.getAccount());
|
accountMap.put("loginName", tbPlussShopStaff.getAccount());
|
||||||
accountMap.put("loginAccount",tbPlussShopStaff.getName());
|
accountMap.put("loginAccount", tbPlussShopStaff.getName());
|
||||||
accountMap.put("clientType", loginReq.getClientType());
|
accountMap.put("clientType", loginReq.getClientType());
|
||||||
accountMap.put("shopId", account.getShopId());
|
accountMap.put("shopId", account.getShopId());
|
||||||
accountMap.put("staffId", tbPlussShopStaff.getId());
|
accountMap.put("staffId", tbPlussShopStaff.getId());
|
||||||
accountMap.put("userCode", tbPlussShopStaff.getCode());
|
accountMap.put("userCode", tbPlussShopStaff.getCode());
|
||||||
accountMap.put("token", token);
|
accountMap.put("token", token);
|
||||||
accountMap.put("loginTime", System.currentTimeMillis());
|
accountMap.put("loginTime", System.currentTimeMillis());
|
||||||
|
accountMap.put("expireDate", "");
|
||||||
if (Objects.nonNull(shopInfo)) {
|
if (Objects.nonNull(shopInfo)) {
|
||||||
accountMap.put("shopName", shopInfo.getShopName());
|
accountMap.put("shopName", shopInfo.getShopName());
|
||||||
|
if(shopInfo.getExpireAt() != null) {
|
||||||
|
Long expireAt = shopInfo.getExpireAt();
|
||||||
|
Date time = DateUtil.calendar(expireAt).getTime();
|
||||||
|
accountMap.put("expireDate", DateUtil.formatDateTime(time));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
accountMap.put("uuid", uuid);
|
accountMap.put("uuid", uuid);
|
||||||
accountMap.put("isStaff", "staff".equals(tbPlussShopStaff.getType()));
|
accountMap.put("isStaff", "staff".equals(tbPlussShopStaff.getType()));
|
||||||
@@ -153,8 +169,8 @@ public class LoginService {
|
|||||||
|
|
||||||
public TbVersion getCurrentPcVersion() {
|
public TbVersion getCurrentPcVersion() {
|
||||||
LambdaQueryWrapper<TbVersion> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<TbVersion> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(TbVersion::getSource,"PC");
|
queryWrapper.eq(TbVersion::getSource, "PC");
|
||||||
queryWrapper.eq(TbVersion::getSel,1);
|
queryWrapper.eq(TbVersion::getSel, 1);
|
||||||
return versionMapper.selectOne(queryWrapper);
|
return versionMapper.selectOne(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +178,7 @@ public class LoginService {
|
|||||||
|
|
||||||
String key = RedisCst.ONLINE_USER.concat(":").concat(clientType).concat(":").concat(loginName);
|
String key = RedisCst.ONLINE_USER.concat(":").concat(clientType).concat(":").concat(loginName);
|
||||||
|
|
||||||
String cacheToken = redisUtil.getMessage(key)+"";
|
String cacheToken = redisUtil.getMessage(key) + "";
|
||||||
|
|
||||||
TbToken tbToken = tbTokenMapper.selectByToken(token);
|
TbToken tbToken = tbTokenMapper.selectByToken(token);
|
||||||
|
|
||||||
@@ -199,32 +215,33 @@ public class LoginService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Result getShopInfo(String token){
|
public Result getShopInfo(String token) {
|
||||||
JSONObject jsonObject= TokenUtil.parseParamFromToken(token);
|
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||||
if(Objects.isNull(jsonObject)){
|
if (Objects.isNull(jsonObject)) {
|
||||||
return Result.fail(CodeEnum.TOKENTERROR);
|
return Result.fail(CodeEnum.TOKENTERROR);
|
||||||
}
|
}
|
||||||
TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(jsonObject.getString("shopId")));
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(jsonObject.getString("shopId")));
|
||||||
|
|
||||||
return Result.success(SUCCESS,shopInfo);
|
return Result.success(SUCCESS, shopInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Result getStaffDiscount(String token){
|
public Result getStaffDiscount(String token) {
|
||||||
|
|
||||||
JSONObject jsonObject= TokenUtil.parseParamFromToken(token);
|
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||||
if(Objects.isNull(jsonObject)){
|
if (Objects.isNull(jsonObject)) {
|
||||||
return Result.fail(CodeEnum.TOKENTERROR);
|
return Result.fail(CodeEnum.TOKENTERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer staffId=Integer.valueOf(jsonObject.getString("staffId"));
|
Integer staffId = Integer.valueOf(jsonObject.getString("staffId"));
|
||||||
|
|
||||||
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
|
TbPlussShopStaff staff = tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
|
||||||
if(Objects.nonNull(staff)&&Objects.nonNull(staff.getMaxDiscountAmount())){
|
if (Objects.nonNull(staff) && Objects.nonNull(staff.getMaxDiscountAmount())) {
|
||||||
return Result.success(SUCCESS,staff.getMaxDiscountAmount());
|
return Result.success(SUCCESS, staff.getMaxDiscountAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success(SUCCESS, BigDecimal.ZERO);
|
return Result.success(SUCCESS, BigDecimal.ZERO);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,5 +61,17 @@ public interface MpCashierCartService extends IService<TbCashierCart> {
|
|||||||
* @param statuses 状态
|
* @param statuses 状态
|
||||||
*/
|
*/
|
||||||
List<TbCashierCart> selectByIds(Integer shopId, Integer orderId, List<Integer> ids, TableConstant.OrderInfo.Status... statuses);
|
List<TbCashierCart> selectByIds(Integer shopId, Integer orderId, List<Integer> ids, TableConstant.OrderInfo.Status... statuses);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据就餐模式查询购物车信息
|
||||||
|
* @param shopEatTypeInfoDTO 就餐模式
|
||||||
|
* @param masterId 取餐码
|
||||||
|
* @param orderId 订单id
|
||||||
|
* @param onlySearchPc 只查询pc
|
||||||
|
* @param statuses 状态
|
||||||
|
*/
|
||||||
|
List<TbCashierCart> selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, boolean onlySearchPc, TableConstant.OrderInfo.Status... statuses);
|
||||||
|
|
||||||
|
Long countByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId, Integer orderId, boolean onlySearchPc, TableConstant.OrderInfo.Status... statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,5 +15,12 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface MpShopTableService extends IService<TbShopTable> {
|
public interface MpShopTableService extends IService<TbShopTable> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询台桌信息
|
||||||
|
* @param tableId 台桌id
|
||||||
|
* @param shopId 店铺id
|
||||||
|
* @return 台桌信息
|
||||||
|
*/
|
||||||
|
TbShopTable selectByTableId(String tableId, Integer shopId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ public class OrderService {
|
|||||||
boolean isSeatCart = productId != null && TableConstant.CashierCart.ID.equals(productId.toString());
|
boolean isSeatCart = productId != null && TableConstant.CashierCart.ID.equals(productId.toString());
|
||||||
if ((StrUtil.isNotBlank(tableId))) {
|
if ((StrUtil.isNotBlank(tableId))) {
|
||||||
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaUpdateWrapper<TbShopTable>()
|
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaUpdateWrapper<TbShopTable>()
|
||||||
|
.eq(TbShopTable::getShopId, shopId)
|
||||||
.eq(TbShopTable::getQrcode, tableId)
|
.eq(TbShopTable::getQrcode, tableId)
|
||||||
.in(TbShopTable::getStatus, "idle", "using", "pending"));
|
.in(TbShopTable::getStatus, "idle", "using", "pending"));
|
||||||
|
|
||||||
@@ -305,6 +306,7 @@ public class OrderService {
|
|||||||
LambdaQueryWrapper<TbCashierCart> cartQuery = new LambdaQueryWrapper<TbCashierCart>()
|
LambdaQueryWrapper<TbCashierCart> cartQuery = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
.eq(TbCashierCart::getShopId, shopId)
|
.eq(TbCashierCart::getShopId, shopId)
|
||||||
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
|
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
|
||||||
|
.eq(TbCashierCart::getIsGift, isGift)
|
||||||
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
||||||
.and(r -> r.eq(TbCashierCart::getMasterId, finalMasterId).or().isNull(TbCashierCart::getMasterId).or().eq(TbCashierCart::getMasterId, ""))
|
.and(r -> r.eq(TbCashierCart::getMasterId, finalMasterId).or().isNull(TbCashierCart::getMasterId).or().eq(TbCashierCart::getMasterId, ""))
|
||||||
.in(TbCashierCart::getStatus, "create");
|
.in(TbCashierCart::getStatus, "create");
|
||||||
@@ -366,7 +368,7 @@ public class OrderService {
|
|||||||
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
|
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
|
||||||
TbCashierCart cashierCart = null;
|
TbCashierCart cashierCart = null;
|
||||||
if (type.equals("edit")) {
|
if (type.equals("edit")) {
|
||||||
cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO, cartId);
|
cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO, cartId, null);
|
||||||
if (cashierCart == null) {
|
if (cashierCart == null) {
|
||||||
needNew = true;
|
needNew = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -413,6 +415,7 @@ public class OrderService {
|
|||||||
cashierCart.setTotalNumber(number);
|
cashierCart.setTotalNumber(number);
|
||||||
cashierCart.setIsPrint(isPrint);
|
cashierCart.setIsPrint(isPrint);
|
||||||
cashierCart.setIsPack(isPack);
|
cashierCart.setIsPack(isPack);
|
||||||
|
cashierCart.setIsGift(isGift);
|
||||||
cashierCart.resetTotalAmount();
|
cashierCart.resetTotalAmount();
|
||||||
cashierCart.setUuid(uuid);
|
cashierCart.setUuid(uuid);
|
||||||
cashierCart.setIsPrint(isPrint);
|
cashierCart.setIsPrint(isPrint);
|
||||||
@@ -428,7 +431,7 @@ public class OrderService {
|
|||||||
|
|
||||||
if (type.equals("add") || needNew) {
|
if (type.equals("add") || needNew) {
|
||||||
if (product == null || product.getGroupType() == null || product.getGroupType() != 1) {
|
if (product == null || product.getGroupType() == null || product.getGroupType() != 1) {
|
||||||
cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO, cartId);
|
cashierCart = getCashierInfo(shopId, skuId, productId, tableId, masterId, shopEatTypeInfoDTO, cartId, isGift);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cashierCart != null) {
|
if (cashierCart != null) {
|
||||||
@@ -542,6 +545,8 @@ public class OrderService {
|
|||||||
cashierCart.setTableId(tableId);
|
cashierCart.setTableId(tableId);
|
||||||
cashierCart.setPlatformType(OrderPlatformTypeEnum.CASH.getValue());
|
cashierCart.setPlatformType(OrderPlatformTypeEnum.CASH.getValue());
|
||||||
if (product != null) {
|
if (product != null) {
|
||||||
|
cashierCart.setIsWeight("weigh".equals(product.getType()) ? 1 : 0);
|
||||||
|
|
||||||
resetGroupProductCart(groupProductIdList, product, cashierCart);
|
resetGroupProductCart(groupProductIdList, product, cashierCart);
|
||||||
}
|
}
|
||||||
list.add(cashierCart);
|
list.add(cashierCart);
|
||||||
@@ -555,7 +560,7 @@ public class OrderService {
|
|||||||
return Result.success(CodeEnum.SUCCESS, masterId);
|
return Result.success(CodeEnum.SUCCESS, masterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TbCashierCart getCashierInfo(Object shopId, Object skuId, Object productId, String tableId, String MasterId, ShopEatTypeInfoDTO shopEatTypeInfoDTO, Integer cartId) {
|
private TbCashierCart getCashierInfo(Object shopId, Object skuId, Object productId, String tableId, String MasterId, ShopEatTypeInfoDTO shopEatTypeInfoDTO, Integer cartId, String isGift) {
|
||||||
LambdaQueryWrapper<TbCashierCart> query = new LambdaQueryWrapper<TbCashierCart>()
|
LambdaQueryWrapper<TbCashierCart> query = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
.eq(TbCashierCart::getShopId, shopId)
|
.eq(TbCashierCart::getShopId, shopId)
|
||||||
.eq(TbCashierCart::getSkuId, skuId)
|
.eq(TbCashierCart::getSkuId, skuId)
|
||||||
@@ -563,6 +568,10 @@ public class OrderService {
|
|||||||
.in(TbCashierCart::getStatus, "create")
|
.in(TbCashierCart::getStatus, "create")
|
||||||
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType());
|
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType());
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(isGift)) {
|
||||||
|
query.eq(TbCashierCart::getIsGift, isGift);
|
||||||
|
}
|
||||||
|
|
||||||
if (cartId != null) {
|
if (cartId != null) {
|
||||||
query.eq(TbCashierCart::getId, cartId);
|
query.eq(TbCashierCart::getId, cartId);
|
||||||
}
|
}
|
||||||
@@ -898,7 +907,7 @@ public class OrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result createOrder(OrderVo orderVo, String clientType, String token, Integer oldOrderId) {
|
public Result createOrder(OrderVo orderVo, String clientType, String token, Integer oldOrderId, boolean isPrint) {
|
||||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(orderVo.getShopId());
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(orderVo.getShopId());
|
||||||
if (shopInfo == null) {
|
if (shopInfo == null) {
|
||||||
throw new MsgException("店铺信息不存在");
|
throw new MsgException("店铺信息不存在");
|
||||||
@@ -980,9 +989,12 @@ public class OrderService {
|
|||||||
Integer mealNum = null;
|
Integer mealNum = null;
|
||||||
Integer orderId = null;
|
Integer orderId = null;
|
||||||
int cartCount = 0;
|
int cartCount = 0;
|
||||||
|
boolean hasNewCart = false;
|
||||||
for (TbCashierCart cart : list) {
|
for (TbCashierCart cart : list) {
|
||||||
if (cart.getOrderId() != null) {
|
if (cart.getOrderId() != null) {
|
||||||
orderId = cart.getOrderId();
|
orderId = cart.getOrderId();
|
||||||
|
}else {
|
||||||
|
hasNewCart = true;
|
||||||
}
|
}
|
||||||
cashierIds.add(cart.getId());
|
cashierIds.add(cart.getId());
|
||||||
if ("-999".equals(cart.getProductId())) {
|
if ("-999".equals(cart.getProductId())) {
|
||||||
@@ -1078,6 +1090,7 @@ public class OrderService {
|
|||||||
if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) {
|
if (TableConstant.CART_SEAT_ID.equals(cashierCart.getProductId())) {
|
||||||
saleAmount = saleAmount.add(shopInfo.getTableFee());
|
saleAmount = saleAmount.add(shopInfo.getTableFee());
|
||||||
}
|
}
|
||||||
|
orderDetail.setIsWeight(cashierCart.getIsWeight());
|
||||||
|
|
||||||
orderDetail.setProGroupInfo(cashierCart.getProGroupInfo());
|
orderDetail.setProGroupInfo(cashierCart.getProGroupInfo());
|
||||||
orderDetail.setIsTemporary(cashierCart.getIsTemporary());
|
orderDetail.setIsTemporary(cashierCart.getIsTemporary());
|
||||||
@@ -1145,7 +1158,7 @@ public class OrderService {
|
|||||||
orderInfo.setPackFee(packAMount);
|
orderInfo.setPackFee(packAMount);
|
||||||
orderInfo.setSendType(eatTypeInfoDTO.getSendType());
|
orderInfo.setSendType(eatTypeInfoDTO.getSendType());
|
||||||
// 堂食自取增加下单次数
|
// 堂食自取增加下单次数
|
||||||
if (eatTypeInfoDTO.isDineInAfter()) {
|
if (eatTypeInfoDTO.isDineInAfter() && hasNewCart) {
|
||||||
orderInfo.setPlaceNum(currentPlaceNum);
|
orderInfo.setPlaceNum(currentPlaceNum);
|
||||||
}
|
}
|
||||||
mPOrderInfoMapper.updateById(orderInfo);
|
mPOrderInfoMapper.updateById(orderInfo);
|
||||||
@@ -1222,15 +1235,19 @@ public class OrderService {
|
|||||||
// 代课下单
|
// 代课下单
|
||||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||||
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
||||||
|
.set(TbShopTable::getProductNum, cashierIds.isEmpty() ? 0 : cashierIds.size())
|
||||||
|
.set(TbShopTable::getTotalAmount, orderInfo.getOrderAmount())
|
||||||
|
.set(TbShopTable::getRealAmount, orderInfo.getOrderAmount())
|
||||||
|
.set(TbShopTable::getUseNum, mealNum)
|
||||||
.set(TbShopTable::getStatus, TableStateEnum.USING.getState()));
|
.set(TbShopTable::getStatus, TableStateEnum.USING.getState()));
|
||||||
|
|
||||||
// 打印票据
|
// 打印票据
|
||||||
if (!addOrderDetailList.isEmpty()) {
|
if (!addOrderDetailList.isEmpty() && isPrint) {
|
||||||
log.info("待打印菜品信息: {}", addOrderDetailList);
|
log.info("待打印菜品信息: {}", addOrderDetailList);
|
||||||
rabbitMsgUtils.printDishesTicket(orderInfo.getId(), false, addOrderDetailList.toArray(new TbOrderDetail[0]));
|
rabbitMsgUtils.printDishesTicket(orderInfo.getId(), false, addOrderDetailList.toArray(new TbOrderDetail[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!removedOrderDetailList.isEmpty()) {
|
if (!removedOrderDetailList.isEmpty() && isPrint) {
|
||||||
log.info("待打印退菜菜品信息: {}", removedOrderDetailList);
|
log.info("待打印退菜菜品信息: {}", removedOrderDetailList);
|
||||||
// 退单票
|
// 退单票
|
||||||
rabbitMsgUtils.printDishesTicket(orderInfo.getId(), true, removedOrderDetailList.toArray(new TbOrderDetail[0]));
|
rabbitMsgUtils.printDishesTicket(orderInfo.getId(), true, removedOrderDetailList.toArray(new TbOrderDetail[0]));
|
||||||
@@ -1393,7 +1410,7 @@ public class OrderService {
|
|||||||
orderVo.setTableId(tableId);
|
orderVo.setTableId(tableId);
|
||||||
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||||
orderVo.setMerchantId(Integer.valueOf(jsonObject.getString("accountId")));
|
orderVo.setMerchantId(Integer.valueOf(jsonObject.getString("accountId")));
|
||||||
Result result = createOrder(orderVo, clientType, token, null);
|
Result result = createOrder(orderVo, clientType, token, null, true);
|
||||||
if (!"0".equals(result.getCode())) {
|
if (!"0".equals(result.getCode())) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1544,9 +1561,13 @@ public class OrderService {
|
|||||||
mpCashierCartMapper.deleteBatchIds(ids);
|
mpCashierCartMapper.deleteBatchIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
|
||||||
.eq(TbShopTable::getQrcode, cartVo.getTableId())
|
Long count = mpCashierCartService.countByShopEatType(shopEatTypeInfoDTO, cartVo.getMasterId(), orderId > 0 ? orderId : null, false, TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN);
|
||||||
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
|
if (count == 0) {
|
||||||
|
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||||
|
.eq(TbShopTable::getQrcode, cartVo.getTableId())
|
||||||
|
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
|
||||||
|
}
|
||||||
|
|
||||||
// 打印退款票据
|
// 打印退款票据
|
||||||
int finalOrderId = orderId;
|
int finalOrderId = orderId;
|
||||||
@@ -2051,6 +2072,7 @@ public class OrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
|
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
|
||||||
|
.eq(TbShopTable::getShopId, choseCountDTO.getShopId())
|
||||||
.eq(TbShopTable::getQrcode, choseCountDTO.getTableId()));
|
.eq(TbShopTable::getQrcode, choseCountDTO.getTableId()));
|
||||||
if (shopTable == null) {
|
if (shopTable == null) {
|
||||||
throw new NotPrintException("台桌不存在");
|
throw new NotPrintException("台桌不存在");
|
||||||
@@ -2083,7 +2105,6 @@ public class OrderService {
|
|||||||
tbCashierCart.setTradeDay(DateUtils.getDay());
|
tbCashierCart.setTradeDay(DateUtils.getDay());
|
||||||
tbCashierCart.setStatus("create");
|
tbCashierCart.setStatus("create");
|
||||||
tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(shopInfo.getTableFee()));
|
tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(shopInfo.getTableFee()));
|
||||||
tbCashierCart.setPlaceNum(1);
|
|
||||||
tbCashierCart.setProductId("-999");
|
tbCashierCart.setProductId("-999");
|
||||||
tbCashierCart.setSkuId("-999");
|
tbCashierCart.setSkuId("-999");
|
||||||
tbCashierCart.setPackFee(BigDecimal.ZERO);
|
tbCashierCart.setPackFee(BigDecimal.ZERO);
|
||||||
@@ -2410,4 +2431,130 @@ public class OrderService {
|
|||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Object switchTable(SwitchTableDTO switchTableDTO, String token) {
|
||||||
|
// 查询当前台桌信息
|
||||||
|
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(switchTableDTO.getShopId(), switchTableDTO.getCurrentTableId());
|
||||||
|
ShopEatTypeInfoDTO targetShopEatTypeInfoDTO = checkEatModel(switchTableDTO.getShopId(), switchTableDTO.getTargetTableId());
|
||||||
|
if (!shopEatTypeInfoDTO.isDineInAfter()) {
|
||||||
|
throw new MsgException("仅后付费模式支持转台");
|
||||||
|
}
|
||||||
|
TbShopTable shopTable = mpShopTableService.selectByTableId(switchTableDTO.getTargetTableId(), switchTableDTO.getShopId());
|
||||||
|
if (shopTable == null) {
|
||||||
|
throw new MsgException("目标台桌信息不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TableConstant.ShopTable.State.CLEANING.getValue().equals(shopTable.getStatus())) {
|
||||||
|
throw new MsgException("当前台桌清理中,不能转台");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TbCashierCart> cashierCarts;
|
||||||
|
long totalSize = 99999;
|
||||||
|
if (switchTableDTO.getIsFull() != null && switchTableDTO.getIsFull()) {
|
||||||
|
cashierCarts = mpCashierCartService.selectByShopEatTypeAndOrderId(shopEatTypeInfoDTO, switchTableDTO.getMasterId(), switchTableDTO.getOrderId(),
|
||||||
|
true, TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN);
|
||||||
|
}else {
|
||||||
|
if (switchTableDTO.getCartIds().isEmpty()) {
|
||||||
|
throw new MsgException("请选择转单商品");
|
||||||
|
}
|
||||||
|
|
||||||
|
totalSize = mpCashierCartService.countByShopEatType(shopEatTypeInfoDTO, switchTableDTO.getMasterId(), switchTableDTO.getOrderId(),
|
||||||
|
true, TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN);
|
||||||
|
cashierCarts = mpCashierCartService.selectByIds(switchTableDTO.getShopId(), null, switchTableDTO.getCartIds(),
|
||||||
|
TableConstant.OrderInfo.Status.CREATE, TableConstant.OrderInfo.Status.RETURN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cashierCarts.isEmpty()) {
|
||||||
|
throw new MsgException("当前台桌购物车为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
String masterId = ((JSONObject)createCode(switchTableDTO.getShopId().toString(), "pc", "", "0", switchTableDTO.getTargetTableId()).getData()).getString("code");
|
||||||
|
// String masterId = getMasterId(switchTableDTO.getShopId(), switchTableDTO.getTargetTableId(), null).getString("masterId");
|
||||||
|
// 查询目标购物车
|
||||||
|
List<TbCashierCart> targetCarts = mpCashierCartService.selectByShopEatTypeAndOrderId(targetShopEatTypeInfoDTO, masterId, null, false);
|
||||||
|
TbCashierCart targetSeatFee = null;
|
||||||
|
Integer targetOrderId = null;
|
||||||
|
for (TbCashierCart targetCart : targetCarts) {
|
||||||
|
if (TableConstant.CART_SEAT_ID.equals(targetCart.getProductId())) {
|
||||||
|
targetSeatFee = targetCart;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetCart.getOrderId() != null) {
|
||||||
|
targetOrderId = targetCart.getOrderId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改原有购物车数据
|
||||||
|
ArrayList<Integer> cartIds = new ArrayList<>();
|
||||||
|
Integer orderId = switchTableDTO.getOrderId();
|
||||||
|
TbCashierCart currentSeatFee = null;
|
||||||
|
ArrayList<TbCashierCart> updateCartInfos = new ArrayList<>();
|
||||||
|
for (TbCashierCart item : cashierCarts) {
|
||||||
|
if (item.getOrderId() == null) {
|
||||||
|
throw new MsgException("未下单商品不允许转台并台");
|
||||||
|
}
|
||||||
|
if (targetSeatFee == null || !TableConstant.CART_SEAT_ID.equals(item.getProductId())) {
|
||||||
|
item.setTableId(switchTableDTO.getTargetTableId());
|
||||||
|
item.setMasterId(masterId);
|
||||||
|
updateCartInfos.add(item);
|
||||||
|
}
|
||||||
|
cartIds.add(item.getId());
|
||||||
|
|
||||||
|
if (item.getOrderId() != null) {
|
||||||
|
orderId = item.getOrderId();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TableConstant.CART_SEAT_ID.equals(item.getProductId())) {
|
||||||
|
currentSeatFee = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentSeatFee != null && targetSeatFee != null) {
|
||||||
|
targetSeatFee.setNumber(currentSeatFee.getNumber().add(targetSeatFee.getNumber()));
|
||||||
|
targetSeatFee.setTotalNumber(currentSeatFee.getTotalNumber().add(targetSeatFee.getTotalNumber()));
|
||||||
|
targetSeatFee.setTotalAmount(targetSeatFee.getSalePrice().multiply(targetSeatFee.getTotalNumber()));
|
||||||
|
mpCashierCartService.updateById(targetSeatFee);
|
||||||
|
mpCashierCartService.removeById(currentSeatFee.getId());
|
||||||
|
}
|
||||||
|
mpCashierCartService.updateBatchById(updateCartInfos);
|
||||||
|
mpCashierCartService.update(new LambdaUpdateWrapper<TbCashierCart>()
|
||||||
|
.in(TbCashierCart::getId, cartIds)
|
||||||
|
.set(TbCashierCart::getOrderId, null)
|
||||||
|
.set(TbCashierCart::getPlaceNum, null));
|
||||||
|
mpOrderDetailService.removeByCartIds(cartIds);
|
||||||
|
|
||||||
|
// 删除原有台桌detail和order信息
|
||||||
|
if (orderId != null && ((switchTableDTO.getIsFull() != null && switchTableDTO.getIsFull()) || switchTableDTO.getCartIds().size() == totalSize)) {
|
||||||
|
mpOrderInfoService.removeById(orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (switchTableDTO.getIsFull() != null && !switchTableDTO.getIsFull() && switchTableDTO.getCartIds().size() != totalSize){
|
||||||
|
// 重新创建订单数据
|
||||||
|
OrderVo createOrderDTO = new OrderVo();
|
||||||
|
createOrderDTO.setMasterId(switchTableDTO.getMasterId());
|
||||||
|
createOrderDTO.setShopId(switchTableDTO.getShopId());
|
||||||
|
createOrderDTO.setTableId(switchTableDTO.getCurrentTableId());
|
||||||
|
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||||
|
String userId = jsonObject.getString("accountId");
|
||||||
|
createOrderDTO.setMerchantId(Integer.valueOf(userId));
|
||||||
|
createOrder(createOrderDTO, "pc", token, switchTableDTO.getOrderId(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetOrderId != null) {
|
||||||
|
// 重新创建订单数据
|
||||||
|
OrderVo createOrderDTO = new OrderVo();
|
||||||
|
createOrderDTO.setMasterId(masterId);
|
||||||
|
createOrderDTO.setShopId(switchTableDTO.getShopId());
|
||||||
|
createOrderDTO.setTableId(switchTableDTO.getTargetTableId());
|
||||||
|
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||||
|
String userId = jsonObject.getString("accountId");
|
||||||
|
createOrderDTO.setMerchantId(Integer.valueOf(userId));
|
||||||
|
createOrder(createOrderDTO, "pc", token, targetOrderId, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.chaozhanggui.system.cashierservice.service;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.thread.ThreadUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
@@ -15,12 +14,11 @@ import com.chaozhanggui.system.cashierservice.bean.TableStateEnum;
|
|||||||
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
|
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
|
||||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.CreditDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.OrderInfoCouponInfoDTO;
|
import com.chaozhanggui.system.cashierservice.entity.dto.OrderInfoCouponInfoDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnOrderDTO;
|
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnOrderDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.po.OrderDetailPo;
|
|
||||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
import com.chaozhanggui.system.cashierservice.exception.NotPrintException;
|
|
||||||
import com.chaozhanggui.system.cashierservice.mapper.MpProductStockDetailMapper;
|
import com.chaozhanggui.system.cashierservice.mapper.MpProductStockDetailMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.mapper.MpShopUnitMapper;
|
import com.chaozhanggui.system.cashierservice.mapper.MpShopUnitMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.model.ReturnOrderReq;
|
import com.chaozhanggui.system.cashierservice.model.ReturnOrderReq;
|
||||||
@@ -43,12 +41,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.PlatformTransactionManager;
|
import org.springframework.transaction.PlatformTransactionManager;
|
||||||
import org.springframework.transaction.TransactionDefinition;
|
|
||||||
import org.springframework.transaction.TransactionManager;
|
|
||||||
import org.springframework.transaction.TransactionStatus;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
||||||
import org.springframework.transaction.support.TransactionCallback;
|
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
@@ -56,7 +49,6 @@ import javax.annotation.Resource;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST;
|
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST;
|
||||||
@@ -146,14 +138,14 @@ public class PayService {
|
|||||||
private final MpProductStockDetailMapper mpProductStockDetailMapper;
|
private final MpProductStockDetailMapper mpProductStockDetailMapper;
|
||||||
private final MpOrderInfoService mpOrderInfoService;
|
private final MpOrderInfoService mpOrderInfoService;
|
||||||
private final TbMemberPointsService memberPointsService;
|
private final TbMemberPointsService memberPointsService;
|
||||||
|
private final TbCreditBuyerOrderService creditBuyerOrderService;
|
||||||
|
|
||||||
|
|
||||||
private final Utils utils;
|
private final Utils utils;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MPOrderInfoMapper mPOrderInfoMapper;
|
private MPOrderInfoMapper mPOrderInfoMapper;
|
||||||
|
|
||||||
public PayService(RedisTemplate<String, Object> redisTemplate, MpCashierCartService mpCashierCartService, TbShopCouponService shopCouponService, MpOrderDetailService mpOrderDetailService, MpShopUnitMapper mpShopUnitMapper, MpProductStockDetailMapper mpProductStockDetailMapper, MpOrderInfoService mpOrderInfoService, Utils utils) {
|
public PayService(RedisTemplate<String, Object> redisTemplate, MpCashierCartService mpCashierCartService, TbShopCouponService shopCouponService, MpOrderDetailService mpOrderDetailService, MpShopUnitMapper mpShopUnitMapper, MpProductStockDetailMapper mpProductStockDetailMapper, MpOrderInfoService mpOrderInfoService, TbMemberPointsService memberPointsService, TbCreditBuyerOrderService creditBuyerOrderService, Utils utils) {
|
||||||
this.redisTemplate = redisTemplate;
|
this.redisTemplate = redisTemplate;
|
||||||
this.mpCashierCartService = mpCashierCartService;
|
this.mpCashierCartService = mpCashierCartService;
|
||||||
this.shopCouponService = shopCouponService;
|
this.shopCouponService = shopCouponService;
|
||||||
@@ -161,8 +153,9 @@ public class PayService {
|
|||||||
this.mpShopUnitMapper = mpShopUnitMapper;
|
this.mpShopUnitMapper = mpShopUnitMapper;
|
||||||
this.mpProductStockDetailMapper = mpProductStockDetailMapper;
|
this.mpProductStockDetailMapper = mpProductStockDetailMapper;
|
||||||
this.mpOrderInfoService = mpOrderInfoService;
|
this.mpOrderInfoService = mpOrderInfoService;
|
||||||
|
this.memberPointsService = memberPointsService;
|
||||||
|
this.creditBuyerOrderService = creditBuyerOrderService;
|
||||||
this.utils = utils;
|
this.utils = utils;
|
||||||
memberPointsService = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@@ -286,7 +279,7 @@ public class PayService {
|
|||||||
return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.runFunAndTransactional(() -> {
|
utils.runFunAndTransactional(() -> {
|
||||||
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId);
|
TbOrderPayment payment = tbOrderPaymentMapper.selectByOrderId(orderId);
|
||||||
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
||||||
payment = new TbOrderPayment();
|
payment = new TbOrderPayment();
|
||||||
@@ -875,6 +868,90 @@ public class PayService {
|
|||||||
return Result.success(SUCCESS);
|
return Result.success(SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Result creditPay(CreditDTO creditDTO, String token) {
|
||||||
|
|
||||||
|
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(creditDTO.getOrderId());
|
||||||
|
|
||||||
|
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||||
|
return Result.fail(CodeEnum.ORDERNOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||||
|
return Result.fail(CodeEnum.ORDERSTATUSERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "cash");
|
||||||
|
if (count < 1) {
|
||||||
|
return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (creditDTO.getPayAmount() != null && creditDTO.getPayAmount().add(creditDTO.getDiscountAmount()).compareTo(orderInfo.getOrderAmount()) != 0) {
|
||||||
|
return Result.fail("优惠金额 + 支付金额不等于订单金额");
|
||||||
|
}
|
||||||
|
|
||||||
|
creditBuyerOrderService.save(creditDTO.getCreditBuyerId(), Long.valueOf(orderInfo.getId()));
|
||||||
|
|
||||||
|
utils.runFunAndTransactional(() -> {
|
||||||
|
|
||||||
|
|
||||||
|
if (creditDTO.getPayAmount() != null && creditDTO.getDiscountAmount() != null) {
|
||||||
|
orderInfo.setPayAmount(creditDTO.getPayAmount());
|
||||||
|
orderInfo.setDiscountAmount(creditDTO.getDiscountAmount());
|
||||||
|
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(creditDTO.getPayAmount()) ? creditDTO.getPayAmount()
|
||||||
|
.divide(orderInfo.getOrderAmount(), 2, RoundingMode.HALF_UP).setScale(2, RoundingMode.HALF_DOWN) : null);
|
||||||
|
} else {
|
||||||
|
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||||
|
}
|
||||||
|
orderInfo.setCreditBuyerId(creditDTO.getCreditBuyerId());
|
||||||
|
orderInfo.setPayType("creditBuyer");
|
||||||
|
orderInfo.setStatus("closed");
|
||||||
|
orderInfo.setPayOrderNo("deposit".concat(SnowFlakeUtil.generateOrderNo()));
|
||||||
|
mPOrderInfoMapper.updateById(orderInfo);
|
||||||
|
//更新购物车状态
|
||||||
|
mpCashierCartService.updateStateByOrderId(TableConstant.OrderInfo.Status.CLOSED, orderInfo.getId());
|
||||||
|
|
||||||
|
|
||||||
|
if (ObjectUtil.isNotNull(orderInfo.getDiscountRatio()) && ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())) {
|
||||||
|
tbOrderDetailMapper.updateStatusByOrderId(creditDTO.getOrderId(), "closed", orderInfo.getDiscountRatio());
|
||||||
|
} else {
|
||||||
|
tbOrderDetailMapper.updateStatusByOrderId(creditDTO.getOrderId(), "closed", null);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("token", token);
|
||||||
|
jsonObject.put("type", "create");
|
||||||
|
jsonObject.put("orderId", creditDTO.getOrderId());
|
||||||
|
|
||||||
|
producer.putOrderCollect(jsonObject.toJSONString());
|
||||||
|
|
||||||
|
// 打印消息
|
||||||
|
if (!OrderUseTypeEnum.DINE_IN_AFTER.getValue().equals(orderInfo.getUseType())) {
|
||||||
|
List<TbOrderDetail> detailList = mPOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||||
|
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
|
||||||
|
.eq(TbOrderDetail::getStatus, "closed"));
|
||||||
|
rabbitMsgUtils.printDishesTicket(orderInfo.getId(), false, detailList.toArray(new TbOrderDetail[0]));
|
||||||
|
}
|
||||||
|
rabbitMsgUtils.printPlaceTicket(orderInfo.getId(), false);
|
||||||
|
|
||||||
|
// 发送库存记录mq消息
|
||||||
|
JSONObject mqData = new JSONObject();
|
||||||
|
mqData.put("orderId", creditDTO.getOrderId());
|
||||||
|
mqData.put("type", "pc");
|
||||||
|
producer.sendStockSaleMsg(mqData);
|
||||||
|
|
||||||
|
String tableCartKey = RedisCst.getCurrentOrderKey(orderInfo.getTableId(),
|
||||||
|
orderInfo.getShopId());
|
||||||
|
redisUtil.del(tableCartKey);
|
||||||
|
clearTableInfoCache(orderInfo);
|
||||||
|
|
||||||
|
return Result.success(SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
public Result vipPay(Integer orderId, String token, Integer vipUserId, BigDecimal payAmount, BigDecimal discountAmount) {
|
public Result vipPay(Integer orderId, String token, Integer vipUserId, BigDecimal payAmount, BigDecimal discountAmount) {
|
||||||
if (ObjectUtil.isEmpty(orderId)) {
|
if (ObjectUtil.isEmpty(orderId)) {
|
||||||
return Result.fail(CodeEnum.PARAM);
|
return Result.fail(CodeEnum.PARAM);
|
||||||
@@ -1197,6 +1274,8 @@ public class PayService {
|
|||||||
BigDecimal saleAmount = BigDecimal.ZERO;
|
BigDecimal saleAmount = BigDecimal.ZERO;
|
||||||
ArrayList<TbOrderDetail> remainOrderDetailList = new ArrayList<>();
|
ArrayList<TbOrderDetail> remainOrderDetailList = new ArrayList<>();
|
||||||
boolean hasNormalReturn = false;
|
boolean hasNormalReturn = false;
|
||||||
|
|
||||||
|
ArrayList<TbOrderDetail> copyDetailList = new ArrayList<>();
|
||||||
for (TbOrderDetail orderDetail : detailList) {
|
for (TbOrderDetail orderDetail : detailList) {
|
||||||
// 原始金额
|
// 原始金额
|
||||||
BigDecimal originalAmount = orderDetail.getPriceAmount();
|
BigDecimal originalAmount = orderDetail.getPriceAmount();
|
||||||
@@ -1255,6 +1334,7 @@ public class PayService {
|
|||||||
if (remainNum.compareTo(BigDecimal.ZERO) <= 0) {
|
if (remainNum.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
returnAmount = returnAmount.add(orderDetail.getPriceAmount());
|
returnAmount = returnAmount.add(orderDetail.getPriceAmount());
|
||||||
packAMount = orderDetail.getPackAmount();
|
packAMount = orderDetail.getPackAmount();
|
||||||
|
currentDetailAMount = orderDetail.getPriceAmount();
|
||||||
} else {
|
} else {
|
||||||
currentDetailAMount = orderDetail.getPriceAmount()
|
currentDetailAMount = orderDetail.getPriceAmount()
|
||||||
.divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP)
|
.divide(orderDetail.getNum(), 8, RoundingMode.HALF_UP)
|
||||||
@@ -1288,6 +1368,11 @@ public class PayService {
|
|||||||
orderDetail.setReturnAmount(returnAmount);
|
orderDetail.setReturnAmount(returnAmount);
|
||||||
// orderDetail.setStatus(isOnline ? "refunding" : "refund");
|
// orderDetail.setStatus(isOnline ? "refunding" : "refund");
|
||||||
orderDetail.setStatus("refund");
|
orderDetail.setStatus("refund");
|
||||||
|
|
||||||
|
TbOrderDetail returnOrderDetailCopy = new TbOrderDetail();
|
||||||
|
cn.hutool.core.bean.BeanUtil.copyProperties(orderDetail, returnOrderDetailCopy);
|
||||||
|
returnOrderDetailCopy.setId(null);
|
||||||
|
copyDetailList.add(returnOrderDetailCopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnAmount.compareTo(BigDecimal.ZERO) < 0) {
|
if (returnAmount.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
@@ -1307,28 +1392,27 @@ public class PayService {
|
|||||||
|
|
||||||
// TbOrderInfo returnOrder = mpOrderInfoService.selectReturnOrderByOrderId(returnOrderDTO.getOrderId());
|
// TbOrderInfo returnOrder = mpOrderInfoService.selectReturnOrderByOrderId(returnOrderDTO.getOrderId());
|
||||||
TbOrderInfo returnOrder = new TbOrderInfo();
|
TbOrderInfo returnOrder = new TbOrderInfo();
|
||||||
String orderNo = generateOrderNumber();
|
String orderNo = generateOrderNumber();
|
||||||
cn.hutool.core.bean.BeanUtil.copyProperties(oldOrderInfo, returnOrder);
|
cn.hutool.core.bean.BeanUtil.copyProperties(oldOrderInfo, returnOrder);
|
||||||
returnOrder.setId(null);
|
returnOrder.setId(null);
|
||||||
returnOrder.setOrderNo(orderNo);
|
returnOrder.setOrderNo(orderNo);
|
||||||
returnOrder.setRefundAmount(returnAmount);
|
returnOrder.setRefundAmount(returnAmount);
|
||||||
returnOrder.setOrderType("return");
|
returnOrder.setOrderType("return");
|
||||||
returnOrder.setStatus(isOnline ? "refunding" : "refund");
|
returnOrder.setStatus(isOnline ? "refunding" : "refund");
|
||||||
returnOrder.setUpdatedAt(null);
|
returnOrder.setUpdatedAt(null);
|
||||||
returnOrder.setSystemTime(DateUtil.date().getTime());
|
returnOrder.setSystemTime(DateUtil.date().getTime());
|
||||||
returnOrder.setCreatedAt(DateUtil.date().getTime());
|
returnOrder.setCreatedAt(DateUtil.date().getTime());
|
||||||
returnOrder.setPayOrderNo(null);
|
returnOrder.setPayOrderNo(null);
|
||||||
returnOrder.setSource(oldOrderInfo.getId());
|
returnOrder.setSource(oldOrderInfo.getId());
|
||||||
returnOrder.setRefundRemark(returnOrderDTO.getNote());
|
returnOrder.setRefundRemark(returnOrderDTO.getNote());
|
||||||
returnOrder.setOrderAmount(returnAmount);
|
returnOrder.setOrderAmount(returnAmount);
|
||||||
returnOrder.setAmount(returnAmount);
|
returnOrder.setAmount(returnAmount);
|
||||||
returnOrder.setSettlementAmount(returnAmount);
|
returnOrder.setSettlementAmount(returnAmount);
|
||||||
returnOrder.setPayAmount(returnAmount);
|
returnOrder.setPayAmount(returnAmount);
|
||||||
mPOrderInfoMapper.insert(returnOrder);
|
mPOrderInfoMapper.insert(returnOrder);
|
||||||
|
// 保存新的退款detail信息
|
||||||
for (TbOrderDetail orderDetail : detailList) {
|
copyDetailList.forEach(item -> item.setOrderId(returnOrder.getId()));
|
||||||
orderDetail.setOrderId(returnOrder.getId());
|
mpOrderDetailService.saveBatch(copyDetailList);
|
||||||
}
|
|
||||||
|
|
||||||
updateStockAndRecord(detailList);
|
updateStockAndRecord(detailList);
|
||||||
mpOrderDetailService.updateBatchById(detailList);
|
mpOrderDetailService.updateBatchById(detailList);
|
||||||
@@ -1424,7 +1508,7 @@ public class PayService {
|
|||||||
// TODO 密码校验
|
// TODO 密码校验
|
||||||
}
|
}
|
||||||
String payType = orderInfo.getPayType();
|
String payType = orderInfo.getPayType();
|
||||||
HashMap<String, Object> returnInfoData = updateReturnOrderInfo(returnOrderDTO, orderInfo, "scanCode".equals(payType) || "wx_lite".equals(payType));
|
HashMap<String, Object> returnInfoData = updateReturnOrderInfo(returnOrderDTO, orderInfo, "scanCode".equals(payType) || "wx_lite".equals(payType) || "ali_lite".equals(payType));
|
||||||
TbOrderInfo returnOrderInfo = (TbOrderInfo) returnInfoData.get("returnOrder");
|
TbOrderInfo returnOrderInfo = (TbOrderInfo) returnInfoData.get("returnOrder");
|
||||||
BigDecimal returnAmount = (BigDecimal) returnInfoData.get("returnAmount");
|
BigDecimal returnAmount = (BigDecimal) returnInfoData.get("returnAmount");
|
||||||
boolean hasNormalReturn = (boolean) returnInfoData.get("hasNormalReturn");
|
boolean hasNormalReturn = (boolean) returnInfoData.get("hasNormalReturn");
|
||||||
@@ -1433,12 +1517,12 @@ public class PayService {
|
|||||||
// // 线上退款
|
// // 线上退款
|
||||||
orderInfo.setRefundAmount(orderInfo.getRefundAmount().add(returnOrderInfo.getRefundAmount()));
|
orderInfo.setRefundAmount(orderInfo.getRefundAmount().add(returnOrderInfo.getRefundAmount()));
|
||||||
orderInfo.setRefundRemark(returnOrderDTO.getNote());
|
orderInfo.setRefundRemark(returnOrderDTO.getNote());
|
||||||
if (hasNormalReturn && ("scanCode".equals(payType) || "wx_lite".equals(payType))) {
|
if (hasNormalReturn && ("scanCode".equals(payType) || "wx_lite".equals(payType) || "ali_lite".equals(payType))) {
|
||||||
if (returnOrderDTO.getIsOnline() != null && !returnOrderDTO.getIsOnline()) {
|
if (returnOrderDTO.getIsOnline() != null && !returnOrderDTO.getIsOnline()) {
|
||||||
mpOrderDetailService.updateStatusByOrderIdAndIds(TableConstant.OrderInfo.Status.REFUNDING, TableConstant.OrderInfo.Status.REFUND,
|
mpOrderDetailService.updateStatusByOrderIdAndIds(TableConstant.OrderInfo.Status.REFUNDING, TableConstant.OrderInfo.Status.REFUND,
|
||||||
returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList()));
|
returnOrderDTO.getOrderId(), returnOrderDTO.getOrderDetails().stream().map(ReturnOrderDTO.OrderDetail::getId).collect(Collectors.toList()));
|
||||||
|
|
||||||
}else {
|
} else {
|
||||||
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
|
TbMerchantThirdApply thirdApply = tbMerchantThirdApplyMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getMerchantId()));
|
||||||
MsgException.checkNull(thirdApply, "支付参数配置错误");
|
MsgException.checkNull(thirdApply, "支付参数配置错误");
|
||||||
|
|
||||||
@@ -2489,4 +2573,5 @@ public class PayService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.chaozhanggui.system.cashierservice.dao.*;
|
|||||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
|
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStatusDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
|
import com.chaozhanggui.system.cashierservice.entity.dto.ProductStockDTO;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.vo.ProductGroupVo;
|
import com.chaozhanggui.system.cashierservice.entity.vo.ProductGroupVo;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo;
|
import com.chaozhanggui.system.cashierservice.entity.vo.ShopCategoryVo;
|
||||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
@@ -15,9 +16,11 @@ import com.chaozhanggui.system.cashierservice.mapper.MpShopUnitMapper;
|
|||||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.BeanUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||||
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.util.PageHelperUtil;
|
import com.chaozhanggui.system.cashierservice.util.PageHelperUtil;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -55,6 +58,9 @@ public class ProductService {
|
|||||||
private TbShopUnitMapper tbShopUnitMapper;
|
private TbShopUnitMapper tbShopUnitMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MpShopUnitMapper mpShopUnitMapper;
|
private MpShopUnitMapper mpShopUnitMapper;
|
||||||
|
private MpCashierCartService cashierCartService;
|
||||||
|
@Autowired
|
||||||
|
private OrderService orderService;
|
||||||
|
|
||||||
public ProductService(RabbitProducer producer) {
|
public ProductService(RabbitProducer producer) {
|
||||||
this.producer = producer;
|
this.producer = producer;
|
||||||
@@ -87,7 +93,7 @@ public class ProductService {
|
|||||||
String day = DateUtils.getDay();
|
String day = DateUtils.getDay();
|
||||||
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
|
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
|
||||||
tbProductWithBLOBs.parallelStream().forEach(it->{
|
tbProductWithBLOBs.parallelStream().forEach(it->{
|
||||||
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, "");
|
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, "", null);
|
||||||
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
|
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
|
||||||
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
|
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
|
||||||
if(ObjectUtil.isEmpty(tbProductSpec)){
|
if(ObjectUtil.isEmpty(tbProductSpec)){
|
||||||
@@ -118,7 +124,8 @@ public class ProductService {
|
|||||||
|
|
||||||
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, String tableId, int page, int pageSize, String masterId) {
|
public Result queryNewCommodityInfo(String shopId, String categoryId, String commdityName, String tableId, int page, int pageSize, String masterId) {
|
||||||
List<TbProduct> tbProductWithBLOBs=null;
|
List<TbProduct> tbProductWithBLOBs=null;
|
||||||
PageHelperUtil.startPage(page,pageSize);
|
|
||||||
|
PageHelperUtil.startPage(page, pageSize);
|
||||||
if(ObjectUtil.isEmpty(categoryId)){
|
if(ObjectUtil.isEmpty(categoryId)){
|
||||||
tbProductWithBLOBs=tbProductMapper.selectByShopIdAndCheckGrounding(shopId,commdityName);
|
tbProductWithBLOBs=tbProductMapper.selectByShopIdAndCheckGrounding(shopId,commdityName);
|
||||||
}else {
|
}else {
|
||||||
@@ -139,10 +146,11 @@ public class ProductService {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
String day = DateUtils.getDay();
|
String day = DateUtils.getDay();
|
||||||
|
ShopEatTypeInfoDTO shopEatTypeInfoDTO = orderService.checkEatModel(shopId, tableId);
|
||||||
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
|
if(ObjectUtil.isNotEmpty(tbProductWithBLOBs)){
|
||||||
Map<String, TbShopUnit> finalShopUnitsMap = shopUnitsMap;
|
Map<String, TbShopUnit> finalShopUnitsMap = shopUnitsMap;
|
||||||
tbProductWithBLOBs.parallelStream().forEach(it->{
|
tbProductWithBLOBs.parallelStream().forEach(it->{
|
||||||
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, tableId);
|
Integer orderCount=tbProductMapper.countOrderByshopIdAndProductId(it.getShopId(),it.getId().toString(),masterId,day, tableId, shopEatTypeInfoDTO.getUseType());
|
||||||
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
|
it.setOrderCount((ObjectUtil.isNull(orderCount)||ObjectUtil.isEmpty(orderCount))?0:orderCount);
|
||||||
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
|
TbProductSpec tbProductSpec= tbProductSpecMapper.selectByPrimaryKey(it.getSpecId());
|
||||||
if(ObjectUtil.isEmpty(tbProductSpec)){
|
if(ObjectUtil.isEmpty(tbProductSpec)){
|
||||||
@@ -165,6 +173,7 @@ public class ProductService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
PageInfo pageInfo=new PageInfo(tbProductWithBLOBs);
|
PageInfo pageInfo=new PageInfo(tbProductWithBLOBs);
|
||||||
|
pageInfo.setList(page <= pageInfo.getNavigateLastPage() ? pageInfo.getList() : new ArrayList());
|
||||||
return Result.success(CodeEnum.SUCCESS,pageInfo);
|
return Result.success(CodeEnum.SUCCESS,pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCallConfig;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【tb_call_config(叫号配置表)】的数据库操作Service
|
||||||
|
* @createDate 2024-12-10 10:12:45
|
||||||
|
*/
|
||||||
|
public interface TbCallConfigService extends IService<TbCallConfig> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCallQueue;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【tb_call_queue(叫号排号表)】的数据库操作Service
|
||||||
|
* @createDate 2024-12-10 10:12:45
|
||||||
|
*/
|
||||||
|
public interface TbCallQueueService extends IService<TbCallQueue> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.calltable.*;
|
||||||
|
|
||||||
|
public interface TbCallService {
|
||||||
|
Object add(CallTableDTO addCallTableDTO);
|
||||||
|
|
||||||
|
Object update(UpdateCallTableDTO callTableDTO);
|
||||||
|
|
||||||
|
Object delete(BaseCallTableDTO baseCallTableDTO);
|
||||||
|
|
||||||
|
Object takeNumber(TakeNumberDTO takeNumber);
|
||||||
|
|
||||||
|
Object call(CallQueueDTO callQueueDTO);
|
||||||
|
|
||||||
|
Object updateInfo(UpdateCallQueueDTO updateCallQueueDTO);
|
||||||
|
|
||||||
|
Object get(Integer page, Integer size, Integer shopId, Integer callTableId, Integer state);
|
||||||
|
|
||||||
|
Object takeNumberCode(Integer shopId, Integer callTableId);
|
||||||
|
|
||||||
|
Object getQueue(Integer shopId, Integer callTableId, Integer state, Integer page, Integer size);
|
||||||
|
|
||||||
|
Object getCallRecord(Integer shopId, Integer callTableId, Integer page, Integer size);
|
||||||
|
|
||||||
|
Object getConfig(Integer shopId);
|
||||||
|
|
||||||
|
Object updateConfig(UpdateConfigDTO configDTO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCallTable;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【tb_call_table(叫号桌型表)】的数据库操作Service
|
||||||
|
* @createDate 2024-12-10 10:12:45
|
||||||
|
*/
|
||||||
|
public interface TbCallTableService extends IService<TbCallTable> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditBuyerOrder;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditPaymentRecord;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.CreditBuyerOrderDTO;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账账单
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
public interface TbCreditBuyerOrderService extends IService<TbCreditBuyerOrder> {
|
||||||
|
|
||||||
|
PageInfo<CreditBuyerOrderDTO> page(Map<String, Object> params);
|
||||||
|
Map<String, Object> summary(Map<String, Object> params);
|
||||||
|
|
||||||
|
void pay(TbCreditPaymentRecord record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存挂账账单
|
||||||
|
* @param creditBuyerId 挂账人id
|
||||||
|
* @param orderId 订单id
|
||||||
|
*/
|
||||||
|
boolean save(String creditBuyerId, Long orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账人退款(整单退款)
|
||||||
|
* @param creditBuyerId 挂账人id
|
||||||
|
* @param orderId 订单id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
boolean refund(String creditBuyerId, Long orderId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账人退款(部分退款)
|
||||||
|
* @param creditBuyerId 挂账人id
|
||||||
|
* @param orderId 订单id
|
||||||
|
* @param refundAmount 退款金额
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean partRefund(String creditBuyerId, Long orderId, BigDecimal refundAmount);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditBuyer;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账人
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface TbCreditBuyerService extends IService<TbCreditBuyer> {
|
||||||
|
|
||||||
|
PageInfo<TbCreditBuyer> page(Map<String, Object> params);
|
||||||
|
|
||||||
|
boolean save(TbCreditBuyer entity);
|
||||||
|
|
||||||
|
boolean update(TbCreditBuyer dto);
|
||||||
|
|
||||||
|
void delete(String id);
|
||||||
|
|
||||||
|
TbCreditBuyer getById(String id);
|
||||||
|
|
||||||
|
Map<String,Object> repayment(Map<String, Object> params);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditPaymentRecord;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账账单付款记录
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
public interface TbCreditPaymentRecordService extends IService<TbCreditPaymentRecord> {
|
||||||
|
|
||||||
|
PageInfo<TbCreditPaymentRecord> page(Map<String, Object> params);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,9 +4,11 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.chaozhanggui.system.cashierservice.bean.OrderPlatformTypeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
|
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||||
@@ -17,8 +19,10 @@ import com.chaozhanggui.system.cashierservice.service.MpCashierCartService;
|
|||||||
import com.chaozhanggui.system.cashierservice.service.MpOrderDetailService;
|
import com.chaozhanggui.system.cashierservice.service.MpOrderDetailService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (TbShopPermission)表服务实现类
|
* (TbShopPermission)表服务实现类
|
||||||
@@ -96,7 +100,9 @@ public class MpCashierCartServiceImpl extends ServiceImpl<MPCashierCartMapper, T
|
|||||||
.eq(TbCashierCart::getShopId, shopId)
|
.eq(TbCashierCart::getShopId, shopId)
|
||||||
.eq(TbCashierCart::getId, cartId);
|
.eq(TbCashierCart::getId, cartId);
|
||||||
if (statuses.length != 0) {
|
if (statuses.length != 0) {
|
||||||
queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
|
queryWrapper.in(TbCashierCart::getStatus, Arrays.stream(statuses)
|
||||||
|
.map(TableConstant.OrderInfo.Status::getValue)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
return getOne(queryWrapper);
|
return getOne(queryWrapper);
|
||||||
}
|
}
|
||||||
@@ -104,13 +110,99 @@ public class MpCashierCartServiceImpl extends ServiceImpl<MPCashierCartMapper, T
|
|||||||
public List<TbCashierCart> selectByIds(Integer shopId, Integer orderId, List<Integer> ids, TableConstant.OrderInfo.Status... statuses) {
|
public List<TbCashierCart> selectByIds(Integer shopId, Integer orderId, List<Integer> ids, TableConstant.OrderInfo.Status... statuses) {
|
||||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
.eq(TbCashierCart::getShopId, shopId)
|
.eq(TbCashierCart::getShopId, shopId)
|
||||||
.eq(TbCashierCart::getOrderId, orderId)
|
|
||||||
.in(TbCashierCart::getId, ids);
|
.in(TbCashierCart::getId, ids);
|
||||||
|
if (orderId != null) {
|
||||||
|
queryWrapper.eq(TbCashierCart::getOrderId, orderId);
|
||||||
|
}
|
||||||
if (statuses.length != 0) {
|
if (statuses.length != 0) {
|
||||||
queryWrapper.in(TbCashierCart::getStatus, CollUtil.newArrayList(statuses));
|
queryWrapper.in(TbCashierCart::getStatus, Arrays.stream(statuses)
|
||||||
|
.map(TableConstant.OrderInfo.Status::getValue)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TbCashierCart> selectByShopEatTypeAndOrderId(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId,
|
||||||
|
Integer orderId, boolean onlySearchPc, TableConstant.OrderInfo.Status... statuses) {
|
||||||
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
|
.eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId())
|
||||||
|
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
|
||||||
|
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
||||||
|
.and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId));
|
||||||
|
|
||||||
|
if (statuses.length == 0) {
|
||||||
|
queryWrapper.in(TbCashierCart::getStatus, "create", "return");
|
||||||
|
} else {
|
||||||
|
queryWrapper.in(TbCashierCart::getStatus, Arrays.stream(statuses)
|
||||||
|
.map(TableConstant.OrderInfo.Status::getValue)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (orderId != null) {
|
||||||
|
queryWrapper.and(q -> q.eq(TbCashierCart::getOrderId, orderId)
|
||||||
|
.or().isNull(TbCashierCart::getOrderId));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlySearchPc) {
|
||||||
|
queryWrapper.ne(TbCashierCart::getPlatformType, "mimiapp");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 非堂食校验台桌状态
|
||||||
|
if (shopEatTypeInfoDTO.isTakeout()) {
|
||||||
|
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
|
||||||
|
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
|
||||||
|
} else {
|
||||||
|
if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) {
|
||||||
|
queryWrapper.eq(TbCashierCart::getTableId, shopEatTypeInfoDTO.getTableId());
|
||||||
|
} else {
|
||||||
|
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long countByShopEatType(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String masterId,
|
||||||
|
Integer orderId, boolean onlySearchPc, TableConstant.OrderInfo.Status... statuses) {
|
||||||
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
|
.eq(TbCashierCart::getShopId, shopEatTypeInfoDTO.getShopId())
|
||||||
|
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
|
||||||
|
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
||||||
|
.and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId));
|
||||||
|
|
||||||
|
if (statuses.length == 0) {
|
||||||
|
queryWrapper.in(TbCashierCart::getStatus, "create", "return");
|
||||||
|
} else {
|
||||||
|
queryWrapper.in(TbCashierCart::getStatus, Arrays.stream(statuses)
|
||||||
|
.map(TableConstant.OrderInfo.Status::getValue)
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (orderId != null) {
|
||||||
|
queryWrapper.and(q -> q.eq(TbCashierCart::getOrderId, orderId)
|
||||||
|
.or().isNull(TbCashierCart::getOrderId));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlySearchPc) {
|
||||||
|
queryWrapper.ne(TbCashierCart::getPlatformType, "mimiapp");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 非堂食校验台桌状态
|
||||||
|
if (shopEatTypeInfoDTO.isTakeout()) {
|
||||||
|
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
|
||||||
|
.in(TbCashierCart::getPlatformType, OrderPlatformTypeEnum.PC.getValue(), OrderPlatformTypeEnum.CASH.getValue());
|
||||||
|
} else {
|
||||||
|
if (StrUtil.isNotBlank(shopEatTypeInfoDTO.getTableId())) {
|
||||||
|
queryWrapper.eq(TbCashierCart::getTableId, shopEatTypeInfoDTO.getTableId());
|
||||||
|
} else {
|
||||||
|
queryWrapper.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return (long) count(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.service.impl;
|
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
|
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
|
||||||
@@ -22,6 +23,12 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class MpShopTableServiceImpl extends ServiceImpl<MpShopTableMapper, TbShopTable> implements MpShopTableService {
|
public class MpShopTableServiceImpl extends ServiceImpl<MpShopTableMapper, TbShopTable> implements MpShopTableService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TbShopTable selectByTableId(String tableId, Integer shopId) {
|
||||||
|
return getOne(new LambdaQueryWrapper<TbShopTable>()
|
||||||
|
.eq(TbShopTable::getShopId, shopId)
|
||||||
|
.eq(TbShopTable::getQrcode, tableId));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCallConfig;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCallConfigService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mapper.TbCallConfigMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【tb_call_config(叫号配置表)】的数据库操作Service实现
|
||||||
|
* @createDate 2024-12-10 10:12:45
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TbCallConfigServiceImpl extends ServiceImpl<TbCallConfigMapper, TbCallConfig>
|
||||||
|
implements TbCallConfigService{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCallQueue;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCallQueueService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mapper.TbCallQueueMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【tb_call_queue(叫号排号表)】的数据库操作Service实现
|
||||||
|
* @createDate 2024-12-10 10:12:45
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TbCallQueueServiceImpl extends ServiceImpl<TbCallQueueMapper, TbCallQueue>
|
||||||
|
implements TbCallQueueService{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,576 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||||
|
import cn.hutool.extra.qrcode.QrConfig;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.dao.TbShopUserMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.calltable.*;
|
||||||
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mapper.TbCallQueueMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mybatis.MpShopUserMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCallConfigService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCallQueueService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCallService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCallTableService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.RabbitMsgUtils;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.RedisCst;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.Utils;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.WxAccountUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TbCallServiceImpl implements TbCallService {
|
||||||
|
|
||||||
|
@Value("${wx.mini.page.call}")
|
||||||
|
private String callPageUrl;
|
||||||
|
|
||||||
|
private final TbCallTableService callTableService;
|
||||||
|
private final TbCallQueueService callQueueService;
|
||||||
|
private final MpShopUserMapper shopUserMapper;
|
||||||
|
private final TbShopInfoMapper shopInfoMapper;
|
||||||
|
private final StringRedisTemplate redisTemplate;
|
||||||
|
private final TbCallQueueMapper tbCallQueueMapper;
|
||||||
|
private final WxAccountUtil wxMiniUtils;
|
||||||
|
private final TbCallConfigService tbCallConfigService;
|
||||||
|
private final RabbitMsgUtils rabbitMsgUtils;
|
||||||
|
|
||||||
|
public TbCallServiceImpl(TbCallTableService callTableService, TbCallQueueService callQueueService,
|
||||||
|
MpShopUserMapper shopUserMapper, TbShopInfoMapper shopInfoMapper,
|
||||||
|
StringRedisTemplate redisTemplate, TbCallQueueMapper tbCallQueueMapper,
|
||||||
|
WxAccountUtil wxMiniUtils, TbCallConfigService tbCallConfigService, RabbitMsgUtils rabbitMsgUtils) {
|
||||||
|
this.callTableService = callTableService;
|
||||||
|
this.callQueueService = callQueueService;
|
||||||
|
this.shopUserMapper = shopUserMapper;
|
||||||
|
this.shopInfoMapper = shopInfoMapper;
|
||||||
|
this.redisTemplate = redisTemplate;
|
||||||
|
this.tbCallQueueMapper = tbCallQueueMapper;
|
||||||
|
this.wxMiniUtils = wxMiniUtils;
|
||||||
|
this.tbCallConfigService = tbCallConfigService;
|
||||||
|
this.rabbitMsgUtils = rabbitMsgUtils;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object add(CallTableDTO addCallTableDTO) {
|
||||||
|
Integer count = callTableService.lambdaQuery()
|
||||||
|
.eq(TbCallTable::getShopId, addCallTableDTO.getShopId())
|
||||||
|
.and(q -> q.eq(TbCallTable::getName, addCallTableDTO.getName())
|
||||||
|
.or()
|
||||||
|
.eq(TbCallTable::getPrefix, addCallTableDTO.getPrefix())).count();
|
||||||
|
if (count > 0) {
|
||||||
|
throw new MsgException("名称或前缀已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
TbCallTable callTable = new TbCallTable();
|
||||||
|
BeanUtil.copyProperties(addCallTableDTO, callTable);
|
||||||
|
callTable.setCreateTime(DateUtil.date());
|
||||||
|
return callTableService.save(callTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object update(UpdateCallTableDTO callTableDTO) {
|
||||||
|
TbCallTable callTable = callTableService.lambdaQuery()
|
||||||
|
.eq(TbCallTable::getShopId, callTableDTO.getShopId())
|
||||||
|
.eq(TbCallTable::getId, callTableDTO.getCallTableId()).one();
|
||||||
|
|
||||||
|
if (callTable == null) {
|
||||||
|
throw new MsgException("桌型不存在");
|
||||||
|
}
|
||||||
|
TbCallTable newInfo = new TbCallTable();
|
||||||
|
BeanUtil.copyProperties(callTableDTO, newInfo);
|
||||||
|
newInfo.setId(callTable.getId());
|
||||||
|
newInfo.setUpdateTime(DateUtil.date());
|
||||||
|
|
||||||
|
return callTableService.updateById(newInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object delete(BaseCallTableDTO baseCallTableDTO) {
|
||||||
|
return callTableService.remove(new LambdaQueryWrapper<TbCallTable>()
|
||||||
|
.eq(TbCallTable::getId, baseCallTableDTO.getCallTableId())
|
||||||
|
.eq(TbCallTable::getShopId, baseCallTableDTO.getShopId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCallNumber(Integer shopId, TbCallTable callTable) {
|
||||||
|
return Utils.runFunAndCheckKey(() -> {
|
||||||
|
String callNumKey = RedisCst.getTableCallNumKey(shopId, callTable.getId());
|
||||||
|
String value = redisTemplate.opsForValue().get(callNumKey);
|
||||||
|
AtomicReference<String> newVal = new AtomicReference<>("");
|
||||||
|
// 初始化
|
||||||
|
if (StrUtil.isBlank(value)) {
|
||||||
|
Boolean setFlag = Utils.runFunAndRetry(() -> redisTemplate.opsForValue().setIfAbsent(callNumKey, callTable.getStart().toString()), flag -> !flag,
|
||||||
|
r -> newVal.set(redisTemplate.opsForValue().get(callNumKey)));
|
||||||
|
|
||||||
|
if (setFlag) {
|
||||||
|
return callTable.getPrefix() + callTable.getStart();
|
||||||
|
}else if (StrUtil.isNotBlank(newVal.get())){
|
||||||
|
value = String.valueOf((Integer.parseInt(newVal.get()) + 1));
|
||||||
|
redisTemplate.opsForValue().set(callNumKey, value);
|
||||||
|
return callTable.getPrefix() + value;
|
||||||
|
}else {
|
||||||
|
throw new MsgException("生成排队号码失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {
|
||||||
|
value = String.valueOf((Integer.parseInt(value) + 1));
|
||||||
|
redisTemplate.opsForValue().set(callNumKey, value);
|
||||||
|
return callTable.getPrefix() + value;
|
||||||
|
}
|
||||||
|
}, redisTemplate, RedisCst.getLockKey("UPDATE_TABLE", shopId, callTable.getId()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object takeNumber(TakeNumberDTO takeNumberDTO) {
|
||||||
|
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(takeNumberDTO.getShopId());
|
||||||
|
if (shopInfo == null) {
|
||||||
|
throw new MsgException("店铺信息不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
TbCallTable callTable = callTableService.lambdaQuery()
|
||||||
|
.eq(TbCallTable::getShopId, takeNumberDTO.getShopId())
|
||||||
|
.eq(TbCallTable::getId, takeNumberDTO.getCallTableId()).one();
|
||||||
|
if (callTable == null) {
|
||||||
|
throw new MsgException("桌型不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询当前
|
||||||
|
|
||||||
|
// 拿取系统内部用户信息
|
||||||
|
TbCallQueue callQueue;
|
||||||
|
if (takeNumberDTO.getUserId() != null) {
|
||||||
|
TbShopUser shopUser = shopUserMapper.selectOne(new LambdaQueryWrapper<TbShopUser>()
|
||||||
|
.eq(TbShopUser::getStatus, 1)
|
||||||
|
.eq(TbShopUser::getShopId, takeNumberDTO.getShopId())
|
||||||
|
.eq(TbShopUser::getId, takeNumberDTO.getUserId()));
|
||||||
|
if (shopUser == null) {
|
||||||
|
throw new MsgException("用户不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
callQueue = callQueueService.lambdaQuery()
|
||||||
|
.eq(TbCallQueue::getUserId, shopUser.getId())
|
||||||
|
.eq(TbCallQueue::getShopId, takeNumberDTO.getShopId())
|
||||||
|
.in(TbCallQueue::getState, 0, 1)
|
||||||
|
.eq(TbCallQueue::getCreateDay, DateUtil.today())
|
||||||
|
.ne(TbCallQueue::getIsPostpone, 2)
|
||||||
|
.eq(TbCallQueue::getCallTableId, takeNumberDTO.getCallTableId()).one();
|
||||||
|
if (callQueue != null) {
|
||||||
|
throw new MsgException("当前用户已取号");
|
||||||
|
}
|
||||||
|
|
||||||
|
callQueue = new TbCallQueue();
|
||||||
|
BeanUtil.copyProperties(takeNumberDTO, callQueue);
|
||||||
|
callQueue.setPhone(StrUtil.isBlank(takeNumberDTO.getPhone()) ? shopUser.getTelephone() : takeNumberDTO.getPhone());
|
||||||
|
|
||||||
|
// callQueue.setOpenId(shopUser.getMiniOpenId());
|
||||||
|
|
||||||
|
}else {
|
||||||
|
// if (StrUtil.isBlank(takeNumberDTO.getPhone()) || StrUtil.isBlank(takeNumberDTO.getOpenId())) {
|
||||||
|
// throw new MsgException("手机号或openId不能为空");
|
||||||
|
// }
|
||||||
|
|
||||||
|
callQueue = callQueueService.lambdaQuery()
|
||||||
|
.eq(TbCallQueue::getPhone, takeNumberDTO.getPhone())
|
||||||
|
.eq(TbCallQueue::getShopId, takeNumberDTO.getShopId())
|
||||||
|
.eq(TbCallQueue::getCreateDay, DateUtil.today())
|
||||||
|
.in(TbCallQueue::getState, 0, 1)
|
||||||
|
.ne(TbCallQueue::getIsPostpone, 2)
|
||||||
|
.eq(TbCallQueue::getCallTableId, takeNumberDTO.getCallTableId()).one();
|
||||||
|
if (callQueue != null) {
|
||||||
|
throw new MsgException("当前用户已取号");
|
||||||
|
}
|
||||||
|
|
||||||
|
callQueue = new TbCallQueue();
|
||||||
|
BeanUtil.copyProperties(takeNumberDTO, callQueue);
|
||||||
|
callQueue.setPhone(takeNumberDTO.getPhone());
|
||||||
|
// callQueue.setOpenId(takeNumberDTO.getOpenId());
|
||||||
|
callQueue.setSubState(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
callQueue.setCreateDay(DateUtil.today());
|
||||||
|
callQueue.setCallNum(getCallNumber(takeNumberDTO.getShopId(), callTable));
|
||||||
|
callQueue.setCreateTime(DateUtil.date());
|
||||||
|
callQueue.setShopId(shopInfo.getId());
|
||||||
|
callQueue.setShopName(shopInfo.getShopName());
|
||||||
|
|
||||||
|
callQueueService.save(callQueue);
|
||||||
|
|
||||||
|
// 打印排号票信息
|
||||||
|
rabbitMsgUtils.printCallNumTicket(callQueue.getId(), callQueue.getShopId());
|
||||||
|
|
||||||
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
|
data.put("tableName", callTable.getName());
|
||||||
|
data.put("tableNote", callTable.getNote());
|
||||||
|
data.put("callNum", callQueue.getCallNum());
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object call(CallQueueDTO callQueueDTO) {
|
||||||
|
TbCallQueue callQueue = callQueueService.lambdaQuery()
|
||||||
|
.notIn(TbCallQueue::getState, -1, 2)
|
||||||
|
.eq(TbCallQueue::getCreateDay, DateUtil.today())
|
||||||
|
.eq(TbCallQueue::getId, callQueueDTO.getCallQueueId())
|
||||||
|
.eq(TbCallQueue::getShopId, callQueueDTO.getShopId())
|
||||||
|
.one();
|
||||||
|
|
||||||
|
if (callQueue == null) {
|
||||||
|
throw new MsgException("叫号用户不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
callQueue.setState(1);
|
||||||
|
callQueue.setCallCount(callQueue.getCallCount() + 1);
|
||||||
|
callQueue.setCallTime(DateUtil.date());
|
||||||
|
callQueueService.updateById(callQueue);
|
||||||
|
|
||||||
|
if (callQueue.getSubState().equals(0)) {
|
||||||
|
return new HashMap<String, Object>(){{
|
||||||
|
put("state", "-1");
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送模板消息通知用户
|
||||||
|
|
||||||
|
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(callQueue.getShopId());
|
||||||
|
if (shopInfo == null) {
|
||||||
|
throw new MsgException("店铺信息不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TbCallQueue> current = callQueueService.lambdaQuery()
|
||||||
|
.eq(TbCallQueue::getCallTableId, callQueue.getCallTableId())
|
||||||
|
.eq(TbCallQueue::getCreateDay, DateUtil.today())
|
||||||
|
.and(r -> {
|
||||||
|
r.eq(TbCallQueue::getState, 1)
|
||||||
|
.or()
|
||||||
|
.eq(TbCallQueue::getState, 0);
|
||||||
|
})
|
||||||
|
.orderByAsc(TbCallQueue::getCreateTime)
|
||||||
|
.page(new Page<>(1, 1)).getRecords();
|
||||||
|
|
||||||
|
|
||||||
|
if (StrUtil.isBlank(callQueue.getOpenId())) {
|
||||||
|
return new HashMap<String, Object>(){{
|
||||||
|
put("state", "-1");
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
wxMiniUtils.sendCurrentOrNearCallMsg(shopInfo.getShopName(), getStrByState(Integer.valueOf(callQueue.getState())),
|
||||||
|
callQueue.getCallNum(), current.isEmpty() ? "" : current.get(0).getCallNum(), "排号信息", callQueue.getOpenId(), false);
|
||||||
|
|
||||||
|
TbCallConfig config = getConfig(callQueueDTO.getShopId());
|
||||||
|
// 临近用户提醒
|
||||||
|
List<TbCallQueue> nearList = callQueueService.lambdaQuery()
|
||||||
|
.eq(TbCallQueue::getCallTableId, callQueue.getCallTableId())
|
||||||
|
.eq(TbCallQueue::getCreateDay, DateUtil.today())
|
||||||
|
.gt(TbCallQueue::getId, current.get(0).getId())
|
||||||
|
.page(new Page<>(config.getNearNum(), 1)).getRecords();
|
||||||
|
if (!nearList.isEmpty()) {
|
||||||
|
TbCallQueue nearQueue = nearList.get(0);
|
||||||
|
wxMiniUtils.sendCurrentOrNearCallMsg(shopInfo.getShopName(), getStrByState(Integer.valueOf(nearQueue.getState())),
|
||||||
|
nearQueue.getCallNum(), current.isEmpty() ? "" : current.get(0).getCallNum(), "排号信息", nearQueue.getOpenId(), true);
|
||||||
|
}
|
||||||
|
return new HashMap<String, Object>(){{
|
||||||
|
put("state", "1");
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getStrByState(Integer state) {
|
||||||
|
String msg = "";
|
||||||
|
switch (state) {
|
||||||
|
case -1:
|
||||||
|
msg = "已取消";
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
msg = "排队中";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
msg = "已到号";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
msg = "已过号";
|
||||||
|
}
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object updateInfo(UpdateCallQueueDTO updateCallQueueDTO) {
|
||||||
|
TbCallQueue callQueue = callQueueService.lambdaQuery()
|
||||||
|
.eq(TbCallQueue::getShopId, updateCallQueueDTO.getShopId())
|
||||||
|
.eq(TbCallQueue::getCreateDay, DateUtil.today())
|
||||||
|
.eq(TbCallQueue::getId, updateCallQueueDTO.getCallQueueId()).one();
|
||||||
|
if (callQueue == null) {
|
||||||
|
throw new MsgException("叫号用户不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (updateCallQueueDTO.getState()) {
|
||||||
|
case -1:
|
||||||
|
callQueue.setCancelTime(DateUtil.date());
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
callQueue.setState(0);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (callQueue.getSubState().equals(0)) {
|
||||||
|
throw new MsgException("当前用户未订阅微信提醒");
|
||||||
|
}
|
||||||
|
callQueue.setState(1);
|
||||||
|
callQueue.setCallCount(callQueue.getCallCount() + 1);
|
||||||
|
callQueue.setCallTime(DateUtil.date());
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
callQueue.setConfirmTime(DateUtil.date());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
callQueue.setPassTime(DateUtil.date());
|
||||||
|
// 已经顺延
|
||||||
|
callQueue.setIsPostpone(callQueue.getIsPostpone() == null ? 1 : callQueue.getIsPostpone() == 0 ? 1 : 2);
|
||||||
|
TbShopInfo shopInfo = shopInfoMapper.selectByPrimaryKey(callQueue.getShopId());
|
||||||
|
if (shopInfo == null) {
|
||||||
|
throw new MsgException("店铺信息不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StrUtil.isBlank(callQueue.getOpenId()) && callQueue.getSubState() != 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
TbCallTable callTable = callTableService.getById(callQueue.getCallTableId());
|
||||||
|
Integer isPostpone = callTable.getIsPostpone();
|
||||||
|
Integer postponeNum = callTable.getPostponeNum();
|
||||||
|
|
||||||
|
// 判断是否需要顺延, 暂时注释
|
||||||
|
if (false && callQueue.getIsPostpone() == 0 && isPostpone != null && isPostpone == 1 && postponeNum != null && postponeNum > 0) {
|
||||||
|
// 查询当前桌以及顺延桌数
|
||||||
|
List<TbCallQueue> current = callQueueService.lambdaQuery()
|
||||||
|
.eq(TbCallQueue::getCallTableId, callQueue.getCallTableId())
|
||||||
|
.eq(TbCallQueue::getCreateDay, DateUtil.today())
|
||||||
|
.eq(TbCallQueue::getShopId, callTable.getShopId())
|
||||||
|
.ge(TbCallQueue::getId, callQueue.getId())
|
||||||
|
.orderByAsc(TbCallQueue::getCreateTime)
|
||||||
|
.page(new Page<>(1, postponeNum + 1)) // 获取当前桌和顺延的桌数
|
||||||
|
.getRecords();
|
||||||
|
|
||||||
|
// 确保有足够的桌可以顺延
|
||||||
|
if (current.size() > 1) {
|
||||||
|
// 获取当前桌以及顺延桌
|
||||||
|
TbCallQueue currentTable = new TbCallQueue();
|
||||||
|
BeanUtil.copyProperties(current.get(0), currentTable);
|
||||||
|
// 顺延替换信息,将每一张顺延桌向前移动
|
||||||
|
for (int i = 0; i < current.size() - 1; i++) {
|
||||||
|
exchangeCallQueueInfo(current.get(i), current.get(i + 1)); // 当前桌替换为顺延桌
|
||||||
|
}
|
||||||
|
|
||||||
|
exchangeCallQueueInfo(current.get(current.size() - 1), currentTable);
|
||||||
|
callQueue = current.get(current.size() - 1);
|
||||||
|
|
||||||
|
// 更新数据库中的桌号信息
|
||||||
|
callQueueService.updateBatchById(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TbCallQueue> current = callQueueService.lambdaQuery()
|
||||||
|
.eq(TbCallQueue::getCallTableId, callQueue.getCallTableId())
|
||||||
|
.eq(TbCallQueue::getCreateDay, DateUtil.today())
|
||||||
|
.and(r -> {
|
||||||
|
r.eq(TbCallQueue::getState, 1)
|
||||||
|
.or()
|
||||||
|
.eq(TbCallQueue::getState, 0);
|
||||||
|
})
|
||||||
|
.orderByAsc(TbCallQueue::getCreateTime)
|
||||||
|
.page(new Page<>(1, 1)).getRecords();
|
||||||
|
wxMiniUtils.sendPassCallMsg(shopInfo.getShopName(), getStrByState(Integer.valueOf(updateCallQueueDTO.getState())),
|
||||||
|
callQueue.getCallNum(), current.isEmpty() ? "" : current.get(0).getCallNum(), "即将过号", callQueue.getOpenId());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new MsgException("错误类型");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
callQueue.setState(updateCallQueueDTO.getState());
|
||||||
|
|
||||||
|
return callQueueService.updateById(callQueue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exchangeCallQueueInfo(TbCallQueue setCallQueue, TbCallQueue copyCallQueue) {
|
||||||
|
setCallQueue.setOpenId(copyCallQueue.getOpenId());
|
||||||
|
setCallQueue.setState(copyCallQueue.getState());
|
||||||
|
setCallQueue.setSubState(copyCallQueue.getSubState());
|
||||||
|
setCallQueue.setCreateTime(copyCallQueue.getCreateTime());
|
||||||
|
setCallQueue.setName(copyCallQueue.getName());
|
||||||
|
setCallQueue.setNote(copyCallQueue.getNote());
|
||||||
|
setCallQueue.setCallNum(copyCallQueue.getCallNum());
|
||||||
|
setCallQueue.setCallTime(copyCallQueue.getCallTime());
|
||||||
|
setCallQueue.setCallCount(copyCallQueue.getCallCount());
|
||||||
|
setCallQueue.setPassTime(copyCallQueue.getPassTime());
|
||||||
|
setCallQueue.setCancelTime(copyCallQueue.getCancelTime());
|
||||||
|
setCallQueue.setUserId(copyCallQueue.getUserId());
|
||||||
|
setCallQueue.setConfirmTime(copyCallQueue.getConfirmTime());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get(Integer page, Integer size, Integer shopId, Integer callTableId, Integer state) {
|
||||||
|
LambdaQueryWrapper<TbCallTable> query = new LambdaQueryWrapper<TbCallTable>()
|
||||||
|
.eq(TbCallTable::getShopId, shopId)
|
||||||
|
.eq(TbCallTable::getState, 1);
|
||||||
|
|
||||||
|
if (callTableId != null) {
|
||||||
|
query.eq(TbCallTable::getId, callTableId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state != null) {
|
||||||
|
query.eq(TbCallTable::getState, state);
|
||||||
|
}
|
||||||
|
Page<TbCallTable> pageInfo = callTableService.page(new Page<>(page, size), query);
|
||||||
|
ArrayList<Map<String, Object>> info = new ArrayList<>();
|
||||||
|
Long totalCount = 0L;
|
||||||
|
for (TbCallTable item : pageInfo.getRecords()) {
|
||||||
|
LambdaQueryChainWrapper<TbCallQueue> q = callQueueService.lambdaQuery()
|
||||||
|
.eq(TbCallQueue::getCallTableId, item.getId())
|
||||||
|
.eq(TbCallQueue::getShopId, shopId)
|
||||||
|
.eq(TbCallQueue::getCreateDay, DateUtil.today())
|
||||||
|
.in(TbCallQueue::getState, 0, 1);
|
||||||
|
Integer count = q.count();
|
||||||
|
|
||||||
|
totalCount += count;
|
||||||
|
|
||||||
|
Map<String, Object> map = BeanUtil.beanToMap(item, false, false);
|
||||||
|
map.put("totalCount", count);
|
||||||
|
map.put("isPostpone", item.getIsPostpone() == 1);
|
||||||
|
info.add(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> toMap = BeanUtil.beanToMap(pageInfo);
|
||||||
|
toMap.put("records", info);
|
||||||
|
toMap.put("totalCount", totalCount);
|
||||||
|
return toMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object takeNumberCode(Integer shopId, Integer callTableId) {
|
||||||
|
// 创建二维码配置对象,设置宽度和高度为400
|
||||||
|
QrConfig config = new QrConfig(400, 400);
|
||||||
|
|
||||||
|
// 使用字节数组输出流来存储二维码图片
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
// 生成二维码图片,输出到字节数组输出流
|
||||||
|
QrCodeUtil.generate(StrUtil.format(callPageUrl, shopId, ""), config, "png", outputStream);
|
||||||
|
|
||||||
|
// 将图片转换为 Base64 字符串
|
||||||
|
String base64 = Base64.getEncoder().encodeToString(outputStream.toByteArray());
|
||||||
|
|
||||||
|
// 返回Base64格式的图片字符串
|
||||||
|
return "data:image/png;base64," + base64;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getQueue(Integer shopId, Integer callTableId, Integer state, Integer page, Integer size) {
|
||||||
|
List<Integer> tableIds;
|
||||||
|
if (callTableId != null) {
|
||||||
|
tableIds = Collections.singletonList(callTableId);
|
||||||
|
}else {
|
||||||
|
List<TbCallTable> list = callTableService.lambdaQuery()
|
||||||
|
.eq(TbCallTable::getShopId, shopId)
|
||||||
|
.eq(TbCallTable::getState, 1).list();
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return new Page<>();
|
||||||
|
}
|
||||||
|
tableIds = list.stream()
|
||||||
|
.map(TbCallTable::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LambdaQueryWrapper<TbCallQueue> query = new LambdaQueryWrapper<TbCallQueue>()
|
||||||
|
.eq(TbCallQueue::getShopId, shopId)
|
||||||
|
.eq(TbCallQueue::getCreateDay, DateUtil.today())
|
||||||
|
.in(TbCallQueue::getCallTableId, tableIds);
|
||||||
|
state = null;
|
||||||
|
if (state != null) {
|
||||||
|
query.eq(TbCallQueue::getState, state);
|
||||||
|
}else {
|
||||||
|
query.in(TbCallQueue::getState, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Page<TbCallQueue> pageInfo = callQueueService.page(new Page<>(page, size),
|
||||||
|
query.orderByAsc(TbCallQueue::getCreateTime)
|
||||||
|
.orderByDesc(TbCallQueue::getState));
|
||||||
|
|
||||||
|
List<TbCallQueue> list1 = pageInfo.getRecords();
|
||||||
|
|
||||||
|
// 创建返回的结果集
|
||||||
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||||
|
|
||||||
|
// 遍历每一个叫号中的记录,计算前面状态为"0" (排队中) 的人数
|
||||||
|
for (TbCallQueue calling : list1) {
|
||||||
|
// 计算前面等待的人数 (状态为"0"且在叫号记录创建时间之前的)
|
||||||
|
long waitingCount = 0;
|
||||||
|
if (calling.getState() == 0) {
|
||||||
|
waitingCount = list1.stream()
|
||||||
|
.filter(item -> item.getState() == 0 || item.getState() == 1) // 过滤出状态为"排队中"的
|
||||||
|
.filter(item -> item.getCreateTime().compareTo(calling.getCreateTime()) < 0 ) // 时间在当前叫号之前
|
||||||
|
.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建一个Map来保存叫号中的记录及其前面排队的人数
|
||||||
|
Map<String, Object> map = BeanUtil.beanToMap(calling, false, false);
|
||||||
|
map.put("waitingCount", waitingCount);
|
||||||
|
// 将该map加入结果集
|
||||||
|
resultList.add(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> toMap = BeanUtil.beanToMap(pageInfo, false, false);
|
||||||
|
toMap.put("records", resultList);
|
||||||
|
|
||||||
|
// 返回结果列表
|
||||||
|
return toMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getCallRecord(Integer shopId, Integer callTableId, Integer page, Integer size) {
|
||||||
|
return tbCallQueueMapper.selectCallRecord(shopId, callTableId, new Page<>(page, size));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TbCallConfig getConfig(Integer shopId) {
|
||||||
|
TbCallConfig config = tbCallConfigService.lambdaQuery().eq(TbCallConfig::getShopId, shopId).one();
|
||||||
|
if (config == null) {
|
||||||
|
config = new TbCallConfig();
|
||||||
|
config.setShopId(shopId);
|
||||||
|
config.setCreateTime(DateUtil.date());
|
||||||
|
tbCallConfigService.save(config);
|
||||||
|
config = tbCallConfigService.lambdaQuery().eq(TbCallConfig::getShopId, shopId).one();
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object updateConfig(UpdateConfigDTO configDTO) {
|
||||||
|
TbCallConfig config = tbCallConfigService.lambdaQuery().eq(TbCallConfig::getShopId, configDTO.getShopId()).one();
|
||||||
|
if (config == null) {
|
||||||
|
throw new MsgException("未查询到配置信息");
|
||||||
|
}
|
||||||
|
|
||||||
|
TbCallConfig tbCallConfig = new TbCallConfig();
|
||||||
|
BeanUtil.copyProperties(configDTO, tbCallConfig);
|
||||||
|
tbCallConfig.setId(config.getId());
|
||||||
|
tbCallConfig.setUpdateTime(DateUtil.date());
|
||||||
|
return tbCallConfigService.updateById(tbCallConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCallTable;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCallTableService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mapper.TbCallTableMapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Administrator
|
||||||
|
* @description 针对表【tb_call_table(叫号桌型表)】的数据库操作Service实现
|
||||||
|
* @createDate 2024-12-10 10:12:45
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TbCallTableServiceImpl extends ServiceImpl<TbCallTableMapper, TbCallTable>
|
||||||
|
implements TbCallTableService{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,347 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.map.MapProxy;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditBuyer;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditBuyerOrder;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditPaymentRecord;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.CreditBuyerOrderDTO;
|
||||||
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mapper.TbCreditBuyerMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mapper.TbCreditBuyerOrderMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mapper.TbCreditPaymentRecordMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.MpOrderInfoService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCreditBuyerOrderService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCreditBuyerService;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账账单
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TbCreditBuyerOrderServiceImpl extends ServiceImpl<TbCreditBuyerOrderMapper, TbCreditBuyerOrder> implements TbCreditBuyerOrderService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbCreditBuyerService tbCreditBuyerService;
|
||||||
|
@Autowired
|
||||||
|
private TbCreditBuyerMapper tbCreditBuyerMapper;
|
||||||
|
@Autowired
|
||||||
|
private TbCreditBuyerOrderMapper tbCreditBuyerOrderMapper;
|
||||||
|
@Autowired
|
||||||
|
private TbCreditPaymentRecordMapper tbCreditPaymentRecordMapper;
|
||||||
|
@Autowired
|
||||||
|
private MpOrderInfoService mpOrderInfoService;
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<TbCreditBuyerOrder> getWrapper(Map<String, Object> params) {
|
||||||
|
MapProxy mapProxy = MapProxy.create(params);
|
||||||
|
String beginDate = mapProxy.getStr("beginDate");
|
||||||
|
String endDate = mapProxy.getStr("endDate");
|
||||||
|
TbCreditBuyerOrder param = BeanUtil.toBean(params, TbCreditBuyerOrder.class);
|
||||||
|
LambdaQueryWrapper<TbCreditBuyerOrder> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.orderByDesc(TbCreditBuyerOrder::getOrderId);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageInfo<CreditBuyerOrderDTO> page(Map<String, Object> params) {
|
||||||
|
MapProxy mapProxy = MapProxy.create(params);
|
||||||
|
int pageNum = mapProxy.getInt("page", 1);
|
||||||
|
int pageSize = mapProxy.getInt("size", 10);
|
||||||
|
PageInfo<CreditBuyerOrderDTO> pageInfo = PageHelper.startPage(pageNum, pageSize).setOrderBy("order_id desc").doSelectPageInfo(() -> baseMapper.getList(params));
|
||||||
|
return pageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> summary(Map<String, Object> params) {
|
||||||
|
long count = baseMapper.getCount(params);
|
||||||
|
Map<String, Object> data = new HashMap<>(5);
|
||||||
|
// 总交易笔数
|
||||||
|
data.put("count", count);
|
||||||
|
// 总交易金额
|
||||||
|
BigDecimal payAmount = baseMapper.getSumPayAmount(params);
|
||||||
|
data.put("payAmountTotal", payAmount);
|
||||||
|
|
||||||
|
// 待支付笔数
|
||||||
|
params.put("statusList", Arrays.asList("unpaid", "partial"));
|
||||||
|
long unpaidCount = baseMapper.getCount(params);
|
||||||
|
data.put("unpaidCount", unpaidCount);
|
||||||
|
params.put("statusList", Arrays.asList("paid", "partial"));
|
||||||
|
BigDecimal paidAmount = baseMapper.getSumPaidAmount(params);
|
||||||
|
params.put("statusList", Arrays.asList("unpaid", "partial"));
|
||||||
|
BigDecimal unpaidAmount = baseMapper.getSumUnpaidAmount(params);
|
||||||
|
data.put("paidAmountTotal", paidAmount);
|
||||||
|
data.put("unpaidAmountTotal", unpaidAmount);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void pay(TbCreditPaymentRecord record) {
|
||||||
|
try {
|
||||||
|
Assert.notNull(record.getCreditBuyerId(), "{}({})不能为空", "挂账人id", "creditBuyerId");
|
||||||
|
Assert.notNull(record.getOrderId(), "{}({})不能为空", "订单id", "orderId");
|
||||||
|
Assert.notNull(record.getRepaymentAmount(), "{}({})不能为空", "还款金额", "repaymentAmount");
|
||||||
|
Assert.notEmpty(record.getPaymentMethod(), "{}({})不能为空", "支付方式", "paymentMethod");
|
||||||
|
//Assert.notNull(record.getPaymentTime(), "{}({})不能为空", "还款时间", "paymentTime");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new MsgException(e.getMessage());
|
||||||
|
}
|
||||||
|
TbCreditBuyer creditBuyer = tbCreditBuyerMapper.selectById(record.getCreditBuyerId());
|
||||||
|
if (creditBuyer == null) {
|
||||||
|
throw new MsgException("挂账人不存在");
|
||||||
|
}
|
||||||
|
String repaymentMethod = creditBuyer.getRepaymentMethod();
|
||||||
|
if (!"order".equals(repaymentMethod)) {
|
||||||
|
throw new MsgException("该挂账人不支持按订单付款");
|
||||||
|
}
|
||||||
|
Map<String, Object> params = new HashMap<>(2);
|
||||||
|
params.put("creditBuyerId", record.getCreditBuyerId());
|
||||||
|
params.put("orderId", record.getOrderId());
|
||||||
|
CreditBuyerOrderDTO dto = baseMapper.getOne(params);
|
||||||
|
if (dto == null) {
|
||||||
|
throw new MsgException("挂账订单不存在");
|
||||||
|
}
|
||||||
|
if ("paid".equals(dto.getStatus())) {
|
||||||
|
throw new MsgException("挂账订单已还清,无需还款");
|
||||||
|
}
|
||||||
|
if (NumberUtil.isLess(record.getRepaymentAmount(), BigDecimal.ZERO)) {
|
||||||
|
throw new MsgException("还款金额不能小于0");
|
||||||
|
}
|
||||||
|
if (NumberUtil.isGreater(record.getRepaymentAmount(), dto.getUnpaidAmount())) {
|
||||||
|
throw new MsgException("还款金额不能大于未支付金额");
|
||||||
|
}
|
||||||
|
TbCreditBuyerOrder entity = new TbCreditBuyerOrder();
|
||||||
|
BeanUtil.copyProperties(dto, entity);
|
||||||
|
if (NumberUtil.equals(record.getRepaymentAmount(), dto.getUnpaidAmount())) {
|
||||||
|
entity.setStatus("paid");
|
||||||
|
} else {
|
||||||
|
entity.setStatus("partial");
|
||||||
|
}
|
||||||
|
entity.setPaidAmount(NumberUtil.add(entity.getPaidAmount(), record.getRepaymentAmount()));
|
||||||
|
entity.setLastPaymentTime(new Date());
|
||||||
|
entity.setLastPaymentMethod(record.getPaymentMethod());
|
||||||
|
entity.setRemark(record.getRemark());
|
||||||
|
super.updateById(entity);
|
||||||
|
record.setCreateTime(new Date());
|
||||||
|
record.setPaymentTime(new Date());
|
||||||
|
tbCreditPaymentRecordMapper.insert(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean save(String creditBuyerId, Long orderId) {
|
||||||
|
if (StrUtil.isBlank(creditBuyerId)) {
|
||||||
|
throw new MsgException("挂账人id不能为空");
|
||||||
|
}
|
||||||
|
TbCreditBuyer creditBuyer = tbCreditBuyerService.getById(creditBuyerId);
|
||||||
|
if (creditBuyer == null) {
|
||||||
|
throw new MsgException("挂账人不存在");
|
||||||
|
}
|
||||||
|
Integer delFlag = creditBuyer.getDelFlag();
|
||||||
|
if (delFlag != null && delFlag == 1) {
|
||||||
|
throw new MsgException("挂账人已删除");
|
||||||
|
}
|
||||||
|
Integer status = creditBuyer.getStatus();
|
||||||
|
if (status != null && status == 0) {
|
||||||
|
throw new MsgException("挂账人已被停用");
|
||||||
|
}
|
||||||
|
TbOrderInfo orderInfo = mpOrderInfoService.getById(orderId);
|
||||||
|
if (orderInfo == null) {
|
||||||
|
throw new MsgException("订单不存在");
|
||||||
|
}
|
||||||
|
// 账户余额
|
||||||
|
BigDecimal accountBalance = creditBuyer.getAccountBalance();
|
||||||
|
// 如果有余额的话,从余额里面扣除,没有余额的话,从信用额度里面扣除,余额和信用额度都为0,则不允许挂账,余额+信用额度刚好够支付这笔订单的话需要同时减余额减信用额度
|
||||||
|
if (NumberUtil.isGreaterOrEqual(accountBalance, orderInfo.getOrderAmount())) {
|
||||||
|
// 减余额
|
||||||
|
creditBuyer.setAccountBalance(NumberUtil.sub(accountBalance, orderInfo.getOrderAmount()));
|
||||||
|
tbCreditBuyerMapper.updateById(creditBuyer);
|
||||||
|
// 记录还款记录
|
||||||
|
TbCreditPaymentRecord record = new TbCreditPaymentRecord();
|
||||||
|
record.setCreditBuyerId(creditBuyerId);
|
||||||
|
record.setOrderId(orderId);
|
||||||
|
record.setRepaymentAmount(orderInfo.getOrderAmount());
|
||||||
|
record.setPaymentMethod("余额支付");
|
||||||
|
record.setPaymentTime(new Date());
|
||||||
|
record.setRemark("挂账时余额充足,直接从余额扣除");
|
||||||
|
record.setCreateTime(new Date());
|
||||||
|
tbCreditPaymentRecordMapper.insert(record);
|
||||||
|
TbCreditBuyerOrder entity = new TbCreditBuyerOrder();
|
||||||
|
entity.setCreditBuyerId(creditBuyerId);
|
||||||
|
entity.setOrderId(orderId);
|
||||||
|
entity.setPaidAmount(orderInfo.getOrderAmount());
|
||||||
|
entity.setStatus("paid");
|
||||||
|
entity.setLastPaymentTime(new Date());
|
||||||
|
entity.setLastPaymentMethod(record.getPaymentMethod());
|
||||||
|
entity.setRemark(record.getRemark());
|
||||||
|
return super.save(entity);
|
||||||
|
}
|
||||||
|
TbCreditBuyerOrder entity = null;
|
||||||
|
if (NumberUtil.isGreater(accountBalance, BigDecimal.ZERO)) {
|
||||||
|
// 减余额
|
||||||
|
creditBuyer.setAccountBalance(BigDecimal.ZERO);
|
||||||
|
tbCreditBuyerMapper.updateById(creditBuyer);
|
||||||
|
// 记录还款记录
|
||||||
|
TbCreditPaymentRecord record = new TbCreditPaymentRecord();
|
||||||
|
record.setCreditBuyerId(creditBuyerId);
|
||||||
|
record.setOrderId(orderId);
|
||||||
|
record.setRepaymentAmount(accountBalance);
|
||||||
|
record.setPaymentMethod("余额支付");
|
||||||
|
record.setPaymentTime(new Date());
|
||||||
|
record.setRemark("挂账时余额不足,先扣除现有余额,其他的从挂账额度中扣除");
|
||||||
|
record.setCreateTime(new Date());
|
||||||
|
tbCreditPaymentRecordMapper.insert(record);
|
||||||
|
entity = new TbCreditBuyerOrder();
|
||||||
|
entity.setCreditBuyerId(creditBuyerId);
|
||||||
|
entity.setOrderId(orderId);
|
||||||
|
entity.setPaidAmount(accountBalance);
|
||||||
|
entity.setStatus("partial");
|
||||||
|
entity.setLastPaymentTime(new Date());
|
||||||
|
entity.setLastPaymentMethod(record.getPaymentMethod());
|
||||||
|
entity.setRemark(record.getRemark());
|
||||||
|
//super.save(entity);
|
||||||
|
orderInfo.setPayAmount(NumberUtil.sub(orderInfo.getOrderAmount(), accountBalance));
|
||||||
|
}
|
||||||
|
// 剩余挂账额度
|
||||||
|
BigDecimal remainingAmount = creditBuyer.getRemainingAmount();
|
||||||
|
// 验证挂账金额是否大于剩余额度
|
||||||
|
boolean greater = NumberUtil.isGreater(orderInfo.getOrderAmount(), remainingAmount);
|
||||||
|
if (greater) {
|
||||||
|
throw new MsgException(StrUtil.format("{}:¥{}不能大于剩余挂账额度({})", "挂账金额", orderInfo.getOrderAmount(), remainingAmount));
|
||||||
|
}
|
||||||
|
if (entity == null) {
|
||||||
|
entity = new TbCreditBuyerOrder();
|
||||||
|
entity.setStatus("unpaid");
|
||||||
|
entity.setPaidAmount(BigDecimal.ZERO);
|
||||||
|
entity.setCreditBuyerId(creditBuyerId);
|
||||||
|
entity.setOrderId(orderId);
|
||||||
|
}
|
||||||
|
return super.saveOrUpdate(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean refund(String creditBuyerId, Long orderId) {
|
||||||
|
if (StrUtil.isBlank(creditBuyerId)) {
|
||||||
|
throw new MsgException("挂账人id不能为空");
|
||||||
|
}
|
||||||
|
TbCreditBuyer creditBuyer = tbCreditBuyerService.getById(creditBuyerId);
|
||||||
|
if (creditBuyer == null) {
|
||||||
|
throw new MsgException("挂账人不存在");
|
||||||
|
}
|
||||||
|
TbOrderInfo orderInfo = mpOrderInfoService.getById(orderId);
|
||||||
|
if (orderInfo == null) {
|
||||||
|
throw new MsgException("订单不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> params = new HashMap<>(2);
|
||||||
|
params.put("creditBuyerId", creditBuyerId);
|
||||||
|
params.put("orderId", orderId);
|
||||||
|
CreditBuyerOrderDTO dto = baseMapper.getOne(params);
|
||||||
|
if (dto == null) {
|
||||||
|
throw new MsgException("挂账订单不存在");
|
||||||
|
}
|
||||||
|
// 1.只挂账未还款的情况,直接删除挂账订单
|
||||||
|
if ("unpaid".equals(dto.getStatus())) {
|
||||||
|
baseMapper.deleteById(dto.getId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// 2.部分还款/已还款,删除挂账订单+红冲还款记录,并把已还款金额退回余额或挂账额度
|
||||||
|
if ("partial".equals(dto.getStatus()) || "paid".equals(dto.getStatus())) {
|
||||||
|
// 已还款金额
|
||||||
|
BigDecimal paidAmount = dto.getPaidAmount();
|
||||||
|
// 已还款金额进行红冲
|
||||||
|
TbCreditPaymentRecord record = new TbCreditPaymentRecord();
|
||||||
|
record.setCreditBuyerId(creditBuyerId);
|
||||||
|
record.setOrderId(orderId);
|
||||||
|
record.setRepaymentAmount(NumberUtil.sub(BigDecimal.ZERO, paidAmount));
|
||||||
|
record.setPaymentMethod("挂账退款");
|
||||||
|
record.setPaymentTime(new Date());
|
||||||
|
record.setRemark(StrUtil.format("挂账订单:{}申请退款,已归还挂账额度或账户余额", orderInfo.getOrderNo()));
|
||||||
|
record.setCreateTime(new Date());
|
||||||
|
tbCreditPaymentRecordMapper.insert(record);
|
||||||
|
// 删除挂账订单,恢复挂账额度
|
||||||
|
baseMapper.deleteById(dto.getId());
|
||||||
|
// 退回余额
|
||||||
|
creditBuyer.setAccountBalance(NumberUtil.add(creditBuyer.getAccountBalance(), paidAmount));
|
||||||
|
tbCreditBuyerService.updateById(creditBuyer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean partRefund(String creditBuyerId, Long orderId, BigDecimal refundAmount) {
|
||||||
|
if (StrUtil.isBlank(creditBuyerId)) {
|
||||||
|
throw new MsgException("挂账人id不能为空");
|
||||||
|
}
|
||||||
|
TbCreditBuyer creditBuyer = tbCreditBuyerService.getById(creditBuyerId);
|
||||||
|
if (creditBuyer == null) {
|
||||||
|
throw new MsgException("挂账人不存在");
|
||||||
|
}
|
||||||
|
TbOrderInfo orderInfo = mpOrderInfoService.getById(orderId);
|
||||||
|
if (orderInfo == null) {
|
||||||
|
throw new MsgException("订单不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> params = new HashMap<>(2);
|
||||||
|
params.put("creditBuyerId", creditBuyerId);
|
||||||
|
params.put("orderId", orderId);
|
||||||
|
CreditBuyerOrderDTO dto = baseMapper.getOne(params);
|
||||||
|
if (dto == null) {
|
||||||
|
throw new MsgException("挂账订单不存在");
|
||||||
|
}
|
||||||
|
// 已还款金额进行红冲
|
||||||
|
TbCreditPaymentRecord record = new TbCreditPaymentRecord();
|
||||||
|
record.setCreditBuyerId(creditBuyerId);
|
||||||
|
record.setOrderId(orderId);
|
||||||
|
record.setRepaymentAmount(NumberUtil.sub(BigDecimal.ZERO, refundAmount));
|
||||||
|
record.setPaymentMethod("挂账退款");
|
||||||
|
record.setPaymentTime(new Date());
|
||||||
|
record.setRemark(StrUtil.format("挂账订单:{},申请退款¥{}元,已恢复挂账额度。", orderInfo.getOrderNo(), refundAmount));
|
||||||
|
record.setCreateTime(new Date());
|
||||||
|
tbCreditPaymentRecordMapper.insert(record);
|
||||||
|
dto = baseMapper.getOne(params);
|
||||||
|
BigDecimal sub = NumberUtil.sub(refundAmount, dto.getUnpaidAmount());
|
||||||
|
if (NumberUtil.isGreater(sub, BigDecimal.ZERO)) {
|
||||||
|
TbCreditPaymentRecord flow = new TbCreditPaymentRecord();
|
||||||
|
flow.setCreditBuyerId(creditBuyerId);
|
||||||
|
flow.setOrderId(orderId);
|
||||||
|
flow.setRepaymentAmount(sub);
|
||||||
|
flow.setPaymentMethod("转储余额");
|
||||||
|
flow.setPaymentTime(new Date());
|
||||||
|
flow.setRemark(StrUtil.format("挂账订单:{},申请退款¥{}元,由于此挂账订单已提前还款,溢出部分¥{}元将转储至账户余额。", orderInfo.getOrderNo(), refundAmount, sub));
|
||||||
|
flow.setCreateTime(new Date());
|
||||||
|
tbCreditPaymentRecordMapper.insert(flow);
|
||||||
|
tbCreditBuyerOrderMapper.update(null, Wrappers.<TbCreditBuyerOrder>lambdaUpdate()
|
||||||
|
.eq(TbCreditBuyerOrder::getId, dto.getId())
|
||||||
|
.set(TbCreditBuyerOrder::getPaidAmount, NumberUtil.sub(dto.getPaidAmount(), sub))
|
||||||
|
);
|
||||||
|
// 退回余额
|
||||||
|
creditBuyer.setAccountBalance(NumberUtil.add(creditBuyer.getAccountBalance(), sub));
|
||||||
|
tbCreditBuyerService.updateById(creditBuyer);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,303 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.lang.Assert;
|
||||||
|
import cn.hutool.core.lang.Validator;
|
||||||
|
import cn.hutool.core.map.MapProxy;
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditBuyer;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditBuyerOrder;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditPaymentRecord;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.CreditBuyerOrderDTO;
|
||||||
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mapper.TbCreditBuyerMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mapper.TbCreditBuyerOrderMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mapper.TbCreditPaymentRecordMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCreditBuyerService;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账人
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TbCreditBuyerServiceImpl extends ServiceImpl<TbCreditBuyerMapper, TbCreditBuyer> implements TbCreditBuyerService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbCreditBuyerOrderMapper tbCreditBuyerOrderMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbCreditPaymentRecordMapper tbCreditPaymentRecordMapper;
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<TbCreditBuyer> getWrapper(Map<String, Object> params) {
|
||||||
|
MapProxy mapProxy = MapProxy.create(params);
|
||||||
|
String keywords = mapProxy.getStr("keywords");
|
||||||
|
String repaymentStatus = mapProxy.getStr("repaymentStatus");
|
||||||
|
TbCreditBuyer param = BeanUtil.toBean(params, TbCreditBuyer.class);
|
||||||
|
|
||||||
|
LambdaQueryWrapper<TbCreditBuyer> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(TbCreditBuyer::getShopId, param.getShopId());
|
||||||
|
wrapper.eq(StrUtil.isNotEmpty(param.getId()), TbCreditBuyer::getId, param.getId());
|
||||||
|
wrapper.like(StrUtil.isNotEmpty(param.getResponsiblePerson()), TbCreditBuyer::getResponsiblePerson, param.getResponsiblePerson());
|
||||||
|
wrapper.eq(param.getStatus() != null, TbCreditBuyer::getStatus, param.getStatus());
|
||||||
|
if (StrUtil.isNotEmpty(keywords)) {
|
||||||
|
wrapper.nested(i -> i.like(TbCreditBuyer::getDebtor, keywords).or().like(TbCreditBuyer::getMobile, keywords));
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotEmpty(repaymentStatus)) {
|
||||||
|
if ("unpaid".equals(repaymentStatus)) {
|
||||||
|
wrapper.apply("0 < ifnull((select x.count from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'unpaid'),0)");
|
||||||
|
wrapper.apply("0 = ifnull((select x.count from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'partial'),0)");
|
||||||
|
} else if ("partial".equals(repaymentStatus)) {
|
||||||
|
wrapper.apply("0 < ifnull((select x.count from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status = 'partial'),0)");
|
||||||
|
} else if ("paid".equals(repaymentStatus)) {
|
||||||
|
wrapper.apply("0 = ifnull((select sum(x.count) from view_credit_buyer_order_count x where x.credit_buyer_id = tb_credit_buyer.id and x.status in ('unpaid','partial')),0)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.eq(TbCreditBuyer::getDelFlag, 0);
|
||||||
|
wrapper.select(TbCreditBuyer::getId, TbCreditBuyer::getShopId, TbCreditBuyer::getStatus, TbCreditBuyer::getDebtor, TbCreditBuyer::getMobile, TbCreditBuyer::getPosition, TbCreditBuyer::getCreditAmount, TbCreditBuyer::getRepaymentMethod, TbCreditBuyer::getPaymentMethod, TbCreditBuyer::getRemark, TbCreditBuyer::getDelFlag, TbCreditBuyer::getOwedAmount, TbCreditBuyer::getAccumulateAmount, TbCreditBuyer::getShopName, TbCreditBuyer::getResponsiblePerson, TbCreditBuyer::getAccountBalance);
|
||||||
|
wrapper.orderByDesc(TbCreditBuyer::getStatus);
|
||||||
|
wrapper.orderByDesc(TbCreditBuyer::getId);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageInfo<TbCreditBuyer> page(Map<String, Object> params) {
|
||||||
|
MapProxy mapProxy = MapProxy.create(params);
|
||||||
|
int pageNum = mapProxy.getInt("page", 1);
|
||||||
|
int pageSize = mapProxy.getInt("size", 10);
|
||||||
|
LambdaQueryWrapper<TbCreditBuyer> wrapper = getWrapper(params);
|
||||||
|
PageInfo<TbCreditBuyer> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> baseMapper.selectList(wrapper));
|
||||||
|
return pageInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void commonVerify(TbCreditBuyer entity) {
|
||||||
|
try {
|
||||||
|
Assert.notNull(entity.getShopId(), "{}({})不能为空", "店铺id", "shopId");
|
||||||
|
Assert.notNull(entity.getStatus(), "{}({})不能为空", "状态", "status");
|
||||||
|
Assert.notEmpty(entity.getDebtor(), "{}({})不能为空", "挂账人", "debtor");
|
||||||
|
Assert.notEmpty(entity.getMobile(), "{}({})不能为空", "手机号", "mobile");
|
||||||
|
Assert.notNull(entity.getCreditAmount(), "{}({})不能为空", "挂账额度", "creditAmount");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new MsgException(e.getMessage());
|
||||||
|
}
|
||||||
|
if (!Validator.isMobile(entity.getMobile())) {
|
||||||
|
throw new MsgException(StrUtil.format("{}({})不合法", "手机号", "mobile"));
|
||||||
|
}
|
||||||
|
if (NumberUtil.isLessOrEqual(entity.getCreditAmount(), BigDecimal.ZERO)) {
|
||||||
|
throw new MsgException(StrUtil.format("{}({})必须大于0", "挂账额度", "creditAmount"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean save(TbCreditBuyer entity) {
|
||||||
|
commonVerify(entity);
|
||||||
|
try {
|
||||||
|
Assert.notEmpty(entity.getRepaymentMethod(), "{}({})不能为空", "还款方式", "repaymentMethod");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new MsgException(e.getMessage());
|
||||||
|
}
|
||||||
|
if (!ArrayUtil.contains(new String[]{"total", "order"}, entity.getRepaymentMethod())) {
|
||||||
|
throw new MsgException(StrUtil.format("{}({})不合法", "还款方式", "repaymentMethod"));
|
||||||
|
}
|
||||||
|
entity.setAccountBalance(BigDecimal.ZERO);
|
||||||
|
return super.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(TbCreditBuyer dto) {
|
||||||
|
try {
|
||||||
|
Assert.notEmpty(dto.getId(), "{}不能为空", "id");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new MsgException(e.getMessage());
|
||||||
|
}
|
||||||
|
commonVerify(dto);
|
||||||
|
TbCreditBuyer entity = super.getById(dto.getId());
|
||||||
|
if (entity == null) {
|
||||||
|
throw new MsgException("挂账人不存在");
|
||||||
|
}
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("id", dto.getId());
|
||||||
|
params.put("shopId", dto.getShopId());
|
||||||
|
LambdaQueryWrapper<TbCreditBuyer> wrapper = getWrapper(params);
|
||||||
|
entity = baseMapper.selectOne(wrapper);
|
||||||
|
|
||||||
|
// 验证挂账额度是否小于已挂账金额
|
||||||
|
boolean less = NumberUtil.isLess(dto.getCreditAmount(), NumberUtil.null2Zero(entity.getOwedAmount()));
|
||||||
|
if (less) {
|
||||||
|
throw new MsgException(StrUtil.format("{}({})不能小于已挂账金额({})", "挂账额度", "creditAmount", entity.getOwedAmount()));
|
||||||
|
}
|
||||||
|
BeanUtil.copyProperties(dto, entity, CopyOptions.create().setIgnoreNullValue(false).setIgnoreProperties("repaymentMethod", "accountBalance"));
|
||||||
|
return super.updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(String id) {
|
||||||
|
try {
|
||||||
|
Assert.notEmpty(id, "{}不能为空", "id");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new MsgException(e.getMessage());
|
||||||
|
}
|
||||||
|
super.update(Wrappers.<TbCreditBuyer>lambdaUpdate().set(TbCreditBuyer::getDelFlag, 1).eq(TbCreditBuyer::getId, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TbCreditBuyer getById(String id) {
|
||||||
|
LambdaQueryWrapper<TbCreditBuyer> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(TbCreditBuyer::getId, id);
|
||||||
|
wrapper.select(TbCreditBuyer::getId, TbCreditBuyer::getShopId, TbCreditBuyer::getStatus, TbCreditBuyer::getDebtor, TbCreditBuyer::getMobile, TbCreditBuyer::getPosition, TbCreditBuyer::getCreditAmount, TbCreditBuyer::getRepaymentMethod, TbCreditBuyer::getPaymentMethod, TbCreditBuyer::getRemark, TbCreditBuyer::getDelFlag, TbCreditBuyer::getOwedAmount, TbCreditBuyer::getAccumulateAmount, TbCreditBuyer::getShopName, TbCreditBuyer::getResponsiblePerson, TbCreditBuyer::getAccountBalance);
|
||||||
|
return baseMapper.selectOne(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Map<String, Object> repayment(Map<String, Object> params) {
|
||||||
|
MapProxy mapProxy = MapProxy.create(params);
|
||||||
|
// 还款金额
|
||||||
|
BigDecimal repaymentAmount = mapProxy.getBigDecimal("repaymentAmount");
|
||||||
|
TbCreditBuyer param = BeanUtil.toBean(params, TbCreditBuyer.class);
|
||||||
|
try {
|
||||||
|
Assert.notEmpty(param.getId(), "{}不能为空", "id");
|
||||||
|
Assert.notNull(repaymentAmount, "{}({})不能为空", "还款金额", "repaymentAmount");
|
||||||
|
Assert.notNull(param.getPaymentMethod(), "{}({})不能为空", "支付方式", "paymentMethod");
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
throw new MsgException(e.getMessage());
|
||||||
|
}
|
||||||
|
TbCreditBuyer entity = getById(param.getId());
|
||||||
|
if (entity == null) {
|
||||||
|
throw new MsgException("挂账人不存在");
|
||||||
|
}
|
||||||
|
Integer delFlag = entity.getDelFlag();
|
||||||
|
if (delFlag == 1) {
|
||||||
|
throw new MsgException("挂账人已删除");
|
||||||
|
}
|
||||||
|
if (!"total".equals(entity.getRepaymentMethod())) {
|
||||||
|
throw new MsgException("此挂账人不能以【按总账户还款】进行还款");
|
||||||
|
}
|
||||||
|
if (NumberUtil.isLess(repaymentAmount, BigDecimal.ZERO)) {
|
||||||
|
throw new MsgException("还款金额不能小于0");
|
||||||
|
}
|
||||||
|
BigDecimal initRepaymentAmount = NumberUtil.add(repaymentAmount, BigDecimal.ZERO);
|
||||||
|
// 已挂账金额
|
||||||
|
BigDecimal owedAmount = entity.getOwedAmount();
|
||||||
|
if (NumberUtil.equals(owedAmount, BigDecimal.ZERO)) {
|
||||||
|
entity.setAccountBalance(NumberUtil.add(entity.getAccountBalance(), repaymentAmount));
|
||||||
|
super.updateById(entity);
|
||||||
|
TbCreditPaymentRecord record = new TbCreditPaymentRecord();
|
||||||
|
record.setCreditBuyerId(param.getId());
|
||||||
|
record.setRepaymentAmount(repaymentAmount);
|
||||||
|
record.setPaymentMethod(param.getPaymentMethod());
|
||||||
|
record.setCreateTime(new Date());
|
||||||
|
record.setPaymentTime(new Date());
|
||||||
|
record.setRemark(param.getRemark());
|
||||||
|
tbCreditPaymentRecordMapper.insert(record);
|
||||||
|
Map<String, Object> result = new HashMap<>(3);
|
||||||
|
result.put("repaymentCount", 0);
|
||||||
|
result.put("repaymentAmount", repaymentAmount);
|
||||||
|
result.put("repaymentMsg", StrUtil.format("账单无需还款,{}元已转储至余额。", repaymentAmount));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// 转存余额
|
||||||
|
BigDecimal rechargeAmount = BigDecimal.ZERO;
|
||||||
|
if (NumberUtil.isGreater(repaymentAmount, owedAmount)) {
|
||||||
|
rechargeAmount = NumberUtil.sub(repaymentAmount, owedAmount);
|
||||||
|
entity.setAccountBalance(NumberUtil.add(entity.getAccountBalance(), rechargeAmount));
|
||||||
|
super.updateById(entity);
|
||||||
|
TbCreditPaymentRecord record = new TbCreditPaymentRecord();
|
||||||
|
record.setCreditBuyerId(param.getId());
|
||||||
|
record.setRepaymentAmount(rechargeAmount);
|
||||||
|
record.setPaymentMethod(param.getPaymentMethod());
|
||||||
|
record.setCreateTime(new Date());
|
||||||
|
record.setPaymentTime(new Date());
|
||||||
|
record.setRemark(param.getRemark());
|
||||||
|
tbCreditPaymentRecordMapper.insert(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验完毕,可以批量还款
|
||||||
|
Map<String, Object> where = new HashMap<>();
|
||||||
|
where.put("creditBuyerId", param.getId());
|
||||||
|
where.put("statusList", Arrays.asList("unpaid", "partial"));
|
||||||
|
List<CreditBuyerOrderDTO> list = tbCreditBuyerOrderMapper.getList(where);
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
throw new MsgException("没有需要还款的订单");
|
||||||
|
}
|
||||||
|
int repaymentCount = 0;
|
||||||
|
List<CreditBuyerOrderDTO> orderList = list.stream().sorted(Comparator.comparing(CreditBuyerOrderDTO::getOrderId)).collect(Collectors.toList());
|
||||||
|
for (CreditBuyerOrderDTO dto : orderList) {
|
||||||
|
// 未付款金额
|
||||||
|
BigDecimal unpaidAmount = dto.getUnpaidAmount();
|
||||||
|
// 记录还款记录
|
||||||
|
TbCreditPaymentRecord record = new TbCreditPaymentRecord();
|
||||||
|
if (NumberUtil.isGreaterOrEqual(repaymentAmount, unpaidAmount)) {
|
||||||
|
// 还全额
|
||||||
|
tbCreditBuyerOrderMapper.update(null, Wrappers.<TbCreditBuyerOrder>lambdaUpdate()
|
||||||
|
.eq(TbCreditBuyerOrder::getStatus, dto.getStatus())
|
||||||
|
.eq(TbCreditBuyerOrder::getId, dto.getId())
|
||||||
|
.eq(TbCreditBuyerOrder::getOrderId, dto.getOrderId())
|
||||||
|
.eq(TbCreditBuyerOrder::getCreditBuyerId, dto.getCreditBuyerId())
|
||||||
|
.eq(TbCreditBuyerOrder::getPaidAmount, dto.getPaidAmount())
|
||||||
|
.set(TbCreditBuyerOrder::getStatus, "paid")
|
||||||
|
.set(TbCreditBuyerOrder::getPaidAmount, NumberUtil.add(dto.getPaidAmount(), unpaidAmount))
|
||||||
|
.set(TbCreditBuyerOrder::getRemark, param.getRemark())
|
||||||
|
.set(TbCreditBuyerOrder::getLastPaymentMethod, param.getPaymentMethod())
|
||||||
|
.set(TbCreditBuyerOrder::getLastPaymentTime, new Date())
|
||||||
|
);
|
||||||
|
record.setRepaymentAmount(unpaidAmount);
|
||||||
|
repaymentAmount = NumberUtil.sub(repaymentAmount, unpaidAmount);
|
||||||
|
} else if (NumberUtil.isLess(repaymentAmount, unpaidAmount)) {
|
||||||
|
// 还部分
|
||||||
|
tbCreditBuyerOrderMapper.update(null, Wrappers.<TbCreditBuyerOrder>lambdaUpdate()
|
||||||
|
.eq(TbCreditBuyerOrder::getStatus, dto.getStatus())
|
||||||
|
.eq(TbCreditBuyerOrder::getId, dto.getId())
|
||||||
|
.eq(TbCreditBuyerOrder::getOrderId, dto.getOrderId())
|
||||||
|
.eq(TbCreditBuyerOrder::getCreditBuyerId, dto.getCreditBuyerId())
|
||||||
|
.eq(TbCreditBuyerOrder::getPaidAmount, dto.getPaidAmount())
|
||||||
|
.set(TbCreditBuyerOrder::getStatus, "partial")
|
||||||
|
.set(TbCreditBuyerOrder::getPaidAmount, NumberUtil.add(dto.getPaidAmount(), repaymentAmount))
|
||||||
|
.set(TbCreditBuyerOrder::getRemark, param.getRemark())
|
||||||
|
.set(TbCreditBuyerOrder::getLastPaymentMethod, param.getPaymentMethod())
|
||||||
|
.set(TbCreditBuyerOrder::getLastPaymentTime, new Date())
|
||||||
|
);
|
||||||
|
record.setRepaymentAmount(repaymentAmount);
|
||||||
|
repaymentAmount = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
record.setCreditBuyerId(dto.getCreditBuyerId());
|
||||||
|
record.setOrderId(dto.getOrderId());
|
||||||
|
record.setPaymentMethod(param.getPaymentMethod());
|
||||||
|
record.setCreateTime(new Date());
|
||||||
|
record.setPaymentTime(new Date());
|
||||||
|
record.setRemark(param.getRemark());
|
||||||
|
tbCreditPaymentRecordMapper.insert(record);
|
||||||
|
repaymentCount++;
|
||||||
|
if (NumberUtil.equals(repaymentAmount, BigDecimal.ZERO)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<String, Object> result = new HashMap<>(5);
|
||||||
|
BigDecimal payAmount = NumberUtil.sub(initRepaymentAmount, repaymentAmount);
|
||||||
|
result.put("repaymentCount", repaymentCount);
|
||||||
|
result.put("repaymentAmount", initRepaymentAmount);
|
||||||
|
result.put("payAmount", payAmount);
|
||||||
|
result.put("rechargeAmount", rechargeAmount);
|
||||||
|
result.put("repaymentMsg", StrUtil.format("共计还款{}笔,还款金额:{}元,支付欠款:{}元,转存余额:{}元,当前余额:{}元。", repaymentCount, initRepaymentAmount, payAmount, rechargeAmount, entity.getAccountBalance()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.map.MapProxy;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbCreditPaymentRecord;
|
||||||
|
import com.chaozhanggui.system.cashierservice.mapper.TbCreditPaymentRecordMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbCreditPaymentRecordService;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 挂账账单付款记录
|
||||||
|
*
|
||||||
|
* @author Tankaikai tankaikai@aliyun.com
|
||||||
|
* @since 2.0 2024-11-20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class TbCreditPaymentRecordServiceImpl extends ServiceImpl<TbCreditPaymentRecordMapper, TbCreditPaymentRecord> implements TbCreditPaymentRecordService {
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<TbCreditPaymentRecord> getWrapper(Map<String, Object> params) {
|
||||||
|
TbCreditPaymentRecord param = BeanUtil.toBean(params, TbCreditPaymentRecord.class);
|
||||||
|
LambdaQueryWrapper<TbCreditPaymentRecord> wrapper = Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(TbCreditPaymentRecord::getCreditBuyerId, param.getCreditBuyerId());
|
||||||
|
wrapper.eq(param.getOrderId() != null, TbCreditPaymentRecord::getOrderId, param.getOrderId());
|
||||||
|
wrapper.like(StrUtil.isNotEmpty(param.getPaymentMethod()), TbCreditPaymentRecord::getPaymentMethod, param.getPaymentMethod());
|
||||||
|
wrapper.orderByDesc(TbCreditPaymentRecord::getId);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageInfo<TbCreditPaymentRecord> page(Map<String, Object> params) {
|
||||||
|
MapProxy mapProxy = MapProxy.create(params);
|
||||||
|
int pageNum = mapProxy.getInt("page", 1);
|
||||||
|
int pageSize = mapProxy.getInt("size", 10);
|
||||||
|
LambdaQueryWrapper<TbCreditPaymentRecord> wrapper = getWrapper(params);
|
||||||
|
wrapper.orderByDesc(TbCreditPaymentRecord::getId);
|
||||||
|
PageInfo<TbCreditPaymentRecord> pageInfo = PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> baseMapper.selectList(wrapper));
|
||||||
|
return pageInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2018 人人开源 All rights reserved.
|
||||||
|
*
|
||||||
|
* https://www.renren.io
|
||||||
|
*
|
||||||
|
* 版权所有,侵权必究!
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.chaozhanggui.system.cashierservice.util;
|
||||||
|
|
||||||
|
import com.aliyun.oss.OSSClient;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云存储
|
||||||
|
*
|
||||||
|
* @author Mark sunlightcs@gmail.com
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class AliUploadUtils {
|
||||||
|
private static String secret;
|
||||||
|
private static String key;
|
||||||
|
private static String endPoint;
|
||||||
|
private static String bucketName;
|
||||||
|
private static String prefix;
|
||||||
|
private static String url;
|
||||||
|
|
||||||
|
// 构造器注入
|
||||||
|
public AliUploadUtils(@Value("${aliyun.keysecret}") String secret,
|
||||||
|
@Value("${aliyun.keyid}") String key,
|
||||||
|
@Value("${aliyun.oss.endpoint}") String endPoint,
|
||||||
|
@Value("${aliyun.oss.bucketname}") String bucketName,
|
||||||
|
@Value("${aliyun.prefix}") String prefix,
|
||||||
|
@Value("${aliyun.url}") String url) {
|
||||||
|
AliUploadUtils.secret = secret;
|
||||||
|
AliUploadUtils.key = key;
|
||||||
|
AliUploadUtils.endPoint = endPoint;
|
||||||
|
AliUploadUtils.bucketName = bucketName;
|
||||||
|
AliUploadUtils.prefix = prefix;
|
||||||
|
AliUploadUtils.url = url;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 文件路径
|
||||||
|
* @param prefix 前缀
|
||||||
|
* @param suffix 后缀
|
||||||
|
* @return 返回上传路径
|
||||||
|
*/
|
||||||
|
public static String getPath(String prefix, String suffix) {
|
||||||
|
//生成uuid
|
||||||
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
|
//文件路径
|
||||||
|
String path = DateUtils.getDays() + "/" + uuid;
|
||||||
|
|
||||||
|
if(StringUtils.isNotBlank(prefix)){
|
||||||
|
path = prefix + "/" + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return path + "." + suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String upload(InputStream inputStream, String path) throws Exception {
|
||||||
|
OSSClient client = new OSSClient(endPoint, key,
|
||||||
|
secret);
|
||||||
|
try {
|
||||||
|
client.putObject(bucketName, path, inputStream);
|
||||||
|
client.shutdown();
|
||||||
|
} catch (Exception e){
|
||||||
|
throw new Exception("上传异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
return "https://"+ url + "/" + path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String uploadSuffix(InputStream inputStream, String fileName) throws Exception {
|
||||||
|
return upload(inputStream, getPath(prefix, getFileExtension(fileName)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFileExtension(String fileName) {
|
||||||
|
int dotIndex = fileName.lastIndexOf(".");
|
||||||
|
if (dotIndex > 0) {
|
||||||
|
return fileName.substring(dotIndex).replace(".", "");
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.chaozhanggui.system.cashierservice.util;
|
package com.chaozhanggui.system.cashierservice.util;
|
||||||
|
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
|
|
||||||
public class PageHelperUtil {
|
public class PageHelperUtil {
|
||||||
@@ -7,7 +8,7 @@ public class PageHelperUtil {
|
|||||||
/**
|
/**
|
||||||
* 解决页数超限 仍返回数据问题
|
* 解决页数超限 仍返回数据问题
|
||||||
*/
|
*/
|
||||||
public static void startPage(int page, int pageSize) {
|
public static Page<Object> startPage(int page, int pageSize) {
|
||||||
PageHelper.startPage(page, pageSize, true, false, false);
|
return PageHelper.startPage(page, pageSize, true, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.util;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO;
|
||||||
import com.chaozhanggui.system.cashierservice.rabbit.RabbitConstants;
|
import com.chaozhanggui.system.cashierservice.rabbit.RabbitConstants;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||||
@@ -80,4 +81,20 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
|
|||||||
public void updateCons(JSONObject jsonObject1) {
|
public void updateCons(JSONObject jsonObject1) {
|
||||||
sendMsg(RabbitConstants.EXCHANGE_CONS, RabbitConstants.ROUTING_KEY_CONS, jsonObject1, "储值卡记录", true);
|
sendMsg(RabbitConstants.EXCHANGE_CONS, RabbitConstants.ROUTING_KEY_CONS, jsonObject1, "储值卡记录", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void printCallNumTicket(Integer callQueueId, Integer shopId) {
|
||||||
|
CallNumPrintDTO printDTO = new CallNumPrintDTO();
|
||||||
|
printDTO.setCallQueueId(callQueueId);
|
||||||
|
printDTO.setShopId(shopId);
|
||||||
|
try {
|
||||||
|
JSONObject currentUserInfo = TokenUtil.getCurrentUserInfo();
|
||||||
|
log.info("用户信息: {}", currentUserInfo);
|
||||||
|
printDTO.setCurrentUserId(currentUserInfo.getLong("accountId"));
|
||||||
|
printDTO.setCurrentUserName(currentUserInfo.getString("name"));
|
||||||
|
printDTO.setCurrentUserNickName(currentUserInfo.getString("nickname"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取当前用户信息失败", e);
|
||||||
|
}
|
||||||
|
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_CALL_TABLE, printDTO, "排号小票打印", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ public class RedisCst {
|
|||||||
// 选择人数锁
|
// 选择人数锁
|
||||||
public static final String CHOSE_TABLE_COUNT = "CHOSE_TABLE_COUNT";
|
public static final String CHOSE_TABLE_COUNT = "CHOSE_TABLE_COUNT";
|
||||||
|
|
||||||
|
// 排队取号全局号码
|
||||||
|
static String TABLE_CALL_NUMBER = "TABLE_CALL_NUMBER:";
|
||||||
|
|
||||||
|
|
||||||
public static String getCurrentOrderKey(String tableId, String shopId) {
|
public static String getCurrentOrderKey(String tableId, String shopId) {
|
||||||
@@ -50,4 +51,8 @@ public class RedisCst {
|
|||||||
}
|
}
|
||||||
return key.toString();
|
return key.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getTableCallNumKey(Integer shopId, Integer callTableId) {
|
||||||
|
return TABLE_CALL_NUMBER + shopId + ":" + callTableId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import io.jsonwebtoken.Claims;
|
|||||||
import io.jsonwebtoken.Jwts;
|
import io.jsonwebtoken.Jwts;
|
||||||
import io.jsonwebtoken.SignatureAlgorithm;
|
import io.jsonwebtoken.SignatureAlgorithm;
|
||||||
import org.springframework.cglib.beans.BeanMap;
|
import org.springframework.cglib.beans.BeanMap;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -106,4 +109,11 @@ public class TokenUtil {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
parseParamFromToken("eyJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50SWQiOiI2IiwiY2xpZW50VHlwZSI6InBjIiwic2hvcElkIjoiMTUiLCJleHAiOjE3MTA1ODc3NjAsImlhdCI6MTcwOTExNjUzMSwibG9naW5OYW1lIjoiMTg4MjE3Nzc4OCJ9.RXfyRgkfC13JGVypd9TQvbNNl_-btyQ-7xnvlj3ej0M");
|
parseParamFromToken("eyJhbGciOiJIUzI1NiJ9.eyJhY2NvdW50SWQiOiI2IiwiY2xpZW50VHlwZSI6InBjIiwic2hvcElkIjoiMTUiLCJleHAiOjE3MTA1ODc3NjAsImlhdCI6MTcwOTExNjUzMSwibG9naW5OYW1lIjoiMTg4MjE3Nzc4OCJ9.RXfyRgkfC13JGVypd9TQvbNNl_-btyQ-7xnvlj3ej0M");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JSONObject getCurrentUserInfo() {
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
String token = request.getHeader("token");
|
||||||
|
return parseParamFromToken(token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,12 @@ public class WxAccountUtil {
|
|||||||
private final TbShopMsgStateMapper shopMsgStateMapper;
|
private final TbShopMsgStateMapper shopMsgStateMapper;
|
||||||
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
|
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
@Value("${wx.mini.user.msgId.currentCall}")
|
||||||
|
private String currentCallTempId;
|
||||||
|
@Value("${wx.mini.user.msgId.nearCall}")
|
||||||
|
private String nearCallTempId;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
linkedHashMap.put("40001","获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口");
|
linkedHashMap.put("40001","获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口");
|
||||||
@@ -132,4 +138,76 @@ public class WxAccountUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendCurrentOrNearCallMsg(String shopName, String state, String callNum, String currentNum, String note, String openId, boolean isNear) {
|
||||||
|
Map<String, Object> data = new HashMap<String, Object>() {{
|
||||||
|
put("thing1", new HashMap<String, Object>() {{
|
||||||
|
put("value", shopName);
|
||||||
|
}});
|
||||||
|
put("phrase2", new HashMap<String, Object>() {{
|
||||||
|
put("value", state);
|
||||||
|
}});
|
||||||
|
put("character_string3", new HashMap<String, Object>() {{
|
||||||
|
put("value", callNum);
|
||||||
|
}});
|
||||||
|
put("character_string4", new HashMap<String, Object>() {{
|
||||||
|
put("value", currentNum);
|
||||||
|
}});
|
||||||
|
put("thing5", new HashMap<String, Object>() {{
|
||||||
|
put("value", note);
|
||||||
|
}});
|
||||||
|
}};
|
||||||
|
try {
|
||||||
|
sendTempMsg(isNear ? nearCallTempId : currentCallTempId, openId, data, "排队到号");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("发送失败, openId:{}, msg: {}", openId, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject sendTempMsg(String tempId, String toUserOpenId, Map<String, Object> data, String note) {
|
||||||
|
log.info("开始发送" + note + "模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
|
||||||
|
String accessToken= getAccessToken();
|
||||||
|
JSONObject object1=new JSONObject();
|
||||||
|
|
||||||
|
object1.put("template_id", tempId);
|
||||||
|
object1.put("touser", toUserOpenId);
|
||||||
|
object1.put("data",data);
|
||||||
|
|
||||||
|
object1.put("miniprogram_state","trial");
|
||||||
|
object1.put("lang","zh_CN");
|
||||||
|
|
||||||
|
String response= HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||||
|
log.info("微信模板消息发送成功,相应内容:{}",response);
|
||||||
|
JSONObject resObj=JSONObject.parseObject(response);
|
||||||
|
if(ObjectUtil.isNotEmpty(resObj)&&ObjectUtil.isNotNull(resObj)&&"0".equals(resObj.get("errcode")+"")){
|
||||||
|
return resObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendPassCallMsg(String shopName, String state, String callNum, String currentNum, String note, String openId) {
|
||||||
|
Map<String, Object> data = new HashMap<String, Object>() {{
|
||||||
|
put("thing1", new HashMap<String, Object>() {{
|
||||||
|
put("value", shopName);
|
||||||
|
}});
|
||||||
|
put("character_string2", new HashMap<String, Object>() {{
|
||||||
|
put("value", callNum);
|
||||||
|
}});
|
||||||
|
put("character_string3", new HashMap<String, Object>() {{
|
||||||
|
put("value", currentNum);
|
||||||
|
}});
|
||||||
|
put("phrase4", new HashMap<String, Object>() {{
|
||||||
|
put("value", state);
|
||||||
|
}});
|
||||||
|
put("thing5", new HashMap<String, Object>() {{
|
||||||
|
put("value", note);
|
||||||
|
}});
|
||||||
|
}};
|
||||||
|
try {
|
||||||
|
sendTempMsg(currentCallTempId, openId, data, "过号");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("发送失败, openId:{}, msg: {}", openId, e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ wx:
|
|||||||
secrete: a34a61adc0602118b49400baa8812454
|
secrete: a34a61adc0602118b49400baa8812454
|
||||||
warnMsgTmpId: AV-KybUHaK3KtFVLqpy6PHccHBS7XeX__mOM4RbufnQ
|
warnMsgTmpId: AV-KybUHaK3KtFVLqpy6PHccHBS7XeX__mOM4RbufnQ
|
||||||
mini:
|
mini:
|
||||||
|
user:
|
||||||
|
appId: wxd88fffa983758a30
|
||||||
|
secrete: a34a61adc0602118b49400baa8812454
|
||||||
|
msgId:
|
||||||
|
nearCall: yxOjWK-KjMEZ_BaHWqDJJpHiUPXN6JWqr7u9y65RIWM
|
||||||
|
currentCall: 3BgFazRpVlvreh5z9u4cNP_VeclXKSQfh-r3x2_bYx4
|
||||||
|
passCall: qUhvEfvCtIcBA3DOn3QMqsGOolrEpyr0YBh99i-AUqw
|
||||||
page:
|
page:
|
||||||
call: https://cashier.sxczgkj.cn/make?shopId={}&queueId={}
|
call: https://cashier.sxczgkj.cn/make?shopId={}&queueId={}
|
||||||
ali:
|
ali:
|
||||||
@@ -76,3 +83,13 @@ mybatis-plus:
|
|||||||
|
|
||||||
# php服务器地址
|
# php服务器地址
|
||||||
phpServer: https://czgdoumei.sxczgkj.com/index.php/api
|
phpServer: https://czgdoumei.sxczgkj.com/index.php/api
|
||||||
|
|
||||||
|
# oss配置
|
||||||
|
aliyun:
|
||||||
|
prefix: upload
|
||||||
|
keyid: LTAI5tPdEfYSZcqHbjCrtPRD
|
||||||
|
keysecret: DZjyHBq3nTujF0NMLxnZgsecU8ZCvy
|
||||||
|
url: cashier-oss.oss-cn-beijing.aliyuncs.com
|
||||||
|
oss:
|
||||||
|
bucketname: cashier-oss
|
||||||
|
endpoint: oss-cn-beijing.aliyuncs.com
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
limit 1
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="updateMemberPoints" resultType="int">
|
<select id="updateMemberPoints" resultType="integer">
|
||||||
update tb_shop_user set last_points_change_time = now(),last_float_points = #{points},account_points = account_points + ${points} where id = #{memberId}
|
update tb_shop_user set last_points_change_time = now(),last_float_points = #{points},account_points = account_points + ${points} where id = #{memberId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,13 @@
|
|||||||
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
||||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="isPostpone" column="is_postpone" jdbcType="TINYINT"/>
|
<result property="nearNum" column="near_num" jdbcType="INTEGER"/>
|
||||||
<result property="postponeNum" column="postpone_num" jdbcType="INTEGER"/>
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id,page_address,is_online,
|
id,page_address,is_online,
|
||||||
bg_cover,success_msg,near_msg,
|
bg_cover,success_msg,near_msg,
|
||||||
calling_msg,shop_id,create_time,
|
calling_msg,shop_id,create_time,
|
||||||
update_time,is_postpone,postpone_num
|
update_time,near_num
|
||||||
</sql>
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
<result property="confirmTime" column="confirm_time" jdbcType="TIMESTAMP"/>
|
<result property="confirmTime" column="confirm_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="callNum" column="call_num" jdbcType="VARCHAR"/>
|
<result property="callNum" column="call_num" jdbcType="VARCHAR"/>
|
||||||
<result property="createDay" column="create_day" jdbcType="VARCHAR"/>
|
<result property="createDay" column="create_day" jdbcType="VARCHAR"/>
|
||||||
|
<result property="isPostpone" column="is_postpone" jdbcType="TINYINT"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
@@ -33,6 +34,6 @@
|
|||||||
call_count,pass_time,cancel_time,
|
call_count,pass_time,cancel_time,
|
||||||
note,user_id,open_id,
|
note,user_id,open_id,
|
||||||
sub_state,confirm_time,call_num,
|
sub_state,confirm_time,call_num,
|
||||||
create_day
|
create_day,is_postpone
|
||||||
</sql>
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -17,12 +17,15 @@
|
|||||||
<result property="qrcode" column="qrcode" jdbcType="VARCHAR"/>
|
<result property="qrcode" column="qrcode" jdbcType="VARCHAR"/>
|
||||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||||
|
<result property="isPostpone" column="is_postpone" jdbcType="TINYINT"/>
|
||||||
|
<result property="postponeNum" column="postpone_num" jdbcType="INTEGER"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id,name,note,
|
id,name,note,
|
||||||
wait_time,prefix,start,
|
wait_time,prefix,start,
|
||||||
near_num,state,shop_id,
|
near_num,state,shop_id,
|
||||||
qrcode,create_time,update_time
|
qrcode,create_time,update_time,
|
||||||
|
is_postpone,postpone_num
|
||||||
</sql>
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
72
src/main/resources/mapper/TbCreditBuyerOrderMapper.xml
Normal file
72
src/main/resources/mapper/TbCreditBuyerOrderMapper.xml
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="com.chaozhanggui.system.cashierservice.mapper.TbCreditBuyerOrderMapper">
|
||||||
|
|
||||||
|
<sql id="commonWhere">
|
||||||
|
<where>
|
||||||
|
and t1.credit_buyer_id = #{creditBuyerId}
|
||||||
|
<if test="orderId != null and orderId != ''">
|
||||||
|
and t1.order_id = #{orderId}
|
||||||
|
</if>
|
||||||
|
<if test="beginDate != null and beginDate != ''">
|
||||||
|
and t1.create_time >= str_to_date(concat(#{beginDate},' 00:00:00'), '%Y-%m-%d %H:%i:%s')
|
||||||
|
</if>
|
||||||
|
<if test="endDate != null and endDate != ''">
|
||||||
|
<![CDATA[
|
||||||
|
and t1.create_time <= str_to_date(concat(#{endDate},' 23:59:59'), '%Y-%m-%d %H:%i:%s')
|
||||||
|
]]>
|
||||||
|
</if>
|
||||||
|
<if test="status != null and status != ''">
|
||||||
|
and t1.status = #{status}
|
||||||
|
</if>
|
||||||
|
<if test="statusList != null">
|
||||||
|
and t1.status in
|
||||||
|
<foreach item="status" collection="statusList" open="(" separator="," close=")">
|
||||||
|
#{status}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="id != null">
|
||||||
|
and t1.id = #{id}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="getOne" resultType="com.chaozhanggui.system.cashierservice.entity.dto.CreditBuyerOrderDTO">
|
||||||
|
select * from view_credit_buyer_order t1
|
||||||
|
<include refid="commonWhere" />
|
||||||
|
order by t1.order_id desc
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getList" resultType="com.chaozhanggui.system.cashierservice.entity.dto.CreditBuyerOrderDTO">
|
||||||
|
select * from view_credit_buyer_order t1
|
||||||
|
<include refid="commonWhere"/>
|
||||||
|
order by t1.order_id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getCount" resultType="long">
|
||||||
|
select count(*) from view_credit_buyer_order t1
|
||||||
|
<include refid="commonWhere" />
|
||||||
|
order by t1.order_id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getSumPayAmount" resultType="decimal">
|
||||||
|
select ifnull(sum(t1.pay_amount),0) from view_credit_buyer_order t1
|
||||||
|
<include refid="commonWhere" />
|
||||||
|
order by t1.order_id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getSumPaidAmount" resultType="decimal">
|
||||||
|
select ifnull(sum(t1.paid_amount),0) from view_credit_buyer_order t1
|
||||||
|
<include refid="commonWhere" />
|
||||||
|
order by t1.order_id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getSumUnpaidAmount" resultType="decimal">
|
||||||
|
select ifnull(sum(t1.unpaid_amount),0) from view_credit_buyer_order t1
|
||||||
|
<include refid="commonWhere" />
|
||||||
|
order by t1.order_id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -542,9 +542,12 @@
|
|||||||
shop_id = #{shopId}
|
shop_id = #{shopId}
|
||||||
AND product_id = #{productId}
|
AND product_id = #{productId}
|
||||||
AND `status` = 'create'
|
AND `status` = 'create'
|
||||||
and master_id = #{masterId}
|
AND created_at > UNIX_TIMESTAMP(NOW() - INTERVAL 1 DAY) * 1000
|
||||||
and table_id = #{tableId}
|
AND (master_id = #{masterId} OR master_id IS NULL)
|
||||||
and trade_day = #{day}
|
<if test="tableId != null and tableId != ''">
|
||||||
|
and table_id = #{tableId}
|
||||||
|
</if>
|
||||||
|
AND use_type = #{useType}
|
||||||
group by shop_id,product_id
|
group by shop_id,product_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user