15 Commits
dkxd ... dkxd2

Author SHA1 Message Date
2b7ca62abf 1.增加台桌状态 2024-08-21 09:21:07 +08:00
da9f1ab68f 1.增加台桌状态 2024-08-21 09:12:52 +08:00
eb424d8eb4 Merge remote-tracking branch 'origin/test' into dkxd2
# Conflicts:
#	src/main/java/com/chaozhanggui/system/cashierservice/service/OrderService.java
2024-08-21 09:11:59 +08:00
a12a1d2e1f 1.增加台桌状态 2024-08-21 09:09:44 +08:00
牛叉闪闪
af3ea12121 Merge remote-tracking branch 'origin/hph' into test 2024-08-20 17:18:26 +08:00
牛叉闪闪
653254f9f3 添加员工折扣 2024-08-20 17:17:55 +08:00
d8027c92b2 1.增加mybatisplus依赖 2024-08-20 17:03:51 +08:00
8d9deb43a3 Merge remote-tracking branch 'origin/hph' into zs 2024-08-20 14:30:24 +08:00
牛叉闪闪
6b436da4d3 加入购物车取消耗材控制 2024-08-20 14:06:06 +08:00
796f43299f 1.代客下单相关接口修改 2024-08-20 13:23:13 +08:00
牛叉闪闪
563541d929 Merge remote-tracking branch 'origin/dev' into hph 2024-08-16 15:39:01 +08:00
牛叉闪闪
8f7ea02d06 加入购物车添加耗材控制 2024-08-16 15:38:47 +08:00
牛叉闪闪
4d462a1d3e 加入购物车添加耗材控制 2024-08-16 14:16:15 +08:00
牛叉闪闪
397c1b4df3 Merge remote-tracking branch 'origin/dev' into hph 2024-08-16 14:15:51 +08:00
牛叉闪闪
178f3c0831 加入购物车添加耗材控制 2024-08-14 16:01:11 +08:00
22 changed files with 523 additions and 121 deletions

85
pom.xml
View File

