Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
bac894dfbc
|
|
@ -0,0 +1,70 @@
|
|||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.area.ShopAreaAddDTO;
|
||||
import com.czg.account.dto.area.ShopAreaEditDTO;
|
||||
import com.czg.account.entity.ShopTableArea;
|
||||
import com.czg.account.service.ShopTableAreaService;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 区域管理
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/shopArea")
|
||||
public class ShopTableAreaController {
|
||||
@Resource
|
||||
private ShopTableAreaService shopTableAreaService;
|
||||
|
||||
/**
|
||||
* 区域获取
|
||||
* 权限标识: shopArea:add
|
||||
* @param name 区域名称
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission("shopArea:list")
|
||||
@GetMapping
|
||||
public CzgResult<Page<ShopTableArea>> list(String name) {
|
||||
return CzgResult.success(shopTableAreaService.pageInfo(StpKit.USER.getShopId(), name));
|
||||
}
|
||||
|
||||
/**
|
||||
* 区域修改
|
||||
* 权限标识: shopArea:edit
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission("shopArea:edit")
|
||||
@PutMapping
|
||||
public CzgResult<Boolean> edit(@RequestBody @Validated ShopAreaEditDTO shopAreaEditDTO) {
|
||||
return CzgResult.success(shopTableAreaService.edit(StpKit.USER.getShopId(), shopAreaEditDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 区域删除
|
||||
* 权限标识: shopArea:del
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission("shopArea:del")
|
||||
@DeleteMapping
|
||||
public CzgResult<Boolean> remove(@RequestBody @Validated ShopAreaEditDTO shopAreaEditDTO) {
|
||||
return CzgResult.success(shopTableAreaService.remove(new QueryWrapper().eq(ShopTableArea::getShopId, StpKit.USER.getShopId()).eq(ShopTableArea::getId, shopAreaEditDTO.getId())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 区域新增
|
||||
* 权限标识: shopArea:add
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission("shopArea:add")
|
||||
@PostMapping
|
||||
public CzgResult<Boolean> add(@RequestBody @Validated ShopAreaAddDTO shopAreaAddDTO) {
|
||||
return CzgResult.success(shopTableAreaService.add(shopAreaAddDTO));
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.czg.controller.admin;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.dto.table.ShopTableAddDTO;
|
||||
import com.czg.account.dto.table.ShopTableBindDTO;
|
||||
import com.czg.account.dto.table.ShopTableDTO;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import com.czg.account.service.ShopTableService;
|
||||
|
|
@ -100,4 +101,15 @@ public class ShopTableController {
|
|||
}
|
||||
return CzgResult.success(shopTableService.add(StpKit.USER.getShopId(), shopTableAddDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 台桌绑定
|
||||
* 权限标识: shopTable:bind
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission("shopTable:bind")
|
||||
@PostMapping("/bind")
|
||||
public CzgResult<Boolean> bind(@RequestBody @Validated ShopTableBindDTO shopTableBindDTO) {
|
||||
return CzgResult.success(shopTableService.bind(StpKit.USER.getShopId(), shopTableBindDTO));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("notify")
|
||||
@RequestMapping("/notify")
|
||||
public class NotifyController {
|
||||
private static final String SUCCESS = "SUCCESS";
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ public class NotifyController {
|
|||
private OrderInfoService orderInfoService;
|
||||
|
||||
|
||||
@RequestMapping("payCallBack")
|
||||
@RequestMapping("/payCallBack")
|
||||
public String notifyCallBack(@RequestBody CzgBaseRespParams respParams){
|
||||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
||||
AssertUtil.isNull(czg, "回调数据为空");
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ public class OrderPayController {
|
|||
private PayService payService;
|
||||
|
||||
|
||||
@PostMapping("/cashPay")
|
||||
public CzgResult<Object> cashPayOrder(@Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
return payService.cashPayOrder(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员支付
|
||||
* payType 必填
|
||||
|
|
@ -37,7 +42,7 @@ public class OrderPayController {
|
|||
* <p>
|
||||
* accountPay(小程序使用) 密码支付 用户密码pwd 必填
|
||||
*/
|
||||
@PostMapping("vipPay")
|
||||
@PostMapping("/vipPay")
|
||||
public CzgResult<Object> vipPayOrder(@Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付类型不可为空");
|
||||
return payService.vipPayOrder(payParam);
|
||||
|
|
@ -46,7 +51,7 @@ public class OrderPayController {
|
|||
/**
|
||||
* h5支付
|
||||
*/
|
||||
@PostMapping("h5Pay")
|
||||
@PostMapping("/h5Pay")
|
||||
public CzgResult<Map<String, Object>> h5PayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
return payService.h5PayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
||||
}
|
||||
|
|
@ -57,7 +62,7 @@ public class OrderPayController {
|
|||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("jsPay")
|
||||
@PostMapping("/jsPay")
|
||||
public CzgResult<Map<String, Object>> jsPayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
return payService.jsPayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
||||
}
|
||||
|
|
@ -67,7 +72,7 @@ public class OrderPayController {
|
|||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("ltPayOrder")
|
||||
@PostMapping("/ltPayOrder")
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
return payService.ltPayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
||||
}
|
||||
|
|
@ -75,7 +80,7 @@ public class OrderPayController {
|
|||
/**
|
||||
* 正扫
|
||||
*/
|
||||
@PostMapping("scanPay")
|
||||
@PostMapping("/scanPay")
|
||||
public CzgResult<Map<String, Object>> scanPayOrder(HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
return payService.scanPayOrder(ServletUtil.getClientIPByHeader(request), payParam);
|
||||
}
|
||||
|
|
@ -84,7 +89,7 @@ public class OrderPayController {
|
|||
* 反扫
|
||||
* authCode 必填 扫描码
|
||||
*/
|
||||
@PostMapping("microPay")
|
||||
@PostMapping("/microPay")
|
||||
public CzgResult<Map<String, Object>> microPayOrder(@Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
return payService.microPayOrder(payParam);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class VipPayController {
|
|||
* 现金充值
|
||||
* 如果shop_info的 is_member_in_pwd=1 则pwd必填 店铺操作密码
|
||||
*/
|
||||
@PostMapping("cashPayVip")
|
||||
@PostMapping("/cashPayVip")
|
||||
public CzgResult<Object> cashPayVip(@Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
|
|
@ -43,7 +43,7 @@ public class VipPayController {
|
|||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("jsPayVip")
|
||||
@PostMapping("/jsPayVip")
|
||||
public CzgResult<Map<String, Object>> jsPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
|
|
@ -55,7 +55,7 @@ public class VipPayController {
|
|||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("ltPayVip")
|
||||
@PostMapping("/ltPayVip")
|
||||
public CzgResult<Map<String, Object>> ltPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
|
|
@ -65,7 +65,7 @@ public class VipPayController {
|
|||
/**
|
||||
* 正扫
|
||||
*/
|
||||
@PostMapping("scanPayVip")
|
||||
@PostMapping("/scanPayVip")
|
||||
public CzgResult<Map<String, Object>> scanPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
|
|
@ -76,7 +76,7 @@ public class VipPayController {
|
|||
* 反扫
|
||||
* authCode 必填 扫描码
|
||||
*/
|
||||
@PostMapping("microPayVip")
|
||||
@PostMapping("/microPayVip")
|
||||
public CzgResult<Map<String, Object>> microPayVip(@Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
* @description
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admin/order")
|
||||
@RequestMapping("/admin/order")
|
||||
public class AdminOrderController {
|
||||
|
||||
@Resource
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
package com.czg.account.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import java.io.Serial;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ShopTableCodeDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 桌码
|
||||
*/
|
||||
private String tableCode;
|
||||
|
||||
/**
|
||||
* 状态 待绑定0 已绑定1
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 绑定时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime bindTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
|
||||
package com.czg.account.dto.area;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 店铺区域 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Data
|
||||
public class ShopAreaAddDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 区域名称
|
||||
*/
|
||||
@NotEmpty(message = "店铺名称不为空")
|
||||
private String name;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
|
||||
package com.czg.account.dto;
|
||||
package com.czg.account.dto.area;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.Serial;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
|
@ -18,21 +20,14 @@ import lombok.NoArgsConstructor;
|
|||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ShopAreaDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
public class ShopAreaEditDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@NotNull
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 店铺Id
|
||||
*/
|
||||
private Integer shopId;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
|
|
@ -43,8 +38,5 @@ public class ShopAreaDTO implements Serializable {
|
|||
*/
|
||||
private String name;
|
||||
|
||||
private Long createdAt;
|
||||
|
||||
private Long updatedAt;
|
||||
|
||||
}
|
||||
|
|
@ -25,4 +25,9 @@ public class ShopInfoByCodeDTO {
|
|||
* 台桌信息
|
||||
*/
|
||||
private ShopTable shopTable;
|
||||
|
||||
/**
|
||||
* 是否会员
|
||||
*/
|
||||
private boolean isVip;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package com.czg.account.dto.table;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class ShopTableBindDTO {
|
||||
/**
|
||||
* 台桌id
|
||||
*/
|
||||
@NotNull(message = "台桌id不为空")
|
||||
private String id;
|
||||
/**
|
||||
* 桌码
|
||||
*/
|
||||
@NotEmpty(message = "桌码不为空")
|
||||
private String tableCode;
|
||||
}
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
|
@ -37,7 +39,7 @@ public class ShopTableArea implements Serializable {
|
|||
/**
|
||||
* 店铺Id
|
||||
*/
|
||||
private Integer shopId;
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
|
|
@ -49,8 +51,10 @@ public class ShopTableArea implements Serializable {
|
|||
*/
|
||||
private String name;
|
||||
|
||||
private Long createdAt;
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createdTime;
|
||||
|
||||
private Long updatedAt;
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updatedTime;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_table_code")
|
||||
@Accessors(chain = true)
|
||||
public class ShopTableCode implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 桌码
|
||||
*/
|
||||
private String tableCode;
|
||||
|
||||
/**
|
||||
* 状态 待绑定0 已绑定1
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 绑定时间
|
||||
*/
|
||||
private LocalDateTime bindTime;
|
||||
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.ShopTableArea;
|
||||
|
||||
/**
|
||||
* 店铺区域 服务层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
public interface ShopAreaService extends IService<ShopTableArea> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.area.ShopAreaAddDTO;
|
||||
import com.czg.account.dto.area.ShopAreaEditDTO;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.ShopTableArea;
|
||||
|
||||
/**
|
||||
* 店铺区域 服务层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
public interface ShopTableAreaService extends IService<ShopTableArea> {
|
||||
|
||||
Page<ShopTableArea> pageInfo(Long shopId, String name);
|
||||
|
||||
boolean edit(Long shopId, ShopAreaEditDTO shopAreaEditDTO);
|
||||
|
||||
Boolean add(ShopAreaAddDTO shopAreaAddDTO);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.ShopTableCode;
|
||||
|
||||
/**
|
||||
* 服务层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
public interface ShopTableCodeService extends IService<ShopTableCode> {
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.table.ShopTableAddDTO;
|
||||
import com.czg.account.dto.table.ShopTableBindDTO;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
|
|
@ -19,4 +20,7 @@ public interface ShopTableService extends IService<ShopTable> {
|
|||
Boolean add(Long shopId, ShopTableAddDTO shopTableAddDTO);
|
||||
|
||||
void createQrCode(Long shopId, Integer num, HttpServletResponse response) throws IOException;
|
||||
|
||||
Boolean bind(Long shopId, ShopTableBindDTO shopTableBindDTO);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.czg.service.order.enums;
|
||||
package com.czg.order.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
|
|
@ -3,10 +3,14 @@ package com.czg.order.service;
|
|||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.order.dto.OrderInfoQueryDTO;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.enums.PayEnums;
|
||||
import com.czg.order.vo.OrderInfoVo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 订单表 服务层。
|
||||
*
|
||||
|
|
@ -16,6 +20,10 @@ import com.mybatisflex.core.service.IService;
|
|||
public interface OrderInfoService extends IService<OrderInfo> {
|
||||
|
||||
Page<OrderInfoVo> getOrderByPage(OrderInfoQueryDTO param);
|
||||
|
||||
void payCallBackOrder(String orderNo, JSONObject resultJson);
|
||||
|
||||
void refundCallBackOrder();
|
||||
|
||||
void upOrderInfo(Long orderId, BigDecimal payAmount, LocalDateTime payTime, Long payOrderId, PayEnums payType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopTableCode;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
public interface ShopTableCodeMapper extends BaseMapper<ShopTableCode> {
|
||||
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopTableArea;
|
||||
import com.czg.account.service.ShopAreaService;
|
||||
import com.czg.service.account.mapper.ShopAreaMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 店铺区域 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Service
|
||||
public class ShopAreaServiceImpl extends ServiceImpl<ShopAreaMapper, ShopTableArea> implements ShopAreaService{
|
||||
|
||||
}
|
||||
|
|
@ -7,14 +7,8 @@ import com.czg.account.dto.PageDTO;
|
|||
import com.czg.account.dto.shopinfo.ShopInfoAddDTO;
|
||||
import com.czg.account.dto.shopinfo.ShopInfoByCodeDTO;
|
||||
import com.czg.account.dto.shopinfo.ShopInfoEditDTO;
|
||||
import com.czg.account.entity.MerchantRegister;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import com.czg.account.entity.SysUser;
|
||||
import com.czg.account.service.MerchantRegisterService;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.ShopTableService;
|
||||
import com.czg.account.service.SysUserService;
|
||||
import com.czg.account.entity.*;
|
||||
import com.czg.account.service.*;
|
||||
import com.czg.enums.StatusEnum;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.exception.CzgException;
|
||||
|
|
@ -42,6 +36,8 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
|||
private MerchantRegisterService merchantRegisterService;
|
||||
@Resource
|
||||
private ShopTableService shopTableService;
|
||||
@Resource
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
private ShopInfo getShopInfo(Long shopId) {
|
||||
ShopInfo shopInfo = getById(shopId);
|
||||
|
|
@ -152,6 +148,8 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
|||
// 计算距离,单位:米
|
||||
distance = GeoUtil.getDistance(Long.parseLong(shopInfo.getLat()), Long.parseLong(shopInfo.getLng()), Long.parseLong(lat), Long.parseLong(lng));
|
||||
}
|
||||
return new ShopInfoByCodeDTO(distance, shopInfo, shopTable);
|
||||
|
||||
ShopUser shopUser = shopUserService.queryChain().eq(ShopUser::getShopId, shopInfo.getId()).eq(ShopUser::getUserId, StpKit.USER.getLoginIdAsLong()).one();
|
||||
return new ShopInfoByCodeDTO(distance, shopInfo, shopTable, shopUser != null && shopUser.getIsVip() != null && shopUser.getIsVip() == 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.mybatisflex.core.query.QueryWrapper;
|
|||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -41,6 +42,7 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
|
|||
private ShopStaffPermissionService shopStaffPermissionService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean add(ShopStaffAddDTO shopStaffAddDTO) {
|
||||
SysUser sysUser = sysUserService.addUser(shopStaffAddDTO.getName(), StpKit.USER.getLoginIdAsString() + "@" +shopStaffAddDTO.getAccountName(),
|
||||
shopStaffAddDTO.getAccountPwd(), shopStaffAddDTO.getPhone(), shopStaffAddDTO.getRoleId());
|
||||
|
|
@ -50,7 +52,9 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
|
|||
save(shopStaff);
|
||||
|
||||
// 权限添加
|
||||
addPermission(shopStaff, shopStaffAddDTO.getShopPermissionIds());
|
||||
if (shopStaffAddDTO.getShopPermissionIds() != null && !shopStaffAddDTO.getShopPermissionIds().isEmpty()) {
|
||||
addPermission(shopStaff, shopStaffAddDTO.getShopPermissionIds());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +70,7 @@ public class ShopStaffServiceImpl extends ServiceImpl<ShopStaffMapper, ShopStaff
|
|||
BeanUtil.copyProperties(shopStaffEditDTO, shopStaff);
|
||||
updateById(shopStaff);
|
||||
|
||||
if (!shopStaffEditDTO.getShopPermissionIds().isEmpty()) {
|
||||
if (shopStaffEditDTO.getShopPermissionIds() != null && !shopStaffEditDTO.getShopPermissionIds().isEmpty()) {
|
||||
shopStaffPermissionService.updateChain().eq(ShopStaffPermission::getStaffId, shopStaff.getId())
|
||||
.eq(ShopStaffPermission::getShopId, StpKit.USER.getShopId()).eq(ShopStaffPermission::getUserId, shopStaff.getId()).remove();
|
||||
// 权限添加
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.dto.area.ShopAreaAddDTO;
|
||||
import com.czg.account.dto.area.ShopAreaEditDTO;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopTableArea;
|
||||
import com.czg.account.service.ShopTableAreaService;
|
||||
import com.czg.service.account.mapper.ShopAreaMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 店铺区域 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-18
|
||||
*/
|
||||
@Service
|
||||
public class ShopTableAreaServiceImpl extends ServiceImpl<ShopAreaMapper, ShopTableArea> implements ShopTableAreaService {
|
||||
|
||||
@Override
|
||||
public Page<ShopTableArea> pageInfo(Long shopId, String name) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper().eq(ShopTableArea::getShopId, shopId);
|
||||
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
queryWrapper.like(ShopTableArea::getName, name);
|
||||
}
|
||||
return page(PageUtil.buildPage(), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean edit(Long shopId, ShopAreaEditDTO shopAreaEditDTO) {
|
||||
ShopTableArea tableArea = queryChain().eq(ShopTableArea::getShopId, shopId).eq(ShopTableArea::getId, shopAreaEditDTO.getId()).one();
|
||||
if (tableArea == null) {
|
||||
throw new ApiNotPrintException("区域不存在");
|
||||
}
|
||||
|
||||
BeanUtil.copyProperties(shopAreaEditDTO, tableArea);
|
||||
return updateById(tableArea);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean add(ShopAreaAddDTO shopAreaAddDTO) {
|
||||
ShopTableArea shopTableArea = BeanUtil.copyProperties(shopAreaAddDTO, ShopTableArea.class);
|
||||
shopTableArea.setShopId(StpKit.USER.getShopId());
|
||||
return save(shopTableArea);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopTableCode;
|
||||
import com.czg.account.service.ShopTableCodeService;
|
||||
import com.czg.service.account.mapper.ShopTableCodeMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-19
|
||||
*/
|
||||
@Service
|
||||
public class ShopTableCodeServiceImpl extends ServiceImpl<ShopTableCodeMapper, ShopTableCode> implements ShopTableCodeService{
|
||||
|
||||
}
|
||||
|
|
@ -1,12 +1,16 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import com.czg.account.dto.table.ShopTableAddDTO;
|
||||
import com.czg.account.dto.table.ShopTableBindDTO;
|
||||
import com.czg.account.entity.ShopTableArea;
|
||||
import com.czg.account.service.ShopAreaService;
|
||||
import com.czg.account.entity.ShopTableCode;
|
||||
import com.czg.account.service.ShopTableAreaService;
|
||||
import com.czg.account.service.ShopTableCodeService;
|
||||
import com.czg.enums.ShopTableStatusEnum;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
|
|
@ -24,6 +28,8 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
|
|
@ -36,7 +42,9 @@ import java.util.zip.ZipOutputStream;
|
|||
@Service
|
||||
public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable> implements ShopTableService{
|
||||
@Resource
|
||||
private ShopAreaService shopAreaService;
|
||||
private ShopTableAreaService shopAreaService;
|
||||
@Resource
|
||||
private ShopTableCodeService shopTableCodeService;
|
||||
|
||||
@Override
|
||||
public Boolean add(Long shopId, ShopTableAddDTO shopTableAddDTO) {
|
||||
|
|
@ -81,27 +89,24 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
|
|||
}
|
||||
|
||||
// 获取可用 id
|
||||
List<Integer> idList = queryChain().isNull(ShopTable::getTableCode)
|
||||
.select("id").orderBy(ShopTable::getId, false)
|
||||
.page(new Page<>(1, num)).getRecords().stream()
|
||||
.map(ShopTable::getId).toList();
|
||||
List<ShopTableCode> records = shopTableCodeService.queryChain().orderBy(ShopTableCode::getId, false).page(new Page<>(1, 1)).getRecords();
|
||||
Map<String, Long> codeMap = shopTableCodeService.queryChain().eq(ShopTableCode::getShopId, shopId).select(ShopTableCode::getTableCode, ShopTableCode::getId)
|
||||
.list().stream().collect(Collectors.toMap(ShopTableCode::getTableCode, ShopTableCode::getId));
|
||||
|
||||
long maxId = idList.isEmpty() ? 1 : idList.getLast();
|
||||
long maxId = records.isEmpty() ? 0 : records.getFirst().getId();
|
||||
|
||||
// 设置 ZIP 响应头
|
||||
response.setContentType("application/zip");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=shop_qrcodes_" + shopId + ".zip");
|
||||
|
||||
ArrayList<ShopTableCode> codeList = new ArrayList<>();
|
||||
// 使用 ZipOutputStream 将二维码写入 zip
|
||||
try (ZipOutputStream zipOut = new ZipOutputStream(response.getOutputStream())) {
|
||||
for (int i = 0; i < num; i++) {
|
||||
String tableCode = shopId.toString();
|
||||
if (i > idList.size() - 1) {
|
||||
tableCode = tableCode + ++maxId;
|
||||
} else {
|
||||
tableCode = tableCode + idList.get(i);
|
||||
}
|
||||
tableCode = tableCode + RandomUtil.randomNumbers(8);
|
||||
String tableCode = generateCode(1, shopId, ++maxId, codeMap);
|
||||
codeMap.put(tableCode, maxId);
|
||||
|
||||
codeList.add(new ShopTableCode().setShopId(shopId).setTableCode(tableCode));
|
||||
|
||||
// 生成二维码
|
||||
BufferedImage qrImage = QrCodeUtil.generate(tableCode, 300, 300);
|
||||
|
|
@ -117,5 +122,48 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
|
|||
zipOut.closeEntry();
|
||||
}
|
||||
}
|
||||
|
||||
shopTableCodeService.saveBatch(codeList);
|
||||
}
|
||||
|
||||
private String generateCode(Integer count, Long shopId, Long id, Map<String, Long> map) {
|
||||
if (count > 100) {
|
||||
throw new ApiNotPrintException("桌码生成失败");
|
||||
}
|
||||
String tableCode = "40" + shopId % 10 + id % 10 + RandomUtil.randomNumbers(7);
|
||||
if (map.containsKey(tableCode)) {
|
||||
generateCode(++count, shopId, id + 1, map);
|
||||
}
|
||||
return tableCode;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean bind(Long shopId, ShopTableBindDTO shopTableBindDTO) {
|
||||
if (!StrUtil.startWith(shopTableBindDTO.getTableCode(), "40")) {
|
||||
throw new ApiNotPrintException("错误码");
|
||||
}
|
||||
|
||||
ShopTableCode tableCode = shopTableCodeService.queryChain().eq(ShopTableCode::getTableCode, shopTableBindDTO.getTableCode())
|
||||
.eq(ShopTableCode::getShopId, shopId).one();
|
||||
if (tableCode == null) {
|
||||
throw new ApiNotPrintException("错误码");
|
||||
}
|
||||
|
||||
if (tableCode.getState() == 1) {
|
||||
throw new ApiNotPrintException("此桌码已绑定,请勿重复绑定");
|
||||
}
|
||||
|
||||
ShopTable shopTable = queryChain().eq(ShopTable::getShopId, shopId).eq(ShopTable::getId, shopTableBindDTO.getId()).one();
|
||||
if (shopTable == null) {
|
||||
throw new ApiNotPrintException("台桌不存在");
|
||||
}
|
||||
|
||||
tableCode.setBindTime(DateUtil.date().toLocalDateTime());
|
||||
tableCode.setState(1);
|
||||
shopTableCodeService.updateById(tableCode);
|
||||
|
||||
shopTable.setTableCode(tableCode.getTableCode());
|
||||
return updateById(shopTable);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||
return CzgResult.failure("加入会员后使用");
|
||||
}
|
||||
String dynamicCode = generatePaymentCode(String.valueOf(shopId), String.valueOf(userInfoId));
|
||||
redisService.set(STR."\{RedisCst.SHOP_USER_DYNAMIC_CODE}\{shopUser.getShopId()}:\{dynamicCode}", shopUser.getId(), 180);
|
||||
redisService.set(RedisCst.SHOP_USER_DYNAMIC_CODE + shopUser.getShopId() + ":" + dynamicCode, shopUser.getId(), 180);
|
||||
return CzgResult.success(dynamicCode);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopTableCodeMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -28,7 +28,7 @@ public class Main {
|
|||
// String packageName = "product";
|
||||
// String packageName = "order";
|
||||
|
||||
String tableName = "tb_shop_area";
|
||||
String tableName = "tb_shop_table_code";
|
||||
String author = "zs";
|
||||
//是否生成DTO实体 默认生成
|
||||
boolean isGenerateDto = true;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ public class VipPayParamDTO {
|
|||
private BigDecimal amount;
|
||||
|
||||
private String buyerRemark;
|
||||
/**
|
||||
* 跳转地址
|
||||
*/
|
||||
private String returnUrl;
|
||||
/**
|
||||
* 平台类型 pc 收银机客户端 wechat 微信小程序 alipay 支付宝小程序 admin-pc PC管理端 admin-app APP管理端
|
||||
|
|
@ -27,6 +30,9 @@ public class VipPayParamDTO {
|
|||
private String platformType;
|
||||
private String payType;
|
||||
private String openId;
|
||||
/**
|
||||
* 扫码支付 扫描码
|
||||
*/
|
||||
private String authCode;
|
||||
private String pwd;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ import java.util.Map;
|
|||
* @author ww
|
||||
*/
|
||||
public interface PayService {
|
||||
/**
|
||||
* 现金支付
|
||||
*/
|
||||
CzgResult<Object> cashPayOrder(OrderPayParamDTO payParam);
|
||||
/**
|
||||
* 会员支付
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||
|
|
@ -14,6 +15,7 @@ import com.czg.order.dto.OrderInfoQueryDTO;
|
|||
import com.czg.order.entity.OrderDetail;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.enums.PayEnums;
|
||||
import com.czg.order.service.OrderDetailService;
|
||||
import com.czg.order.service.OrderInfoService;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
|
|
@ -25,6 +27,7 @@ import com.czg.utils.CzgStrUtils;
|
|||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.update.UpdateChain;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
|
@ -34,6 +37,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -104,15 +108,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
|
||||
if ("TRADE_SUCCESS".equals(czgCallBackDto.getState())) {
|
||||
if ("order".equals(payment.getPayType())) {
|
||||
updateChain()
|
||||
.set(OrderInfo::getPayAmount, new BigDecimal(czgCallBackDto.getAmount() / 100L))
|
||||
.set(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
|
||||
.set(OrderInfo::getPaidTime, DateUtil.parseLocalDateTime(czgCallBackDto.getPayTime()))
|
||||
.set(OrderInfo::getPayOrderId, payment.getId())
|
||||
.where(OrderInfo::getId).eq(payment.getSourceId())
|
||||
.update();
|
||||
//发送打票信息
|
||||
rabbitPublisher.sendOrderPrintMsg(payment.getSourceId().toString());
|
||||
upOrderInfo(payment.getSourceId(), new BigDecimal(czgCallBackDto.getAmount() / 100L),
|
||||
DateUtil.parseLocalDateTime(czgCallBackDto.getPayTime()), payment.getId(), null);
|
||||
} else if ("memberIn".equals(payment.getPayType())) {
|
||||
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
||||
if (shopUser == null) {
|
||||
|
|
@ -152,4 +149,33 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
|
|||
public void refundCallBackOrder() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新订单信息 (支付成功后调用)
|
||||
*
|
||||
* @param payAmount 注意是分 还是元
|
||||
* @param payTime 支付时间
|
||||
* @param payOrderId 支付订单号
|
||||
* 现金支付为空
|
||||
* 会员支付为tb_shop_user_flow.id
|
||||
* 其它支付为 tb_order_payment.id
|
||||
*/
|
||||
@Override
|
||||
public void upOrderInfo(Long orderId, BigDecimal payAmount, LocalDateTime payTime, Long payOrderId, PayEnums payType) {
|
||||
UpdateChain<OrderInfo> updateChain = updateChain()
|
||||
.set(OrderInfo::getPayAmount, payAmount)
|
||||
.set(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
|
||||
.set(OrderInfo::getPaidTime, payTime)
|
||||
.where(OrderInfo::getId).eq(orderId);
|
||||
if (payOrderId != null) {
|
||||
updateChain.set(OrderInfo::getPayOrderId, payOrderId);
|
||||
}
|
||||
if (ObjectUtil.isNotNull(payType)) {
|
||||
updateChain.set(OrderInfo::getPayType, payType.getValue());
|
||||
}
|
||||
updateChain.update();
|
||||
//发送打票信息
|
||||
rabbitPublisher.sendOrderPrintMsg(orderId.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.czg.entity.resp.*;
|
|||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.order.entity.OrderInfo;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.enums.PayEnums;
|
||||
import com.czg.order.service.OrderInfoService;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.resp.CzgResult;
|
||||
|
|
@ -24,8 +25,6 @@ import com.czg.service.CzgPayService;
|
|||
import com.czg.service.RedisService;
|
||||
import com.czg.service.order.dto.OrderPayParamDTO;
|
||||
import com.czg.service.order.dto.VipPayParamDTO;
|
||||
import com.czg.service.order.enums.OrderStatusEnums;
|
||||
import com.czg.service.order.enums.PayEnums;
|
||||
import com.czg.service.order.service.PayService;
|
||||
import com.czg.system.enums.SysParamCodeEnum;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
|
|
@ -76,19 +75,32 @@ public class PayServiceImpl implements PayService {
|
|||
|
||||
private final BigDecimal MONEY_RATE = new BigDecimal("100");
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Object> vipPayOrder(OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||
private OrderInfo checkPay(Long orderId) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(orderId);
|
||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||
return CzgResult.failure("该订单已不可支付");
|
||||
throw new ValidateException("该订单已不可支付");
|
||||
}
|
||||
if (!"afterPay".equals(orderInfo.getPayMode())
|
||||
&& orderInfo.getCreateTime().isAfter(LocalDateTimeUtil.offset(LocalDateTime.now(), -15, ChronoUnit.SECONDS))) {
|
||||
return CzgResult.failure("订单十五分钟内有效,当前已超时,请重新下单。");
|
||||
throw new ValidateException("订单十五分钟内有效,当前已超时,请重新下单。");
|
||||
}
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Object> cashPayOrder(OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getOrderId());
|
||||
orderInfoService.upOrderInfo(orderInfo.getId(), orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), null, PayEnums.CASH_PAY);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Object> vipPayOrder(OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = checkPay(payParam.getOrderId());
|
||||
ShopUser shopUser = new ShopUser();
|
||||
if ("scanCode".equals(payParam.getPayType())) {
|
||||
AssertUtil.isBlank(payParam.getAuthCode(), "会员码不能为空");
|
||||
|
|
@ -128,28 +140,19 @@ public class PayServiceImpl implements PayService {
|
|||
.build();
|
||||
//更新会员余额 并生成流水
|
||||
Long flowId = shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
|
||||
orderInfoService.updateChain()
|
||||
.set(OrderInfo::getPayAmount, orderInfo.getOrderAmount())
|
||||
.set(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode())
|
||||
.set(OrderInfo::getPaidTime, LocalDateTime.now())
|
||||
.set(OrderInfo::getPayType, "vip-pay")
|
||||
.set(OrderInfo::getPayOrderId, flowId)
|
||||
.where(OrderInfo::getId).eq(orderInfo.getId())
|
||||
.update();
|
||||
//发送打票信息
|
||||
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId().toString());
|
||||
orderInfoService.upOrderInfo(orderInfo.getId(), orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), flowId, PayEnums.VIP_PAY);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> h5PayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||
OrderInfo orderInfo = checkPay(payParam.getOrderId());
|
||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), payParam.getOrderId(),
|
||||
"order", payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY.getValue(), paymentId);
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.H5_PAY, paymentId);
|
||||
return h5Pay(payParam.getShopId(), new CzgH5PayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
|
||||
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
|
@ -158,14 +161,13 @@ public class PayServiceImpl implements PayService {
|
|||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> jsPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
OrderInfo orderInfo = checkPay(payParam.getOrderId());
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), payParam.getOrderId(),
|
||||
"order", payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI.getValue() : PayEnums.WECHAT_MINI.getValue(), paymentId);
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId);
|
||||
return jsPay(payParam.getShopId(), payParam.getPayType(), new CzgJsPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
|
||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
|
@ -173,12 +175,13 @@ public class PayServiceImpl implements PayService {
|
|||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||
OrderInfo orderInfo = checkPay(payParam.getOrderId());
|
||||
AssertUtil.isBlank(payParam.getPayType(), "支付方式不能为空");
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), payParam.getOrderId(),
|
||||
"order", payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI.getValue() : PayEnums.WECHAT_MINI.getValue(), paymentId);
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId);
|
||||
return ltPay(payParam.getShopId(), payParam.getPayType(), new CzgLtPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
|
||||
"点餐支付", payParam.getOpenId(), clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
|
@ -186,12 +189,12 @@ public class PayServiceImpl implements PayService {
|
|||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> scanPayOrder(@NonNull String clintIp, OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||
OrderInfo orderInfo = checkPay(payParam.getOrderId());
|
||||
|
||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), payParam.getOrderId(),
|
||||
"order", payOrderNo, "", orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN.getValue(), paymentId);
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.MAIN_SCAN, paymentId);
|
||||
return scanPay(payParam.getShopId(), new CzgScanPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
|
||||
"点餐支付", clintIp, payParam.getReturnUrl(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
|
@ -199,13 +202,12 @@ public class PayServiceImpl implements PayService {
|
|||
@Override
|
||||
@Transactional
|
||||
public CzgResult<Map<String, Object>> microPayOrder(OrderPayParamDTO payParam) {
|
||||
OrderInfo orderInfo = orderInfoService.getById(payParam.getOrderId());
|
||||
AssertUtil.isNull(orderInfo, "订单不存在");
|
||||
OrderInfo orderInfo = checkPay(payParam.getOrderId());
|
||||
AssertUtil.isBlank(payParam.getAuthCode(), "扫描码不能为空");
|
||||
String payOrderNo = orderInfo.getPlatformType() + IdUtil.getSnowflakeNextId();
|
||||
Long paymentId = initOrderPayment(new OrderPayment(payParam.getShopId(), payParam.getOrderId(),
|
||||
"order", payOrderNo, payParam.getAuthCode(), orderInfo.getOrderAmount()));
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN.getValue(), paymentId);
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId);
|
||||
return microPay(payParam.getShopId(), new CzgMicroPayReq(payOrderNo, orderInfo.getOrderAmount().multiply(MONEY_RATE).longValue(),
|
||||
"点餐支付", payParam.getAuthCode(), payParam.getBuyerRemark(), ""));
|
||||
}
|
||||
|
|
@ -322,10 +324,10 @@ public class PayServiceImpl implements PayService {
|
|||
return payment.getId();
|
||||
}
|
||||
|
||||
private void upOrderPayInfo(@NonNull Long orderId, @NotBlank String payType, @NotBlank Long paymentId) {
|
||||
private void upOrderPayInfo(@NonNull Long orderId, @NonNull PayEnums payType, @NotBlank Long paymentId) {
|
||||
orderInfoService.updateChain()
|
||||
.set(OrderInfo::getPayOrderId, paymentId)
|
||||
.set(OrderInfo::getPayType, payType)
|
||||
.set(OrderInfo::getPayType, payType.getValue())
|
||||
.where(OrderInfo::getId).eq(orderId)
|
||||
.update();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue