Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b7ca62abf | |||
| da9f1ab68f | |||
| eb424d8eb4 | |||
| a12a1d2e1f | |||
|
|
af3ea12121 | ||
|
|
653254f9f3 | ||
| d8027c92b2 | |||
| 8d9deb43a3 | |||
|
|
6b436da4d3 | ||
| 796f43299f | |||
|
|
563541d929 | ||
|
|
8f7ea02d06 | ||
|
|
4d462a1d3e | ||
|
|
397c1b4df3 | ||
|
|
178f3c0831 |
85
pom.xml
85
pom.xml
@@ -48,11 +48,11 @@
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>4.5.18</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba</groupId>-->
|
||||
<!-- <artifactId>fastjson</artifactId>-->
|
||||
<!-- <version>1.2.9</version>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba</groupId>-->
|
||||
<!-- <artifactId>fastjson</artifactId>-->
|
||||
<!-- <version>1.2.9</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
@@ -185,30 +185,57 @@
|
||||
<version>2.2.0</version>
|
||||
</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>
|
||||
<!-- <profiles>-->
|
||||
<!-- <profile>-->
|
||||
<!-- <id>dev</id>-->
|
||||
<!-- <properties>-->
|
||||
<!-- <env>dev</env>-->
|
||||
<!-- </properties>-->
|
||||
<!-- <activation>-->
|
||||
<!-- <activeByDefault>true</activeByDefault>-->
|
||||
<!-- </activation>-->
|
||||
<!-- </profile>-->
|
||||
<!-- <profile>-->
|
||||
<!-- <id>test</id>-->
|
||||
<!-- <properties>-->
|
||||
<!-- <env>test</env>-->
|
||||
<!-- </properties>-->
|
||||
<!-- </profile>-->
|
||||
<!-- <profile>-->
|
||||
<!-- <id>pro</id>-->
|
||||
<!-- <properties>-->
|
||||
<!-- <env>pro</env>-->
|
||||
<!-- </properties>-->
|
||||
<!-- </profile>-->
|
||||
<!-- </profiles>-->
|
||||
<!-- <profiles>-->
|
||||
<!-- <profile>-->
|
||||
<!-- <id>dev</id>-->
|
||||
<!-- <properties>-->
|
||||
<!-- <env>dev</env>-->
|
||||
<!-- </properties>-->
|
||||
<!-- <activation>-->
|
||||
<!-- <activeByDefault>true</activeByDefault>-->
|
||||
<!-- </activation>-->
|
||||
<!-- </profile>-->
|
||||
<!-- <profile>-->
|
||||
<!-- <id>test</id>-->
|
||||
<!-- <properties>-->
|
||||
<!-- <env>test</env>-->
|
||||
<!-- </properties>-->
|
||||
<!-- </profile>-->
|
||||
<!-- <profile>-->
|
||||
<!-- <id>pro</id>-->
|
||||
<!-- <properties>-->
|
||||
<!-- <env>pro</env>-->
|
||||
<!-- </properties>-->
|
||||
<!-- </profile>-->
|
||||
<!-- </profiles>-->
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
@@ -266,4 +293,4 @@
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
||||
@@ -10,7 +10,7 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum LogTag {
|
||||
JPUSH("极光"), CLIENT("安卓"),
|
||||
LOGIN("登录"), SYSTEM("系统"), CART("订单购物车");
|
||||
LOGIN("登录"), SYSTEM("系统"), CART("订单购物车"), PLACE("下单");
|
||||
private final String value;
|
||||
|
||||
LogTag(String value) {
|
||||
|
||||
@@ -6,12 +6,15 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.annotation.MyLog;
|
||||
import com.chaozhanggui.system.cashierservice.bean.LogTag;
|
||||
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.service.OrderService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@@ -24,6 +27,14 @@ public class OrderController {
|
||||
@Autowired
|
||||
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")
|
||||
public Result createCart(@RequestHeader("token") String token,
|
||||
@RequestHeader("loginName") String loginName,
|
||||
@@ -34,7 +45,7 @@ public class OrderController {
|
||||
String userId = jsonObject.getString("accountId");
|
||||
return orderService.createCart(cartVo.getMasterId(),cartVo.getProductId(),cartVo.getShopId(),
|
||||
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)
|
||||
@@ -49,7 +60,7 @@ public class OrderController {
|
||||
if (tableId == null && StrUtil.isBlank(masterId)) {
|
||||
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);
|
||||
String userId = jsonObject.getString("accountId");
|
||||
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")
|
||||
public Result createOrder(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@CrossOrigin(origins = "*")
|
||||
@@ -55,10 +56,12 @@ public class PayController {
|
||||
@RequestHeader("loginName") String loginName,
|
||||
@RequestHeader("clientType") String clientType,
|
||||
@RequestParam("orderId") String orderId,
|
||||
@RequestParam("payAmount") BigDecimal payAmount,
|
||||
@RequestParam("discountAmount") BigDecimal discountAmount,
|
||||
@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,
|
||||
@RequestParam("orderId") String orderId,
|
||||
@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("clientType") String clientType,
|
||||
@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,
|
||||
@RequestHeader("loginName") String loginName,
|
||||
@RequestHeader("clientType") String clientType,
|
||||
@RequestParam("orderId") String orderId){
|
||||
return payService.cashPay(orderId,token);
|
||||
@RequestParam("orderId") String orderId,
|
||||
@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,
|
||||
@RequestHeader("loginName") String loginName,
|
||||
@RequestHeader("clientType") String clientType,
|
||||
@RequestParam("orderId") String orderId){
|
||||
return payService.bankPay(orderId,token);
|
||||
@RequestParam("orderId") String orderId,
|
||||
@RequestParam("payAmount") BigDecimal payAmount,
|
||||
@RequestParam("discountAmount") BigDecimal discountAmount){
|
||||
return payService.bankPay(orderId,token, payAmount, discountAmount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,4 +12,6 @@ public class OrderVo {
|
||||
private Integer shopId;
|
||||
private String userId;
|
||||
private Integer merchantId;
|
||||
private String tableId;
|
||||
private Integer vipUserId;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -57,8 +58,12 @@ public class TbCashierCart implements Serializable {
|
||||
private Long updatedAt;
|
||||
private Integer userId;
|
||||
private String tableId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private TbProductSpec tbProductSpec;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String selectSpec="";
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,8 @@ public class TbOrderInfo implements Serializable {
|
||||
|
||||
private String outNumber;
|
||||
|
||||
private Integer staffId;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
public TbOrderInfo(){
|
||||
super();
|
||||
|
||||
@@ -14,6 +14,8 @@ public class TbPlussShopStaff implements Serializable {
|
||||
|
||||
private String password;
|
||||
|
||||
private String discountType;
|
||||
|
||||
private BigDecimal maxDiscountAmount;
|
||||
|
||||
private Boolean status;
|
||||
@@ -72,6 +74,14 @@ public class TbPlussShopStaff implements Serializable {
|
||||
this.password = password == null ? null : password.trim();
|
||||
}
|
||||
|
||||
public String getDiscountType() {
|
||||
return discountType;
|
||||
}
|
||||
|
||||
public void setDiscountType(String discountType) {
|
||||
this.discountType = discountType;
|
||||
}
|
||||
|
||||
public BigDecimal getMaxDiscountAmount() {
|
||||
return maxDiscountAmount;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,6 @@ import lombok.Data;
|
||||
@Data
|
||||
public class CartVo {
|
||||
private String productId;
|
||||
|
||||
// orderId不为空为代客下单
|
||||
private String masterId;
|
||||
private String tableId;
|
||||
private String shopId;
|
||||
private Integer skuId;
|
||||
private Integer number;
|
||||
@@ -18,4 +14,7 @@ public class CartVo {
|
||||
private String uuid;
|
||||
private String type;
|
||||
private Integer cartId;
|
||||
private String masterId;
|
||||
private String tableId;
|
||||
private Integer vipUserId;
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -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> {
|
||||
}
|
||||
@@ -37,8 +37,6 @@ public class RabbitProducer implements RabbitTemplate.ConfirmCallback {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void cons(String content){
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CONS_COLLECT_PUT, RabbitConstants.CONS_COLLECT_ROUTINGKEY_PUT, content, correlationId);
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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.dao.*;
|
||||
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.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.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
@@ -26,7 +32,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -68,6 +73,7 @@ public class OrderService {
|
||||
RedisUtil redisUtil;
|
||||
|
||||
private final WxAccountUtil wxAccountUtil;
|
||||
private final MPCashierCartMapper mpCashierCartMapper;
|
||||
|
||||
@Autowired
|
||||
RabbitProducer producer;
|
||||
@@ -77,6 +83,7 @@ public class OrderService {
|
||||
private final TbUserShopMsgMapper tbUserShopMsgMapper;
|
||||
|
||||
private final TbShopOpenIdMapper shopOpenIdMapper;
|
||||
private final MpShopTableMapper mpShopTableMapper;
|
||||
|
||||
@Autowired
|
||||
private TbProskuConMapper tbProskuConMapper;
|
||||
@@ -90,16 +97,18 @@ public class OrderService {
|
||||
@Autowired
|
||||
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.mpCashierCartMapper = mpCashierCartMapper;
|
||||
this.wechatUtil = wechatUtil;
|
||||
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
|
||||
this.shopOpenIdMapper = shopOpenIdMapper;
|
||||
this.mpShopTableMapper = mpShopTableMapper;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
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) {
|
||||
return Result.fail(CodeEnum.NUMBER);
|
||||
}
|
||||
@@ -128,31 +137,30 @@ public class OrderService {
|
||||
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"));
|
||||
|
||||
|
||||
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.egt(proskuCon.getSurplusStock(),consInfo.getStockNumber().abs().subtract(consInfo.getStockConsume().abs()))){
|
||||
return Result.fail("商品:".concat(product.getName()).concat("对应的:").concat(consInfo.getConName()).concat("耗材不足"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shopTable == null) {
|
||||
return Result.fail("台桌不处于开台或空闲状态");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -201,6 +209,7 @@ public class OrderService {
|
||||
cashierCart.setNumber(cashierCart.getNumber()+number);
|
||||
cashierCart.setTotalNumber(cashierCart.getNumber()+number);
|
||||
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
||||
cashierCart.setUserId(vipUserId);
|
||||
cashierCartMapper.updateByPrimaryKey(cashierCart);
|
||||
|
||||
cashierCartMapper.deleteByPrimaryKey(cart.getId());
|
||||
@@ -212,6 +221,8 @@ public class OrderService {
|
||||
cart.setNumber(number);
|
||||
cart.setIsGift(isGift);
|
||||
cart.setIsPack(isPack);
|
||||
cart.setUserId(vipUserId);
|
||||
|
||||
if (isPack.equals("false")){
|
||||
cart.setPackFee(BigDecimal.ZERO);
|
||||
}else {
|
||||
@@ -227,10 +238,6 @@ public class OrderService {
|
||||
cart.setUuid(uuid);
|
||||
cashierCartMapper.updateByPrimaryKeySelective(cart);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
List<TbCashierCart> list = cashierCartMapper.selectALlByMasterId(masterId, "create");
|
||||
TbCashierCart cashierCart = cashierCartMapper.selectByDetail(masterId, productId, shopId, skuId.toString(), DateUtils.getDay(), uuid);
|
||||
@@ -252,6 +259,7 @@ public class OrderService {
|
||||
cashierCart.setStatus("create");
|
||||
cashierCart.setIsPack(isPack);
|
||||
cashierCart.setIsGift(isGift);
|
||||
cashierCart.setUserId(vipUserId);
|
||||
if (isGift.equals("false")) {
|
||||
cashierCart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()));
|
||||
} else {
|
||||
@@ -273,6 +281,7 @@ public class OrderService {
|
||||
cashierCartMapper.insert(cashierCart);
|
||||
cart=cashierCart;
|
||||
} else {
|
||||
cashierCart.setUserId(vipUserId);
|
||||
if (type.equals("add")) {
|
||||
cashierCart.setNumber(cashierCart.getNumber() + number);
|
||||
|
||||
@@ -284,8 +293,9 @@ public class OrderService {
|
||||
}else {
|
||||
cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
|
||||
}
|
||||
cashierCart.setUserId(vipUserId);
|
||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getNumber()).multiply(skuWithBLOBs.getSalePrice()).add(cashierCart.getPackFee()));
|
||||
cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
|
||||
mpCashierCartMapper.updateById(cashierCart);
|
||||
}
|
||||
} else {
|
||||
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)) {
|
||||
return Result.fail(CodeEnum.SHOPINFONOEXIST);
|
||||
}
|
||||
String day = DateUtils.getDay();
|
||||
List<TbCashierCart> list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId),"create",day);
|
||||
if (list.size() < 1){
|
||||
list = cashierCartMapper.selectByMaskerId(masterId, Integer.valueOf(shopId), "refund",day);
|
||||
if (list.size() > 0){
|
||||
if (list.size() < 1) {
|
||||
|
||||
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)) {
|
||||
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);
|
||||
}
|
||||
int orderId = 0;
|
||||
String uuid = "";
|
||||
ArrayList<Integer> ids = new ArrayList<>();
|
||||
for (TbCashierCart cashierCart : list) {
|
||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||
orderId = Integer.valueOf(cashierCart.getOrderId());
|
||||
break;
|
||||
orderId = Integer.parseInt(cashierCart.getOrderId());
|
||||
}
|
||||
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) {
|
||||
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
|
||||
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
|
||||
@@ -446,9 +483,32 @@ public class OrderService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result createOrder(OrderVo orderVo, String clientType, String token) {
|
||||
String day = DateUtils.getDay();
|
||||
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
|
||||
if (list.size() < 1) {
|
||||
list = cashierCartMapper.selectAllCreateOrder(orderVo.getMasterId(), orderVo.getShopId(), day, "create", orderVo.getUuid());
|
||||
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.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){
|
||||
@@ -735,11 +795,34 @@ public class OrderService {
|
||||
|
||||
|
||||
@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 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)) {
|
||||
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) {
|
||||
return Result.fail(CodeEnum.CREATEORDER);
|
||||
}
|
||||
@@ -810,31 +893,40 @@ public class OrderService {
|
||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||
flag = false;
|
||||
}
|
||||
cashierCart.setUserId(vipUserId);
|
||||
cashierCart.setOrderId(orderId + "");
|
||||
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
||||
cashierCart.setPendingAt(System.currentTimeMillis());
|
||||
cashierCart.setStatus("refund");
|
||||
cashierCart.setUuid(newUuid);
|
||||
cashierCartMapper.updateByPrimaryKeySelective(cashierCart);
|
||||
mpCashierCartMapper.updateById(cashierCart);
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
redisUtil.deleteByKey("SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId);
|
||||
}
|
||||
} else {
|
||||
|
||||
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, "", "refund", uuid);
|
||||
if (list.size() < 1) {
|
||||
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper
|
||||
.eq(TbCashierCart::getStatus, "refund"));
|
||||
// List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, "", "refund", uuid);
|
||||
if (list.isEmpty()) {
|
||||
return Result.fail(CodeEnum.CARTJH);
|
||||
}
|
||||
int orderId = 0;
|
||||
ArrayList<Integer> ids = new ArrayList<>();
|
||||
for (TbCashierCart cashierCart : list) {
|
||||
if (StringUtils.isNotEmpty(cashierCart.getOrderId())) {
|
||||
orderId = Integer.valueOf(cashierCart.getOrderId());
|
||||
break;
|
||||
orderId = Integer.parseInt(cashierCart.getOrderId());
|
||||
}
|
||||
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) {
|
||||
tbOrderInfoMapper.updateStatusById(orderId, "cancelled");
|
||||
orderDetailMapper.updateStatusByOrderId(orderId, "cancelled");
|
||||
@@ -881,10 +973,30 @@ public class OrderService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Result clearCart(CartVo cartVo) {
|
||||
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;
|
||||
List<ProductSkuPo> productSkuPos=new ArrayList<>();
|
||||
List<String> skuIds=new ArrayList<>();
|
||||
List<ProductSkuPo> productSkuPos = new ArrayList<>();
|
||||
List<String> skuIds = new ArrayList<>();
|
||||
for (TbCashierCart cashierCart : list) {
|
||||
// 数量减少, 返还库存
|
||||
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));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
|
||||
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST;
|
||||
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.SUCCESS;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -115,6 +116,10 @@ public class PayService {
|
||||
TbmerchantAccountMapper tbmerchantAccountMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
TbPlussShopStaffMapper tbPlussShopStaffMapper;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
System.out.printf("%.2f%n", new BigDecimal(1).setScale(2, RoundingMode.DOWN));
|
||||
@@ -126,7 +131,7 @@ public class PayService {
|
||||
}
|
||||
|
||||
@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)) {
|
||||
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);
|
||||
if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) {
|
||||
return Result.fail(CodeEnum.CARTEXIST);
|
||||
@@ -194,7 +219,7 @@ public class PayService {
|
||||
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
||||
payment = new TbOrderPayment();
|
||||
payment.setPayTypeId("ysk");
|
||||
payment.setAmount(orderInfo.getOrderAmount());
|
||||
payment.setAmount(ObjectUtil.isEmpty(payAmount)?orderInfo.getOrderAmount():payAmount);
|
||||
payment.setPaidAmount(orderInfo.getPayAmount());
|
||||
payment.setHasRefundAmount(BigDecimal.ZERO);
|
||||
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.setUpdatedAt(System.currentTimeMillis());
|
||||
orderInfo.setStaffId(ObjectUtil.isNotNull(staff)?staff.getId():null);
|
||||
tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
if ("ysk".equals(thirdPayType)) {
|
||||
@@ -432,7 +460,7 @@ public class PayService {
|
||||
}
|
||||
|
||||
@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(memberAccount)){
|
||||
if(ObjectUtil.isEmpty(memberId)){
|
||||
@@ -460,12 +488,33 @@ public class PayService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
int count = tbShopPayTypeMapper.countSelectByShopIdAndPayType(orderInfo.getShopId(), "deposit");
|
||||
if (count < 1) {
|
||||
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;
|
||||
|
||||
if(ObjectUtil.isNotEmpty(memberId)){
|
||||
@@ -510,7 +559,10 @@ public class PayService {
|
||||
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.setMemberId(user.getId().toString());
|
||||
orderInfo.setPayType("deposit");
|
||||
@@ -546,7 +598,7 @@ public class PayService {
|
||||
}
|
||||
|
||||
@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)) {
|
||||
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);
|
||||
if (ObjectUtil.isEmpty(tbUserInfo)) {
|
||||
return Result.fail(ACCOUNTEIXST);
|
||||
@@ -601,8 +673,10 @@ public class PayService {
|
||||
flow.setCreateTime(new Date());
|
||||
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.setMemberId(user.getUserId());
|
||||
orderInfo.setPayType("deposit");
|
||||
orderInfo.setStatus("closed");
|
||||
@@ -637,7 +711,7 @@ public class PayService {
|
||||
}
|
||||
|
||||
@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)) {
|
||||
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");
|
||||
if (count < 1) {
|
||||
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.setStatus("closed");
|
||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
@@ -691,7 +786,7 @@ public class PayService {
|
||||
}
|
||||
|
||||
@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)) {
|
||||
return Result.fail(CodeEnum.PARAM);
|
||||
}
|
||||
@@ -713,8 +808,29 @@ public class PayService {
|
||||
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.setStatus("closed");
|
||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
@@ -835,6 +951,9 @@ public class PayService {
|
||||
saleAmount = saleAmount.add(it.getPrice());
|
||||
payAmount = payAmount.add(it.getPriceAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN)
|
||||
.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());
|
||||
packAMount = packAMount.add(it.getPackAmount().divide(new BigDecimal(it.getNum()), 2, RoundingMode.DOWN).multiply(new BigDecimal(map1.get(it.getId()))));
|
||||
|
||||
|
||||
@@ -104,6 +104,11 @@ public enum CodeEnum {
|
||||
PWDERROE("100038",false,"操作密码错误","fail"),
|
||||
|
||||
|
||||
STAFFNOEXISTERROE("100039",false,"员工信息不存在","fail"),
|
||||
|
||||
STAFFDISCOUNTAMOUNTHIGHT("100040",false,"优惠金额不能大于员工授权额度","fail"),
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.thirdpay.req;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Data
|
||||
public class MainScanReq implements Serializable {
|
||||
@@ -25,7 +26,13 @@ public class MainScanReq implements Serializable {
|
||||
|
||||
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.body = body;
|
||||
this.amount = amount;
|
||||
@@ -35,6 +42,9 @@ public class MainScanReq implements Serializable {
|
||||
this.mchOrderNo = mchOrderNo;
|
||||
this.storeId = storeId;
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.divisionMode=divisionMode;
|
||||
this.divList=divList;
|
||||
this.divTemplateNo=divTemplateNo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.thirdpay.req;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Data
|
||||
public class WxScanPayReq implements Serializable {
|
||||
@@ -28,11 +29,20 @@ public class WxScanPayReq implements Serializable {
|
||||
|
||||
private String storeId;
|
||||
|
||||
private int divisionMode;
|
||||
|
||||
private ArrayList divList;
|
||||
|
||||
private String divTemplateNo;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
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.body = body;
|
||||
this.amount = amount;
|
||||
@@ -45,5 +55,8 @@ public class WxScanPayReq implements Serializable {
|
||||
this.storeId = storeId;
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.returnUrl = returnUrl;
|
||||
this.divisionMode=divisionMode;
|
||||
this.divList=divList;
|
||||
this.divTemplateNo=divTemplateNo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
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()));
|
||||
|
||||
|
||||
@@ -99,7 +108,14 @@ public class ThirdPayService {
|
||||
|
||||
String clinetIp,String orderNo, String storeId, String notifyUrl,String returnUrl,
|
||||
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()));
|
||||
|
||||
|
||||
|
||||
@@ -57,5 +57,8 @@ wx:
|
||||
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0
|
||||
|
||||
|
||||
|
||||
mybatis-plus:
|
||||
global-config:
|
||||
db-config:
|
||||
id-type: auto
|
||||
|
||||
|
||||
@@ -515,6 +515,10 @@
|
||||
<if test="remark != null and remark!=''">
|
||||
remark = #{remark,jdbcType=VARCHAR},
|
||||
</if>
|
||||
|
||||
<if test="staffId != null and staffId!=''">
|
||||
staff_id = #{staffId,jdbcType=INTEGER},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="account" jdbcType="VARCHAR" property="account" />
|
||||
<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="status" jdbcType="BIT" property="status" />
|
||||
<result column="employee" jdbcType="VARCHAR" property="employee" />
|
||||
@@ -19,7 +20,7 @@
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
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
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
|
||||
Reference in New Issue
Block a user