@@ -48,11 +48,11 @@
<artifactId>hutool-all</artifactId> <artifactId>hutool-all</artifactId>
<version>4.5.18</version> <version>4.5.18</version>
</dependency> </dependency>
<!-- <dependency>--> <!-- <dependency>-->
<!-- <groupId>com.alibaba</groupId>--> <!-- <groupId>com.alibaba</groupId>-->
<!-- <artifactId>fastjson</artifactId>--> <!-- <artifactId>fastjson</artifactId>-->
<!-- <version>1.2.9</version>--> <!-- <version>1.2.9</version>-->
<!-- </dependency>--> <!-- </dependency>-->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
@@ -185,30 +185,57 @@
<version>2.2.0</version> <version>2.2.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
<!-- <profiles>--> <!-- <profiles>-->
<!-- <profile>--> <!-- <profile>-->
<!-- <id>dev</id>--> <!-- <id>dev</id>-->
<!-- <properties>--> <!-- <properties>-->
<!-- <env>dev</env>--> <!-- <env>dev</env>-->
<!-- </properties>--> <!-- </properties>-->
<!-- <activation>--> <!-- <activation>-->
<!-- <activeByDefault>true</activeByDefault>--> <!-- <activeByDefault>true</activeByDefault>-->
<!-- </activation>--> <!-- </activation>-->
<!-- </profile>--> <!-- </profile>-->
<!-- <profile>--> <!-- <profile>-->
<!-- <id>test</id>--> <!-- <id>test</id>-->
<!-- <properties>--> <!-- <properties>-->
<!-- <env>test</env>--> <!-- <env>test</env>-->
<!-- </properties>--> <!-- </properties>-->
<!-- </profile>--> <!-- </profile>-->
<!-- <profile>--> <!-- <profile>-->
<!-- <id>pro</id>--> <!-- <id>pro</id>-->
<!-- <properties>--> <!-- <properties>-->
<!-- <env>pro</env>--> <!-- <env>pro</env>-->
<!-- </properties>--> <!-- </properties>-->
<!-- </profile>--> <!-- </profile>-->
<!-- </profiles>--> <!-- </profiles>-->
<build> <build>
<plugins> <plugins>
@@ -266,4 +293,4 @@
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@@ -10,7 +10,7 @@ import lombok.Getter;
@Getter @Getter
public enum LogTag { public enum LogTag {
JPUSH("极光"), CLIENT("安卓"), JPUSH("极光"), CLIENT("安卓"),
LOGIN("登录"), SYSTEM("系统"), CART("订单购物车"); LOGIN("登录"), SYSTEM("系统"), CART("订单购物车"), PLACE("下单");
private final String value; private final String value;
LogTag(String value) { LogTag(String value) {

View File

@@ -6,12 +6,15 @@ import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.system.cashierservice.annotation.MyLog; import com.chaozhanggui.system.cashierservice.annotation.MyLog;
import com.chaozhanggui.system.cashierservice.bean.LogTag; import com.chaozhanggui.system.cashierservice.bean.LogTag;
import com.chaozhanggui.system.cashierservice.entity.OrderVo; import com.chaozhanggui.system.cashierservice.entity.OrderVo;
import com.chaozhanggui.system.cashierservice.entity.dto.UpdateVipDTO;
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo; import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
import com.chaozhanggui.system.cashierservice.service.OrderService; import com.chaozhanggui.system.cashierservice.service.OrderService;
import com.chaozhanggui.system.cashierservice.sign.Result; import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.util.TokenUtil; 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.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@@ -24,6 +27,14 @@ public class OrderController {
@Autowired @Autowired
private OrderService orderService; private OrderService orderService;
@PutMapping("/updateVip")
@MyLog(value = "代客下单 修改会员", tag = LogTag.PLACE)
public ResponseEntity<Object> updateVip(
@Validated @RequestBody UpdateVipDTO updateVipDTO
) {
return ResponseEntity.ok(orderService.updateVip(updateVipDTO));
}
@PostMapping("/createCart") @PostMapping("/createCart")
public Result createCart(@RequestHeader("token") String token, public Result createCart(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@@ -34,7 +45,7 @@ public class OrderController {
String userId = jsonObject.getString("accountId"); String userId = jsonObject.getString("accountId");
return orderService.createCart(cartVo.getMasterId(),cartVo.getProductId(),cartVo.getShopId(), return orderService.createCart(cartVo.getMasterId(),cartVo.getProductId(),cartVo.getShopId(),
cartVo.getSkuId(),cartVo.getNumber(),userId,clientType,cartVo.getCartId(),cartVo.getIsGift(), cartVo.getSkuId(),cartVo.getNumber(),userId,clientType,cartVo.getCartId(),cartVo.getIsGift(),
cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType()); cartVo.getIsPack(),cartVo.getUuid(),cartVo.getType(), cartVo.getVipUserId(), cartVo.getTableId());
} }
@MyLog(value = "查询购物车信息", tag = LogTag.CART) @MyLog(value = "查询购物车信息", tag = LogTag.CART)
@@ -49,7 +60,7 @@ public class OrderController {
if (tableId == null && StrUtil.isBlank(masterId)) { if (tableId == null && StrUtil.isBlank(masterId)) {
return Result.fail("masterId和tableId不能同时为空"); return Result.fail("masterId和tableId不能同时为空");
} }
return orderService.queryCart(masterId,shopId); return orderService.queryCart(masterId,shopId, tableId);
} }
@@ -90,7 +101,8 @@ public class OrderController {
JSONObject jsonObject = TokenUtil.parseParamFromToken(token); JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
String userId = jsonObject.getString("accountId"); String userId = jsonObject.getString("accountId");
String code = jsonObject.getString("code"); String code = jsonObject.getString("code");
return orderService.cartStatus(Integer.valueOf(cartVo.getShopId()),cartVo.getMasterId(),cartVo.getStatus(),userId,cartVo.getUuid(),clientType); return orderService.cartStatus(Integer.valueOf(cartVo.getShopId()),cartVo.getMasterId(),
cartVo.getStatus(),userId,cartVo.getUuid(),clientType, cartVo.getVipUserId(), cartVo.getTableId());
} }
@PostMapping("/createOrder") @PostMapping("/createOrder")
public Result createOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName, public Result createOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,

View File

@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
@CrossOrigin(origins = "*") @CrossOrigin(origins = "*")
@@ -55,10 +56,12 @@ public class PayController {
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId, @RequestParam("orderId") String orderId,
@RequestParam("payAmount") BigDecimal payAmount,
@RequestParam("discountAmount") BigDecimal discountAmount,
@RequestParam("authCode") String authCode @RequestParam("authCode") String authCode
) { ) {
return payService.scanPay(orderId,authCode, IpUtil.getIpAddr(request),token); return payService.scanPay(orderId,authCode, IpUtil.getIpAddr(request),token,payAmount,discountAmount);
} }
@@ -79,9 +82,11 @@ public class PayController {
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId, @RequestParam("orderId") String orderId,
@RequestParam("memberId") String memberId, @RequestParam("memberId") String memberId,
@RequestParam("memberAccount") String memberAccount @RequestParam("memberAccount") String memberAccount,
@RequestParam("payAmount") BigDecimal payAmount,
@RequestParam("discountAmount") BigDecimal discountAmount
){ ){
return payService.accountPay(orderId,memberId,token,memberAccount); return payService.accountPay(orderId,memberId,token,memberAccount,payAmount,discountAmount);
} }
@@ -164,9 +169,11 @@ public class PayController {
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId, @RequestParam("orderId") String orderId,
@RequestParam("memberCode") String memberCode @RequestParam("memberCode") String memberCode,
@RequestParam("payAmount") BigDecimal payAmount,
@RequestParam("discountAmount") BigDecimal discountAmount
){ ){
return payService.memberScanPay(orderId,memberCode,token); return payService.memberScanPay(orderId,memberCode,token,payAmount,discountAmount);
} }
@@ -184,8 +191,10 @@ public class PayController {
public Result cashPay(@RequestHeader("token") String token, public Result cashPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId){ @RequestParam("orderId") String orderId,
return payService.cashPay(orderId,token); @RequestParam("payAmount") BigDecimal payAmount,
@RequestParam("discountAmount") BigDecimal discountAmount){
return payService.cashPay(orderId,token,payAmount,discountAmount);
} }
@@ -204,8 +213,10 @@ public class PayController {
public Result bankPay(@RequestHeader("token") String token, public Result bankPay(@RequestHeader("token") String token,
@RequestHeader("loginName") String loginName, @RequestHeader("loginName") String loginName,
@RequestHeader("clientType") String clientType, @RequestHeader("clientType") String clientType,
@RequestParam("orderId") String orderId){ @RequestParam("orderId") String orderId,
return payService.bankPay(orderId,token); @RequestParam("payAmount") BigDecimal payAmount,
@RequestParam("discountAmount") BigDecimal discountAmount){
return payService.bankPay(orderId,token, payAmount, discountAmount);
} }

View File

@@ -12,4 +12,6 @@ public class OrderVo {
private Integer shopId; private Integer shopId;
private String userId; private String userId;
private Integer merchantId; private Integer merchantId;
private String tableId;
private Integer vipUserId;
} }

View File

@@ -1,5 +1,6 @@
package com.chaozhanggui.system.cashierservice.entity; package com.chaozhanggui.system.cashierservice.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@@ -57,8 +58,12 @@ public class TbCashierCart implements Serializable {
private Long updatedAt; private Long updatedAt;
private Integer userId; private Integer userId;
private String tableId; private String tableId;
@TableField(exist = false)
private TbProductSpec tbProductSpec; private TbProductSpec tbProductSpec;
@TableField(exist = false)
private String selectSpec=""; private String selectSpec="";
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@@ -100,6 +100,8 @@ public class TbOrderInfo implements Serializable {
private String outNumber; private String outNumber;
private Integer staffId;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public TbOrderInfo(){ public TbOrderInfo(){
super(); super();

View File

@@ -14,6 +14,8 @@ public class TbPlussShopStaff implements Serializable {
private String password; private String password;
private String discountType;
private BigDecimal maxDiscountAmount; private BigDecimal maxDiscountAmount;
private Boolean status; private Boolean status;
@@ -72,6 +74,14 @@ public class TbPlussShopStaff implements Serializable {
this.password = password == null ? null : password.trim(); this.password = password == null ? null : password.trim();
} }
public String getDiscountType() {
return discountType;
}
public void setDiscountType(String discountType) {
this.discountType = discountType;
}
public BigDecimal getMaxDiscountAmount() { public BigDecimal getMaxDiscountAmount() {
return maxDiscountAmount; return maxDiscountAmount;
} }

View File

@@ -0,0 +1,23 @@
package com.chaozhanggui.system.cashierservice.entity.dto;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
@Data
public class UpdateVipDTO {
@NotNull
private Integer shopId;
@NotEmpty
private String tableId;
@NotNull
private String masterId;
private Integer vipUserId;
@NotNull
@Range(min = 0, max = 1)
private Integer type;
}

View File

@@ -5,10 +5,6 @@ import lombok.Data;
@Data @Data
public class CartVo { public class CartVo {
private String productId; private String productId;
// orderId不为空为代客下单
private String masterId;
private String tableId;
private String shopId; private String shopId;
private Integer skuId; private Integer skuId;
private Integer number; private Integer number;
@@ -18,4 +14,7 @@ public class CartVo {
private String uuid; private String uuid;
private String type; private String type;
private Integer cartId; private Integer cartId;
private String masterId;
private String tableId;
private Integer vipUserId;
} }

View File

@@ -0,0 +1,7 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
public interface MPCashierCartMapper extends BaseMapper<TbCashierCart> {
}

View File

@@ -0,0 +1,8 @@
package com.chaozhanggui.system.cashierservice.mybatis;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
public interface MpShopTableMapper extends BaseMapper<TbShopTable> {
}

View File

@@ -37,8 +37,6 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
public void cons(String content){ public void cons(String content){
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString()); CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId); rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId);

View File

@@ -1,17 +1,23 @@
package com.chaozhanggui.system.cashierservice.service; package com.chaozhanggui.system.cashierservice.service;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
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.http.HttpRequest; import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.bean.ShopWxMsgTypeEnum; import com.chaozhanggui.system.cashierservice.bean.ShopWxMsgTypeEnum;
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.UpdateVipDTO;
import com.chaozhanggui.system.cashierservice.entity.po.*; import com.chaozhanggui.system.cashierservice.entity.po.*;
import com.chaozhanggui.system.cashierservice.entity.vo.CartVo; import com.chaozhanggui.system.cashierservice.entity.vo.CartVo;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mybatis.MPCashierCartMapper;
import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
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;
@@ -26,7 +32,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@@ -68,6 +73,7 @@ public class OrderService {
RedisUtil redisUtil; RedisUtil redisUtil;
private final WxAccountUtil wxAccountUtil; private final WxAccountUtil wxAccountUtil;
private final MPCashierCartMapper mpCashierCartMapper;
@Autowired @Autowired
RabbitProducer producer; RabbitProducer producer;
@@ -77,6 +83,7 @@ public class OrderService {
private final TbUserShopMsgMapper tbUserShopMsgMapper; private final TbUserShopMsgMapper tbUserShopMsgMapper;
private final TbShopOpenIdMapper shopOpenIdMapper; private final TbShopOpenIdMapper shopOpenIdMapper;
private final MpShopTableMapper mpShopTableMapper;
@Autowired @Autowired
private TbProskuConMapper tbProskuConMapper; private TbProskuConMapper tbProskuConMapper;
@@ -90,16 +97,18 @@ public class OrderService {
@Autowired @Autowired
private ProductService productService; private ProductService productService;
public OrderService(WxAccountUtil wxAccountUtil, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper) { public OrderService(WxAccountUtil wxAccountUtil, MPCashierCartMapper mpCashierCartMapper, WechatUtil wechatUtil, TbUserShopMsgMapper tbUserShopMsgMapper, TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper) {
this.wxAccountUtil = wxAccountUtil; this.wxAccountUtil = wxAccountUtil;
this.mpCashierCartMapper = mpCashierCartMapper;
this.wechatUtil = wechatUtil; this.wechatUtil = wechatUtil;
this.tbUserShopMsgMapper = tbUserShopMsgMapper; this.tbUserShopMsgMapper = tbUserShopMsgMapper;
this.shopOpenIdMapper = shopOpenIdMapper; this.shopOpenIdMapper = shopOpenIdMapper;
this.mpShopTableMapper = mpShopTableMapper;
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result createCart(String masterId, String productId, String shopId, Integer skuId, Integer number, public Result createCart(String masterId, String productId, String shopId, Integer skuId, Integer number,
String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type) { String userId, String clientType, Integer cartId, String isGift, String isPack, String uuid, String type, Integer vipUserId, String tableId) {
if (Objects.isNull(number) || number < 0) { if (Objects.isNull(number) || number < 0) {
return Result.fail(CodeEnum.NUMBER); return Result.fail(CodeEnum.NUMBER);
} }
@@ -128,31 +137,30 @@ public class OrderService {
return Result.fail(CodeEnum.PRODUCTSKUERROR); return Result.fail(CodeEnum.PRODUCTSKUERROR);
} }
// 台桌点单
if ((StrUtil.isNotBlank(tableId))) {
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaUpdateWrapper<TbShopTable>()
.eq(TbShopTable::getQrcode, tableId)
.in(TbShopTable::getStatus, "idle", "using", "pending"));
if (shopTable == null) {
List<TbProskuCon> proskuConList= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(skuId,shopInfo.getId(),product.getId()); return Result.fail("台桌不处于开台或空闲状态");
if(Objects.nonNull(proskuConList)&&proskuConList.size()>0){
for (TbProskuCon proskuCon : proskuConList) {
if("1".equals(proskuCon.getStatus())){
TbConsInfo consInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
if("1".equals(consInfo.getIsCheck())){
if(N.egt(proskuCon.getSurplusStock(),consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))){
return Result.fail("商品:".concat(product.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足"));
}
}
}
} }
} }
// List<TbProskuCon> proskuConList= tbProskuConMapper.selectByShopIdAndSkuIdAndProductId(skuId,shopInfo.getId(),product.getId());
// if(Objects.nonNull(proskuConList)&&proskuConList.size()>0){
// for (TbProskuCon proskuCon : proskuConList) {
// if("1".equals(proskuCon.getStatus())){
// TbConsInfo consInfo= tbConsInfoMapper.selectByPrimaryKey(proskuCon.getConInfoId());
// if("1".equals(consInfo.getIsCheck())){
// if(N.gt(proskuCon.getSurplusStock(),consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))){
// return Result.fail("商品:".concat(product.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足"));
// }
// }
// }
// }
// }
String exists = redisUtil.getMessage(RedisCst.ORDER_CART_EXISTS + cartId); String exists = redisUtil.getMessage(RedisCst.ORDER_CART_EXISTS + cartId);
@@ -201,6 +209,7 @@ public class OrderService {
cashierCart.setNumber(cashierCart.getNumber()+number); cashierCart.setNumber(cashierCart.getNumber()+number);
cashierCart.setTotalNumber(cashierCart.getNumber()+number); cashierCart.setTotalNumber(cashierCart.getNumber()+number);
cashierCart.setUpdatedAt(System.currentTimeMillis()); cashierCart.setUpdatedAt(System.currentTimeMillis());
cashierCart.setUserId(vipUserId);
cashierCartMapper.updateByPrimaryKey(cashierCart); cashierCartMapper.updateByPrimaryKey(cashierCart);
cashierCartMapper.deleteByPrimaryKey(cart.getId()); cashierCartMapper.deleteByPrimaryKey(cart.getId());
@@ -212,6 +221,8 @@ public class OrderService {
cart.setNumber(number); cart.setNumber(number);
cart.setIsGift(isGift); cart.setIsGift(isGift);
cart.setIsPack(isPack); cart.setIsPack(isPack);
cart.setUserId(vipUserId);
if (isPack.equals("false")){ if (isPack.equals("false")){
cart.setPackFee(BigDecimal.ZERO); cart.setPackFee(BigDecimal.ZERO);
}else { }else {
@@ -227,10 +238,6 @@ public class OrderService {
cart.setUuid(uuid); cart.setUuid(uuid);
cashierCartMapper.updateByPrimaryKeySelective(cart); cashierCartMapper.updateByPrimaryKeySelective(cart);
} }
} else { } else {
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create"); List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid); TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid);
@@ -252,6 +259,7 @@ public class OrderService {
cashierCart.setStatus("create"); cashierCart.setStatus("create");
cashierCart.setIsPack(isPack); cashierCart.setIsPack(isPack);
cashierCart.setIsGift(isGift); cashierCart.setIsGift(isGift);
cashierCart.setUserId(vipUserId);
if (isGift.equals("false")) { if (isGift.equals("false")) {
cashierCart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice())); cashierCart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()));
} else { } else {
@@ -273,6 +281,7 @@ public class OrderService {
cashierCartMapper.insert(cashierCart); cashierCartMapper.insert(cashierCart);
cart=cashierCart; cart=cashierCart;
} else { } else {
cashierCart.setUserId(vipUserId);
if (type.equals("add")) { if (type.equals("add")) {
cashierCart.setNumber(cashierCart.getNumber() + number); cashierCart.setNumber(cashierCart.getNumber() + number);
@@ -284,8 +293,9 @@ public class OrderService {
}else { }else {
cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee())); cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
} }
cashierCart.setUserId(vipUserId);
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getNumber()).multiply(skuWithBLOBs.getSalePrice()).add(cashierCart.getPackFee())); cashierCart.setTotalAmount(new BigDecimal(cashierCart.getNumber()).multiply(skuWithBLOBs.getSalePrice()).add(cashierCart.getPackFee()));
cashierCartMapper.updateByPrimaryKeySelective(cashierCart); mpCashierCartMapper.updateById(cashierCart);
} }
} else { } else {
cashierCartMapper.updateStatus(cashierCart.getId(), "close"); cashierCartMapper.updateStatus(cashierCart.getId(), "close");
@@ -344,27 +354,54 @@ public class OrderService {
} }
} }
public Result queryCart(String masterId, String shopId) { public Result queryCart(String masterId, String shopId, String tableId) {
if (StringUtils.isEmpty(shopId)) { if (StringUtils.isEmpty(shopId)) {
return Result.fail(CodeEnum.SHOPINFONOEXIST); return Result.fail(CodeEnum.SHOPINFONOEXIST);
} }
String day = DateUtils.getDay(); String day = DateUtils.getDay();
List<TbCashierCart> list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId),"create",day);
if (list.size() < 1){ LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId), "refund",day); .eq(TbCashierCart::getShopId, shopId);
if (list.size() > 0){
if (list.size() < 1) { // 普通点单
if (StrUtil.isBlank(tableId)) {
queryWrapper.eq(TbCashierCart::getMasterId, masterId);
queryWrapper.isNull(TbCashierCart::getTableId);
// 台桌点单
}else if (StrUtil.isNotBlank(tableId)) {
queryWrapper.eq(TbCashierCart::getTableId, tableId)
.and(query -> {
query.eq(TbCashierCart::getMasterId, masterId)
.or()
.isNull(TbCashierCart::getMasterId);
});
}
// List<TbCashierCart> list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId),"create",day);
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
if (list.isEmpty()){
list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "refund"));
// list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId), "refund",day);
if (!list.isEmpty()){
if (list.isEmpty()) {
return Result.fail(CodeEnum.CARTJH); return Result.fail(CodeEnum.CARTJH);
} }
int orderId = 0; int orderId = 0;
String uuid = ""; String uuid = "";
ArrayList<Integer> ids = new ArrayList<>();
for (TbCashierCart cashierCart : list) { for (TbCashierCart cashierCart : list) {
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) { if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
orderId = Integer.valueOf(cashierCart.getOrderId()); orderId = Integer.parseInt(cashierCart.getOrderId());
break;
} }
cashierCart.setStatus("create");
ids.add(cashierCart.getId());
} }
cashierCartMapper.updateStatusByMaster(Integer.valueOf(shopId), masterId, "create", day, uuid); // mpCashierCartMapper.insertOrUpdate(list);
// cashierCartMapper.updateStatusByMaster(Integer.valueOf(shopId), masterId, "create", day, uuid);
mpCashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.set(TbCashierCart::getStatus, "create")
.in(TbCashierCart::getId, ids));
if (orderId > 0) { if (orderId > 0) {
tbOrderInfoMapper.updateStatusById(orderId, "cancelled"); tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled"); orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
@@ -446,9 +483,32 @@ public class OrderService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result createOrder(OrderVo orderVo, String clientType, String token) { public Result createOrder(OrderVo orderVo, String clientType, String token) {
String day = DateUtils.getDay(); String day = DateUtils.getDay();
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
if (list.size() < 1) { LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid()); .eq(TbCashierCart::getShopId, orderVo.getShopId())
.eq(TbCashierCart::getStatus, "create");
// 普通点单
if (StrUtil.isBlank(orderVo.getTableId())) {
queryWrapper.eq(TbCashierCart::getMasterId, orderVo.getMasterId())
.eq(TbCashierCart::getTradeDay, day);
queryWrapper.isNull(TbCashierCart::getTableId);
// 台桌点单
}else if (StrUtil.isNotBlank(orderVo.getTableId()) && orderVo.getVipUserId() == null) {
queryWrapper.eq(TbCashierCart::getTableId, orderVo.getTableId())
.and(query -> {
query.eq(TbCashierCart::getMasterId, orderVo.getMasterId())
.or()
.isNull(TbCashierCart::getMasterId);
});
}
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
if (list.isEmpty()) {
list = mpCashierCartMapper.selectList(queryWrapper);
// list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
} }
if(ObjectUtil.isEmpty(list)||ObjectUtil.isNull(list)||list.size()<=0){ if(ObjectUtil.isEmpty(list)||ObjectUtil.isNull(list)||list.size()<=0){
@@ -735,11 +795,34 @@ public class OrderService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result cartStatus(Integer shopId, String masterId, String status, String userId, String uuid, String clientType) { public Result cartStatus(Integer shopId, String masterId, String status, String userId, String uuid,
String clientType, Integer vipUserId, String tableId) {
String newUuid = redisUtil.getMessage("CART:UUID:" + shopId + userId)+""; String newUuid = redisUtil.getMessage("CART:UUID:" + shopId + userId)+"";
String day = DateUtils.getDay(); String day = DateUtils.getDay();
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId);
// 普通点单
if (StrUtil.isBlank(tableId)) {
queryWrapper.eq(TbCashierCart::getMasterId, masterId);
queryWrapper.isNull(TbCashierCart::getTableId);
// 台桌点单
}else if (StrUtil.isNotBlank(tableId) && vipUserId == null) {
queryWrapper.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getMasterId, masterId);
// 会员点单
}else {
queryWrapper
.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getUserId, vipUserId);
}
if ("true".equals(status)) { if ("true".equals(status)) {
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, day, "create", uuid); List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, day, "create", uuid);
if (list.size() < 1) { if (list.size() < 1) {
return Result.fail(CodeEnum.CREATEORDER); return Result.fail(CodeEnum.CREATEORDER);
} }
@@ -810,31 +893,40 @@ public class OrderService {
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) { if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
flag = false; flag = false;
} }
cashierCart.setUserId(vipUserId);
cashierCart.setOrderId(orderId + ""); cashierCart.setOrderId(orderId + "");
cashierCart.setUpdatedAt(System.currentTimeMillis()); cashierCart.setUpdatedAt(System.currentTimeMillis());
cashierCart.setPendingAt(System.currentTimeMillis()); cashierCart.setPendingAt(System.currentTimeMillis());
cashierCart.setStatus("refund"); cashierCart.setStatus("refund");
cashierCart.setUuid(newUuid); cashierCart.setUuid(newUuid);
cashierCartMapper.updateByPrimaryKeySelective(cashierCart); mpCashierCartMapper.updateById(cashierCart);
} }
if (flag) { if (flag) {
redisUtil.deleteByKey("SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId); redisUtil.deleteByKey("SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId);
} }
} else { } else {
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, "", "refund", uuid); .eq(TbCashierCart::getStatus, "refund"));
if (list.size() < 1) { // List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, "", "refund", uuid);
if (list.isEmpty()) {
return Result.fail(CodeEnum.CARTJH); return Result.fail(CodeEnum.CARTJH);
} }
int orderId = 0; int orderId = 0;
ArrayList<Integer> ids = new ArrayList<>();
for (TbCashierCart cashierCart : list) { for (TbCashierCart cashierCart : list) {
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) { if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
orderId = Integer.valueOf(cashierCart.getOrderId()); orderId = Integer.parseInt(cashierCart.getOrderId());
break;
} }
ids.add(cashierCart.getId());
// cashierCart.setStatus("create");
// }
} }
cashierCartMapper.updateStatusByMaster(shopId, masterId, "create", day, uuid); mpCashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
.set(TbCashierCart::getStatus, "create")
.in(TbCashierCart::getId, ids));
// cashierCartMapper.updateStatusByMaster(shopId, masterId, "create", day, uuid);
if (orderId > 0) { if (orderId > 0) {
tbOrderInfoMapper.updateStatusById(orderId, "cancelled"); tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled"); orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
@@ -881,10 +973,30 @@ public class OrderService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result clearCart(CartVo cartVo) { public Result clearCart(CartVo cartVo) {
String day = DateUtils.getDay(); String day = DateUtils.getDay();
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid()); LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, cartVo.getShopId())
.eq(TbCashierCart::getTradeDay, day)
.eq(TbCashierCart::getStatus, "create");
// 普通点单
if (StrUtil.isBlank(cartVo.getTableId())) {
queryWrapper.eq(TbCashierCart::getMasterId, cartVo.getMasterId());
queryWrapper.isNull(TbCashierCart::getTableId);
// 台桌点单
}else if (StrUtil.isNotBlank(cartVo.getTableId()) && cartVo.getVipUserId() == null) {
queryWrapper.eq(TbCashierCart::getTableId, cartVo.getTableId())
.eq(TbCashierCart::getMasterId, cartVo.getMasterId());
// 会员点单
}else {
queryWrapper.eq(TbCashierCart::getUserId, cartVo.getVipUserId());
}
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper);
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(cartVo.getMasterId(), Integer.valueOf(cartVo.getShopId()), day, "create", cartVo.getUuid());
int orderId = 0; int orderId = 0;
List<ProductSkuPo> productSkuPos=new ArrayList<>(); List<ProductSkuPo> productSkuPos = new ArrayList<>();
List<String> skuIds=new ArrayList<>(); List<String> skuIds = new ArrayList<>();
for (TbCashierCart cashierCart : list) { for (TbCashierCart cashierCart : list) {
// 数量减少, 返还库存 // 数量减少, 返还库存
String message = redisUtil.getMessage(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId()); String message = redisUtil.getMessage(RedisCst.ORDER_PRODUCT_NUM + cashierCart.getId());
@@ -1379,4 +1491,19 @@ public class OrderService {
JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doGet(requestUrl,requestUrlParam)); JSONObject jsonObject = JSON.parseObject(HttpClientUtil.doGet(requestUrl,requestUrlParam));
return jsonObject; return jsonObject;
} }
public Object updateVip(UpdateVipDTO updateVipDTO) {
LambdaUpdateWrapper<TbCashierCart> queryWrapper = new LambdaUpdateWrapper<>();
queryWrapper.eq(TbCashierCart::getTableId, updateVipDTO.getTableId())
.eq(TbCashierCart::getShopId, updateVipDTO.getShopId())
.eq(TbCashierCart::getMasterId, updateVipDTO.getMasterId());
if (updateVipDTO.getType().equals(0)) {
queryWrapper.set(TbCashierCart::getUserId, null);
queryWrapper.eq(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
}else {
queryWrapper.set(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
}
return mpCashierCartMapper.update(null, queryWrapper);
}
} }

View File

@@ -32,6 +32,7 @@ import java.math.RoundingMode;
import java.util.*; import java.util.*;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST; import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.SUCCESS;
@Service @Service
@Slf4j @Slf4j
@@ -115,6 +116,10 @@ public class PayService {
TbmerchantAccountMapper tbmerchantAccountMapper; TbmerchantAccountMapper tbmerchantAccountMapper;
@Autowired
TbPlussShopStaffMapper tbPlussShopStaffMapper;
public static void main(String[] args) { public static void main(String[] args) {
System.out.printf("%.2f%n", new BigDecimal(1).setScale(2, RoundingMode.DOWN)); System.out.printf("%.2f%n", new BigDecimal(1).setScale(2, RoundingMode.DOWN));
@@ -126,7 +131,7 @@ public class PayService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result scanPay(String orderId, String authCode, String ip, String token) { public Result scanPay(String orderId, String authCode, String ip, String token,BigDecimal payAmount,BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(authCode) || ObjectUtil.isEmpty(ip)) { if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(authCode) || ObjectUtil.isEmpty(ip)) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
} }
@@ -143,6 +148,26 @@ public class PayService {
} }
JSONObject tokeObj= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(tokeObj)){
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId=Integer.valueOf(tokeObj.containsKey("staffId")?tokeObj.getString("staffId"):"0");
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(ObjectUtil.isNotNull(staff)&&ObjectUtil.isNotNull(payAmount)&&ObjectUtil.isNotNull(discountAmount)&&ObjectUtil.isNotEmpty(payAmount)&&ObjectUtil.isNotEmpty(discountAmount)){
if("0".equals(staff.getDiscountType())){
if(N.gt(discountAmount,staff.getMaxDiscountAmount())){
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null); List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null);
if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) { if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) {
return Result.fail(CodeEnum.CARTEXIST); return Result.fail(CodeEnum.CARTEXIST);
@@ -194,7 +219,7 @@ public class PayService {
if (ObjectUtil.isEmpty(payment) || payment == null) { if (ObjectUtil.isEmpty(payment) || payment == null) {
payment = new TbOrderPayment(); payment = new TbOrderPayment();
payment.setPayTypeId("ysk"); payment.setPayTypeId("ysk");
payment.setAmount(orderInfo.getOrderAmount()); payment.setAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
payment.setPaidAmount(orderInfo.getPayAmount()); payment.setPaidAmount(orderInfo.getPayAmount());
payment.setHasRefundAmount(BigDecimal.ZERO); payment.setHasRefundAmount(BigDecimal.ZERO);
payment.setPayName(payName); payment.setPayName(payName);
@@ -214,9 +239,12 @@ public class PayService {
} }
orderInfo.setPayAmount(orderInfo.getOrderAmount()); orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount)?BigDecimal.ZERO:discountAmount);
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount)?payAmount.divide(orderInfo.getOrderAmount()).setScale(2,BigDecimal.ROUND_DOWN):null);
orderInfo.setPayType(qpay); orderInfo.setPayType(qpay);
orderInfo.setUpdatedAt(System.currentTimeMillis()); orderInfo.setUpdatedAt(System.currentTimeMillis());
orderInfo.setStaffId(ObjectUtil.isNotNull(staff)?staff.getId():null);
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo); tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
if ("ysk".equals(thirdPayType)) { if ("ysk".equals(thirdPayType)) {
@@ -432,7 +460,7 @@ public class PayService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result accountPay(String orderId, String memberId, String token,String memberAccount) { public Result accountPay(String orderId, String memberId, String token,String memberAccount,BigDecimal payAmount,BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId) ) { if (ObjectUtil.isEmpty(orderId) ) {
if(ObjectUtil.isEmpty(memberAccount)){ if(ObjectUtil.isEmpty(memberAccount)){
if(ObjectUtil.isEmpty(memberId)){ if(ObjectUtil.isEmpty(memberId)){
@@ -460,12 +488,33 @@ public class PayService {
} }
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "deposit"); int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "deposit");
if (count < 1) { if (count < 1) {
return Result.fail(CodeEnum.PAYTYPENOEXIST); return Result.fail(CodeEnum.PAYTYPENOEXIST);
} }
JSONObject tokeObj= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(tokeObj)){
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId=Integer.valueOf(tokeObj.containsKey("staffId")?tokeObj.getString("staffId"):"0");
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(ObjectUtil.isNotNull(staff)&&ObjectUtil.isNotNull(payAmount)&&ObjectUtil.isNotNull(discountAmount)&&ObjectUtil.isNotEmpty(payAmount)&&ObjectUtil.isNotEmpty(discountAmount)){
if("0".equals(staff.getDiscountType())){
if(N.gt(discountAmount,staff.getMaxDiscountAmount())){
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
TbShopUser user =null; TbShopUser user =null;
if(ObjectUtil.isNotEmpty(memberId)){ if(ObjectUtil.isNotEmpty(memberId)){
@@ -510,7 +559,10 @@ public class PayService {
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
orderInfo.setPayAmount(orderInfo.getOrderAmount()); orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount)?BigDecimal.ZERO:discountAmount);
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount)?payAmount.divide(orderInfo.getOrderAmount()).setScale(2,BigDecimal.ROUND_DOWN):null);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff)?null:staff.getId());
orderInfo.setUserId(user.getUserId()); orderInfo.setUserId(user.getUserId());
orderInfo.setMemberId(user.getId().toString()); orderInfo.setMemberId(user.getId().toString());
orderInfo.setPayType("deposit"); orderInfo.setPayType("deposit");
@@ -546,7 +598,7 @@ public class PayService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result memberScanPay(String orderId, String memberCode, String token) { public Result memberScanPay(String orderId, String memberCode, String token,BigDecimal payAmount,BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(memberCode)) { if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(memberCode)) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
} }
@@ -569,6 +621,26 @@ public class PayService {
} }
JSONObject tokeObj= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(tokeObj)){
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId=Integer.valueOf(tokeObj.containsKey("staffId")?tokeObj.getString("staffId"):"0");
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(ObjectUtil.isNotNull(staff)&&ObjectUtil.isNotNull(payAmount)&&ObjectUtil.isNotNull(discountAmount)&&ObjectUtil.isNotEmpty(payAmount)&&ObjectUtil.isNotEmpty(discountAmount)){
if("0".equals(staff.getDiscountType())){
if(N.gt(discountAmount,staff.getMaxDiscountAmount())){
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByCardNo(memberCode); TbUserInfo tbUserInfo = tbUserInfoMapper.selectByCardNo(memberCode);
if (ObjectUtil.isEmpty(tbUserInfo)) { if (ObjectUtil.isEmpty(tbUserInfo)) {
return Result.fail(ACCOUNTEIXST); return Result.fail(ACCOUNTEIXST);
@@ -601,8 +673,10 @@ public class PayService {
flow.setCreateTime(new Date()); flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow); tbShopUserFlowMapper.insert(flow);
orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
orderInfo.setPayAmount(orderInfo.getOrderAmount()); orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount)?BigDecimal.ZERO:discountAmount);
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount)?payAmount.divide(orderInfo.getOrderAmount()).setScale(2,BigDecimal.ROUND_DOWN):null);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff)?null:staff.getId());
orderInfo.setMemberId(user.getUserId()); orderInfo.setMemberId(user.getUserId());
orderInfo.setPayType("deposit"); orderInfo.setPayType("deposit");
orderInfo.setStatus("closed"); orderInfo.setStatus("closed");
@@ -637,7 +711,7 @@ public class PayService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result cashPay(String orderId, String token) { public Result cashPay(String orderId, String token,BigDecimal payAmount,BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId)) { if (ObjectUtil.isEmpty(orderId)) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
} }
@@ -654,13 +728,34 @@ public class PayService {
} }
JSONObject tokeObj= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(tokeObj)){
return Result.fail(CodeEnum.TOKENTERROR);
}
Integer staffId=Integer.valueOf(tokeObj.containsKey("staffId")?tokeObj.getString("staffId"):"0");
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(ObjectUtil.isNotNull(staff)&&ObjectUtil.isNotNull(payAmount)&&ObjectUtil.isNotNull(discountAmount)&&ObjectUtil.isNotEmpty(payAmount)&&ObjectUtil.isNotEmpty(discountAmount)){
if("0".equals(staff.getDiscountType())){
if(N.gt(discountAmount,staff.getMaxDiscountAmount())){
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "cash"); int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "cash");
if (count < 1) { if (count < 1) {
return Result.fail(CodeEnum.PAYTYPENOEXIST); return Result.fail(CodeEnum.PAYTYPENOEXIST);
} }
orderInfo.setPayAmount(orderInfo.getOrderAmount()); orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount)?BigDecimal.ZERO:discountAmount);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff)?null:staff.getId());
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount)?payAmount.divide(orderInfo.getOrderAmount()).setScale(2,BigDecimal.ROUND_DOWN):null);
orderInfo.setPayType("cash"); orderInfo.setPayType("cash");
orderInfo.setStatus("closed"); orderInfo.setStatus("closed");
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo())); orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
@@ -691,7 +786,7 @@ public class PayService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Result bankPay(String orderId, String token) { public Result bankPay(String orderId, String token,BigDecimal payAmount,BigDecimal discountAmount) {
if (ObjectUtil.isEmpty(orderId)) { if (ObjectUtil.isEmpty(orderId)) {
return Result.fail(CodeEnum.PARAM); return Result.fail(CodeEnum.PARAM);
} }
@@ -713,8 +808,29 @@ public class PayService {
return Result.fail(CodeEnum.PAYTYPENOEXIST); return Result.fail(CodeEnum.PAYTYPENOEXIST);
} }
JSONObject tokeObj= TokenUtil.parseParamFromToken(token);
if(Objects.isNull(tokeObj)){
return Result.fail(CodeEnum.TOKENTERROR);
}
orderInfo.setPayAmount(orderInfo.getOrderAmount()); Integer staffId=Integer.valueOf(tokeObj.containsKey("staffId")?tokeObj.getString("staffId"):"0");
TbPlussShopStaff staff= tbPlussShopStaffMapper.selectByPrimaryKey(staffId);
if(ObjectUtil.isNotNull(staff)&&ObjectUtil.isNotNull(payAmount)&&ObjectUtil.isNotNull(discountAmount)&&ObjectUtil.isNotEmpty(payAmount)&&ObjectUtil.isNotEmpty(discountAmount)){
if("0".equals(staff.getDiscountType())){
if(N.gt(discountAmount,staff.getMaxDiscountAmount())){
return Result.fail(CodeEnum.STAFFDISCOUNTAMOUNTHIGHT);
}
}
}
orderInfo.setPayAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
orderInfo.setDiscountAmount(ObjectUtil.isEmpty(discountAmount)?BigDecimal.ZERO:discountAmount);
orderInfo.setStaffId(ObjectUtil.isEmpty(staff)?null:staff.getId());
orderInfo.setDiscountRatio(ObjectUtil.isNotEmpty(payAmount)?payAmount.divide(orderInfo.getOrderAmount()).setScale(2,BigDecimal.ROUND_DOWN):null);
orderInfo.setPayType("cash"); orderInfo.setPayType("cash");
orderInfo.setStatus("closed"); orderInfo.setStatus("closed");
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo())); orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
@@ -835,6 +951,9 @@ public class PayService {
saleAmount = saleAmount.add(it.getPrice()); saleAmount = saleAmount.add(it.getPrice());
payAmount = payAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN) payAmount = payAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN)
.multiply(new BigDecimal(map1.get(it.getId())))); .multiply(new BigDecimal(map1.get(it.getId()))));
if(ObjectUtil.isNotEmpty(orderInfo.getDiscountRatio())&&ObjectUtil.isNotNull(orderInfo.getDiscountRatio())){
payAmount=payAmount.multiply(orderInfo.getDiscountRatio()).setScale(2,BigDecimal.ROUND_DOWN);
}
// payAmount=payAmount.add(it.getPriceAmount()); // payAmount=payAmount.add(it.getPriceAmount());
packAMount = packAMount.add(it.getPackAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId())))); packAMount = packAMount.add(it.getPackAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId()))));

View File

@@ -104,6 +104,11 @@ public enum CodeEnum {
PWDERROE("100038",false,"操作密码错误","fail"), PWDERROE("100038",false,"操作密码错误","fail"),
STAFFNOEXISTERROE("100039",false,"员工信息不存在","fail"),
STAFFDISCOUNTAMOUNTHIGHT("100040",false,"优惠金额不能大于员工授权额度","fail"),

View File

@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
@Data @Data
public class MainScanReq implements Serializable { public class MainScanReq implements Serializable {
@@ -25,7 +26,13 @@ public class MainScanReq implements Serializable {
private String notifyUrl; private String notifyUrl;
public MainScanReq(String subject, String body, Long amount, String subAppid, String currency, String authCode, String mchOrderNo, String storeId, String notifyUrl) { private int divisionMode;
private ArrayList divList;
private String divTemplateNo;
public MainScanReq(String subject, String body, Long amount, String subAppid, String currency, String authCode, String mchOrderNo, String storeId, String notifyUrl,int divisionMode,String divTemplateNo,ArrayList divList) {
this.subject = subject; this.subject = subject;
this.body = body; this.body = body;
this.amount = amount; this.amount = amount;
@@ -35,6 +42,9 @@ public class MainScanReq implements Serializable {
this.mchOrderNo = mchOrderNo; this.mchOrderNo = mchOrderNo;
this.storeId = storeId; this.storeId = storeId;
this.notifyUrl = notifyUrl; this.notifyUrl = notifyUrl;
this.divisionMode=divisionMode;
this.divList=divList;
this.divTemplateNo=divTemplateNo;
} }

View File

@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.thirdpay.req;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
@Data @Data
public class WxScanPayReq implements Serializable { public class WxScanPayReq implements Serializable {
@@ -28,11 +29,20 @@ public class WxScanPayReq implements Serializable {
private String storeId; private String storeId;
private int divisionMode;
private ArrayList divList;
private String divTemplateNo;
private String notifyUrl; private String notifyUrl;
private String returnUrl; private String returnUrl;
public WxScanPayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId, String notifyUrl, String returnUrl) { public WxScanPayReq(String subject, String body, Long amount, String currency, String payType, String subAppid, String userId, String clientIp, String mchOrderNo, String storeId,
int divisionMode,ArrayList divList,String divTemplateNo,
String notifyUrl, String returnUrl) {
this.subject = subject; this.subject = subject;
this.body = body; this.body = body;
this.amount = amount; this.amount = amount;
@@ -45,5 +55,8 @@ public class WxScanPayReq implements Serializable {
this.storeId = storeId; this.storeId = storeId;
this.notifyUrl = notifyUrl; this.notifyUrl = notifyUrl;
this.returnUrl = returnUrl; this.returnUrl = returnUrl;
this.divisionMode=divisionMode;
this.divList=divList;
this.divTemplateNo=divTemplateNo;
} }
} }

View File

@@ -47,8 +47,17 @@ public class ThirdPayService {
public PublicResp<MainScanResp> mainScan(String url,String appId, String subject, String body, Long amount, String subAppId, String authCode, String orderNo, String storeId, String notifyUrl, public PublicResp<MainScanResp> mainScan(String url,String appId, String subject, String body, Long amount, String subAppId, String authCode, String orderNo, String storeId, String notifyUrl,
String key String key
) { ) {
MainScanReq mainScanReq=null;
if("66bab943ae82f63b50ae3cff".equals(appId)){
mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,1,"TA1824003985261588482",null);
url="https://paymentweb.sxczgkj.cn";
}else {
mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl,0,null,null);
}
MainScanReq mainScanReq = new MainScanReq(subject, body, amount, subAppId, "cny", authCode, orderNo, storeId, notifyUrl);
PublicParam param = new PublicParam(appId, "", SignTypeEnum.MD5.getValue(), null, DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis())); PublicParam param = new PublicParam(appId, "", SignTypeEnum.MD5.getValue(), null, DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));
@@ -99,7 +108,14 @@ public class ThirdPayService {
String clinetIp,String orderNo, String storeId, String notifyUrl,String returnUrl, String clinetIp,String orderNo, String storeId, String notifyUrl,String returnUrl,
String key){ String key){
WxScanPayReq scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,notifyUrl,returnUrl); WxScanPayReq scanPayReq=null;
if("66bab943ae82f63b50ae3cff".equals(appId)){
scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,1,null,"TA1824003985261588482",notifyUrl,returnUrl);
url="https://paymentweb.sxczgkj.cn";
}else {
scanPayReq=new WxScanPayReq(subject,body,amount,"cny",payType,subAppId,userId,clinetIp,orderNo,storeId,0,null,null,notifyUrl,returnUrl);
}
PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(),null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis())); PublicParam param=new PublicParam(appId,null,SignTypeEnum.MD5.getValue(),null,DateUtils.getSdfTimes(), "1.0", String.valueOf(System.currentTimeMillis()));

View File

@@ -57,5 +57,8 @@ wx:
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0 warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0
mybatis-plus:
global-config:
db-config:
id-type: auto

View File

@@ -515,6 +515,10 @@
<if test="remark != null and remark!=''"> <if test="remark != null and remark!=''">
remark = #{remark,jdbcType=VARCHAR}, remark = #{remark,jdbcType=VARCHAR},
</if> </if>
<if test="staffId != null and staffId!=''">
staff_id = #{staffId,jdbcType=INTEGER},
</if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>

View File

@@ -7,6 +7,7 @@
<result column="name" jdbcType="VARCHAR" property="name" /> <result column="name" jdbcType="VARCHAR" property="name" />
<result column="account" jdbcType="VARCHAR" property="account" /> <result column="account" jdbcType="VARCHAR" property="account" />
<result column="password" jdbcType="VARCHAR" property="password" /> <result column="password" jdbcType="VARCHAR" property="password" />
<result column="discount_type" jdbcType="VARCHAR" property="discountType" />
<result column="max_discount_amount" jdbcType="DECIMAL" property="maxDiscountAmount" /> <result column="max_discount_amount" jdbcType="DECIMAL" property="maxDiscountAmount" />
<result column="status" jdbcType="BIT" property="status" /> <result column="status" jdbcType="BIT" property="status" />
<result column="employee" jdbcType="VARCHAR" property="employee" /> <result column="employee" jdbcType="VARCHAR" property="employee" />
@@ -19,7 +20,7 @@
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id id
, code, name, account, password, max_discount_amount, status, employee, shop_id, , code, name, account, password,discount_type, max_discount_amount, status, employee, shop_id,
created_at, updated_at, type,is_manage,is_pc created_at, updated_at, type,is_manage,is_pc
</sql> </sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">