Merge branch 'test' into dev
# Conflicts: # eladmin-system/src/main/java/cn/ysk/cashier/cons/service/impl/TbConsInfoServiceImpl.java
This commit is contained in:
@@ -72,6 +72,7 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
||||
private final TbProductStockOperateRepository tbProductStockOperateRepository;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TbConsInfoQueryCriteria criteria, Pageable pageable) {
|
||||
Page<TbConsInfo> page = tbConsInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
@@ -154,24 +155,12 @@ public class TbConsInfoServiceImpl implements TbConsInfoService {
|
||||
throw new Exception("耗材信息不存在");
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(resource.getConName())) {
|
||||
tbConsInfo.setConName(resource.getConName());
|
||||
}
|
||||
if (resource.getPrice() != null) {
|
||||
tbConsInfo.setPrice(resource.getPrice());
|
||||
}
|
||||
if (StrUtil.isNotBlank(resource.getConUnit())) {
|
||||
tbConsInfo.setConUnit(resource.getConUnit());
|
||||
}
|
||||
if (resource.getConWarning() != null) {
|
||||
tbConsInfo.setConWarning(resource.getConWarning());
|
||||
}
|
||||
if (StrUtil.isNotBlank(resource.getStatus())) {
|
||||
tbConsInfo.setStatus(resource.getStatus());
|
||||
}
|
||||
if (StrUtil.isNotBlank(resource.getIsCheck())) {
|
||||
tbConsInfo.setIsCheck(resource.getIsCheck());
|
||||
}
|
||||
tbConsInfo.setConName(ObjectUtil.isEmpty(resource.getConName())||ObjectUtil.isNull(resource.getConName())?tbConsInfo.getConName():resource.getConName());
|
||||
tbConsInfo.setPrice(ObjectUtil.isEmpty(resource.getPrice())||ObjectUtil.isNull(resource.getPrice())?tbConsInfo.getPrice():resource.getPrice());
|
||||
tbConsInfo.setConUnit(ObjectUtil.isEmpty(resource.getConUnit())||ObjectUtil.isNull(resource.getConUnit())?tbConsInfo.getConUnit(): resource.getConUnit());
|
||||
tbConsInfo.setConWarning(ObjectUtil.isEmpty(resource.getConWarning())||ObjectUtil.isNull(resource.getConWarning())?tbConsInfo.getConWarning():resource.getConWarning());
|
||||
tbConsInfo.setStatus(ObjectUtil.isEmpty(resource.getStatus())||ObjectUtil.isNull(resource.getStatus())?tbConsInfo.getStatus():resource.getStatus());
|
||||
tbConsInfo.setIsCheck(ObjectUtil.isEmpty(resource.getIsCheck())||ObjectUtil.isNull(resource.getIsCheck())?tbConsInfo.getIsCheck():resource.getIsCheck());
|
||||
tbConsInfo.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||
|
||||
tbConsInfoRepository.save(tbConsInfo);
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.ysk.cashier.controller;
|
||||
|
||||
import cn.ysk.cashier.dto.TbMiniAppPagesDto;
|
||||
import cn.ysk.cashier.mybatis.service.TbMiniAppPagesService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/miniAppPages")
|
||||
public class TbMiniAppPagesController {
|
||||
|
||||
final private TbMiniAppPagesService tbMiniAppPagesService;
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("新增/system/miniAppPages")
|
||||
public ResponseEntity<Object> createTbMiniAppPages(@Validated @RequestBody TbMiniAppPagesDto pagesDto) {
|
||||
return tbMiniAppPagesService.createTbMiniAppPages(pagesDto);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation("修改/system/miniAppPages")
|
||||
public ResponseEntity<Object> updateTbMiniAppPages(@Validated @RequestBody TbMiniAppPagesDto pagesDto) {
|
||||
return tbMiniAppPagesService.updateTbMiniAppPages(pagesDto);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{pagesId}")
|
||||
@ApiOperation("删除/system/miniAppPages")
|
||||
public ResponseEntity<Object> deleteTbMiniAppPages(@PathVariable Integer pagesId) {
|
||||
return tbMiniAppPagesService.deleteTbMiniAppPages(pagesId);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询/system/miniAppPages")
|
||||
public ResponseEntity<Object> getTbMiniAppPages(@RequestParam Map<String, Object> params) {
|
||||
return tbMiniAppPagesService.getTbMiniAppPages(params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.ysk.cashier.controller;
|
||||
|
||||
import cn.ysk.cashier.dto.ScanPayDTO;
|
||||
import cn.ysk.cashier.service.TbPayService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/pay")
|
||||
public class TbPayController {
|
||||
|
||||
private final TbPayService payService;
|
||||
|
||||
public TbPayController(TbPayService payService) {
|
||||
this.payService = payService;
|
||||
}
|
||||
|
||||
@PostMapping("/scanPay")
|
||||
public ResponseEntity<?> scanPay(
|
||||
@RequestBody @Validated ScanPayDTO scanPayDTO
|
||||
) {
|
||||
payService.scanPay(scanPayDTO);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,11 +2,16 @@ package cn.ysk.cashier.controller.product;
|
||||
|
||||
import cn.ysk.cashier.annotation.AnonymousAccess;
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.cons.rabbit.RabbitConstants;
|
||||
import cn.ysk.cashier.dto.shoptable.*;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.service.product.TbProductService;
|
||||
import cn.ysk.cashier.service.shop.TbShopTableService;
|
||||
import cn.ysk.cashier.utils.RabbitMsgUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.Validator;
|
||||
@@ -14,6 +19,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/place")
|
||||
@@ -23,6 +29,7 @@ public class TbPlaceController {
|
||||
|
||||
private final TbProductService tbProductService;
|
||||
private final Validator validator;
|
||||
private final RabbitMsgUtils rabbitMsgUtils;
|
||||
|
||||
|
||||
@AnonymousAccess
|
||||
@@ -38,10 +45,12 @@ public class TbPlaceController {
|
||||
return new ResponseEntity<>(tbProductService.activateProduct(page, size, categoryId, shopId, productId),HttpStatus.OK);
|
||||
}
|
||||
|
||||
public TbPlaceController(TbShopTableService tbShopTableService, TbProductService tbProductService, Validator validator) {
|
||||
public TbPlaceController(TbShopTableService tbShopTableService, TbProductService tbProductService, Validator validator, RabbitTemplate rabbitTemplate, RabbitMsgUtils rabbitMsgUtils) {
|
||||
this.tbShopTableService = tbShopTableService;
|
||||
this.tbProductService = tbProductService;
|
||||
this.validator = validator;
|
||||
this.rabbitTemplate = rabbitTemplate;
|
||||
this.rabbitMsgUtils = rabbitMsgUtils;
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
@@ -92,15 +101,26 @@ public class TbPlaceController {
|
||||
@Log("代客下单 查询购物车")
|
||||
@ApiOperation("代客下单 查询购物车 /shop/table")
|
||||
public ResponseEntity<Object> getCart(
|
||||
@RequestParam Long tableId,
|
||||
@RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "10") Integer size,
|
||||
@RequestParam Long tableId,
|
||||
@RequestParam Integer shopId,
|
||||
@RequestParam(required = false) Integer vipUserId,
|
||||
@RequestParam String masterId
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.getCart(tableId, page, size, shopId, vipUserId, masterId));
|
||||
}
|
||||
@AnonymousAccess
|
||||
|
||||
@GetMapping("/pending/cart")
|
||||
@Log("代客下单 查询购物车")
|
||||
@ApiOperation("代客下单 查询购物车 /shop/table")
|
||||
public ResponseEntity<Object> getPendingCart(
|
||||
@RequestParam Integer shopId,
|
||||
@RequestParam String tableId
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.getCar(shopId, tableId));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
||||
@@ -123,7 +143,7 @@ public class TbPlaceController {
|
||||
public ResponseEntity<Object> createOrder(
|
||||
@RequestBody CreateOrderDTO createOrderDTO
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO));
|
||||
return ResponseEntity.ok(tbShopTableService.createOrder(createOrderDTO, true));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
@@ -134,22 +154,12 @@ public class TbPlaceController {
|
||||
public ResponseEntity<Object> pending(
|
||||
@RequestBody PendingDTO pendingDTO
|
||||
) {
|
||||
pendingDTO.setIsPending(true);
|
||||
return ResponseEntity.ok(tbShopTableService.pending(pendingDTO));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
||||
@GetMapping("/car")
|
||||
@Log("代客下单 查询购物车")
|
||||
@ApiOperation("代客下单 查询购物车 /shop/table")
|
||||
public ResponseEntity<Object> getCar(
|
||||
@RequestParam Integer shopId
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.getCar(shopId));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
||||
@GetMapping("/payType")
|
||||
@Log("代客下单 查询购物车")
|
||||
@ApiOperation("代客下单 查询购物车 /shop/table")
|
||||
@@ -159,6 +169,16 @@ public class TbPlaceController {
|
||||
return ResponseEntity.ok(tbShopTableService.getPayType(shopId));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
||||
@DeleteMapping("/order")
|
||||
@Log("代客下单 删除订单")
|
||||
@ApiOperation("代客下单 查询购物车 /shop/table")
|
||||
public ResponseEntity<Object> delete(
|
||||
@Validated @RequestBody DeleteOrderDTO deleteOrderDTO
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.deleteOrder(deleteOrderDTO));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
||||
@@ -171,4 +191,29 @@ public class TbPlaceController {
|
||||
return ResponseEntity.ok(tbShopTableService.pay(payDTO));
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
@PutMapping("/updateVip")
|
||||
@Log("代客下单 查询购物车")
|
||||
@ApiOperation("代客下单 查询购物车 /shop/table")
|
||||
public ResponseEntity<Object> updateVip(
|
||||
@Validated @RequestBody UpdateVipDTO updateVipDTO
|
||||
) {
|
||||
return ResponseEntity.ok(tbShopTableService.updateVip(updateVipDTO));
|
||||
}
|
||||
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
@AnonymousAccess
|
||||
@GetMapping("/test")
|
||||
public void test(
|
||||
@RequestParam Integer id
|
||||
) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("type", "create");
|
||||
jsonObject.put("orderId", id);
|
||||
// rabbitTemplate.convertAndSend(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, jsonObject.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||
rabbitMsgUtils.printTicket(String.valueOf(id));
|
||||
// rabbitTemplate.convertAndSend(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, id, new CorrelationData(UUID.randomUUID().toString()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,13 +2,10 @@ package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
|
||||
import cn.ysk.cashier.dto.ShopSummaryDto;
|
||||
import cn.ysk.cashier.dto.shop.ShopTableSeleInfoDto;
|
||||
import cn.ysk.cashier.dto.shop.ShopTableSaleInfoDto;
|
||||
import cn.ysk.cashier.service.SummaryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -68,8 +65,8 @@ public class SummaryController {
|
||||
|
||||
@PostMapping("/table/download")
|
||||
@AnonymousPostMapping
|
||||
private void downloadShopSummaryTable(HttpServletResponse response, @RequestBody ShopTableSeleInfoDto exportRequest) throws IOException {
|
||||
summaryService.downloadTableSeleInfo(exportRequest, response);
|
||||
private void downloadShopSummaryTable(HttpServletResponse response, @RequestBody ShopTableSaleInfoDto exportRequest) throws IOException {
|
||||
summaryService.downloadTableSaleInfo(exportRequest, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopAdDto;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopAdService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/ad")
|
||||
public class TbShopAdController {
|
||||
final private TbShopAdService tbShopAdService;
|
||||
|
||||
@PostMapping
|
||||
public ResponseEntity<Object> createTbShopAd(@RequestBody TbShopAdDto adDto) {
|
||||
return tbShopAdService.createTbShopAd(adDto);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public ResponseEntity<Object> updateTbShopAd(@RequestBody TbShopAdDto adDto) {
|
||||
return tbShopAdService.updateTbShopAd(adDto);
|
||||
}
|
||||
|
||||
@DeleteMapping("/{adId}")
|
||||
public ResponseEntity<Object> deleteTbShopAd(@PathVariable Integer adId) {
|
||||
return tbShopAdService.deleteTbShopAd(adId);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<Object> getTbShopAd(@RequestParam Map<String, Object> params) {
|
||||
return tbShopAdService.getTbShopAd(params);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
package cn.ysk.cashier.controller.shop;
|
||||
|
||||
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousDeleteMapping;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousGetMapping;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousPostMapping;
|
||||
import cn.ysk.cashier.annotation.rest.AnonymousPutMapping;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopExtend;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopExtendService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -35,29 +30,26 @@ public class TbShopExtendController {
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("分页查询")
|
||||
@AnonymousGetMapping
|
||||
public ResponseEntity<Object> selectAll(TbShopExtendQueryCriteria criteria) {
|
||||
return new ResponseEntity<>(tbShopExtendService.queryAll(criteria), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation("通过Id查询详情")
|
||||
@AnonymousGetMapping
|
||||
public TbShopExtend selectOne(@PathVariable Serializable id) {
|
||||
return tbShopExtendService.getById(id);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation("新增")
|
||||
@AnonymousPostMapping
|
||||
public ResponseEntity<Object> insert(@RequestBody TbShopExtend tbShopExtend) {
|
||||
tbShopExtend.setCreateTime(new Date());
|
||||
return new ResponseEntity<>(tbShopExtendService.save(tbShopExtend), HttpStatus.CREATED);
|
||||
tbShopExtendService.saveInfo(tbShopExtend);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation("通过id修改")
|
||||
@AnonymousPutMapping
|
||||
public ResponseEntity<Object> update(@RequestBody TbShopExtend tbShopExtend) {
|
||||
tbShopExtend.setUpdateTime(new Date());
|
||||
tbShopExtendService.updateById(tbShopExtend);
|
||||
@@ -66,7 +58,6 @@ public class TbShopExtendController {
|
||||
|
||||
@DeleteMapping
|
||||
@ApiOperation("删除")
|
||||
@AnonymousDeleteMapping
|
||||
public ResponseEntity<Object> delete(@RequestParam("idList") List<Long> idList) {
|
||||
tbShopExtendService.removeByIds(idList);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
@@ -50,7 +51,6 @@ public class TbShopUserController {
|
||||
|
||||
@GetMapping("queryAllShopUser")
|
||||
@ApiOperation("查询商家用户")
|
||||
@AnonymousGetMapping
|
||||
public ResponseEntity<Object> queryAllShopUser(TbShopUserQueryCriteria criteria) {
|
||||
return new ResponseEntity<>(tbShopUserService.queryShopUser(criteria), HttpStatus.OK);
|
||||
}
|
||||
@@ -96,4 +96,12 @@ public class TbShopUserController {
|
||||
public void rechargeListDownload(HttpServletResponse response, @RequestBody TbShopRechargeListDto criteria) throws IOException {
|
||||
tbShopUserService.rechargeListDownload(response, criteria);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("midfiyAccount")
|
||||
@ApiOperation("增加扣减会员余额")
|
||||
public ResponseEntity<Object> midfiyAccount(@RequestBody Map<String,Object> map){
|
||||
tbShopUserService.modfiyAccount(map);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.ysk.cashier.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ScanPayDTO {
|
||||
private Integer shopId;
|
||||
private Integer orderId;
|
||||
private String authCode;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cn.ysk.cashier.dto;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表(TbActivateProduct)表查询类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 11:27:40
|
||||
*/
|
||||
@Data
|
||||
public class TbActivateProductQueryCriteria {
|
||||
|
||||
private Integer id;
|
||||
//活动Id
|
||||
private Integer activateId;
|
||||
//商品id
|
||||
private Integer productId;
|
||||
//数量
|
||||
private Integer num;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
private long page;
|
||||
private long size;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.ysk.cashier.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
public class TbMiniAppPagesDto {
|
||||
private Integer id;
|
||||
private Integer shopId;
|
||||
private String name;
|
||||
private String path;
|
||||
private String icon;
|
||||
private String description;
|
||||
private Integer sort;
|
||||
private Integer status;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -59,4 +59,7 @@ public class TbOrderDetailDto implements Serializable {
|
||||
|
||||
/** 打包费 */
|
||||
private BigDecimal packAmount;
|
||||
|
||||
private Integer isVip;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.ysk.cashier.dto.product;
|
||||
|
||||
import cn.ysk.cashier.annotation.Query;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -11,6 +12,7 @@ public class StockQueryDto {
|
||||
private Double num;
|
||||
private Integer isStock;
|
||||
private String categoryId;
|
||||
private String sort;
|
||||
|
||||
public void setName(String name) {
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.Date;
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
public class ShopTableSeleInfoDto {
|
||||
public class ShopTableSaleInfoDto {
|
||||
private Integer shopId;
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date startTime;
|
||||
@@ -49,6 +49,8 @@ public class TbPlussShopStaffDto implements Serializable {
|
||||
/** 密码 */
|
||||
private String password;
|
||||
|
||||
private String discountType;
|
||||
|
||||
/** 最大优惠金额 */
|
||||
private BigDecimal maxDiscountAmount;
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package cn.ysk.cashier.dto.shop;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopAd;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
public class TbShopAdDto {
|
||||
private Integer id;
|
||||
private Integer shopId;
|
||||
private String imgUrl;
|
||||
private String linkPath;
|
||||
private Integer borderRadius;
|
||||
private String showPosition;
|
||||
private String frequency;
|
||||
private Integer status;
|
||||
private Integer sort;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
|
||||
public TbShopAd convertToTbShopAd() {
|
||||
TbShopAd tbShopAd = new TbShopAd();
|
||||
tbShopAd.setId(this.id);
|
||||
tbShopAd.setShopId(this.shopId);
|
||||
tbShopAd.setImgUrl(this.imgUrl);
|
||||
tbShopAd.setLinkPath(this.linkPath);
|
||||
tbShopAd.setBorderRadius(this.borderRadius);
|
||||
tbShopAd.setShowPosition(this.showPosition);
|
||||
tbShopAd.setFrequency(this.frequency);
|
||||
tbShopAd.setStatus(this.status);
|
||||
tbShopAd.setSort(this.sort);
|
||||
tbShopAd.setCreateTime(this.createTime);
|
||||
tbShopAd.setUpdateTime(this.updateTime);
|
||||
return tbShopAd;
|
||||
}
|
||||
}
|
||||
@@ -186,4 +186,10 @@ public class TbShopInfoDto implements Serializable {
|
||||
private String districts;
|
||||
|
||||
private String cities;
|
||||
|
||||
private String isCustom;
|
||||
|
||||
private String isReturn;
|
||||
private String isMemberIn;
|
||||
private String isMemberReturn;
|
||||
}
|
||||
@@ -15,4 +15,5 @@ public class CreateOrderDTO {
|
||||
@NotEmpty
|
||||
private Long tableId;
|
||||
private String note;
|
||||
private boolean postPay;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.ysk.cashier.dto.shoptable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeleteOrderDTO {
|
||||
private Integer shopId;
|
||||
private Integer orderId;
|
||||
}
|
||||
@@ -16,4 +16,5 @@ public class PendingDTO {
|
||||
@NotNull
|
||||
private Boolean isPending;
|
||||
private Integer orderId;
|
||||
private String note;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.ysk.cashier.dto.shoptable;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.ysk.cashier.enums;
|
||||
|
||||
public enum TableStateEnum {
|
||||
IDLE("idle"),
|
||||
CLOSED("closed"), PAYING("paying"), PENDING("pending"), USING("using");
|
||||
private String state = "closed";
|
||||
|
||||
TableStateEnum(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.ysk.cashier.mybatis.Handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import cn.ysk.cashier.utils.ListUtil;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
@@ -8,12 +7,9 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@@ -28,26 +24,8 @@ public class Activate extends Model<Activate> {
|
||||
private BigDecimal handselNum;
|
||||
private String handselType;
|
||||
private String isDel;
|
||||
private String isUser;
|
||||
//是否赠送商品 0否 1是
|
||||
private Integer isGiftPro;
|
||||
private String productIds;
|
||||
@TableField(exist = false)
|
||||
private List<Integer> prodIds;
|
||||
|
||||
public void setProductIds(String productIds) {
|
||||
this.productIds = productIds;
|
||||
if(StringUtils.isNotBlank(productIds)){
|
||||
prodIds=ListUtil.stringChangeIntegerList(productIds);
|
||||
}
|
||||
}
|
||||
|
||||
public void setProdIds(List<Integer> prodIds) {
|
||||
this.prodIds = prodIds;
|
||||
if(!CollectionUtils.isEmpty(prodIds)){
|
||||
productIds="["+prodIds.stream()
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.joining(","))+"]";
|
||||
}
|
||||
}
|
||||
private List<TbActivateProduct> products;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateInRecord)表实体类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:50:16
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class TbActivateInRecord extends Model<TbActivateInRecord> {
|
||||
|
||||
private Integer id;
|
||||
//会员id
|
||||
private Integer vipUserId;
|
||||
//商品id
|
||||
private Integer proId;
|
||||
//赠送数量
|
||||
private Integer num;
|
||||
//未使用数量
|
||||
private Integer overNum;
|
||||
//店铺id
|
||||
private Integer shopId;
|
||||
//来源活动id
|
||||
private Integer sourceActId;
|
||||
|
||||
private Integer sourceFlowId;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getVipUserId() {
|
||||
return vipUserId;
|
||||
}
|
||||
|
||||
public void setVipUserId(Integer vipUserId) {
|
||||
this.vipUserId = vipUserId;
|
||||
}
|
||||
|
||||
public Integer getProId() {
|
||||
return proId;
|
||||
}
|
||||
|
||||
public void setProId(Integer proId) {
|
||||
this.proId = proId;
|
||||
}
|
||||
|
||||
public Integer getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(Integer num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public Integer getOverNum() {
|
||||
return overNum;
|
||||
}
|
||||
|
||||
public void setOverNum(Integer overNum) {
|
||||
this.overNum = overNum;
|
||||
}
|
||||
|
||||
public Integer getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(Integer shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public Integer getSourceActId() {
|
||||
return sourceActId;
|
||||
}
|
||||
|
||||
public void setSourceActId(Integer sourceActId) {
|
||||
this.sourceActId = sourceActId;
|
||||
}
|
||||
|
||||
public Integer getSourceFlowId() {
|
||||
return sourceFlowId;
|
||||
}
|
||||
|
||||
public void setSourceFlowId(Integer sourceFlowId) {
|
||||
this.sourceFlowId = sourceFlowId;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表(TbActivateOutRecord)表实体类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:53:52
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class TbActivateOutRecord extends Model<TbActivateOutRecord> {
|
||||
|
||||
private Integer id;
|
||||
//商品赠送Id
|
||||
private Integer giveId;
|
||||
//商品id
|
||||
private Integer proId;
|
||||
//未使用数量
|
||||
private Integer useNum;
|
||||
//退单量
|
||||
private Integer refNum;
|
||||
//订单id
|
||||
private String orderId;
|
||||
//新建: create, 完成: closed, 取消:cancel,
|
||||
private String status;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getGiveId() {
|
||||
return giveId;
|
||||
}
|
||||
|
||||
public void setGiveId(Integer giveId) {
|
||||
this.giveId = giveId;
|
||||
}
|
||||
|
||||
public Integer getProId() {
|
||||
return proId;
|
||||
}
|
||||
|
||||
public void setProId(Integer proId) {
|
||||
this.proId = proId;
|
||||
}
|
||||
|
||||
public Integer getUseNum() {
|
||||
return useNum;
|
||||
}
|
||||
|
||||
public void setUseNum(Integer useNum) {
|
||||
this.useNum = useNum;
|
||||
}
|
||||
|
||||
public Integer getRefNum() {
|
||||
return refNum;
|
||||
}
|
||||
|
||||
public void setRefNum(Integer refNum) {
|
||||
this.refNum = refNum;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表(TbActivateProduct)表实体类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 11:27:40
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class TbActivateProduct extends Model<TbActivateProduct> {
|
||||
|
||||
private Integer id;
|
||||
//活动Id
|
||||
private Integer activateId;
|
||||
//商品id
|
||||
private Integer productId;
|
||||
//数量
|
||||
private Integer num;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getActivateId() {
|
||||
return activateId;
|
||||
}
|
||||
|
||||
public void setActivateId(Integer activateId) {
|
||||
this.activateId = activateId;
|
||||
}
|
||||
|
||||
public Integer getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Integer productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Integer getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public void setNum(Integer num) {
|
||||
this.num = num;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("tb_mini_app_pages")
|
||||
public class TbMiniAppPages extends Model<TbMiniAppPages> {
|
||||
private Integer id;
|
||||
private String icon;
|
||||
private String name;
|
||||
private String path;
|
||||
private String description;
|
||||
private Integer status;
|
||||
private Integer sort;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("tb_shop_ad")
|
||||
public class TbShopAd extends Model<TbShopAd> {
|
||||
private Integer id;
|
||||
private Integer shopId;
|
||||
private String imgUrl;
|
||||
private String linkPath;
|
||||
private Integer borderRadius;
|
||||
private String showPosition;
|
||||
private String frequency;
|
||||
private Integer status;
|
||||
private Integer sort;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public class TbShopExtend extends Model<TbShopExtend> {
|
||||
//商户Id
|
||||
private Integer shopId;
|
||||
//img:图片;text:文本;
|
||||
private String name;
|
||||
private String type;
|
||||
//自定义key
|
||||
private String autokey;
|
||||
@@ -53,6 +54,14 @@ public class TbShopExtend extends Model<TbShopExtend> {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAutokey() {
|
||||
return autokey;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.Data;
|
||||
@@ -14,7 +12,7 @@ import lombok.Data;
|
||||
*/
|
||||
@Table(name="tb_shop_user")
|
||||
@Data
|
||||
public class TbMShopUser implements Serializable {
|
||||
public class TbShopUser implements Serializable {
|
||||
/**
|
||||
* (随机)
|
||||
*/
|
||||
@@ -82,7 +80,7 @@ public class TbMShopUser implements Serializable {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private String head_img;
|
||||
|
||||
@@ -142,12 +140,12 @@ public class TbMShopUser implements Serializable {
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private Long created_at;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
private Long updated_at;
|
||||
|
||||
@@ -174,7 +172,7 @@ public class TbMShopUser implements Serializable {
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
TbMShopUser other = (TbMShopUser) that;
|
||||
TbShopUser other = (TbShopUser) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getAmount() == null ? other.getAmount() == null : this.getAmount().equals(other.getAmount()))
|
||||
&& (this.getCredit_amount() == null ? other.getCredit_amount() == null : this.getCredit_amount().equals(other.getCredit_amount()))
|
||||
@@ -281,4 +279,4 @@ public class TbMShopUser implements Serializable {
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface MpShopTableMapper extends BaseMapper<TbShopTable> {
|
||||
}
|
||||
@@ -13,18 +13,18 @@ import org.apache.ibatis.annotations.Select;
|
||||
public interface ShopUserMapper extends BaseMapper<TbShopUser> {
|
||||
|
||||
@Select("<script>" +
|
||||
"SELECT su.id as id, u.head_img as headImg, u.nick_name as nickName, u.sex as sex, " +
|
||||
"su.amount as amount, u.total_score as totalScore, u.telephone as telephone, " +
|
||||
"u.birth_day as birthDay, su.is_vip as isVip, su.created_at as createAt, u.last_log_in_at as lastLoginAt " +
|
||||
"SELECT su.id as id, su.head_img as headImg, su.name as nickName, su.sex as sex, " +
|
||||
"su.amount as amount, 0 as totalScore, su.telephone as telephone, u.last_log_in_at as lastLoginAt, " +
|
||||
"su.birth_day as birthDay, su.is_vip as isVip, su.created_at as createAt " +
|
||||
"FROM tb_shop_user su " +
|
||||
"LEFT JOIN tb_user_info u ON su.user_id = u.id " +
|
||||
"left join tb_user_info u on u.id = su.user_id " +
|
||||
"<where> " +
|
||||
"<if test='param.shopId != null and param.shopId != "" and param.shopId != 1'>" +
|
||||
"AND su.shop_id = #{param.shopId} " +
|
||||
"</if>" +
|
||||
"<if test='param.name != null and param.name != ""'>" +
|
||||
"AND (u.nick_name like concat('%', #{param.name}, '%') or su.name LIKE concat( '%', #{param.name}, '%' ) " +
|
||||
" or u.telephone like concat('%', #{param.name}, '%') or su.telephone like concat('%', #{param.name}, '%'))" +
|
||||
"AND (su.name like concat('%', #{param.name}, '%') or su.name LIKE concat( '%', #{param.name}, '%' ) " +
|
||||
" or su.telephone like concat('%', #{param.name}, '%') or su.telephone like concat('%', #{param.name}, '%'))" +
|
||||
"</if>" +
|
||||
"<if test='isVip != null'>" +
|
||||
"AND su.is_vip=#{isVip} " +
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateInRecord)表数据库访问层
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:50:16
|
||||
*/
|
||||
public interface TbActivateInRecordMapper extends BaseMapper<TbActivateInRecord> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表(TbActivateOutRecord)表数据库访问层
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:53:52
|
||||
*/
|
||||
public interface TbActivateOutRecordMapper extends BaseMapper<TbActivateOutRecord> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateProduct;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表(TbActivateProduct)表数据库访问层
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 11:27:40
|
||||
*/
|
||||
public interface TbActivateProductMapper extends BaseMapper<TbActivateProduct> {
|
||||
|
||||
}
|
||||
|
||||
@@ -20,9 +20,11 @@ public interface TbCashierCartMapper extends BaseMapper<TbCashierCart> {
|
||||
" from tb_cashier_cart where table_id is not null and shop_id = #{shopId} and status = 'refund' group by shop_Id, master_id order by trade_day desc")
|
||||
List<CarVO> selectCar(@Param("shopId") Integer shopId);
|
||||
|
||||
@Select(" SELECT order_id orderId, pending_at, sum(total_amount) totalAmount, count(id) totalCount, count(total_number) totalNumber from tb_cashier_cart where status = 'refund' and shop_id=#{shopId} " +
|
||||
" GROUP BY order_id ORDER BY trade_day")
|
||||
List<PendingCountVO> countPending(@Param("shopId") Integer shopId);
|
||||
@Select("select a.id orderId,b.pending_at pendingAt, sum(b.total_amount) totalAmount, count(b.id) totalCount, sum(b.total_number) totalNumber, a.remark from tb_order_info a " +
|
||||
"JOIN tb_cashier_cart b on a.id=b.order_id " +
|
||||
"where a.shop_id=#{shopId} and a.`status`='pending' and a.table_id=#{tableId} and a.trade_day=#{day}" +
|
||||
"GROUP BY a.id ORDER BY a.id desc ")
|
||||
List<PendingCountVO> countPending(@Param("shopId") Integer shopId, @Param("tableId") String tableId, @Param("day") String day);
|
||||
|
||||
@Select("select a.*, b.spec_snap from tb_cashier_cart as a left join tb_product_sku as b on a.sku_id=b.id where a.shop_id=#{shopId} and a.status='refund';")
|
||||
List<TbCashierCartVO> selectPending(Integer shopId);
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
|
||||
import cn.ysk.cashier.mybatis.entity.TbMShopUser;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -14,7 +15,7 @@ import java.util.Map;
|
||||
* @createDate 2024-07-06 11:46:46
|
||||
* @Entity cn.ysk.cashier.mybatis.entity.TbMShopUser
|
||||
*/
|
||||
public interface TbMShopUserMapper extends BaseMapper<TbMShopUser> {
|
||||
public interface TbMShopUserMapper extends BaseMapper<TbShopUser> {
|
||||
@Select("<script>" +
|
||||
"SELECT \n" +
|
||||
" COUNT(DISTINCT a.id) AS userTotal, \n" +
|
||||
@@ -36,6 +37,8 @@ public interface TbMShopUserMapper extends BaseMapper<TbMShopUser> {
|
||||
"</script>")
|
||||
Map<String, Object> selectUserSummary(@Param("shopId") String shopId, @Param("isVip") Integer isVip);
|
||||
|
||||
@Update("update tb_shop_user set amount=amount-#{orderAmount}, consume_amount=consume_amount+#{orderAmount} where id=#{vipUserId} and amount-#{orderAmount} >= 0")
|
||||
long decrBalance(@Param("vipUserId") Integer vipUserId, @Param("orderAmount") BigDecimal orderAmount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbMiniAppPages;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
public interface TbMiniAppPagesMapper extends BaseMapper<TbMiniAppPages> {
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbMShopUser;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.vo.TbOrderSaleVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@@ -8,7 +7,6 @@ import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public interface TbOrderInfoMapper extends BaseMapper<TbOrderInfo> {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopAd;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
public interface TbShopAdMapper extends BaseMapper<TbShopAd> {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface TbShopPayTypeMapper extends BaseMapper<TbShopPayType> {
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package cn.ysk.cashier.mybatis.rest;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.domain.QiniuContent;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.entity.Activate;
|
||||
@@ -46,9 +47,11 @@ public class StorageController {
|
||||
String userName = SecurityUtils.getCurrentUsername();
|
||||
return new ResponseEntity<>(shopService.findActivate(shopId), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("修改活动数据")
|
||||
@PostMapping("/modityActivate")
|
||||
public ResponseEntity<Object> modityActivate(@RequestBody Activate activate){
|
||||
if (activate.getIsGiftPro() != null && activate.getIsGiftPro() == 1 && CollectionUtils.isEmpty(activate.getProdIds()))
|
||||
if (activate.getIsGiftPro() != null && activate.getIsGiftPro() == 1 && CollectionUtils.isEmpty(activate.getProducts()))
|
||||
throw new BadRequestException("赠送商品不可为空");
|
||||
String userName = SecurityUtils.getCurrentUsername();
|
||||
shopService.modityActivate(activate);
|
||||
|
||||
@@ -2,6 +2,7 @@ package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.Activate;
|
||||
import cn.ysk.cashier.mybatis.entity.StorageVo;
|
||||
import cn.ysk.cashier.mybatis.vo.ActivateProsVo;
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
@@ -25,5 +26,5 @@ public interface ShopService {
|
||||
|
||||
void modityActivate(Activate activate);
|
||||
|
||||
List<TbProduct> findActivatePros(Integer activate);
|
||||
List<ActivateProsVo> findActivatePros(Integer activate);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
||||
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateInRecord)表服务接口
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:50:16
|
||||
*/
|
||||
public interface TbActivateInRecordService extends IService<TbActivateInRecord> {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表(TbActivateOutRecord)表服务接口
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:53:52
|
||||
*/
|
||||
public interface TbActivateOutRecordService extends IService<TbActivateOutRecord> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateProduct;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
|
||||
/**
|
||||
* 活动赠送商品表(TbActivateProduct)表服务接口
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 11:27:40
|
||||
*/
|
||||
public interface TbActivateProductService extends IService<TbActivateProduct> {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
|
||||
import cn.ysk.cashier.mybatis.entity.TbMShopUser;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUser;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
* @description 针对表【tb_shop_user(商户储值会员)】的数据库操作Service
|
||||
* @createDate 2024-07-06 11:46:46
|
||||
*/
|
||||
public interface TbMShopUserService extends IService<TbMShopUser> {
|
||||
public interface TbMShopUserService extends IService<TbShopUser> {
|
||||
|
||||
/**
|
||||
* 查询会员概述信息
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.dto.TbMiniAppPagesDto;
|
||||
import cn.ysk.cashier.mybatis.entity.TbMiniAppPages;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
public interface TbMiniAppPagesService extends IService<TbMiniAppPages> {
|
||||
|
||||
ResponseEntity<Object> createTbMiniAppPages(TbMiniAppPagesDto pagesDto);
|
||||
|
||||
ResponseEntity<Object> updateTbMiniAppPages(TbMiniAppPagesDto pagesDto);
|
||||
|
||||
ResponseEntity<Object> deleteTbMiniAppPages(Integer pagesId);
|
||||
|
||||
ResponseEntity<Object> getTbMiniAppPages(Map<String, Object> params);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopAdDto;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopAd;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
public interface TbShopAdService extends IService<TbShopAd> {
|
||||
|
||||
ResponseEntity<Object> createTbShopAd(TbShopAdDto adDto);
|
||||
|
||||
ResponseEntity<Object> updateTbShopAd(TbShopAdDto adDto);
|
||||
|
||||
ResponseEntity<Object> deleteTbShopAd(Integer adId);
|
||||
|
||||
ResponseEntity<Object> getTbShopAd(Map<String, Object> params);
|
||||
}
|
||||
@@ -16,5 +16,7 @@ public interface TbShopExtendService extends IService<TbShopExtend> {
|
||||
|
||||
Map<String, Object> queryAll(TbShopExtendQueryCriteria criteria);
|
||||
|
||||
void saveInfo(TbShopExtend tbShopExtend);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.Activate;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateProduct;
|
||||
import cn.ysk.cashier.mybatis.mapper.*;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateProductService;
|
||||
import cn.ysk.cashier.mybatis.vo.ActivateProsVo;
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import cn.ysk.cashier.pojo.product.TbProductSku;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
|
||||
import cn.ysk.cashier.repository.product.TbProductRepository;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -19,7 +24,9 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
@@ -40,6 +47,8 @@ public class ShopServiceImpl implements ShopService {
|
||||
private ActivateMapper activateMapper;
|
||||
@Autowired
|
||||
private TbProductRepository tbProductRepository;
|
||||
@Resource
|
||||
private TbActivateProductService actProductService;
|
||||
@Override
|
||||
public Object findStorage(Integer shopId, String account, Pageable pageable) {
|
||||
QueryWrapper<TbUserStorage> queryWrapper = new QueryWrapper<>();
|
||||
@@ -128,13 +137,49 @@ public class ShopServiceImpl implements ShopService {
|
||||
activate.setMaxNum(activate.getMinNum());
|
||||
activateMapper.insert(activate);
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(activate.getProducts())){
|
||||
List<Integer> collect = new ArrayList<>();
|
||||
for (TbActivateProduct product : activate.getProducts()) {
|
||||
product.setActivateId(activate.getId());
|
||||
if (product.getId() != null) collect.add(product.getId());
|
||||
}
|
||||
QueryWrapper<TbActivateProduct> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("activate_id",activate.getId());
|
||||
List<TbActivateProduct> actProducts = actProductService.list(queryWrapper);
|
||||
for (TbActivateProduct actProduct : actProducts) {
|
||||
if (!collect.contains(actProduct.getId())) {
|
||||
actProductService.removeById(actProduct.getId());
|
||||
}
|
||||
}
|
||||
actProductService.saveOrUpdateBatch(activate.getProducts());
|
||||
}else {
|
||||
LambdaQueryWrapper<TbActivateProduct> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(TbActivateProduct::getActivateId, activate.getId()); // 条件:年龄等于30
|
||||
actProductService.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TbProduct> findActivatePros(Integer activateId) {
|
||||
Activate activate = activateMapper.selectById(activateId);
|
||||
if (!CollectionUtils.isEmpty(activate.getProdIds())){
|
||||
return tbProductRepository.findByIds(activate.getProdIds());
|
||||
public List<ActivateProsVo> findActivatePros(Integer activateId) {
|
||||
QueryWrapper<TbActivateProduct> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("activate_id", activateId);
|
||||
List<TbActivateProduct> actProducts = actProductService.list(queryWrapper);
|
||||
if (!CollectionUtils.isEmpty(actProducts)) {
|
||||
Map<Integer, Integer> map = actProducts.stream().collect(
|
||||
Collectors.toMap(
|
||||
TbActivateProduct::getProductId,
|
||||
TbActivateProduct::getNum,
|
||||
(existing, replacement) -> existing));
|
||||
if (!CollectionUtils.isEmpty(map)) {
|
||||
List<TbProduct> products = tbProductRepository.findByIds(new ArrayList<>(map.keySet()));
|
||||
List<ActivateProsVo> results= new ArrayList<>();
|
||||
for (TbProduct product : products) {
|
||||
ActivateProsVo pro =new ActivateProsVo(product.getId(),product.getName(),product.getCoverImg());
|
||||
pro.setNum(map.get(pro.getId()));
|
||||
results.add(pro);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbActivateInRecordMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateInRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 活动商品赠送表(TbActivateInRecord)表服务实现类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:50:16
|
||||
*/
|
||||
@Service("tbActivateInRecordService")
|
||||
public class TbActivateInRecordServiceImpl extends ServiceImpl<TbActivateInRecordMapper, TbActivateInRecord> implements TbActivateInRecordService {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbActivateOutRecordMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateOutRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 活动赠送商品使用记录表(TbActivateOutRecord)表服务实现类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-22 14:53:52
|
||||
*/
|
||||
@Service("tbActivateOutRecordService")
|
||||
public class TbActivateOutRecordServiceImpl extends ServiceImpl<TbActivateOutRecordMapper, TbActivateOutRecord> implements TbActivateOutRecordService {
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbActivateProductMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateProduct;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateProductService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.ysk.cashier.dto.TbActivateProductQueryCriteria;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import cn.ysk.cashier.utils.PageUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 活动赠送商品表(TbActivateProduct)表服务实现类
|
||||
*
|
||||
* @author ww
|
||||
* @since 2024-08-20 11:27:40
|
||||
*/
|
||||
@Service("tbActivateProductService")
|
||||
public class TbActivateProductServiceImpl extends ServiceImpl<TbActivateProductMapper, TbActivateProduct> implements TbActivateProductService {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.entity.TbMShopUser;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUser;
|
||||
import cn.ysk.cashier.mybatis.service.TbMShopUserService;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbMShopUserMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -13,7 +13,7 @@ import org.springframework.stereotype.Service;
|
||||
* @createDate 2024-07-06 11:46:46
|
||||
*/
|
||||
@Service
|
||||
public class TbMShopUserServiceImpl extends ServiceImpl<TbMShopUserMapper, TbMShopUser>
|
||||
public class TbMShopUserServiceImpl extends ServiceImpl<TbMShopUserMapper, TbShopUser>
|
||||
implements TbMShopUserService{
|
||||
|
||||
private final TbMShopUserMapper shopUserMapper;
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.dto.TbMiniAppPagesDto;
|
||||
import cn.ysk.cashier.mybatis.entity.TbMiniAppPages;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbMiniAppPagesMapper;
|
||||
import cn.ysk.cashier.mybatis.service.TbMiniAppPagesService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbMiniAppPagesServiceImpl extends ServiceImpl<TbMiniAppPagesMapper, TbMiniAppPages> implements TbMiniAppPagesService {
|
||||
@Override
|
||||
public ResponseEntity<Object> createTbMiniAppPages(TbMiniAppPagesDto pagesDto) {
|
||||
if (pagesDto == null) {
|
||||
return ResponseEntity.badRequest().body("参数不能为空");
|
||||
}
|
||||
if (pagesDto.getName() == null || pagesDto.getPath() == null) {
|
||||
return ResponseEntity.badRequest().body("页面名称和路径不能为空");
|
||||
}
|
||||
QueryWrapper<TbMiniAppPages> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("name", pagesDto.getName());
|
||||
TbMiniAppPages tbMiniAppPages = baseMapper.selectOne(wrapper);
|
||||
if (tbMiniAppPages != null) {
|
||||
return ResponseEntity.badRequest().body("页面已存在");
|
||||
}
|
||||
|
||||
tbMiniAppPages = new TbMiniAppPages();
|
||||
tbMiniAppPages.setName(pagesDto.getName());
|
||||
tbMiniAppPages.setPath(pagesDto.getPath());
|
||||
tbMiniAppPages.setIcon(pagesDto.getIcon());
|
||||
tbMiniAppPages.setSort(pagesDto.getSort());
|
||||
tbMiniAppPages.setDescription(pagesDto.getDescription());
|
||||
tbMiniAppPages.setStatus(pagesDto.getStatus());
|
||||
tbMiniAppPages.setCreateTime(new Date());
|
||||
tbMiniAppPages.setUpdateTime(new Date());
|
||||
|
||||
baseMapper.insert(tbMiniAppPages);
|
||||
|
||||
return ResponseEntity.ok().body("新增成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> updateTbMiniAppPages(TbMiniAppPagesDto pagesDto) {
|
||||
TbMiniAppPages appPages = baseMapper.selectById(pagesDto.getId());
|
||||
if (appPages == null) {
|
||||
return ResponseEntity.badRequest().body("页面不存在");
|
||||
}
|
||||
|
||||
if (pagesDto.getName() == null || pagesDto.getPath() == null) {
|
||||
return ResponseEntity.badRequest().body("页面名称和路径不能为空");
|
||||
}
|
||||
|
||||
if (!appPages.getName().equals(pagesDto.getName())) {
|
||||
QueryWrapper<TbMiniAppPages> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("name", pagesDto.getName());
|
||||
TbMiniAppPages tbMiniAppPages = baseMapper.selectOne(wrapper);
|
||||
if (tbMiniAppPages != null) {
|
||||
return ResponseEntity.badRequest().body("页面已存在");
|
||||
}
|
||||
}
|
||||
|
||||
if (pagesDto.getName() != null) {
|
||||
appPages.setName(pagesDto.getName());
|
||||
}
|
||||
if (pagesDto.getPath() != null) {
|
||||
appPages.setPath(pagesDto.getPath());
|
||||
}
|
||||
if (pagesDto.getIcon() != null) {
|
||||
appPages.setIcon(pagesDto.getIcon());
|
||||
}
|
||||
if (pagesDto.getSort() != null) {
|
||||
appPages.setSort(pagesDto.getSort());
|
||||
}
|
||||
if (pagesDto.getDescription() != null) {
|
||||
appPages.setDescription(pagesDto.getDescription());
|
||||
}
|
||||
if (pagesDto.getStatus() != null) {
|
||||
appPages.setStatus(pagesDto.getStatus());
|
||||
}
|
||||
appPages.setUpdateTime(new Date());
|
||||
|
||||
baseMapper.updateById(appPages);
|
||||
|
||||
return ResponseEntity.ok().body("更新成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> deleteTbMiniAppPages(Integer pagesId) {
|
||||
TbMiniAppPages appPages = baseMapper.selectById(pagesId);
|
||||
if (appPages == null) {
|
||||
return ResponseEntity.badRequest().body("页面不存在");
|
||||
}
|
||||
|
||||
baseMapper.deleteById(pagesId);
|
||||
|
||||
return ResponseEntity.ok().body("删除成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> getTbMiniAppPages(Map<String, Object> params) {
|
||||
QueryWrapper<TbMiniAppPages> wrapper = new QueryWrapper<>();
|
||||
if (params.get("status") != null) {
|
||||
wrapper.eq("status", params.get("status"));
|
||||
}
|
||||
wrapper.orderByDesc("sort");
|
||||
return ResponseEntity.ok().body(baseMapper.selectList(wrapper));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.shop.TbShopAdDto;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopAd;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopAdMapper;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopAdService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TbShopAdServiceImpl extends ServiceImpl<TbShopAdMapper, TbShopAd> implements TbShopAdService {
|
||||
@Override
|
||||
public ResponseEntity<Object> createTbShopAd(TbShopAdDto adDto) {
|
||||
if (adDto.getShopId() == null || adDto.getShopId() == 0) {
|
||||
return ResponseEntity.badRequest().body("店铺ID不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(adDto.getImgUrl())) {
|
||||
return ResponseEntity.badRequest().body("图片地址不能为空");
|
||||
}
|
||||
TbShopAd shopAd = adDto.convertToTbShopAd();
|
||||
shopAd.setCreateTime(new Date());
|
||||
shopAd.setUpdateTime(new Date());
|
||||
baseMapper.insert(shopAd);
|
||||
return ResponseEntity.ok().body("新增成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> updateTbShopAd(TbShopAdDto adDto) {
|
||||
if (adDto.getShopId() == null || adDto.getShopId() == 0) {
|
||||
return ResponseEntity.badRequest().body("店铺ID不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(adDto.getImgUrl())) {
|
||||
return ResponseEntity.badRequest().body("图片地址不能为空");
|
||||
}
|
||||
TbShopAd shopAd = baseMapper.selectById(adDto.getId());
|
||||
if (shopAd == null) {
|
||||
return ResponseEntity.badRequest().body("广告不存在");
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(adDto.getImgUrl())) {
|
||||
shopAd.setImgUrl(adDto.getImgUrl());
|
||||
}
|
||||
if (StrUtil.isNotBlank(adDto.getLinkPath())) {
|
||||
shopAd.setLinkPath(adDto.getLinkPath());
|
||||
}
|
||||
if (adDto.getBorderRadius() != null) {
|
||||
shopAd.setBorderRadius(adDto.getBorderRadius());
|
||||
}
|
||||
if (StrUtil.isNotBlank(adDto.getShowPosition())) {
|
||||
shopAd.setShowPosition(adDto.getShowPosition());
|
||||
}
|
||||
if (StrUtil.isNotBlank(adDto.getFrequency())) {
|
||||
shopAd.setFrequency(adDto.getFrequency());
|
||||
}
|
||||
if (adDto.getStatus() != null) {
|
||||
shopAd.setStatus(adDto.getStatus());
|
||||
}
|
||||
if (adDto.getSort() != null) {
|
||||
shopAd.setSort(adDto.getSort());
|
||||
}
|
||||
shopAd.setUpdateTime(new Date());
|
||||
|
||||
baseMapper.updateById(shopAd);
|
||||
|
||||
return ResponseEntity.ok().body("修改成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> deleteTbShopAd(Integer adId) {
|
||||
TbShopAd shopAd = baseMapper.selectById(adId);
|
||||
if (shopAd == null) {
|
||||
return ResponseEntity.badRequest().body("广告不存在");
|
||||
}
|
||||
|
||||
baseMapper.deleteById(adId);
|
||||
|
||||
return ResponseEntity.ok().body("删除成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Object> getTbShopAd(Map<String, Object> params) {
|
||||
QueryWrapper<TbShopAd> wrapper = new QueryWrapper<>();
|
||||
|
||||
if (StrUtil.isBlank((String) params.get("shopId"))) {
|
||||
return ResponseEntity.badRequest().body("店铺ID不能为空");
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank((String) params.get("status"))) {
|
||||
wrapper.eq("status", params.get("status"));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank((String) params.get("showPosition"))) {
|
||||
wrapper.eq("show_position", params.get("showPosition"));
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank((String) params.get("frequency"))) {
|
||||
wrapper.eq("frequency", params.get("frequency"));
|
||||
}
|
||||
|
||||
wrapper.orderByDesc("sort");
|
||||
|
||||
return ResponseEntity.ok().body(baseMapper.selectList(wrapper));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopExtendMapper;
|
||||
@@ -41,5 +42,16 @@ public class TbShopExtendServiceImpl extends ServiceImpl<TbShopExtendMapper, TbS
|
||||
Page<TbShopExtend> ipage = tbShopExtendmapper.selectPage(page, wrapper);
|
||||
return PageUtil.toPage(ipage.getRecords(), ipage.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveInfo(TbShopExtend tbShopExtend) {
|
||||
QueryWrapper<TbShopExtend> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("shop_id", tbShopExtend.getShopId());
|
||||
wrapper.like("autokey",tbShopExtend.getAutokey());
|
||||
if(tbShopExtendmapper.exists(wrapper)){
|
||||
throw new BadRequestException("该自定义key已存在");
|
||||
}
|
||||
tbShopExtendmapper.insert(tbShopExtend);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.ysk.cashier.mybatis.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ActivateProsVo {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String coverImg;
|
||||
private Integer num;
|
||||
|
||||
public ActivateProsVo(Integer id, String name, String coverImg) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.coverImg = coverImg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package cn.ysk.cashier.mybatis.vo.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class BaseRequest implements Serializable {
|
||||
|
||||
private String appId;
|
||||
|
||||
private String sign;
|
||||
|
||||
private Long timestamp;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.ysk.cashier.mybatis.vo.pay;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.ysk.cashier.utils.BeanUtil;
|
||||
import cn.ysk.cashier.utils.MD5Util;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class PayReq extends BaseRequest{
|
||||
|
||||
private String ip;
|
||||
private String mercOrderNo;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
private String payAmt;
|
||||
|
||||
private String payType;
|
||||
|
||||
private String payWay;
|
||||
|
||||
private String subject;
|
||||
|
||||
private String userId;
|
||||
|
||||
|
||||
public static void main(String[] args){
|
||||
PayReq req=new PayReq();
|
||||
String privateKey="MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAIqNqTqhN8zE7eFZnwKcyBTENce2wdAtl/gaDHNuNVgg33dS27Jx0fKl9QSHXyzyxbAdG8F94niYbRBstrMymFRjuO72jH+rIH62Ym1k7l8JSLVK2dKHXt8lHDaQGUP10q0EEocnDQ9cL93oBNG1ttsV6vOAu1TPvRK9TGihRAe1AgMBAAECgYBmI8KCl0DkcrSOsRvYuC2DqZWf8el1B3eFjeZp3e/zVOCIPYv6Q5ArWg6DVSxjnWEA0KSagqvGjU+xkQMqnXzPcPMhsIS+1wyR/pP+pwiatO2ioHaQpEqHg9eXhxrgA477/xuKVw9zl5GNqaIgd++2NDXnqLh0Y6OR73f0OB5eDQJBAPihEm+UWLOam/Q/k2+k4Lm2dvxJTBur1fslBiJpgMhgcz/PlwRwpL7aPD0AuPv0NqLouuoTiKpq9icnUv12tgsCQQCOqTANw0IErCHUNdinjXewmG3ui1j9XgM41rSn5ZeTrPL4GhZc2zbS/pZT4PBKUL6NLGkfPHmw4rOmNL/Xc5E/AkBqAwQBX5eSvVHSC2mqKPtJNGv3lqlFAzfyJg8/jQzEY5vAkZsq4Xzdg+A7gptdkvvY6rMIK9wSDhl3CGVyfbORAkA1N+g1OiHmnFACWhP4bU25EyPvWQxZeDi7e1zpRTzGWj5JT3IIMb7B9zcdE0yQbI6pG2gbvvOmiOt7lTH7raEBAkBas2gugvR3f0aGqQcqMpyM627pyRppQ2h58/7KBylP3oR2BReqMUcXeiJ8TuBXzbRXpeVQ0DWOva5CWZJmBMdz";
|
||||
|
||||
req.setAppId("M800202305094c170c");
|
||||
req.setTimestamp(1693966210242l);
|
||||
req.setIp("47.97.26.47");
|
||||
req.setMercOrderNo("bb243a4731234f19af7734350fad19a4");
|
||||
req.setNotifyUrl("https://cashier.machine.sxczgkj.cn/web-custom/custom/third/ysk/wx-pay-notify/bb243a4731234f19af7734350fad19a4");
|
||||
req.setPayAmt("20.00");
|
||||
req.setPayType("03");
|
||||
req.setPayWay("WXZF");
|
||||
req.setSubject("描述");
|
||||
req.setUserId("o5Fun5XQAaAhf00hB9qBNnel9vYQ");
|
||||
|
||||
Map<String,Object> map= BeanUtil.transBean2Map(req);
|
||||
|
||||
req.setSign(MD5Util.encrypt(map,privateKey));
|
||||
System.out.println(JSONUtil.toJsonStr(req));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.ysk.cashier.mybatis.vo.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ScanPayReq extends BaseRequest{
|
||||
|
||||
private String consumeFee;
|
||||
|
||||
private String authCode;
|
||||
|
||||
private String notifyUrl;
|
||||
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args){
|
||||
// String privateKey="MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBALqNx7fzuGjrBFBxbLHOy3SPdVXacVShGAQbpjBP9C+64iQfMnGUUTSTU1IOCY+KTirgE1tZ9oDGYd6bXZcvoMvTheP1rjBlvPxeyolaK0w72bufEcr3TyiZwSEjDzvl0dnj1kUmZTnyImvQeLptVKTPbtdc0ak6ebBB61FuHvPFAgMBAAECgYAYWLKM7lDN2IYanYLq/asNzj8o8jZCLjf9KUKaIYUjyYcD4dJqgknKy8Ne/RgAVLN44v+Dt4z1J27UZ4BiX8PjPIb1MfLnQtNBQf+gITXy6+vRILK7K5js4c23BWHlmxpjsFQjVIN57/d3/eZHY8+wiSCi63fudIEWQcy7xY9BTQJBAPZj8AMSbD89D6iPbB9K5CoqpbWY1XOrbtPdG43FVEcz3Mx45U5Z7pfTuHACsTEkMBB5DjNQavZK5ZIc/mtvtqcCQQDB1GjzaeUVJ3nb4zudaDrB5UoJUsVgFCHZ7TdEB0dWyGg5CtW5Au4auMcHzBvozJDbTLQ8uZsKGbKQ09/TwHuzAkAMsELY9abrbsqSpKgtyF6NqVqVSoSbi1WOxZE4sNPRQuN5CDTO3yTBXt7drdXQMQvknUdU7yxC+MJvztxvTfZ7AkBEkK37hTcrL4a02QIKoYc/daul9qipXxXGcFp/bw+2TDhKDWIjCz1NKJYHVRV+WXbYjJ6paILGpOZ8wuZHkqxvAkAfX4h0XMyastZHj7BNB2rPHYcX8DjThRKNgSKPI5X8Ld0LCssuhkyjwv8qI3jO0+P0yXWqw4T8xZ+fqSmw1eS4";
|
||||
// ScanPayReq req=new ScanPayReq();
|
||||
//
|
||||
// req.setAppId("M800202307127ae681");
|
||||
// req.setTimestamp(1692929677702L);
|
||||
// req.setAuthCode("133423954644827557");
|
||||
// req.setNotifyUrl("https://cashier.machine.sxczgkj.cn/web-netty/netty/third-pay/third-pay-notify/ef554b58bf3a487eabe277c3f16e7200");
|
||||
// req.setConsumeFee(N.mul(new BigDecimal(0.01),BigDecimal.ONE));
|
||||
//
|
||||
// Map<String,Object> map= BeanUtil.transBean2Map(req);
|
||||
// req.setSign(MD5Util.encrypt(map,privateKey,true));
|
||||
//
|
||||
//
|
||||
// System.out.println(MD5Util.check(req,privateKey));
|
||||
//
|
||||
// System.out.println(JSONUtil.toJsonStr(req));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -153,6 +153,8 @@ public class TbCashierCart implements Serializable {
|
||||
@Column(name = "`uuid`")
|
||||
@ApiModelProperty(value = "uuid")
|
||||
private String uuid;
|
||||
@Column(name = "`sku_name`")
|
||||
private String skuName;
|
||||
|
||||
public void copy(TbCashierCart source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
|
||||
@@ -103,6 +103,10 @@ public class TbOrderDetail implements Serializable {
|
||||
@ApiModelProperty(value = "退单数量")
|
||||
private Integer refundNumber;
|
||||
|
||||
@Column(name = "`is_vip`")
|
||||
@ApiModelProperty(value = "isVip")
|
||||
private Integer isVip;
|
||||
|
||||
public void copy(TbOrderDetail source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
@@ -226,6 +226,8 @@ public class TbOrderInfo implements Serializable {
|
||||
@Column(name = "`is_use_coupon`")
|
||||
@ApiModelProperty(value = "是否使用优惠券")
|
||||
private String isUseCoupon;
|
||||
@Column(name = "`use_type`")
|
||||
private String useType;
|
||||
public void copy(TbOrderInfo source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
@@ -57,6 +57,10 @@ public class TbPlussShopStaff implements Serializable {
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
@Column(name = "`discount_type`")
|
||||
@ApiModelProperty(value = "优惠类型 1 折扣 0 金额")
|
||||
private String discountType;
|
||||
|
||||
@Column(name = "`max_discount_amount`")
|
||||
@ApiModelProperty(value = "最大优惠金额")
|
||||
private BigDecimal maxDiscountAmount;
|
||||
|
||||
@@ -244,6 +244,28 @@ public class TbShopInfo implements Serializable {
|
||||
@ApiModelProperty(value = "区")
|
||||
private String districts;
|
||||
|
||||
@Column(name = "is_custom")
|
||||
@ApiModelProperty(value = "是否允许用户自定义金额")
|
||||
private String isCustom;
|
||||
|
||||
|
||||
@Column(name = "is_return")
|
||||
@ApiModelProperty(value = "是否允许用户自定义金额")
|
||||
private String isReturn;
|
||||
|
||||
|
||||
@Column(name = "is_member_in")
|
||||
@ApiModelProperty(value = "是否允许用户自定义金额")
|
||||
private String isMemberIn;
|
||||
|
||||
|
||||
@Column(name = "is_member_return")
|
||||
@ApiModelProperty(value = "是否允许用户自定义金额")
|
||||
private String isMemberReturn;
|
||||
|
||||
|
||||
|
||||
|
||||
public void copy(TbShopInfo source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false));
|
||||
}
|
||||
|
||||
@@ -80,6 +80,26 @@ public interface TbProductSkuRepository extends JpaRepository<TbProductSku, Inte
|
||||
Page<StockV2Vo> searchProStockV2(@Param("shopId") String shopId, @Param("proName") String proName, @Param("isStock")Integer isStock,
|
||||
@Param("categoryId") String categoryId, Pageable pageable);
|
||||
|
||||
@Query("SELECT new cn.ysk.cashier.vo.StockV2Vo(" +
|
||||
"sku.id,pro.id,pro.coverImg,pro.name,unit.name,pro.typeEnum,sku.specSnap,pro.isStock, " +
|
||||
"CASE WHEN pro.isDistribute = 1 THEN IFNULL(pro.stockNumber, 0) ELSE SUM(sku.stockNumber) END as number" +
|
||||
", pro.isDistribute, pro.isPauseSale, true, sku.warnLine, pro.lowPrice, CASE WHEN sum(sku.isGrounding) > 0 THEN true ELSE false END as isGrounding) " +
|
||||
"from " +
|
||||
"TbProduct pro " +
|
||||
"LEFT JOIN TbProductSku sku on pro.id = sku.productId " +
|
||||
"LEFT JOIN TbShopUnit unit ON pro.unitId = unit.id " +
|
||||
"WHERE " +
|
||||
"pro.shopId = :shopId " +
|
||||
"AND pro.status = 1 " +
|
||||
"AND sku.isDel = 0 " +
|
||||
"AND (:categoryId IS NULL OR pro.categoryId = :categoryId) " +
|
||||
"AND (:proName IS NULL OR pro.name LIKE %:proName%) " +
|
||||
"AND (:isStock IS NULL OR pro.isStock = :isStock) " +
|
||||
"group by pro.id " +
|
||||
"order by number desc ")
|
||||
Page<StockV2Vo> searchProStockV2ByDesc(@Param("shopId") String shopId, @Param("proName") String proName, @Param("isStock")Integer isStock,
|
||||
@Param("categoryId") String categoryId, Pageable pageable);
|
||||
|
||||
@Query("SELECT new cn.ysk.cashier.vo.StockV2Vo(" +
|
||||
"sku.id,pro.id,pro.coverImg,pro.name,unit.name,pro.typeEnum,sku.specSnap,pro.isStock, " +
|
||||
"CASE " +
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.ysk.cashier.service;
|
||||
|
||||
import cn.ysk.cashier.dto.ShopSummaryDto;
|
||||
import cn.ysk.cashier.dto.shop.ShopTableSeleInfoDto;
|
||||
import cn.ysk.cashier.dto.shop.ShopTableSaleInfoDto;
|
||||
import cn.ysk.cashier.vo.ShopTableSaleInfoVo;
|
||||
import cn.ysk.cashier.vo.SummaryVO;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
@@ -41,5 +41,5 @@ public interface SummaryService {
|
||||
|
||||
List<ShopTableSaleInfoVo> selectSummaryTable(Integer shopId, Date startTime, Date endTime);
|
||||
|
||||
void downloadTableSeleInfo(ShopTableSeleInfoDto shopTableSeleInfoDto, HttpServletResponse response) throws IOException;
|
||||
void downloadTableSaleInfo(ShopTableSaleInfoDto shopTableSaleInfoDto, HttpServletResponse response) throws IOException;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.ysk.cashier.service;
|
||||
|
||||
import cn.ysk.cashier.dto.ScanPayDTO;
|
||||
import cn.ysk.cashier.dto.shoptable.PayDTO;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public interface TbPayService {
|
||||
void scanPay(ScanPayDTO scanPayDTO);
|
||||
|
||||
TbOrderInfo vipPay(@NotNull Integer shopId, @NotNull Integer orderId);
|
||||
|
||||
TbOrderInfo cashPay(PayDTO payDTO);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package cn.ysk.cashier.service.impl;
|
||||
|
||||
import cn.ysk.cashier.dto.ShopSummaryDto;
|
||||
import cn.ysk.cashier.dto.shop.ShopTableSeleInfoDto;
|
||||
import cn.ysk.cashier.dto.shop.ShopTableSaleInfoDto;
|
||||
import cn.ysk.cashier.enums.PayTypeEnum;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.service.TbShopUserFlowService;
|
||||
@@ -15,8 +15,6 @@ import cn.ysk.cashier.service.SummaryService;
|
||||
import cn.ysk.cashier.utils.DateUtil;
|
||||
import cn.ysk.cashier.utils.FileUtil;
|
||||
import cn.ysk.cashier.vo.*;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.beust.ah.A;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -37,7 +35,6 @@ import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -543,29 +540,31 @@ public class SummaryServiceImpl implements SummaryService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadTableSeleInfo(ShopTableSeleInfoDto shopTableSeleInfoDto, HttpServletResponse response) throws IOException {
|
||||
if (shopTableSeleInfoDto.getStartTime() == null) {
|
||||
shopTableSeleInfoDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
||||
public void downloadTableSaleInfo(ShopTableSaleInfoDto shopTableSaleInfoDto, HttpServletResponse response) throws IOException {
|
||||
if (shopTableSaleInfoDto.getStartTime() == null) {
|
||||
shopTableSaleInfoDto.setStartTime(DateUtil.toDate(DateUtil.fromTimeStamp(1704038400L)));
|
||||
}
|
||||
|
||||
if (shopTableSeleInfoDto.getEndTime() == null) {
|
||||
shopTableSeleInfoDto.setEndTime(new Date());
|
||||
if (shopTableSaleInfoDto.getEndTime() == null) {
|
||||
shopTableSaleInfoDto.setEndTime(new Date());
|
||||
}
|
||||
|
||||
List<ShopTableSaleInfoVo> infoVos = selectSummaryTable(shopTableSeleInfoDto.getShopId(), shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
|
||||
List<ShopTableSaleInfoVo> infoVos = selectSummaryTable(shopTableSaleInfoDto.getShopId(), shopTableSaleInfoDto.getStartTime(), shopTableSaleInfoDto.getEndTime());
|
||||
|
||||
List<TbOrderSalesCountByTable> countByTables = tbOrderDetailRepository.queryTbOrderSalesCountByTable(shopTableSeleInfoDto.getShopId(), shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
|
||||
infoVos.add(new ShopTableSaleInfoVo(99999, shopTableSaleInfoDto.getShopId(), null, "", "收银台", null, null, null, null));
|
||||
|
||||
List<TbOrderSalesCountByTable> countByTables = tbOrderDetailRepository.queryTbOrderSalesCountByTable(shopTableSaleInfoDto.getShopId(), shopTableSaleInfoDto.getStartTime(), shopTableSaleInfoDto.getEndTime());
|
||||
|
||||
Map<String, List<TbOrderSalesCountByTable>> countByTableMap = countByTables.stream()
|
||||
.collect(Collectors.groupingBy(TbOrderSalesCountByTable::getTableId));
|
||||
|
||||
|
||||
// 比较 shopTableSeleInfoDto 的 startTime 和 endTime 是不是同一天
|
||||
boolean sameDay = cn.hutool.core.date.DateUtil.isSameDay(shopTableSeleInfoDto.getStartTime(), shopTableSeleInfoDto.getEndTime());
|
||||
// 比较 shopTableSaleInfoDto 的 startTime 和 endTime 是不是同一天
|
||||
boolean sameDay = cn.hutool.core.date.DateUtil.isSameDay(shopTableSaleInfoDto.getStartTime(), shopTableSaleInfoDto.getEndTime());
|
||||
|
||||
String queryDate = cn.hutool.core.date.DateUtil.format(shopTableSeleInfoDto.getStartTime(), "yyyy-MM-dd");
|
||||
String queryDate = cn.hutool.core.date.DateUtil.format(shopTableSaleInfoDto.getStartTime(), "yyyy-MM-dd");
|
||||
if (!sameDay) {
|
||||
queryDate += " 至 " + cn.hutool.core.date.DateUtil.format(shopTableSeleInfoDto.getEndTime(), "yyyy-MM-dd");
|
||||
queryDate += " 至 " + cn.hutool.core.date.DateUtil.format(shopTableSaleInfoDto.getEndTime(), "yyyy-MM-dd");
|
||||
}
|
||||
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
|
||||
@@ -0,0 +1,395 @@
|
||||
package cn.ysk.cashier.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.ysk.cashier.dto.ScanPayDTO;
|
||||
import cn.ysk.cashier.dto.shoptable.PayDTO;
|
||||
import cn.ysk.cashier.enums.TableStateEnum;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUser;
|
||||
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUserFlow;
|
||||
import cn.ysk.cashier.mybatis.mapper.*;
|
||||
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantThirdApply;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import cn.ysk.cashier.repository.shop.TbMerchantThirdApplyRepository;
|
||||
import cn.ysk.cashier.service.TbPayService;
|
||||
import cn.ysk.cashier.utils.RabbitMsgUtils;
|
||||
import cn.ysk.cashier.utils.SnowFlakeUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TbPayServiceImpl implements TbPayService {
|
||||
|
||||
// @Value("${gateway.url}")
|
||||
// private String gateWayUrl;
|
||||
// @Value("${client.backUrl}")
|
||||
// private String backUrl;
|
||||
// @Value("${thirdPay.payType}")
|
||||
// private String thirdPayType;
|
||||
// @Value("${thirdPay.url}")
|
||||
// private String url;
|
||||
// @Value("${thirdPay.callBack}")
|
||||
// private String callBack;
|
||||
|
||||
private final TbOrderInfoMapper orderInfoMapper;
|
||||
private final TbCashierCartMapper cashierCartMapper;
|
||||
private final TbMerchantThirdApplyRepository merchantThirdApplyRepository;
|
||||
private final TbOrderPaymentService orderPaymentService;
|
||||
private final TbShopPayTypeMapper shopPayTypeMapper;
|
||||
private final TbOrderDetailMapper orderDetailMapper;
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
private final RabbitMsgUtils rabbitMsgUtils;
|
||||
private final MpShopTableMapper mpShopTableMapper;
|
||||
|
||||
|
||||
|
||||
public TbPayServiceImpl(TbOrderInfoMapper orderInfoMapper, TbCashierCartMapper cashierCartMapper, TbMerchantThirdApplyRepository merchantThirdApplyRepository, TbOrderPaymentService orderPaymentService, TbShopPayTypeMapper shopPayTypeMapper, TbOrderDetailMapper orderDetailMapper, RabbitTemplate rabbitTemplate, RabbitMsgUtils rabbitMsgUtils, MpShopTableMapper mpShopTableMapper, TbMShopUserMapper shopUserMapper, TbShopUserFlowMapper shopUserFlowMapper) {
|
||||
this.orderInfoMapper = orderInfoMapper;
|
||||
this.cashierCartMapper = cashierCartMapper;
|
||||
this.merchantThirdApplyRepository = merchantThirdApplyRepository;
|
||||
this.orderPaymentService = orderPaymentService;
|
||||
this.shopPayTypeMapper = shopPayTypeMapper;
|
||||
this.orderDetailMapper = orderDetailMapper;
|
||||
this.rabbitTemplate = rabbitTemplate;
|
||||
this.rabbitMsgUtils = rabbitMsgUtils;
|
||||
this.mpShopTableMapper = mpShopTableMapper;
|
||||
this.shopUserMapper = shopUserMapper;
|
||||
this.shopUserFlowMapper = shopUserFlowMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scanPay(ScanPayDTO scanPayDTO) {
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectOne(new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.in(TbOrderInfo::getStatus, "unpaid", "paying")
|
||||
.eq(TbOrderInfo::getId, scanPayDTO.getOrderId())
|
||||
.eq(TbOrderInfo::getShopId, scanPayDTO.getShopId()));
|
||||
|
||||
if (orderInfo == null) {
|
||||
throw new BadRequestException("订单不存在或已支付");
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNull(orderInfo.getMerchantId()) || ObjectUtil.isEmpty(orderInfo.getMerchantId())) {
|
||||
throw new BadRequestException("订单商户id为空");
|
||||
}
|
||||
|
||||
|
||||
List<TbCashierCart> cashierCarts = cashierCartMapper.selectList(new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, scanPayDTO.getShopId())
|
||||
.eq(TbCashierCart::getOrderId, scanPayDTO.getOrderId()));
|
||||
if (cashierCarts.isEmpty()) {
|
||||
throw new BadRequestException("购物车为空");
|
||||
}
|
||||
|
||||
StringBuilder body = new StringBuilder();
|
||||
for (TbCashierCart cashierCart : cashierCarts) {
|
||||
body.append(cashierCart.getName());
|
||||
}
|
||||
|
||||
|
||||
TbMerchantThirdApply thirdApply = merchantThirdApplyRepository.getById(Integer.valueOf(orderInfo.getMerchantId()));
|
||||
if (ObjectUtil.isEmpty(thirdApply) || ObjectUtil.isNull(thirdApply)) {
|
||||
throw new BadRequestException("三方支付信息不存在");
|
||||
}
|
||||
|
||||
String payType;
|
||||
String payName;
|
||||
String qpay;
|
||||
String payTypeCode = scanPayDTO.getAuthCode().substring(0, 2);// 判断收款码
|
||||
|
||||
if(Integer.parseInt(payTypeCode) >=25 && Integer.parseInt(payTypeCode) <= 30){
|
||||
payType = "aliPay";
|
||||
payName = "支付宝支付";
|
||||
qpay = "scanCode";
|
||||
}else if(Integer.parseInt(payTypeCode) >=10 &&Integer.parseInt(payTypeCode) <=19){
|
||||
payType = "wechatPay";
|
||||
payName = "微信支付";
|
||||
qpay = "scanCode";
|
||||
}else if("62".equals(payTypeCode)){
|
||||
throw new BadRequestException("错误码");
|
||||
}else if("01".equals(payTypeCode)){
|
||||
throw new BadRequestException("错误码");
|
||||
}else {
|
||||
throw new BadRequestException("错误码");
|
||||
}
|
||||
|
||||
long count = shopPayTypeMapper.selectCount(new LambdaUpdateWrapper<TbShopPayType>()
|
||||
.eq(TbShopPayType::getShopId, scanPayDTO.getShopId())
|
||||
.eq(TbShopPayType::getIsDisplay, 1)
|
||||
.eq(TbShopPayType::getPayType, qpay));
|
||||
if (count < 1) {
|
||||
throw new BadRequestException("未到找支付方式");
|
||||
}
|
||||
|
||||
TbOrderPayment payment = orderPaymentService.getById(scanPayDTO.getOrderId());
|
||||
if (ObjectUtil.isEmpty(payment) || payment == null) {
|
||||
payment = new TbOrderPayment();
|
||||
payment.setPayTypeId("ysk");
|
||||
payment.setAmount(orderInfo.getOrderAmount().doubleValue());
|
||||
payment.setPaidAmount(orderInfo.getPayAmount().doubleValue());
|
||||
payment.setHasRefundAmount((double) 0);
|
||||
payment.setPayName(payName);
|
||||
payment.setPayType(payType);
|
||||
payment.setReceived(payment.getAmount());
|
||||
payment.setChangeFee((double) 0);
|
||||
payment.setMemberId(orderInfo.getMemberId());
|
||||
payment.setShopId(orderInfo.getShopId());
|
||||
payment.setOrderId(orderInfo.getId().toString());
|
||||
payment.setCreatedAt(System.currentTimeMillis());
|
||||
payment.setAuthCode(scanPayDTO.getAuthCode());
|
||||
orderPaymentService.save(payment);
|
||||
} else {
|
||||
payment.setAuthCode(scanPayDTO.getAuthCode());
|
||||
payment.setUpdatedAt(System.currentTimeMillis());
|
||||
orderPaymentService.updateById(payment);
|
||||
}
|
||||
|
||||
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderInfo.setPayType(qpay);
|
||||
orderInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
orderInfoMapper.update(orderInfo, new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, scanPayDTO.getOrderId()));
|
||||
|
||||
// if ("ysk".equals(thirdPayType)) {
|
||||
//
|
||||
// ScanPayReq scanPayReq = new ScanPayReq();
|
||||
// scanPayReq.setAppId(thirdApply.getAppId());
|
||||
// scanPayReq.setTimestamp(System.currentTimeMillis());
|
||||
// scanPayReq.setAuthCode(scanPayDTO.getAuthCode());
|
||||
// scanPayReq.setNotifyUrl(backUrl);
|
||||
// scanPayReq.setConsumeFee(BigDecimal.valueOf(payment.getAmount()).setScale(2, RoundingMode.DOWN).toPlainString());
|
||||
//
|
||||
// Map<String, Object> map = BeanUtil.transBean2Map(scanPayReq);
|
||||
// scanPayReq.setSign(MD5Util.encrypt(map, thirdApply.getAppToken(), true));
|
||||
//
|
||||
//
|
||||
// ResponseEntity<String> response = restTemplate.postForEntity(gateWayUrl.concat("merchantOrder/scanPay"), scanPayReq, String.class);
|
||||
// if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||
// JSONObject object = JSONObject.parseObject(response.getBody());
|
||||
// if (object.get("code").equals("0")) {
|
||||
// payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
|
||||
// payment.setUpdatedAt(System.currentTimeMillis());
|
||||
// orderPaymentService.saveOrUpdate(payment);
|
||||
//
|
||||
// //处理支付成功的订单
|
||||
// orderInfo.setStatus("closed");
|
||||
// orderInfo.setPayOrderNo(object.getJSONObject("data").get("orderNumber").toString());
|
||||
// orderInfoMapper.update(orderInfo, new LambdaQueryWrapper<TbOrderInfo>()
|
||||
// .eq(TbOrderInfo::getId, scanPayDTO.getOrderId()));
|
||||
//
|
||||
// //更新购物车状态
|
||||
// TbCashierCart cashierCart = new TbCashierCart();
|
||||
// cashierCart.setStatus("final");
|
||||
// int cartCount = cashierCartMapper.update(cashierCart, new LambdaQueryWrapper<TbCashierCart>()
|
||||
// .eq(TbCashierCart::getOrderId, scanPayDTO.getOrderId()));
|
||||
// log.info("更新购物车:{}", cartCount);
|
||||
//
|
||||
// //更新子单状态
|
||||
// TbOrderDetail orderDetail = new TbOrderDetail();
|
||||
// orderDetail.setStatus("closed");
|
||||
// orderDetailMapper.update(orderDetail, new LambdaQueryWrapper<TbOrderDetail>()
|
||||
// .eq(TbOrderDetail::getOrderId, scanPayDTO.getOrderId()));
|
||||
//
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("type", "create");
|
||||
// jsonObject.put("orderId", scanPayDTO.getOrderId());
|
||||
//
|
||||
// rabbitMsgUtils.sendOrderCollectMsg(jsonObject);
|
||||
//
|
||||
//
|
||||
// producer.printMechine(orderId);
|
||||
//
|
||||
// return Result.success(CodeEnum.SUCCESS, object.getJSONObject("data"));
|
||||
// } else {
|
||||
// String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
|
||||
// if (ObjectUtil.isNotNull(status) && "7".equals(status)) {
|
||||
//
|
||||
// orderInfo.setStatus("paying");
|
||||
// orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
//
|
||||
// payment.setTradeNumber(object.getJSONObject("data").get("orderNumber").toString());
|
||||
// payment.setUpdatedAt(System.currentTimeMillis());
|
||||
// tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
// return Result.success(CodeEnum.PAYING);
|
||||
// }
|
||||
//// orderInfo.setStatus("fail");
|
||||
//// orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
//// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
//
|
||||
// return Result.fail(object.getString("msg"));
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
//
|
||||
// String reqbody = "";
|
||||
//
|
||||
// if (body.length() > 15) {
|
||||
// reqbody = body.substring(0, 6).concat("....").concat(body.substring(body.length() - 6, body.length()));
|
||||
// } else {
|
||||
// reqbody = body.toString();
|
||||
// }
|
||||
//
|
||||
// PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), reqbody, reqbody, payment.getAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), payType.equals("wechatPay") ? thirdApply.getSmallAppid() : null, authCode, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
|
||||
// if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||
// if ("000000".equals(publicResp.getCode())) {
|
||||
// MainScanResp mainScanResp = publicResp.getObjData();
|
||||
// if ("TRADE_SUCCESS".equals(mainScanResp.getState())) {
|
||||
// payment.setTradeNumber(mainScanResp.getPayOrderId());
|
||||
// payment.setUpdatedAt(System.currentTimeMillis());
|
||||
// tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
//
|
||||
// //处理支付成功的订单
|
||||
// orderInfo.setStatus("closed");
|
||||
// orderInfo.setPayOrderNo(mainScanResp.getPayOrderId());
|
||||
// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
//
|
||||
// //更新购物车状态
|
||||
// int cartCount = tbCashierCartMapper.updateByOrderId(orderId, "final");
|
||||
// log.info("更新购物车:{}", cartCount);
|
||||
//
|
||||
// //更新子单状态
|
||||
// tbOrderDetailMapper.updateStatusByOrderIdAndStatus(Integer.valueOf(orderId), "closed");
|
||||
//
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.put("token", token);
|
||||
// jsonObject.put("type", "create");
|
||||
// jsonObject.put("orderId", orderId);
|
||||
//
|
||||
// producer.putOrderCollect(jsonObject.toJSONString());
|
||||
//
|
||||
// producer.printMechine(orderId);
|
||||
//
|
||||
// return Result.success(CodeEnum.SUCCESS, mainScanResp);
|
||||
// } else if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
|
||||
// orderInfo.setStatus("paying");
|
||||
// orderInfo.setPayOrderNo(payment.getTradeNumber());
|
||||
// tbOrderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
//
|
||||
// payment.setTradeNumber(mainScanResp.getPayOrderId());
|
||||
// payment.setUpdatedAt(System.currentTimeMillis());
|
||||
// tbOrderPaymentMapper.updateByPrimaryKeySelective(payment);
|
||||
// return Result.success(CodeEnum.PAYING);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private final TbMShopUserMapper shopUserMapper;
|
||||
private final TbShopUserFlowMapper shopUserFlowMapper;
|
||||
|
||||
@Override
|
||||
public TbOrderInfo vipPay(@NotNull Integer shopId, @NotNull Integer orderId) {
|
||||
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectById(orderId);
|
||||
|
||||
if (ObjectUtil.isEmpty(orderInfo)) {
|
||||
throw new BadRequestException("订单不存在");
|
||||
}
|
||||
|
||||
if (!"unpaid".equals(orderInfo.getStatus()) && !"pending".equals(orderInfo.getStatus())) {
|
||||
throw new BadRequestException("订单非未支付状态");
|
||||
}
|
||||
|
||||
|
||||
// 扣减会员余额
|
||||
TbShopUser shopUser = shopUserMapper.selectOne(new LambdaUpdateWrapper<TbShopUser>()
|
||||
.eq(TbShopUser::getStatus, 1)
|
||||
.eq(TbShopUser::getId, orderInfo.getUserId()));
|
||||
|
||||
if (shopUser == null) {
|
||||
throw new BadRequestException("用户不存在或已被禁用");
|
||||
}
|
||||
|
||||
long flag = shopUserMapper.decrBalance(Integer.valueOf(orderInfo.getUserId()), orderInfo.getOrderAmount());
|
||||
if (flag < 1) {
|
||||
throw new BadRequestException("余额不足或扣除余额失败");
|
||||
}
|
||||
|
||||
TbShopUserFlow userFlow = new TbShopUserFlow();
|
||||
userFlow.setAmount(orderInfo.getOrderAmount());
|
||||
userFlow.setBalance(shopUser.getAmount());
|
||||
userFlow.setShopUserId(shopUser.getId());
|
||||
userFlow.setBizCode("vipCardCash");
|
||||
userFlow.setBizName("代客下单会员余额支付");
|
||||
userFlow.setCreateTime(DateUtil.date());
|
||||
userFlow.setType("-");
|
||||
shopUserFlowMapper.insert(userFlow);
|
||||
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderInfo.setPayType("cash");
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
//更新购物车状态
|
||||
int cartCount = cashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getOrderId, orderId)
|
||||
.set(TbCashierCart::getStatus, "final"));
|
||||
|
||||
orderDetailMapper.update(null, new LambdaUpdateWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, orderId)
|
||||
.set(TbOrderDetail::getStatus, "closed"));
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbOrderInfo cashPay(PayDTO payDTO) {
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectOne(new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, payDTO.getOrderId())
|
||||
.eq(TbOrderInfo::getShopId, payDTO.getShopId()));
|
||||
|
||||
if (orderInfo == null) {
|
||||
throw new BadRequestException("订单信息不存在");
|
||||
}
|
||||
|
||||
if (!"unpaid".equals(orderInfo.getStatus()) && !"pending".equals(orderInfo.getStatus())) {
|
||||
throw new BadRequestException("此订单不处于未支付状态");
|
||||
}
|
||||
|
||||
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.PAYING.getState()));
|
||||
// int count = shopInfoRepository.countSelectByShopIdAndPayType(orderInfo.getShopId(), "cash");
|
||||
// if (count < 1) {
|
||||
// return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
||||
// }
|
||||
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderInfo.setPayType("cash");
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
|
||||
//更新购物车状态
|
||||
TbCashierCart cashierCart = new TbCashierCart();
|
||||
cashierCart.setStatus("final");
|
||||
int cartCount = cashierCartMapper.update(cashierCart, new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getOrderId, payDTO.getOrderId()));
|
||||
|
||||
TbOrderDetail orderDetail = new TbOrderDetail();
|
||||
orderDetail.setStatus("closed");
|
||||
orderDetailMapper.update(orderDetail, new LambdaUpdateWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, payDTO.getOrderId()));
|
||||
|
||||
return orderInfo;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,12 @@ import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mapper.order.TbOrderInfoMapper;
|
||||
import cn.ysk.cashier.mapper.product.TbProductMapper;
|
||||
import cn.ysk.cashier.mapper.product.TbProductSkuMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateInRecord;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateOutRecord;
|
||||
import cn.ysk.cashier.mybatis.entity.TbActivateProduct;
|
||||
import cn.ysk.cashier.mybatis.entity.TbOrderPayment;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateInRecordService;
|
||||
import cn.ysk.cashier.mybatis.service.TbActivateOutRecordService;
|
||||
import cn.ysk.cashier.mybatis.service.TbOrderPaymentService;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
@@ -33,6 +38,8 @@ import cn.ysk.cashier.vo.TbOrderInfoVo;
|
||||
import cn.ysk.cashier.vo.TbOrderPayCountVo;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -79,6 +86,8 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
private final RedisUtils redisUtils;
|
||||
private final ThirdPayService thirdPayService;
|
||||
private final TbCashierCartRepository cartRepository;
|
||||
private final TbActivateInRecordService inRecordService;
|
||||
private final TbActivateOutRecordService outRecordService;
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
|
||||
@Value("${thirdPay.url}")
|
||||
@@ -362,6 +371,22 @@ public class TbOrderInfoServiceImpl implements TbOrderInfoService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void upOrderStatus(TbOrderInfo tbOrderInfo) {
|
||||
tbOrderInfo.setStatus("cancelled");
|
||||
//订单取消 赠送商品数量返回
|
||||
QueryWrapper<TbActivateOutRecord> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id",tbOrderInfo.getId());
|
||||
queryWrapper.eq("status","create");
|
||||
List<TbActivateOutRecord> outRecords = outRecordService.list(queryWrapper);
|
||||
for (TbActivateOutRecord outRecord : outRecords) {
|
||||
TbActivateInRecord inRecord = inRecordService.getById(outRecord.getGiveId());
|
||||
inRecord.setOverNum(inRecord.getOverNum() + outRecord.getUseNum());
|
||||
inRecordService.updateById(inRecord);
|
||||
}
|
||||
LambdaUpdateWrapper<TbActivateOutRecord> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(TbActivateOutRecord::getOrderId, tbOrderInfo.getId())
|
||||
.eq(TbActivateOutRecord::getStatus, "create")
|
||||
.set(TbActivateOutRecord::getStatus, "cancel");
|
||||
outRecordService.update(lambdaUpdateWrapper);
|
||||
|
||||
List<TbOrderDetail> details = tbOrderDetailRepository.searchDetailByOrderId(tbOrderInfo.getId());
|
||||
Set<String> keys = new HashSet<>();
|
||||
for (TbOrderDetail detail : details) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.ysk.cashier.service.impl.productimpl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.product.OutAndOnDto;
|
||||
import cn.ysk.cashier.dto.product.StockQueryDto;
|
||||
import cn.ysk.cashier.dto.product.TbProductDto;
|
||||
@@ -73,7 +74,10 @@ public class StockServiceImpl implements StockService {
|
||||
@Override
|
||||
public Page queryAllV2(StockQueryDto criteria, Integer page, Integer size) {
|
||||
Pageable pageable = PageRequest.of(page, size);
|
||||
return tbProductSkuRepository.searchProStockV2(criteria.getShopId(), criteria.getName(), criteria.getIsStock(), criteria.getCategoryId(), pageable);
|
||||
if (StrUtil.isNotBlank(criteria.getSort()) && Boolean.parseBoolean(criteria.getSort())) {
|
||||
return tbProductSkuRepository.searchProStockV2ByDesc(criteria.getShopId(), criteria.getName(), criteria.getIsStock(), criteria.getCategoryId(), pageable);
|
||||
}
|
||||
return tbProductSkuRepository.searchProStockV2(criteria.getShopId(), criteria.getName(), criteria.getIsStock(), criteria.getCategoryId(), pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,12 +18,13 @@ package cn.ysk.cashier.service.impl.shopimpl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.ysk.cashier.config.security.security.TokenProvider;
|
||||
import cn.ysk.cashier.cons.RedisConstant;
|
||||
import cn.ysk.cashier.cons.rabbit.RabbitConstants;
|
||||
import cn.ysk.cashier.dto.shoptable.*;
|
||||
import cn.ysk.cashier.enums.ShopWxMsgTypeEnum;
|
||||
import cn.ysk.cashier.enums.TableStateEnum;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
|
||||
import cn.ysk.cashier.mybatis.mapper.*;
|
||||
@@ -40,6 +41,7 @@ import cn.ysk.cashier.repository.order.TbCashierCartRepository;
|
||||
import cn.ysk.cashier.repository.product.TbProductRepository;
|
||||
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
|
||||
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||
import cn.ysk.cashier.service.impl.TbPayServiceImpl;
|
||||
import cn.ysk.cashier.utils.*;
|
||||
import cn.ysk.cashier.vo.PendingCountVO;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -100,11 +102,14 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
private final WxAccountUtil wxAccountUtil;
|
||||
private final WxMsgUtils wxMsgUtils;
|
||||
private final TbShopPayTypeRepository payTypeRepository;
|
||||
private final MpShopTableMapper mpShopTableMapper;
|
||||
|
||||
/**
|
||||
* 桌码前缀
|
||||
*/
|
||||
private final String QRCODE = "https://kysh.sxczgkj.cn/codeplate?code=";
|
||||
private final RabbitMsgUtils rabbitMsgUtils;
|
||||
private final TbPayServiceImpl tbPayServiceImpl;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TbShopTableQueryCriteria criteria, Pageable pageable) {
|
||||
@@ -275,8 +280,28 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
return tbCashierCart;
|
||||
}
|
||||
|
||||
/**
|
||||
* 台桌状态校验
|
||||
*
|
||||
* @param tableId 桌码
|
||||
* @return z
|
||||
*/
|
||||
private TbShopTable checkTableIsOpen(String tableId) {
|
||||
TbShopTable shopTable = tbShopTableRepository.findByQrcode(tableId);
|
||||
if (shopTable == null) {
|
||||
throw new BadRequestException("桌码不存在,桌码" + tableId);
|
||||
}
|
||||
if (!shopTable.getStatus().equals("using") && !shopTable.getStatus().equals("idle")
|
||||
&& !shopTable.getStatus().equals("pending")) {
|
||||
throw new BadRequestException("当前台桌非开台状态");
|
||||
}
|
||||
return shopTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TbCashierCart addCartForUser(AddCartDTO addCartDTO) {
|
||||
checkTableIsOpen(addCartDTO.getTableId());
|
||||
|
||||
TbProductSku productSku = productMapper.selectSkuByIdAndShopId(addCartDTO.getShopId(), addCartDTO.getSkuId());
|
||||
TbProduct product = productMapper.selectByIdAndShopId(addCartDTO.getShopId(), addCartDTO.getProductId());
|
||||
|
||||
@@ -287,26 +312,24 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
if ((product.getIsDistribute().equals(1) && product.getStockNumber() < 1)
|
||||
|| (!product.getIsDistribute().equals(1) && productSku.getStockNumber() < 1)
|
||||
) {
|
||||
throw new BadRequestException("商品库存不足");
|
||||
}
|
||||
|
||||
TbShopTable shopTable = tbShopTableRepository.findByQrcode(addCartDTO.getTableId());
|
||||
if (shopTable == null) {
|
||||
throw new BadRequestException("桌码不存在,桌码" + addCartDTO.getTableId());
|
||||
throw new BadRequestException(product.getName() + "商品库存不足");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TbCashierCart> query = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, addCartDTO.getShopId())
|
||||
.eq(TbCashierCart::getSkuId, addCartDTO.getSkuId())
|
||||
.eq(TbCashierCart::getProductId, addCartDTO.getProductId())
|
||||
.eq(TbCashierCart::getTableId, addCartDTO.getTableId());
|
||||
if (addCartDTO.getVipUserId() != null) {
|
||||
query.eq(TbCashierCart::getUserId, addCartDTO.getVipUserId());
|
||||
} else {
|
||||
query.eq(TbCashierCart::getMasterId, addCartDTO.getMasterId());
|
||||
query.isNull(TbCashierCart::getUserId);
|
||||
}
|
||||
|
||||
.eq(TbCashierCart::getTableId, addCartDTO.getTableId())
|
||||
.and(query2 -> {
|
||||
query2.and(query3 -> {
|
||||
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||
.eq(TbCashierCart::getMasterId, addCartDTO.getMasterId());
|
||||
})
|
||||
.or((query4 -> {
|
||||
query4.isNull(TbCashierCart::getTradeDay)
|
||||
.eq(TbCashierCart::getMasterId, "");
|
||||
}));
|
||||
});
|
||||
TbCashierCart tbCashierCart = cashierCartMapper.selectOne(query);
|
||||
// 首次加入
|
||||
if (tbCashierCart == null) {
|
||||
@@ -328,6 +351,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
tbCashierCart.setIsGift(String.valueOf(addCartDTO.isGift()));
|
||||
tbCashierCart.setSalePrice(productSku.getSalePrice());
|
||||
tbCashierCart.setTotalAmount(new BigDecimal(addCartDTO.getNum()).multiply(productSku.getSalePrice()));
|
||||
tbCashierCart.setSkuName(productSku.getSpecSnap());
|
||||
if (!addCartDTO.isPack()) {
|
||||
tbCashierCart.setPackFee(BigDecimal.ZERO);
|
||||
} else {
|
||||
@@ -376,6 +400,17 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
@Override
|
||||
public void removeCart(RemoveCartDTO removeCartDTO) {
|
||||
// 会员点单
|
||||
TbCashierCart cashierCart = cashierCartMapper.selectOne(new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, removeCartDTO.getShopId())
|
||||
.eq(TbCashierCart::getId, removeCartDTO.getCartId()));
|
||||
if (cashierCart == null) {
|
||||
throw new BadRequestException("购物车商品不存在");
|
||||
}
|
||||
|
||||
if (cashierCart.getOrderId() != null) {
|
||||
orderDetailMapper.delete(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, cashierCart.getOrderId()));
|
||||
}
|
||||
cashierCartMapper.delete(new LambdaQueryWrapper<TbCashierCart>().eq(TbCashierCart::getShopId, removeCartDTO.getShopId())
|
||||
.eq(TbCashierCart::getId, removeCartDTO.getCartId()));
|
||||
}
|
||||
@@ -400,15 +435,25 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
Integer size, Integer shopId, Integer vipUserId, String masterId) {
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getTableId, tableId)
|
||||
.eq(TbCashierCart::getStatus, "create")
|
||||
.eq(TbCashierCart::getShopId, shopId);
|
||||
.in(TbCashierCart::getStatus, "create", "refund")
|
||||
.eq(TbCashierCart::getShopId, shopId)
|
||||
.and(query2 -> {
|
||||
query2.or(query3 -> {
|
||||
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||
.eq(TbCashierCart::getMasterId, masterId);
|
||||
})
|
||||
.or((query4 -> {
|
||||
query4.isNull(TbCashierCart::getTradeDay)
|
||||
.eq(TbCashierCart::getMasterId, "");
|
||||
}));
|
||||
});
|
||||
|
||||
if (vipUserId != null) {
|
||||
queryWrapper.eq(TbCashierCart::getUserId, vipUserId);
|
||||
}else {
|
||||
queryWrapper.eq(TbCashierCart::getMasterId, masterId);
|
||||
queryWrapper.isNull(TbCashierCart::getUserId);
|
||||
}
|
||||
// if (vipUserId != null) {
|
||||
// queryWrapper.eq(TbCashierCart::getUserId, vipUserId);
|
||||
// }else {
|
||||
// queryWrapper.eq(TbCashierCart::getMasterId, masterId);
|
||||
// queryWrapper.isNull(TbCashierCart::getUserId);
|
||||
// }
|
||||
|
||||
com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbCashierCart> cartPage = cashierCartMapper
|
||||
.selectPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size), queryWrapper);
|
||||
@@ -444,13 +489,23 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getTableId, packCartDTO.getTableId())
|
||||
.eq(TbCashierCart::getShopId, packCartDTO.getShopId())
|
||||
.eq(TbCashierCart::getStatus, "create");
|
||||
.in(TbCashierCart::getStatus, "create", "refund")
|
||||
.and(query2 -> {
|
||||
query2.or(query3 -> {
|
||||
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||
.eq(TbCashierCart::getMasterId, packCartDTO.getMasterId());
|
||||
})
|
||||
.or((query4 -> {
|
||||
query4.isNull(TbCashierCart::getTradeDay)
|
||||
.eq(TbCashierCart::getMasterId, "");
|
||||
}));
|
||||
});
|
||||
|
||||
if (packCartDTO.getVipUserId() != null) {
|
||||
queryWrapper.eq(TbCashierCart::getUserId, packCartDTO.getVipUserId());
|
||||
} else {
|
||||
queryWrapper.isNull(TbCashierCart::getUserId);
|
||||
}
|
||||
// if (packCartDTO.getVipUserId() != null) {
|
||||
// queryWrapper.eq(TbCashierCart::getUserId, packCartDTO.getVipUserId());
|
||||
// } else {
|
||||
// queryWrapper.isNull(TbCashierCart::getUserId);
|
||||
// }
|
||||
|
||||
List<TbCashierCart> tbCashierCarts = cashierCartMapper.selectList(queryWrapper);
|
||||
tbCashierCarts.forEach(item -> {
|
||||
@@ -469,41 +524,43 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
|
||||
/**
|
||||
* 增加库存
|
||||
*
|
||||
* @param productId 商品id
|
||||
* @param skuId sku
|
||||
* @param addNum 增加的库存数量
|
||||
* @param skuId sku
|
||||
* @param addNum 增加的库存数量
|
||||
*/
|
||||
public void incrStock(Integer productId, Integer skuId, Integer addNum) {
|
||||
TbProduct product = productMapper.selectById(productId);
|
||||
if (product.getIsDistribute() == 1) {
|
||||
productMapper.incrStock(product.getId(), addNum);
|
||||
}else {
|
||||
} else {
|
||||
producSkutMapper.incrStock(skuId, addNum);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 减少库存
|
||||
*
|
||||
* @param productId 商品数据
|
||||
* @param skuId sku
|
||||
* @param decrNum 减少的数量
|
||||
* @param skuId sku
|
||||
* @param decrNum 减少的数量
|
||||
*/
|
||||
public void decrStock(Integer productId, String skuId, int decrNum) {
|
||||
TbProduct product = productMapper.selectById(productId);
|
||||
if (product.getIsDistribute() == 1) {
|
||||
if (product.getIsStock() == 1) {
|
||||
if (productMapper.decrStock(productId, decrNum) < 1) {
|
||||
throw new BadRequestException("库存不足,下单失败");
|
||||
throw new BadRequestException(product.getName() + "库存不足,下单失败");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
productMapper.decrStockUnCheck(productId, decrNum);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
if (product.getIsStock() == 1) {
|
||||
if (producSkutMapper.decrStock(String.valueOf(skuId), decrNum) < 1) {
|
||||
throw new BadRequestException("库存不足,下单失败");
|
||||
throw new BadRequestException(product.getName() + "库存不足,下单失败");
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
producSkutMapper.decrStockUnCheck(String.valueOf(skuId), decrNum);
|
||||
}
|
||||
}
|
||||
@@ -535,6 +592,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
|
||||
/**
|
||||
* 更新库存
|
||||
*
|
||||
* @param cashierCart 购物车
|
||||
* @return 是否是第一次添加的商品
|
||||
*/
|
||||
@@ -564,6 +622,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
|
||||
/**
|
||||
* 更新取餐号
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @return 当前取餐号
|
||||
*/
|
||||
@@ -625,7 +684,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
);
|
||||
|
||||
wxMsgUtils.aboardStockMsg(shopInfo.getShopName(), shopId, product.getName(),
|
||||
product.getIsDistribute() == 1 ? product.getStockNumber()-num : (int) (productSku.getStockNumber() - num));
|
||||
product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -636,6 +695,16 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
return "DDPL" + date + randomNum;
|
||||
}
|
||||
|
||||
public synchronized void addGlobalCode(String day, String clientType, String shopId) {
|
||||
String code = redisTemplate.opsForValue().get("SHOP:CODE:" + clientType + ":" + shopId + ":" + day);
|
||||
if (StrUtil.isBlank(code)) {
|
||||
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "1");
|
||||
} else {
|
||||
redisTemplate.opsForValue().get("SHOP:CODE:" + clientType + ":" + shopId + ":" + (Integer.parseInt(code) + 1));
|
||||
}
|
||||
redisTemplate.opsForValue().setIfAbsent("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, "1");
|
||||
}
|
||||
|
||||
public synchronized String generateOrderCode(String day, String clientType, String shopId) {
|
||||
String code = redisTemplate.opsForValue().get("SHOP:CODE:" + clientType + ":" + shopId + ":" + day);
|
||||
// 使用顺序递增的计数器生成取餐码
|
||||
@@ -646,7 +715,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
} else {
|
||||
orderCode = String.valueOf(Integer.parseInt(code.replace("#", "")) + 1);
|
||||
}
|
||||
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, String.valueOf(Integer.parseInt(orderCode) + 1));
|
||||
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, orderCode);
|
||||
boolean flag = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, orderCode));
|
||||
if (flag) {
|
||||
return generateOrderCode(day, clientType, shopId);
|
||||
@@ -668,7 +737,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
TbMerchantAccount merchantAccount = merchantAccountMapper.selectOne(new LambdaQueryWrapper<TbMerchantAccount>().eq(TbMerchantAccount::getAccount, account));
|
||||
String day = DateUtils.getDay();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String key = "SHOP:CODE:USER:pc" + ":" + shopId + ":" + day + ":" + tableId + ":" + (vipUserId == null ? "" : vipUserId);
|
||||
// 当前台桌码
|
||||
String key = "SHOP:CODE:USER:pc" + ":" + shopId + ":" + day + ":" + tableId;
|
||||
String userCode = redisTemplate.opsForValue().get(key);
|
||||
|
||||
if (StringUtils.isEmpty(userCode) || "null".equals(userCode) || "#null".equals(userCode)) {
|
||||
@@ -683,18 +753,29 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
|
||||
|
||||
@Override
|
||||
public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO) {
|
||||
public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO, boolean addMaterId) {
|
||||
|
||||
String day = DateUtils.getDay();
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, createOrderDTO.getShopId())
|
||||
.eq(TbCashierCart::getTableId, createOrderDTO.getTableId())
|
||||
.eq(TbCashierCart::getStatus, "create");
|
||||
if (createOrderDTO.getVipUserId() != null) {
|
||||
queryWrapper.eq(TbCashierCart::getUserId, createOrderDTO.getVipUserId());
|
||||
}else {
|
||||
queryWrapper.eq(TbCashierCart::getMasterId, createOrderDTO.getMasterId())
|
||||
.isNull(TbCashierCart::getUserId);
|
||||
}
|
||||
.in(TbCashierCart::getStatus, "create", "refund")
|
||||
.and(query2 -> {
|
||||
query2.or(query3 -> {
|
||||
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||
.eq(TbCashierCart::getMasterId, createOrderDTO.getMasterId());
|
||||
})
|
||||
.or((query4 -> {
|
||||
query4.isNull(TbCashierCart::getTradeDay)
|
||||
.eq(TbCashierCart::getMasterId, "");
|
||||
}));
|
||||
});
|
||||
// if (createOrderDTO.getVipUserId() != null) {
|
||||
// queryWrapper.eq(TbCashierCart::getUserId, createOrderDTO.getVipUserId());
|
||||
// }else {
|
||||
// queryWrapper.eq(TbCashierCart::getMasterId, createOrderDTO.getMasterId())
|
||||
// .isNull(TbCashierCart::getUserId);
|
||||
// }
|
||||
List<TbCashierCart> cashierCarts = cashierCartMapper
|
||||
.selectList(queryWrapper);
|
||||
if (cashierCarts.isEmpty()) {
|
||||
@@ -751,18 +832,20 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
orderInfo.setSettlementAmount(totalAmount);
|
||||
orderInfo.setAmount(totalAmount);
|
||||
orderInfo.setOriginAmount(totalAmount);
|
||||
orderInfo.setStatus("unpaid");
|
||||
// orderInfo.setStatus("unpaid");
|
||||
orderInfo.setOrderAmount(totalAmount);
|
||||
orderInfo.setRemark(createOrderDTO.getNote());
|
||||
orderInfo.setFreightAmount(feeAmount);
|
||||
orderInfo.setProductAmount(saleAmount);
|
||||
orderInfo.setTradeDay(DateUtils.getDay());
|
||||
orderInfo.setUseType(createOrderDTO.isPostPay() ? "postPay" : "afterPay");
|
||||
orderInfo.setUserId(createOrderDTO.getVipUserId() == null ? null : String.valueOf(createOrderDTO.getVipUserId()));
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
|
||||
}else {
|
||||
} else {
|
||||
String orderNo = generateOrderNumber();
|
||||
orderInfo = new TbOrderInfo();
|
||||
orderInfo.setOrderNo(orderNo);
|
||||
orderInfo.setUseType(createOrderDTO.isPostPay() ? "postPay" : "afterPay");
|
||||
orderInfo.setAmount(totalAmount);
|
||||
orderInfo.setPackFee(packAMount);
|
||||
orderInfo.setSettlementAmount(totalAmount);
|
||||
@@ -778,11 +861,19 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
orderInfo.setTradeDay(day);
|
||||
orderInfo.setMasterId(createOrderDTO.getMasterId());
|
||||
orderInfo.setRemark(createOrderDTO.getNote());
|
||||
orderInfo.setUserId(createOrderDTO.getVipUserId() == null ? null : String.valueOf(createOrderDTO.getVipUserId()));
|
||||
orderInfo.setCreatedAt(DateUtil.current());
|
||||
TbMerchantAccount merchantAccount = merchantAccountMapper.selectOne(new LambdaQueryWrapper<TbMerchantAccount>()
|
||||
.eq(TbMerchantAccount::getShopId, createOrderDTO.getShopId())
|
||||
.eq(TbMerchantAccount::getStatus, 1));
|
||||
if (merchantAccount == null) {
|
||||
throw new BadRequestException("商户信息不存在");
|
||||
}
|
||||
orderInfo.setMerchantId(merchantAccount.getId().toString());
|
||||
orderInfoMapper.insert(orderInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 添加订单详细数据
|
||||
orderId = orderInfo.getId();
|
||||
for (TbOrderDetail orderDetail : orderDetails) {
|
||||
@@ -804,23 +895,49 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
isFirst = updateStock(cashierCart);
|
||||
cashierCart.setOrderId(orderId);
|
||||
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
||||
cashierCart.setStatus("pending".equals(orderInfo.getStatus()) ? "refund" : cashierCart.getStatus());
|
||||
cashierCartMapper.updateById(cashierCart);
|
||||
}
|
||||
if (isFirst) {
|
||||
redisTemplate.delete("SHOP:CODE:USER:pc:" + createOrderDTO.getShopId() + ":"
|
||||
+ day + ":" + createOrderDTO.getTableId() + ":" + (createOrderDTO.getVipUserId() == null ? "" : createOrderDTO.getVipUserId()));
|
||||
// 后付费,不增加当前台桌取餐号
|
||||
if (createOrderDTO.isPostPay()) {
|
||||
// addGlobalCode(day, "pc", String.valueOf(createOrderDTO.getShopId()));
|
||||
String key = "SHOP:CODE:USER:pc" + ":" + createOrderDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
||||
redisTemplate.delete(key);
|
||||
} else {
|
||||
String key = "SHOP:CODE:USER:pc" + ":" + createOrderDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
// 推送耗材信息
|
||||
pushConsMsg(orderInfo, cashierCarts);
|
||||
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.USING.getState()));
|
||||
|
||||
if (createOrderDTO.isPostPay()) {
|
||||
rabbitMsgUtils.printTicket(String.valueOf(orderId));
|
||||
}
|
||||
|
||||
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Object pending(PendingDTO pendingDTO) {
|
||||
|
||||
if (pendingDTO.getOrderId() != null) {
|
||||
TbOrderInfo tbOrderInfo = orderInfoMapper.selectOne(new LambdaQueryWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, pendingDTO.getOrderId())
|
||||
.eq(TbOrderInfo::getStatus, "pending"));
|
||||
if (tbOrderInfo != null) {
|
||||
return tbOrderInfo;
|
||||
}
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, pendingDTO.getShopId());
|
||||
|
||||
@@ -829,15 +946,27 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
throw new BadRequestException("取消挂起订单id不为空");
|
||||
}
|
||||
queryWrapper.eq(TbCashierCart::getOrderId, pendingDTO.getOrderId());
|
||||
}else {
|
||||
|
||||
} else {
|
||||
queryWrapper.eq(TbCashierCart::getTableId, pendingDTO.getTableId())
|
||||
.eq(TbCashierCart::getStatus, "create");
|
||||
if (pendingDTO.getVipUserId() != null) {
|
||||
queryWrapper.eq(TbCashierCart::getUserId, pendingDTO.getVipUserId());
|
||||
}else {
|
||||
queryWrapper.eq(TbCashierCart::getMasterId, pendingDTO.getMasterId())
|
||||
.isNull(TbCashierCart::getUserId);
|
||||
}
|
||||
.eq(TbCashierCart::getStatus, "create")
|
||||
.eq(TbCashierCart::getTableId, pendingDTO.getTableId())
|
||||
.and(query2 -> {
|
||||
query2.or(query3 -> {
|
||||
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||
.eq(TbCashierCart::getMasterId, pendingDTO.getMasterId());
|
||||
})
|
||||
.or((query4 -> {
|
||||
query4.isNull(TbCashierCart::getTradeDay)
|
||||
.eq(TbCashierCart::getMasterId, "");
|
||||
}));
|
||||
});
|
||||
// if (pendingDTO.getVipUserId() != null) {
|
||||
// queryWrapper.eq(TbCashierCart::getUserId, pendingDTO.getVipUserId());
|
||||
// }else {
|
||||
// queryWrapper.eq(TbCashierCart::getMasterId, pendingDTO.getMasterId())
|
||||
// .isNull(TbCashierCart::getUserId);
|
||||
// }
|
||||
|
||||
}
|
||||
List<TbCashierCart> cashierCarts = cashierCartMapper
|
||||
@@ -859,7 +988,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
createOrderDTO.setShopId(pendingDTO.getShopId());
|
||||
createOrderDTO.setMasterId(pendingDTO.getMasterId());
|
||||
createOrderDTO.setVipUserId(pendingDTO.getVipUserId());
|
||||
orderId = createOrder(createOrderDTO).getId();
|
||||
createOrderDTO.setNote(pendingDTO.getNote());
|
||||
orderId = createOrder(createOrderDTO, true).getId();
|
||||
|
||||
}
|
||||
|
||||
@@ -877,26 +1007,56 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
|
||||
TbCashierCart cashierCart = new TbCashierCart();
|
||||
cashierCart.setStatus(pendingDTO.getIsPending() ? "refund" : "create");
|
||||
cashierCart.setPendingAt(pendingDTO.getIsPending() ? DateUtil.current() : cashierCart.getPendingAt());
|
||||
cashierCartMapper.update(cashierCart, new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getOrderId, orderId));
|
||||
return orderInfo;
|
||||
|
||||
|
||||
// 后付款订单,修改台桌状态并打票
|
||||
if (pendingDTO.getIsPending()) {
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, cashierCart.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.PENDING.getState()));
|
||||
|
||||
rabbitMsgUtils.printTicket(String.valueOf(orderId));
|
||||
}
|
||||
return orderInfoMapper.selectById(orderId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getCar(Integer shopId) {
|
||||
public Object getCar(Integer shopId, String tableId) {
|
||||
ArrayList<Map<String, Object>> data = new ArrayList<>();
|
||||
|
||||
List<PendingCountVO> pendingCountVOS = cashierCartMapper.countPending(shopId);
|
||||
List<PendingCountVO> pendingCountVOS = cashierCartMapper.countPending(shopId, tableId, DateUtils.getDay());
|
||||
List<TbCashierCart> tbCashierCarts = cashierCartMapper.selectList(new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, shopId)
|
||||
.eq(TbCashierCart::getTableId, tableId)
|
||||
.eq(TbCashierCart::getStatus, "refund"));
|
||||
|
||||
ArrayList<Integer> skuIds = new ArrayList<>();
|
||||
tbCashierCarts.forEach(item -> {
|
||||
skuIds.add(Integer.valueOf(item.getSkuId()));
|
||||
});
|
||||
|
||||
List<TbProductSku> skuList = productSkuRepository.findAllById(skuIds);
|
||||
|
||||
LinkedHashMap<String, TbProductSku> skuMap = new LinkedHashMap<>();
|
||||
skuList.forEach(item -> {
|
||||
skuMap.put(item.getId().toString(), item);
|
||||
});
|
||||
|
||||
|
||||
cashierCartMapper.selectPending(shopId);
|
||||
|
||||
HashMap<String, List<TbCashierCart>> cashierMap = new HashMap<>();
|
||||
HashMap<String, List<Map<String, Object>>> cashierMap = new HashMap<>();
|
||||
for (TbCashierCart tbCashierCart : tbCashierCarts) {
|
||||
List<TbCashierCart> list = cashierMap.computeIfAbsent(tbCashierCart.getOrderId().toString(), k -> new ArrayList<>());
|
||||
list.add(tbCashierCart);
|
||||
TbProductSku productSku = skuMap.get(tbCashierCart.getSkuId());
|
||||
Map<String, Object> map = BeanUtil.beanToMap(tbCashierCart, false, false);
|
||||
map.put("specSnap", productSku == null ? "" : productSku.getSpecSnap());
|
||||
|
||||
List<Map<String, Object>> list = cashierMap.computeIfAbsent(tbCashierCart.getOrderId().toString(), k -> new ArrayList<>());
|
||||
|
||||
list.add(map);
|
||||
}
|
||||
|
||||
pendingCountVOS.forEach(item -> {
|
||||
@@ -914,55 +1074,80 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
|
||||
@Override
|
||||
public Object pay(PayDTO payDTO) {
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectOne(new LambdaUpdateWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getId, payDTO.getOrderId())
|
||||
.eq(TbOrderInfo::getShopId, payDTO.getShopId()));
|
||||
|
||||
if (orderInfo == null) {
|
||||
throw new BadRequestException("订单信息不存在");
|
||||
TbOrderInfo orderInfo = null;
|
||||
switch (payDTO.getPayType()) {
|
||||
case "vipPay":
|
||||
orderInfo = tbPayServiceImpl.vipPay(payDTO.getShopId(), payDTO.getOrderId());
|
||||
break;
|
||||
case "cash":
|
||||
orderInfo = tbPayServiceImpl.cashPay(payDTO);
|
||||
break;
|
||||
default:
|
||||
throw new BadRequestException("未知支付方式");
|
||||
}
|
||||
|
||||
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||
return new BadRequestException("此订单不处于未支付状态");
|
||||
}
|
||||
|
||||
// int count = shopInfoRepository.countSelectByShopIdAndPayType(orderInfo.getShopId(), "cash");
|
||||
// if (count < 1) {
|
||||
// return Result.fail(CodeEnum.PAYTYPENOEXIST);
|
||||
// }
|
||||
|
||||
orderInfo.setPayAmount(orderInfo.getOrderAmount());
|
||||
orderInfo.setPayType("cash");
|
||||
orderInfo.setStatus("closed");
|
||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||
orderInfoMapper.updateById(orderInfo);
|
||||
|
||||
//更新购物车状态
|
||||
TbCashierCart cashierCart = new TbCashierCart();
|
||||
cashierCart.setStatus("final");
|
||||
int cartCount = cashierCartMapper.update(cashierCart, new LambdaUpdateWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getOrderId, payDTO.getOrderId()));
|
||||
|
||||
TbOrderDetail orderDetail = new TbOrderDetail();
|
||||
orderDetail.setStatus("closed");
|
||||
orderDetailMapper.update(orderDetail, new LambdaUpdateWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, payDTO.getOrderId()));
|
||||
|
||||
log.info("更新购物车:{}", cartCount);
|
||||
log.info("更新购物车");
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("token", null);
|
||||
jsonObject.put("type", "create");
|
||||
jsonObject.put("orderId", payDTO.getOrderId());
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, jsonObject.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||
jsonObject.put("orderId", orderInfo.getId());
|
||||
|
||||
// 打印消息
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, payDTO.getOrderId().toString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||
rabbitMsgUtils.sendOrderCollectMsg(jsonObject);
|
||||
if (StrUtil.isBlank(orderInfo.getUseType()) || orderInfo.getUseType().equals("afterPay")) {
|
||||
rabbitMsgUtils.printTicket(String.valueOf(orderInfo.getId()));
|
||||
}
|
||||
|
||||
// 发送库存记录mq消息
|
||||
JSONObject mqData = new JSONObject();
|
||||
mqData.put("orderId", payDTO.getOrderId());
|
||||
mqData.put("type", "pc");
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, mqData.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||
|
||||
// 修改台桌状态
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
|
||||
|
||||
if ("postPay".equals(orderInfo.getUseType())) {
|
||||
String day = DateUtils.getDay();
|
||||
String key = "SHOP:CODE:USER:pc" + ":" + payDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deleteOrder(DeleteOrderDTO deleteOrderDTO) {
|
||||
int count1 = orderInfoMapper.delete(new LambdaQueryWrapper<TbOrderInfo>()
|
||||
.eq(TbOrderInfo::getShopId, deleteOrderDTO.getShopId())
|
||||
.eq(TbOrderInfo::getId, deleteOrderDTO.getOrderId()));
|
||||
|
||||
int count2 = orderDetailMapper.delete(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getShopId, deleteOrderDTO.getShopId())
|
||||
.eq(TbOrderDetail::getOrderId, deleteOrderDTO.getOrderId()));
|
||||
|
||||
int count3 = cashierCartMapper.delete(new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, deleteOrderDTO.getShopId())
|
||||
.eq(TbCashierCart::getOrderId, deleteOrderDTO.getOrderId()));
|
||||
return count1 > 0 && count2 > 0 && count3 > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object updateVip(UpdateVipDTO updateVipDTO) {
|
||||
LambdaUpdateWrapper<TbCashierCart> queryWrapper = new LambdaUpdateWrapper<>();
|
||||
queryWrapper.eq(TbCashierCart::getTableId, updateVipDTO.getTableId())
|
||||
.eq(TbCashierCart::getMasterId, updateVipDTO.getMasterId())
|
||||
.eq(TbCashierCart::getShopId, updateVipDTO.getShopId());
|
||||
|
||||
if (updateVipDTO.getType().equals(0)) {
|
||||
queryWrapper.set(TbCashierCart::getUserId, null);
|
||||
queryWrapper.eq(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
|
||||
} else {
|
||||
queryWrapper.set(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
|
||||
}
|
||||
return cashierCartMapper.update(null, queryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package cn.ysk.cashier.service.impl.shopimpl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.ysk.cashier.dto.shop.TbShopRechargeListDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopRechargeRespDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopUserDto;
|
||||
import cn.ysk.cashier.dto.shop.TbShopUserQueryCriteria;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mapper.shop.TbShopUserMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUserFlow;
|
||||
import cn.ysk.cashier.mybatis.mapper.ShopUserMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbShopUserFlowMapper;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||
@@ -31,6 +34,7 @@ import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
@@ -50,6 +54,10 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
||||
@Autowired
|
||||
private ShopUserMapper shopUserMapper;
|
||||
|
||||
@Autowired
|
||||
private TbShopUserFlowMapper tbShopUserFlowMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryShopUser(TbShopUserQueryCriteria criteria) {
|
||||
IPage<ShopUserInfoVo> iPage = shopUserMapper.queryUser(criteria, criteria.getIsVip(),
|
||||
@@ -183,4 +191,71 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modfiyAccount(Map<String, Object> map) {
|
||||
if(ObjectUtil.isNull(map)||ObjectUtil.isEmpty(map)||!map.containsKey("id")||!map.containsKey("type")||!map.containsKey("amount")
|
||||
||ObjectUtil.isEmpty(map.get("id"))||ObjectUtil.isNull(map.get("id"))||ObjectUtil.isNull(map.get("type"))||ObjectUtil.isEmpty(map.get("type"))
|
||||
||ObjectUtil.isEmpty(map.get("amount"))||ObjectUtil.isNull(map.get("amount"))||!map.containsKey("operationType")||ObjectUtil.isEmpty(map.get("operationType"))||ObjectUtil.isNull(map.get("operationType"))
|
||||
|
||||
){
|
||||
throw new BadRequestException("参数错误");
|
||||
|
||||
}
|
||||
|
||||
String regex = "^(([1-9][0-9]*)|(([0]\\.\\d{1,2}|[1-9][0-9]*\\.\\d{1,2})))$";
|
||||
if(!map.get("amount").toString().matches(regex)){
|
||||
throw new BadRequestException("请输入正确的数字");
|
||||
}
|
||||
|
||||
|
||||
|
||||
TbShopUser tbShopUser= tbShopUserRepository.getById(Integer.valueOf(map.get("id")+""));
|
||||
if(ObjectUtil.isNull(tbShopUser)){
|
||||
throw new BadRequestException("不存在的会员信息");
|
||||
}
|
||||
String operationType=map.get("operationType").toString();
|
||||
|
||||
BigDecimal amount=new BigDecimal(map.get("amount").toString());
|
||||
if("out".equals(operationType)){
|
||||
if(amount.compareTo(tbShopUser.getAmount())>0){
|
||||
throw new BadRequestException("账户余额不足,请输入正确的金额");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
String type=map.get("type").toString();
|
||||
TbShopUserFlow flow=new TbShopUserFlow();
|
||||
|
||||
if("in".equals(operationType)){
|
||||
flow.setType("+");
|
||||
flow.setBizName("inMoney".equals(type)?"充值退款":"消费退款");
|
||||
flow.setBizCode("inMoney".equals(type)?"inMoneyIn":"consumeIn");
|
||||
tbShopUser.setAmount(tbShopUser.getAmount().add(amount));
|
||||
}else if("out".equals(operationType)){
|
||||
flow.setBizName("inMoney".equals(type)?"充值退款扣除":"消费扣除");
|
||||
flow.setBizCode("inMoney".equals(type)?"inMoneyOut":"consumeOut");
|
||||
flow.setType("-");
|
||||
tbShopUser.setAmount(tbShopUser.getAmount().subtract(amount));
|
||||
}else {
|
||||
throw new BadRequestException("错误的请求类型");
|
||||
}
|
||||
|
||||
tbShopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
tbShopUserRepository.save(tbShopUser);
|
||||
|
||||
|
||||
flow.setShopUserId(tbShopUser.getId());
|
||||
flow.setAmount(amount);
|
||||
flow.setBalance(tbShopUser.getAmount());
|
||||
flow.setCreateTime(new Date());
|
||||
|
||||
tbShopUserFlowMapper.insert(flow);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -108,15 +108,19 @@ public interface TbShopTableService {
|
||||
|
||||
void pack(PackCartDTO packCartDTO);
|
||||
|
||||
Object createOrder(CreateOrderDTO createOrderDTO);
|
||||
Object createOrder(CreateOrderDTO createOrderDTO, boolean addMasterId);
|
||||
|
||||
Object getMasterId(Integer shopId, Long tableId, Integer vipUserId);
|
||||
|
||||
Object pending(PendingDTO pendingDTO);
|
||||
|
||||
Object getCar(Integer shopId);
|
||||
Object getCar(Integer shopId, String tableId);
|
||||
|
||||
Object getPayType(Integer shopId);
|
||||
|
||||
Object pay(PayDTO payDTO);
|
||||
|
||||
Object deleteOrder(DeleteOrderDTO deleteOrderDTO);
|
||||
|
||||
Object updateVip(UpdateVipDTO updateVipDTO);
|
||||
}
|
||||
|
||||
@@ -89,4 +89,6 @@ public interface TbShopUserService {
|
||||
|
||||
void rechargeListDownload(HttpServletResponse response, TbShopRechargeListDto criteria) throws IOException;
|
||||
|
||||
void modfiyAccount(Map<String,Object> map);
|
||||
|
||||
}
|
||||
|
||||
158
eladmin-system/src/main/java/cn/ysk/cashier/utils/MD5Util.java
Normal file
158
eladmin-system/src/main/java/cn/ysk/cashier/utils/MD5Util.java
Normal file
@@ -0,0 +1,158 @@
|
||||
package cn.ysk.cashier.utils;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class MD5Util {
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MD5Util.class);
|
||||
|
||||
private static final String hexDigIts[] = {"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};
|
||||
|
||||
public static String encrypt(String plainText) {
|
||||
try {
|
||||
return encrypt(plainText,true);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
log.error("MD5加密异常:",e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Title: encrypt
|
||||
* @Description: TODO(16位或32位密码)
|
||||
* @param @param
|
||||
* plainText
|
||||
* @param @param
|
||||
* flag true为32位,false为16位
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
public static String encrypt(String plainText, boolean flag) throws UnsupportedEncodingException {
|
||||
try {
|
||||
if (ObjectUtil.isEmpty(plainText)) {
|
||||
return null;
|
||||
}
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
String encrStr = byteArrayToHexString(md.digest(plainText.getBytes("UTF-8")));
|
||||
if (flag)
|
||||
return encrStr;
|
||||
else
|
||||
return encrStr.substring(8, 24);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static String encrypt(Object obj,String privateKey){
|
||||
if(obj==null){
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<String,Object>();
|
||||
if(obj instanceof Map){
|
||||
map=(Map<String, Object>) obj;
|
||||
}else{
|
||||
map = BeanUtil.transBean2Map(obj);
|
||||
}
|
||||
return encrypt(map,privateKey,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Title: encrypt
|
||||
* @Description: TODO(16位或32位密码)
|
||||
* @param @param
|
||||
* plainText
|
||||
* @param @param
|
||||
* flag true为32位,false为16位
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
public static String encrypt(Map<String, Object> map, String privateKey,boolean flag) {
|
||||
String param = null;
|
||||
map.remove("sign");
|
||||
map.remove("encrypt");
|
||||
String result = BeanUtil.mapOrderStr(map);
|
||||
if (StringUtils.isEmpty(result)) {
|
||||
return null;
|
||||
}
|
||||
param = encrypt(encrypt(result)+privateKey);
|
||||
if (flag) {
|
||||
return param;
|
||||
} else {
|
||||
param = param.substring(8, 24);
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
public static Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, Object> mapFn(Map<String, Object> map) {
|
||||
for (String key : map.keySet()) {
|
||||
if (map.get(key) != null && map.get(key) != "" && (!key.equals("BTYPE") && !key.equals("SIGN"))) {
|
||||
if (key.equals("INPUT")) {
|
||||
if (map.get(key) != null) {
|
||||
mapFn((Map<String, Object>) map.get(key));
|
||||
}
|
||||
} else {
|
||||
resultMap.put(key, map.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static boolean check(Object obj,String privateKey){
|
||||
Map<String,Object> map=new HashMap<String,Object>();
|
||||
if(obj==null){
|
||||
return false;
|
||||
}
|
||||
if(obj instanceof Map){
|
||||
map=(Map<String, Object>) obj;
|
||||
}else{
|
||||
map = BeanUtil.transBean2Map(obj);
|
||||
}
|
||||
System.out.println("check:"+ JSONUtil.toJsonStr(map));
|
||||
String sign=(String)map.get("sign");
|
||||
if(sign==null){
|
||||
return false;
|
||||
}
|
||||
String str=encrypt(obj,privateKey);
|
||||
System.out.println("check: "+str);
|
||||
|
||||
return sign.equals(str)?true:false;
|
||||
}
|
||||
|
||||
public static String byteArrayToHexString(byte b[]){
|
||||
StringBuffer resultSb = new StringBuffer();
|
||||
for(int i = 0; i < b.length; i++){
|
||||
resultSb.append(byteToHexString(b[i]));
|
||||
}
|
||||
return resultSb.toString();
|
||||
}
|
||||
|
||||
public static String byteToHexString(byte b){
|
||||
int n = b;
|
||||
if(n < 0){
|
||||
n += 256;
|
||||
}
|
||||
int d1 = n / 16;
|
||||
int d2 = n % 16;
|
||||
return hexDigIts[d1] + hexDigIts[d2];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.ysk.cashier.utils;
|
||||
|
||||
import cn.ysk.cashier.cons.rabbit.RabbitConstants;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
|
||||
public RabbitMsgUtils(RabbitTemplate rabbitTemplate) {
|
||||
this.rabbitTemplate = rabbitTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void confirm(CorrelationData correlationData, boolean ack, String cause) {
|
||||
log.info(" 回调id:{}", correlationData);
|
||||
if (ack) {
|
||||
log.info("消息成功消费");
|
||||
} else {
|
||||
log.info("消息消费失败:{}", cause);
|
||||
}
|
||||
}
|
||||
|
||||
private <T> void sendMsg(String exchange, String routingKey, T data, String note, boolean isJson) {
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
log.info("开始发送{}mq消息, msgId: {}, exchange: {}, routingKey: {}, data: {}", correlationId.getId(), note, exchange, routingKey, data);
|
||||
rabbitTemplate.convertAndSend(exchange, routingKey, isJson ? JSONObject.toJSONString(data) : data, correlationId);
|
||||
}
|
||||
|
||||
public <T> void sendOrderCollectMsg(T data) {
|
||||
sendMsg(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, data, "订单信息收集", true);
|
||||
}
|
||||
|
||||
public void printTicket(String orderId){
|
||||
sendMsg(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, orderId, "打印票", false);
|
||||
}
|
||||
|
||||
public <T> void sendStockMsg(T mqData) {
|
||||
// 发送库存记录mq消息
|
||||
sendMsg(RabbitConstants.EXCHANGE_STOCK_RECORD, RabbitConstants.ROUTING_STOCK_RECORD_SALE, mqData, "库存记录", true);
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,5 @@ public class PendingCountVO {
|
||||
private Integer totalCount;
|
||||
private Integer totalNumber;
|
||||
private Integer orderId;
|
||||
private String remark;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.ysk.cashier.mybatis.mapper.TbMShopUserMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="cn.ysk.cashier.mybatis.entity.TbMShopUser">
|
||||
<resultMap id="BaseResultMap" type="cn.ysk.cashier.mybatis.entity.TbShopUser">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="amount" column="amount" jdbcType="DECIMAL"/>
|
||||
<result property="credit_amount" column="credit_amount" jdbcType="DECIMAL"/>
|
||||
|
||||
Reference in New Issue
Block a user