新增Order、OrderGoods、Cart表

This commit is contained in:
2024-11-11 20:53:42 +08:00
parent 810d0c140b
commit 57f1bbddb6
21 changed files with 1688 additions and 469 deletions

View File

@@ -0,0 +1,136 @@
package com.gxwebsoft.common.system.controller;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Cart;
import com.gxwebsoft.common.system.entity.OrderGoods;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.param.CartParam;
import com.gxwebsoft.common.system.service.CartService;
import com.gxwebsoft.common.system.service.OrderGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* 购物车控制器
*
* @author 科技小王子
* @since 2024-10-26 10:54:51
*/
@Api(tags = "购物车管理")
@RestController
@RequestMapping("/api/system/cart")
public class CartController extends BaseController {
@Resource
private CartService cartService;
@Resource
private OrderGoodsService orderGoodsService;
@ApiOperation("分页查询购物车")
@GetMapping("/page")
public ApiResult<PageResult<Cart>> page(CartParam param) {
// 使用关联查询
return success(cartService.pageRel(param));
}
@ApiOperation("查询全部购物车")
@GetMapping()
public ApiResult<List<Cart>> list(CartParam param) {
// 使用关联查询
return success(cartService.listRel(param));
}
@ApiOperation("根据id查询购物车")
@GetMapping("/{id}")
public ApiResult<Cart> get(@PathVariable("id") Long id) {
// 使用关联查询
return success(cartService.getByIdRel(id));
}
@ApiOperation("添加购物车")
@PostMapping()
public ApiResult<?> save(@RequestBody Cart cart) {
System.out.println("cart = " + cart);
final ArrayList<OrderGoods> orderGoods = new ArrayList<>();
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
cart.setUserId(loginUser.getUserId());
cart.setTenantId(loginUser.getTenantId());
if (cart.getType().equals(1)) {
cart.getList().forEach(item -> {
final OrderGoods og = new OrderGoods();
og.setType(cart.getType());
og.setItemId(item.getCompanyId());
og.setPayPrice(item.getPrice());
og.setMonth(cart.getMonth());
og.setTotalNum(cart.getCartNum());
og.setPayStatus(false);
og.setOrderStatus(0);
og.setTenantId(loginUser.getTenantId());
og.setUserId(loginUser.getUserId());
og.setComments("购买".concat(item.getTenantName()));
orderGoods.add(og);
});
}
if (cartService.save(cart)) {
orderGoodsService.saveBatch(orderGoods);
return success("添加成功");
}
}
return fail("添加失败");
}
@ApiOperation("修改购物车")
@PutMapping()
public ApiResult<?> update(@RequestBody Cart cart) {
if (cartService.updateById(cart)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除购物车")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (cartService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加购物车")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<Cart> list) {
if (cartService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改购物车")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<Cart> batchParam) {
if (batchParam.update(cartService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除购物车")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (cartService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}

View File

@@ -0,0 +1,281 @@
package com.gxwebsoft.common.system.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Cart;
import com.gxwebsoft.common.system.entity.Order;
import com.gxwebsoft.common.system.entity.OrderGoods;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.mapper.MenuMapper;
import com.gxwebsoft.common.system.param.MenuParam;
import com.gxwebsoft.common.system.param.OrderParam;
import com.gxwebsoft.common.system.service.MenuService;
import com.gxwebsoft.common.system.service.OrderGoodsService;
import com.gxwebsoft.common.system.service.OrderService;
import com.gxwebsoft.shop.entity.ShopMerchantApply;
import com.gxwebsoft.shop.service.ShopMerchantApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* 订单控制器
*
* @author 科技小王子
* @since 2024-10-16 12:32:52
*/
@Api(tags = "订单管理")
@RestController
@RequestMapping("/api/system/order")
public class OrderController extends BaseController {
@Resource
private OrderService orderService;
@Resource
private OrderGoodsService orderGoodsService;
@Resource
private ShopMerchantApplyService shopMerchantApplyService;
@Resource
private MenuService menuService;
@Resource
private MenuMapper menuMapper;
@ApiOperation("分页查询订单")
@GetMapping("/page")
public ApiResult<PageResult<Order>> page(OrderParam param) {
// 使用关联查询
final User loginUser = getLoginUser();
if (loginUser == null) {
return fail("请先登陆",null);
}
// 非平台权限
if (!loginUser.getTenantId().equals(5)) {
param.setUserId(loginUser.getUserId());
}
return success(orderService.pageRel(param));
}
@PreAuthorize("hasAuthority('sys:order:list')")
@OperationLog
@ApiOperation("查询全部订单")
@GetMapping()
public ApiResult<List<Order>> list(OrderParam param) {
final User loginUser = getLoginUser();
// 非平台权限
if (!loginUser.getTenantId().equals(5)) {
param.setUserId(loginUser.getUserId());
}
// 使用关联查询
return success(orderService.listRel(param));
}
@PreAuthorize("hasAuthority('sys:order:list')")
@OperationLog
@ApiOperation("根据id查询订单")
@GetMapping("/{id}")
public ApiResult<Order> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(orderService.getByIdRel(id));
}
@ApiOperation("添加订单")
@PostMapping()
public ApiResult<?> save(@RequestBody Order order) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if(loginUser == null){
return fail("请先登录");
}
if (ObjectUtil.isEmpty(order.getType())) {
return fail("订单类型不能为空");
}
// 封装订单信息
order.setUserId(loginUser.getUserId());
order.setTenantId(loginUser.getTenantId());
order.setOrderNo(Long.toString(IdUtil.getSnowflakeNextId()));
order.setPhone(loginUser.getPhone());
order.setRealName(loginUser.getRealName());
final ShopMerchantApply shopMerchantApply = shopMerchantApplyService.getOne(new LambdaQueryWrapper<ShopMerchantApply>().eq(ShopMerchantApply::getUserId, loginUser.getUserId()).eq(ShopMerchantApply::getStatus, 1));
if (ObjectUtil.isNotEmpty(shopMerchantApply)) {
order.setRealName(shopMerchantApply.getRealName());
}
// 购买商品
if (order.getType().equals(0)) {
order.setVersion(0);
}
// 购买插件
if (order.getType().equals(1)) {
order.setVersion(1);
}
if (orderService.save(order)) {
// 余额支付
if(order.getPayType().equals(0)){
if (loginUser.getBalance().compareTo(order.getPayPrice()) < 0) {
return fail("余额不足"+loginUser.getBalance()+"==="+order.getPayPrice());
}
return success("支付成功");
}
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('sys:order:update')")
@OperationLog
@ApiOperation("修改订单")
@PutMapping()
public ApiResult<?> update(@RequestBody Order order) {
if (orderService.updateById(order)) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('sys:order:remove')")
@OperationLog
@ApiOperation("删除订单")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (orderService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('sys:order:save')")
@OperationLog
@ApiOperation("批量添加订单")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<Order> list) {
if (orderService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('sys:order:update')")
@OperationLog
@ApiOperation("批量修改订单")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<Order> batchParam) {
if (batchParam.update(orderService, "order_id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('sys:order:remove')")
@OperationLog
@ApiOperation("批量删除订单")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (orderService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("统一下单")
@PostMapping("/createOrder")
public ApiResult<?> createOrder(@RequestBody Cart cart) {
final MenuParam menuParam = new MenuParam();
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
// 封装订单数据
final Order order = new Order();
order.setType(cart.getType());
order.setPayType(cart.getPayType());
order.setPayPrice(cart.getPayPrice());
order.setTotalPrice(cart.getTotalPrice());
order.setMonth(cart.getMonth());
order.setUserId(loginUser.getUserId());
order.setOrderNo(Long.toString(IdUtil.getSnowflakeNextId()));
order.setPhone(loginUser.getPhone());
order.setComments(cart.getComments());
order.setTenantId(loginUser.getTenantId());
order.setRealName(loginUser.getRealName());
order.setPayTime(DateUtil.date());
// 购买商品
if (order.getType().equals(0)) {
order.setVersion(0);
}
// 购买插件
if (order.getType().equals(1)) {
order.setVersion(1);
}
// 判断支付方式
if(order.getPayType() == null){
return fail("支付方式不能为空");
}
// 商品描述(必填)
if (StrUtil.isBlank(order.getComments())) {
return fail("商品描述(必填)");
}
// 微信支付
if(order.getPayType().equals(1)){
// 微信openid(必填)
if (StrUtil.isBlank(loginUser.getOpenid())) {
return fail("微信openid(必填)");
}
// 微信支付(商品金额不能为0)
if (order.getTotalPrice().compareTo(BigDecimal.ZERO) == 0) {
return fail("商品金额不能为0");
}
}
// 创建订单成功
if (orderService.save(order)) {
final ArrayList<OrderGoods> orderGoods = new ArrayList<>();
if (order.getType().equals(1)) {
cart.getList().forEach(item -> {
final OrderGoods og = new OrderGoods();
og.setOrderId(order.getOrderId());
og.setType(order.getType());
og.setItemId(item.getCompanyId());
og.setMenuId(item.getMenuId());
og.setPayPrice(item.getPrice());
og.setMonth(order.getMonth());
og.setTotalNum(order.getCartNum());
og.setPayStatus(false);
og.setOrderStatus(0);
og.setTenantId(loginUser.getTenantId());
og.setUserId(loginUser.getUserId());
og.setComments(item.getTenantName());
orderGoods.add(og);
menuParam.setMenuId(item.getMenuId());
menuParam.setTenantId(item.getTenantId());
});
}
// 记录订单商品
orderGoodsService.saveBatch(orderGoods);
// 余额支付
if(order.getPayType().equals(0)){
if (loginUser.getBalance().compareTo(order.getPayPrice()) < 0) {
return fail("余额不足"+loginUser.getBalance()+"==="+order.getPayPrice());
}
// 附加插件参数
order.setMenuParam(menuParam);
// 执行支付成功后事务
orderService.paySuccess(order);
return success("余额支付成功");
}
}
}
return fail("下单失败");
}
}

View File

@@ -0,0 +1,128 @@
package com.gxwebsoft.common.system.controller;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.OrderGoods;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.param.OrderGoodsParam;
import com.gxwebsoft.common.system.service.OrderGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 订单商品控制器
*
* @author 科技小王子
* @since 2024-10-26 12:18:05
*/
@Api(tags = "订单商品管理")
@RestController
@RequestMapping("/api/system/order-goods")
public class OrderGoodsController extends BaseController {
@Resource
private OrderGoodsService orderGoodsService;
@ApiOperation("分页查询订单商品")
@GetMapping("/page")
public ApiResult<PageResult<OrderGoods>> page(OrderGoodsParam param) {
// 使用关联查询
final User loginUser = getLoginUser();
if (loginUser == null) {
return fail("请先登陆",null);
}
// 非平台权限
if (!loginUser.getTenantId().equals(5)) {
param.setUserId(loginUser.getUserId());
}
return success(orderGoodsService.pageRel(param));
}
@PreAuthorize("hasAuthority('sys:order:list')")
@ApiOperation("查询全部订单商品")
@GetMapping()
public ApiResult<List<OrderGoods>> list(OrderGoodsParam param) {
// 使用关联查询
return success(orderGoodsService.listRel(param));
}
@PreAuthorize("hasAuthority('sys:order:list')")
@ApiOperation("根据id查询订单商品")
@GetMapping("/{id}")
public ApiResult<OrderGoods> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(orderGoodsService.getByIdRel(id));
}
@PreAuthorize("hasAuthority('sys:order:save')")
@ApiOperation("添加订单商品")
@PostMapping()
public ApiResult<?> save(@RequestBody OrderGoods orderGoods) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
orderGoods.setUserId(loginUser.getUserId());
}
if (orderGoodsService.save(orderGoods)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('sys:order:update')")
@ApiOperation("修改订单商品")
@PutMapping()
public ApiResult<?> update(@RequestBody OrderGoods orderGoods) {
if (orderGoodsService.updateById(orderGoods)) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('sys:order:remove')")
@ApiOperation("删除订单商品")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (orderGoodsService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('sys:order:save')")
@ApiOperation("批量添加订单商品")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<OrderGoods> list) {
if (orderGoodsService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('sys:order:update')")
@ApiOperation("批量修改订单商品")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<OrderGoods> batchParam) {
if (batchParam.update(orderGoodsService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('sys:order:remove')")
@ApiOperation("批量删除订单商品")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (orderGoodsService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}

View File

@@ -0,0 +1,106 @@
package com.gxwebsoft.common.system.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 购物车
*
* @author 科技小王子
* @since 2024-10-26 10:54:51
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "Cart对象", description = "购物车")
@TableName("sys_cart")
public class Cart implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "购物车表ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty(value = "类型 0商城 1应用插件")
private Integer type;
@ApiModelProperty(value = "唯一标识")
private String code;
@ApiModelProperty(value = "项目ID0 goodId 1 companyId")
private Long itemId;
@ApiModelProperty(value = "商品规格")
private String spec;
@ApiModelProperty(value = "商品价格")
private BigDecimal price;
@ApiModelProperty(value = "购买时长")
private Integer month;
@ApiModelProperty(value = "商品数量")
private Integer cartNum;
@ApiModelProperty(value = "单商品合计")
private BigDecimal totalPrice;
@ApiModelProperty(value = "0 = 未购买 1 = 已购买")
private Boolean isPay;
@ApiModelProperty(value = "是否为立即购买")
private Boolean isNew;
@ApiModelProperty(value = "拼团id")
private Integer combinationId;
@ApiModelProperty(value = "秒杀产品ID")
private Integer seckillId;
@ApiModelProperty(value = "砍价id")
private Integer bargainId;
@ApiModelProperty(value = "是否选中")
private Boolean selected;
@ApiModelProperty(value = "商户ID")
private Long merchantId;
@ApiModelProperty(value = "用户ID")
private Integer userId;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "商品描述")
@TableField(exist = false)
private String comments;
@ApiModelProperty(value = "支付方式")
@TableField(exist = false)
private Integer payType;
@ApiModelProperty(value = "支付金额")
@TableField(exist = false)
private BigDecimal payPrice;
@ApiModelProperty(value = "应用列表")
private List<Company> list;
}

View File

@@ -1,245 +1,171 @@
package com.gxwebsoft.common.system.entity; package com.gxwebsoft.common.system.entity;
import java.math.BigDecimal;
import cn.hutool.core.util.DesensitizedUtil;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable; import com.gxwebsoft.common.system.param.MenuParam;
import java.util.Date;
import java.util.List;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/** /**
* 订单 * 订单
* *
* @author 科技小王子 * @author 科技小王子
* @since 2024-04-24 13:46:21 * @since 2024-10-16 12:32:52
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@ApiModel(value = "Order对象", description = "订单") @ApiModel(value = "Order对象", description = "订单")
@TableName("sys_order") @TableName("sys_order")
public class Order implements Serializable { public class Order implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "订单号") @ApiModelProperty(value = "订单号")
@TableId(value = "order_id", type = IdType.AUTO) @TableId(value = "order_id", type = IdType.AUTO)
private Integer orderId; private Integer orderId;
@ApiModelProperty(value = "订单编号") @ApiModelProperty(value = "订单编号")
private String orderNo; private String orderNo;
@ApiModelProperty(value = "微信支付订单号") @ApiModelProperty(value = "订单类型0产品 1插件")
private String wechatOrder; private Integer type;
@ApiModelProperty(value = "微信退款订单号") @ApiModelProperty(value = "下单渠道0网站 1小程序 2其他")
private String refundOrder; private Integer channel;
@ApiModelProperty(value = "场馆id用于权限判断") @ApiModelProperty(value = "微信支付订单号")
private Long merchantId; private String transactionId;
@ApiModelProperty(value = "用户id") @ApiModelProperty(value = "微信退款订单号")
private Integer userId; private String refundOrder;
@ApiModelProperty(value = "使用的优惠券id") @ApiModelProperty(value = "使用的优惠券id")
private Integer couponId; private Integer couponId;
@ApiModelProperty(value = "使用的会员卡id") @ApiModelProperty(value = "真实姓名")
private Integer cardId; private String realName;
@ApiModelProperty(value = "关联管理员id") @ApiModelProperty(value = "手机号码")
private Integer aid; private String phone;
@ApiModelProperty(value = "核销管理员id") @ApiModelProperty(value = "订单总额")
private Integer adminId; private BigDecimal totalPrice;
@ApiModelProperty(value = "IC卡号") @ApiModelProperty(value = "减少的金额使用VIP会员折扣、优惠券抵扣、优惠券折扣后减去的价格")
private String code; private BigDecimal reducePrice;
@ApiModelProperty(value = "真实姓名") @ApiModelProperty(value = "实际付款")
private String name; private BigDecimal payPrice;
@ApiModelProperty(value = "手机号码") @ApiModelProperty(value = "用于统计")
private String phone; private BigDecimal price;
@ApiModelProperty(value = "订单总额") @ApiModelProperty(value = "价钱,用于积分赠送")
private BigDecimal totalPrice; private BigDecimal money;
@ApiModelProperty(value = "减少的金额使用VIP会员折扣、优惠券抵扣、优惠券折扣后减去的价格") @ApiModelProperty(value = "退款金额")
private BigDecimal reducePrice; private BigDecimal refundMoney;
@ApiModelProperty(value = "实际付款") @ApiModelProperty(value = "购买数量")
private BigDecimal payPrice; private Integer totalNum;
@ApiModelProperty(value = "用于统计") @ApiModelProperty(value = "0余额支付, 1微信支付102微信Native2会员卡支付3支付宝4现金5POS机")
private BigDecimal price; private Integer payType;
@ApiModelProperty(value = "价钱,用于积分赠送") @ApiModelProperty(value = "0未付款1已付款")
private BigDecimal money; private Boolean payStatus;
@ApiModelProperty(value = "退款金额") @ApiModelProperty(value = "0未完成1已完成2已取消3取消中4退款申请中5退款被拒绝6退款成功7客户端申请退款")
private BigDecimal refundMoney; private Integer orderStatus;
@ApiModelProperty(value = "教练价格") @ApiModelProperty(value = "优惠类型0无、1抵扣优惠券、2折扣优惠券、3、VIP月卡、4VIP年卡5VIP次卡、6VIP会员卡、7IC月卡、8IC年卡、9IC次卡、10IC会员卡、11免费订单、12VIP充值卡、13IC充值卡、14VIP季卡、15IC季卡")
private BigDecimal coachPrice; private Integer couponType;
@ApiModelProperty(value = "教练id") @ApiModelProperty(value = "优惠说明")
private Integer coachId; private String couponDesc;
@ApiModelProperty(value = "1微信支付2积分3支付宝4现金5POS机6VIP月卡7VIP年卡8VIP次卡9IC月卡10IC年卡11IC次卡12免费13VIP充值卡14IC充值卡15积分支付16VIP季卡17IC季卡") @ApiModelProperty(value = "二维码地址,保存订单号,支付成功后才生成")
private Integer payType; private String qrcode;
@ApiModelProperty(value = "1已付款2未付款") @ApiModelProperty(value = "预约详情开始时间数组")
private Integer payStatus; private Long startTime;
@ApiModelProperty(value = "1已完成2未使用3已取消4退款申请中5退款被拒绝6退款成功7客户端申请退款") @ApiModelProperty(value = "是否已开具发票0未开发票1已开发票2不能开具发票")
private Integer orderStatus; private Boolean isInvoice;
@ApiModelProperty(value = "优惠类型0无、1抵扣优惠券、2折扣优惠券、3、VIP月卡、4VIP年卡5VIP次卡、6VIP会员卡、7IC月卡、8IC年卡、9IC次卡、10IC会员卡、11免费订单、12VIP充值卡、13IC充值卡、14VIP季卡、15IC季卡") @ApiModelProperty(value = "发票流水号")
private Integer type; private String invoiceNo;
@ApiModelProperty(value = "二维码地址,保存订单号,支付成功后才生成") @ApiModelProperty(value = "支付时间")
private String qrcode; private Date payTime;
@ApiModelProperty(value = "优惠说明") @ApiModelProperty(value = "退款时间")
private String desc; private Date refundTime;
@ApiModelProperty(value = "vip月卡年卡、ic月卡年卡回退次数") @ApiModelProperty(value = "申请退款时间")
private Integer returnNum; private Date refundApplyTime;
@ApiModelProperty(value = "vip充值回退金额") @ApiModelProperty(value = "过期时间")
private BigDecimal returnMoney; private Date expirationTime;
@ApiModelProperty(value = "预约详情开始时间数组") @ApiModelProperty(value = "对账情况0=未对账1=已对账3=已对账金额对不上4=未查询到该订单")
private Integer startTime; private Integer checkBill;
@ApiModelProperty(value = "是否已开具发票1已开发票2未开发票3不能开具发票") @ApiModelProperty(value = "订单是否已结算(0未结算 1已结算)")
private Integer isInvoice; private Integer isSettled;
@ApiModelProperty(value = "付款时间") @ApiModelProperty(value = "系统版本号 0当前版本 value=其他版本")
private Date payTime; private Integer version;
@ApiModelProperty(value = "退款时间") @ApiModelProperty(value = "用户id")
private Integer refundTime; private Integer userId;
@ApiModelProperty(value = "申请退款时间") @ApiModelProperty(value = "备注")
private Integer refundApplyTime; private String comments;
@ApiModelProperty(value = "对账情况1=已对账2=未对账3=已对账金额对不上4=未查询到该订单") @ApiModelProperty(value = "排序号")
private Integer checkBill; private Integer sortNumber;
@ApiModelProperty(value = "系统版本") @ApiModelProperty(value = "是否删除, 0否, 1是")
private Integer version; @TableLogic
private Integer deleted;
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "租户id")
private String comments; private Integer tenantId;
@ApiModelProperty(value = "是否删除, 0否, 1是") @ApiModelProperty(value = "修改时间")
@TableLogic private Date updateTime;
private Integer deleted;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")
private Date createTime; private Date createTime;
@ApiModelProperty(value = "更新时间") @ApiModelProperty(value = "购买时长")
private Date updateTime; @TableField(exist = false)
private Integer month;
@ApiModelProperty(value = "租户id") @ApiModelProperty(value = "购买数量")
private Integer tenantId; @TableField(exist = false)
private Integer cartNum;
@ApiModelProperty(value = "商户名称") @ApiModelProperty(value = "应用列表")
@TableField(exist = false) private List<Company> list;
private String merchantName;
@ApiModelProperty(value = "商户图标") @ApiModelProperty(value = "插件安装参数")
@TableField(exist = false) @TableField(exist = false)
private String merchantAvatar; private MenuParam menuParam;
@ApiModelProperty(value = "微信OPENID,用于微信支付") @ApiModelProperty(value = "应用名称")
@TableField(exist = false) @TableField(exist = false)
private String openid; private String tenantName;
@ApiModelProperty(value = "订单详情") @ApiModelProperty(value = "应用图标")
@TableField(exist = false) @TableField(exist = false)
private List<OrderInfo> orderInfoList; private String logo;
@ApiModelProperty(value = "套餐ID")
private Integer planId;
@ApiModelProperty(value = "卡ID")
private Integer priceId;
@ApiModelProperty(value = "获得的会员等级")
private Integer gradeId;
@ApiModelProperty(value = "卡名称")
private String priceName;
@ApiModelProperty(value = "持有者ID")
private Integer memberId;
@ApiModelProperty(value = "真实姓名")
private String realName;
@ApiModelProperty(value = "支付流水号")
private String transactionId;
@ApiModelProperty(value = "支付方式(余额/微信/支付宝)")
private String payMethod;
@ApiModelProperty(value = "到期时间")
private Date expirationTime;
@ApiModelProperty(value = "所在省份")
private String province;
@ApiModelProperty(value = "所在城市")
private String city;
@ApiModelProperty(value = "所在辖区")
private String region;
@ApiModelProperty(value = "所在地区")
private String area;
@ApiModelProperty(value = "街道地址")
private String address;
@ApiModelProperty(value = "退款凭证")
private String refundImage;
@ApiModelProperty(value = "退款理由")
private String refundContent;
@ApiModelProperty(value = "订单是否已结算(0未结算 1已结算)")
private Integer isSettled;
@ApiModelProperty(value = "排序(数字越小越靠前)")
private Integer sortNumber;
@ApiModelProperty(value = "状态, 0正常, 1冻结")
private Integer status;
@ApiModelProperty(value = "租户名称")
@TableField(exist = false)
private String tenantName;
@ApiModelProperty(value = "企业ID")
@TableField(exist = false)
private Integer companyId;
@ApiModelProperty("手机号(脱敏)")
@TableField(exist = false)
private String mobile;
public String getMobile() {
return DesensitizedUtil.mobilePhone(this.phone);
}
} }

View File

@@ -0,0 +1,101 @@
package com.gxwebsoft.common.system.entity;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* 订单商品
*
* @author 科技小王子
* @since 2024-10-26 12:18:05
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "OrderGoods对象", description = "订单商品")
@TableName("sys_order_goods")
public class OrderGoods implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "订单号")
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
@ApiModelProperty(value = "订单类型0商城 1应用插件")
private Integer type;
@ApiModelProperty(value = "订单号")
private Integer orderId;
@ApiModelProperty(value = "项目ID")
private Integer itemId;
@ApiModelProperty(value = "插件ID")
private Integer menuId;
@ApiModelProperty(value = "实际付款")
private BigDecimal payPrice;
@ApiModelProperty(value = "购买时长")
private Integer month;
@ApiModelProperty(value = "购买数量")
private Integer totalNum;
@ApiModelProperty(value = "0未付款1已付款")
private Boolean payStatus;
@ApiModelProperty(value = "0未完成1已完成2已取消3取消中4退款申请中5退款被拒绝6退款成功7客户端申请退款")
private Integer orderStatus;
@ApiModelProperty(value = "预约详情开始时间数组")
private String startTime;
@ApiModelProperty(value = "是否已开具发票0未开发票1已开发票2不能开具发票")
private Boolean isInvoice;
@ApiModelProperty(value = "发票流水号")
private String invoiceNo;
@ApiModelProperty(value = "支付时间")
private Date payTime;
@ApiModelProperty(value = "过期时间")
private Date expirationTime;
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "排序号")
private Integer sortNumber;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "修改时间")
private Date updateTime;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "应用名称")
@TableField(exist = false)
private String tenantName;
@ApiModelProperty(value = "应用图标")
@TableField(exist = false)
private String logo;
}

View File

@@ -0,0 +1,37 @@
package com.gxwebsoft.common.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.common.system.entity.Cart;
import com.gxwebsoft.common.system.param.CartParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 购物车Mapper
*
* @author 科技小王子
* @since 2024-10-26 10:54:51
*/
public interface CartMapper extends BaseMapper<Cart> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<Cart>
*/
List<Cart> selectPageRel(@Param("page") IPage<Cart> page,
@Param("param") CartParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<Cart> selectListRel(@Param("param") CartParam param);
}

View File

@@ -0,0 +1,37 @@
package com.gxwebsoft.common.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.common.system.entity.OrderGoods;
import com.gxwebsoft.common.system.param.OrderGoodsParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 订单商品Mapper
*
* @author 科技小王子
* @since 2024-10-26 12:18:05
*/
public interface OrderGoodsMapper extends BaseMapper<OrderGoods> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<OrderGoods>
*/
List<OrderGoods> selectPageRel(@Param("page") IPage<OrderGoods> page,
@Param("param") OrderGoodsParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<OrderGoods> selectListRel(@Param("param") OrderGoodsParam param);
}

View File

@@ -1,6 +1,5 @@
package com.gxwebsoft.common.system.mapper; package com.gxwebsoft.common.system.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.common.system.entity.Order; import com.gxwebsoft.common.system.entity.Order;
@@ -13,7 +12,7 @@ import java.util.List;
* 订单Mapper * 订单Mapper
* *
* @author 科技小王子 * @author 科技小王子
* @since 2024-04-24 13:46:21 * @since 2024-10-16 12:32:52
*/ */
public interface OrderMapper extends BaseMapper<Order> { public interface OrderMapper extends BaseMapper<Order> {
@@ -35,10 +34,4 @@ public interface OrderMapper extends BaseMapper<Order> {
*/ */
List<Order> selectListRel(@Param("param") OrderParam param); List<Order> selectListRel(@Param("param") OrderParam param);
@InterceptorIgnore(tenantLine = "true")
List<Order> getByOutTradeNo(OrderParam param);
@InterceptorIgnore(tenantLine = "true")
void updateByOutTradeNo(@Param("param") Order outTradeNo);
} }

View File

@@ -0,0 +1,77 @@
<?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.gxwebsoft.common.system.mapper.CartMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM sys_cart a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.type != null">
AND a.type = #{param.type}
</if>
<if test="param.code != null">
AND a.code LIKE CONCAT('%', #{param.code}, '%')
</if>
<if test="param.itemId != null">
AND a.item_id LIKE CONCAT('%', #{param.itemId}, '%')
</if>
<if test="param.spec != null">
AND a.spec LIKE CONCAT('%', #{param.spec}, '%')
</if>
<if test="param.price != null">
AND a.price = #{param.price}
</if>
<if test="param.cartNum != null">
AND a.cart_num = #{param.cartNum}
</if>
<if test="param.totalPrice != null">
AND a.total_price = #{param.totalPrice}
</if>
<if test="param.isPay != null">
AND a.is_pay = #{param.isPay}
</if>
<if test="param.isNew != null">
AND a.is_new = #{param.isNew}
</if>
<if test="param.combinationId != null">
AND a.combination_id = #{param.combinationId}
</if>
<if test="param.seckillId != null">
AND a.seckill_id = #{param.seckillId}
</if>
<if test="param.bargainId != null">
AND a.bargain_id = #{param.bargainId}
</if>
<if test="param.selected != null">
AND a.selected = #{param.selected}
</if>
<if test="param.merchantId != null">
AND a.merchant_id LIKE CONCAT('%', #{param.merchantId}, '%')
</if>
<if test="param.userId != null">
AND a.user_id LIKE CONCAT('%', #{param.userId}, '%')
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.common.system.entity.Cart">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.common.system.entity.Cart">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -0,0 +1,84 @@
<?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.gxwebsoft.common.system.mapper.OrderGoodsMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*, b.short_name AS tenantName,b.company_logo as logo
FROM sys_order_goods a
LEFT JOIN sys_company b ON a.tenant_id = b.tenant_id
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.type != null">
AND a.type = #{param.type}
</if>
<if test="param.orderId != null">
AND a.order_id = #{param.type}
</if>
<if test="param.itemId != null">
AND a.item_id = #{param.itemId}
</if>
<if test="param.payPrice != null">
AND a.pay_price = #{param.payPrice}
</if>
<if test="param.totalNum != null">
AND a.total_num = #{param.totalNum}
</if>
<if test="param.payStatus != null">
AND a.pay_status = #{param.payStatus}
</if>
<if test="param.orderStatus != null">
AND a.order_status = #{param.orderStatus}
</if>
<if test="param.startTime != null">
AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
</if>
<if test="param.isInvoice != null">
AND a.is_invoice = #{param.isInvoice}
</if>
<if test="param.invoiceNo != null">
AND a.invoice_no LIKE CONCAT('%', #{param.invoiceNo}, '%')
</if>
<if test="param.payTime != null">
AND a.pay_time LIKE CONCAT('%', #{param.payTime}, '%')
</if>
<if test="param.expirationTime != null">
AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%')
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if>
<if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.common.system.entity.OrderGoods">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.common.system.entity.OrderGoods">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -4,8 +4,9 @@
<!-- 关联查询sql --> <!-- 关联查询sql -->
<sql id="selectSql"> <sql id="selectSql">
SELECT a.* SELECT a.*, b.short_name AS tenantName,b.company_logo as logo
FROM sys_order a FROM sys_order a
LEFT JOIN sys_company b ON a.tenant_id = b.tenant_id
<where> <where>
<if test="param.orderId != null"> <if test="param.orderId != null">
AND a.order_id = #{param.orderId} AND a.order_id = #{param.orderId}
@@ -16,29 +17,17 @@
<if test="param.type != null"> <if test="param.type != null">
AND a.type = #{param.type} AND a.type = #{param.type}
</if> </if>
<if test="param.money != null"> <if test="param.channel != null">
AND a.money = #{param.money} AND a.channel = #{param.channel}
</if> </if>
<if test="param.payPrice != null"> <if test="param.transactionId != null">
AND a.pay_price = #{param.payPrice} AND a.transaction_id LIKE CONCAT('%', #{param.transactionId}, '%')
</if> </if>
<if test="param.planId != null"> <if test="param.refundOrder != null">
AND a.plan_id = #{param.planId} AND a.refund_order LIKE CONCAT('%', #{param.refundOrder}, '%')
</if> </if>
<if test="param.priceId != null"> <if test="param.couponId != null">
AND a.price_id = #{param.priceId} AND a.coupon_id = #{param.couponId}
</if>
<if test="param.gradeId != null">
AND a.grade_id = #{param.gradeId}
</if>
<if test="param.priceName != null">
AND a.price_name LIKE CONCAT('%', #{param.priceName}, '%')
</if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.memberId != null">
AND a.member_id = #{param.memberId}
</if> </if>
<if test="param.realName != null"> <if test="param.realName != null">
AND a.real_name LIKE CONCAT('%', #{param.realName}, '%') AND a.real_name LIKE CONCAT('%', #{param.realName}, '%')
@@ -46,56 +35,83 @@
<if test="param.phone != null"> <if test="param.phone != null">
AND a.phone LIKE CONCAT('%', #{param.phone}, '%') AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
</if> </if>
<if test="param.payTime != null"> <if test="param.totalPrice != null">
AND a.pay_time LIKE CONCAT('%', #{param.payTime}, '%') AND a.total_price = #{param.totalPrice}
</if> </if>
<if test="param.transactionId != null"> <if test="param.reducePrice != null">
AND a.transaction_id LIKE CONCAT('%', #{param.transactionId}, '%') AND a.reduce_price = #{param.reducePrice}
</if>
<if test="param.payPrice != null">
AND a.pay_price = #{param.payPrice}
</if>
<if test="param.price != null">
AND a.price = #{param.price}
</if>
<if test="param.money != null">
AND a.money = #{param.money}
</if>
<if test="param.refundMoney != null">
AND a.refund_money = #{param.refundMoney}
</if>
<if test="param.totalNum != null">
AND a.total_num = #{param.totalNum}
</if>
<if test="param.payType != null">
AND a.pay_type = #{param.payType}
</if> </if>
<if test="param.payStatus != null"> <if test="param.payStatus != null">
AND a.pay_status = #{param.payStatus} AND a.pay_status = #{param.payStatus}
</if> </if>
<if test="param.payMethod != null"> <if test="param.orderStatus != null">
AND a.pay_method LIKE CONCAT('%', #{param.payMethod}, '%') AND a.order_status = #{param.orderStatus}
</if>
<if test="param.couponType != null">
AND a.coupon_type = #{param.couponType}
</if>
<if test="param.couponDesc != null">
AND a.coupon_desc LIKE CONCAT('%', #{param.couponDesc}, '%')
</if>
<if test="param.qrcode != null">
AND a.qrcode LIKE CONCAT('%', #{param.qrcode}, '%')
</if>
<if test="param.startTime != null">
AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
</if>
<if test="param.isInvoice != null">
AND a.is_invoice = #{param.isInvoice}
</if>
<if test="param.invoiceNo != null">
AND a.invoice_no LIKE CONCAT('%', #{param.invoiceNo}, '%')
</if>
<if test="param.payTime != null">
AND a.pay_time LIKE CONCAT('%', #{param.payTime}, '%')
</if>
<if test="param.refundTime != null">
AND a.refund_time LIKE CONCAT('%', #{param.refundTime}, '%')
</if>
<if test="param.refundApplyTime != null">
AND a.refund_apply_time LIKE CONCAT('%', #{param.refundApplyTime}, '%')
</if> </if>
<if test="param.expirationTime != null"> <if test="param.expirationTime != null">
AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%') AND a.expiration_time LIKE CONCAT('%', #{param.expirationTime}, '%')
</if> </if>
<if test="param.province != null"> <if test="param.checkBill != null">
AND a.province LIKE CONCAT('%', #{param.province}, '%') AND a.check_bill = #{param.checkBill}
</if>
<if test="param.city != null">
AND a.city LIKE CONCAT('%', #{param.city}, '%')
</if>
<if test="param.region != null">
AND a.region LIKE CONCAT('%', #{param.region}, '%')
</if>
<if test="param.area != null">
AND a.area LIKE CONCAT('%', #{param.area}, '%')
</if>
<if test="param.address != null">
AND a.address LIKE CONCAT('%', #{param.address}, '%')
</if>
<if test="param.refundImage != null">
AND a.refund_image LIKE CONCAT('%', #{param.refundImage}, '%')
</if>
<if test="param.refundContent != null">
AND a.refund_content LIKE CONCAT('%', #{param.refundContent}, '%')
</if> </if>
<if test="param.isSettled != null"> <if test="param.isSettled != null">
AND a.is_settled = #{param.isSettled} AND a.is_settled = #{param.isSettled}
</if> </if>
<if test="param.sortNumber != null"> <if test="param.version != null">
AND a.sort_number = #{param.sortNumber} AND a.version = #{param.version}
</if> </if>
<if test="param.merchantId != null"> <if test="param.userId != null">
AND a.merchant_id = #{param.merchantId} AND a.user_id = #{param.userId}
</if> </if>
<if test="param.comments != null"> <if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%') AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if> </if>
<if test="param.status != null"> <if test="param.sortNumber != null">
AND a.status = #{param.status} AND a.sort_number = #{param.sortNumber}
</if> </if>
<if test="param.deleted != null"> <if test="param.deleted != null">
AND a.deleted = #{param.deleted} AND a.deleted = #{param.deleted}
@@ -109,6 +125,14 @@
<if test="param.createTimeEnd != null"> <if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd} AND a.create_time &lt;= #{param.createTimeEnd}
</if> </if>
<if test="param.keywords != null">
AND (a.tenant_id = #{param.keywords}
OR a.order_id = #{param.keywords}
OR a.phone = #{param.keywords}
OR a.real_name LIKE CONCAT('%', #{param.keywords}, '%')
OR a.order_no LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where> </where>
</sql> </sql>
@@ -122,14 +146,4 @@
<include refid="selectSql"></include> <include refid="selectSql"></include>
</select> </select>
<!-- 按OutTradeNo查询 -->
<select id="getByOutTradeNo" resultType="com.gxwebsoft.common.system.entity.Order">
<include refid="selectSql"></include>
</select>
<!-- 更新订单状态 -->
<select id="updateByOutTradeNo" resultType="com.gxwebsoft.common.system.entity.Order">
UPDATE sys_order SET pay_status = #{param.payStatus},pay_time = #{param.payTime},pay_price = #{param.payPrice},transaction_id = #{param.transactionId} WHERE order_no = #{param.orderNo}
</select>
</mapper> </mapper>

View File

@@ -0,0 +1,86 @@
package com.gxwebsoft.common.system.param;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 购物车查询参数
*
* @author 科技小王子
* @since 2024-10-26 10:54:51
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "CartParam对象", description = "购物车查询参数")
public class CartParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "购物车表ID")
@QueryField(type = QueryType.EQ)
private Long id;
@ApiModelProperty(value = "类型 0商城 1应用插件")
@QueryField(type = QueryType.EQ)
private Integer type;
@ApiModelProperty(value = "唯一标识")
private String code;
@ApiModelProperty(value = "项目ID0 goodId 1 companyId")
private Long itemId;
@ApiModelProperty(value = "商品规格")
private String spec;
@ApiModelProperty(value = "商品价格")
@QueryField(type = QueryType.EQ)
private BigDecimal price;
@ApiModelProperty(value = "商品数量")
@QueryField(type = QueryType.EQ)
private Integer cartNum;
@ApiModelProperty(value = "单商品合计")
@QueryField(type = QueryType.EQ)
private BigDecimal totalPrice;
@ApiModelProperty(value = "0 = 未购买 1 = 已购买")
@QueryField(type = QueryType.EQ)
private Boolean isPay;
@ApiModelProperty(value = "是否为立即购买")
@QueryField(type = QueryType.EQ)
private Boolean isNew;
@ApiModelProperty(value = "拼团id")
@QueryField(type = QueryType.EQ)
private Integer combinationId;
@ApiModelProperty(value = "秒杀产品ID")
@QueryField(type = QueryType.EQ)
private Integer seckillId;
@ApiModelProperty(value = "砍价id")
@QueryField(type = QueryType.EQ)
private Integer bargainId;
@ApiModelProperty(value = "是否选中")
@QueryField(type = QueryType.EQ)
private Boolean selected;
@ApiModelProperty(value = "商户ID")
private Long merchantId;
@ApiModelProperty(value = "用户ID")
private Long userId;
}

View File

@@ -0,0 +1,90 @@
package com.gxwebsoft.common.system.param;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 订单商品查询参数
*
* @author 科技小王子
* @since 2024-10-26 12:18:05
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "OrderGoodsParam对象", description = "订单商品查询参数")
public class OrderGoodsParam extends BaseParam {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "订单号")
@QueryField(type = QueryType.EQ)
private Integer id;
@ApiModelProperty(value = "订单类型0商城 1应用插件")
@QueryField(type = QueryType.EQ)
private Integer type;
@ApiModelProperty(value = "订单号")
@QueryField(type = QueryType.EQ)
private Integer orderId;
@ApiModelProperty(value = "项目ID")
@QueryField(type = QueryType.EQ)
private Integer itemId;
@ApiModelProperty(value = "实际付款")
@QueryField(type = QueryType.EQ)
private BigDecimal payPrice;
@ApiModelProperty(value = "购买数量")
@QueryField(type = QueryType.EQ)
private Integer totalNum;
@ApiModelProperty(value = "0未付款1已付款")
@QueryField(type = QueryType.EQ)
private Boolean payStatus;
@ApiModelProperty(value = "0未完成1已完成2已取消3取消中4退款申请中5退款被拒绝6退款成功7客户端申请退款")
@QueryField(type = QueryType.EQ)
private Integer orderStatus;
@ApiModelProperty(value = "预约详情开始时间数组")
private String startTime;
@ApiModelProperty(value = "是否已开具发票0未开发票1已开发票2不能开具发票")
@QueryField(type = QueryType.EQ)
private Boolean isInvoice;
@ApiModelProperty(value = "发票流水号")
private String invoiceNo;
@ApiModelProperty(value = "支付时间")
private String payTime;
@ApiModelProperty(value = "过期时间")
private String expirationTime;
@ApiModelProperty(value = "用户id")
@QueryField(type = QueryType.EQ)
private Integer userId;
@ApiModelProperty(value = "备注")
private String comments;
@ApiModelProperty(value = "排序号")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
}

View File

@@ -15,7 +15,7 @@ import java.math.BigDecimal;
* 订单查询参数 * 订单查询参数
* *
* @author 科技小王子 * @author 科技小王子
* @since 2024-04-24 13:46:21 * @since 2024-10-16 12:32:52
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@@ -24,109 +24,131 @@ import java.math.BigDecimal;
public class OrderParam extends BaseParam { public class OrderParam extends BaseParam {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "ID") @ApiModelProperty(value = "订单号")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer orderId; private Integer orderId;
@ApiModelProperty(value = "订单号") @ApiModelProperty(value = "订单")
private String orderNo; private String orderNo;
@ApiModelProperty(value = "类型") @ApiModelProperty(value = "订单类型0产品 1插件")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer type; private Integer type;
@ApiModelProperty(value = "订单金额") @ApiModelProperty(value = "下单渠道0网站 1小程序 2其他")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private BigDecimal money; private Integer channel;
@ApiModelProperty(value = "实际付款金额(包含运费)") @ApiModelProperty(value = "微信支付订单号")
private String transactionId;
@ApiModelProperty(value = "微信退款订单号")
private String refundOrder;
@ApiModelProperty(value = "使用的优惠券id")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private BigDecimal payPrice; private Integer couponId;
@ApiModelProperty(value = "套餐ID")
@QueryField(type = QueryType.EQ)
private Integer planId;
@ApiModelProperty(value = "卡ID")
@QueryField(type = QueryType.EQ)
private Integer priceId;
@ApiModelProperty(value = "获得的会员等级")
@QueryField(type = QueryType.EQ)
private Integer gradeId;
@ApiModelProperty(value = "卡名称")
private String priceName;
@ApiModelProperty(value = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
@ApiModelProperty(value = "持有者ID")
@QueryField(type = QueryType.EQ)
private Integer memberId;
@ApiModelProperty(value = "真实姓名") @ApiModelProperty(value = "真实姓名")
private String realName; private String realName;
@ApiModelProperty(value = "联系电话") @ApiModelProperty(value = "手机号码")
private String phone; private String phone;
@ApiModelProperty(value = "付款时间") @ApiModelProperty(value = "订单总额")
@QueryField(type = QueryType.EQ)
private BigDecimal totalPrice;
@ApiModelProperty(value = "减少的金额使用VIP会员折扣、优惠券抵扣、优惠券折扣后减去的价格")
@QueryField(type = QueryType.EQ)
private BigDecimal reducePrice;
@ApiModelProperty(value = "实际付款")
@QueryField(type = QueryType.EQ)
private BigDecimal payPrice;
@ApiModelProperty(value = "用于统计")
@QueryField(type = QueryType.EQ)
private BigDecimal price;
@ApiModelProperty(value = "价钱,用于积分赠送")
@QueryField(type = QueryType.EQ)
private BigDecimal money;
@ApiModelProperty(value = "退款金额")
@QueryField(type = QueryType.EQ)
private BigDecimal refundMoney;
@ApiModelProperty(value = "购买数量")
@QueryField(type = QueryType.EQ)
private Integer totalNum;
@ApiModelProperty(value = "0余额支付, 1微信支付102微信Native2会员卡支付3支付宝4现金5POS机")
@QueryField(type = QueryType.EQ)
private Integer payType;
@ApiModelProperty(value = "0未付款1已付款")
@QueryField(type = QueryType.EQ)
private Boolean payStatus;
@ApiModelProperty(value = "0未完成1已完成2已取消3取消中4退款申请中5退款被拒绝6退款成功7客户端申请退款")
@QueryField(type = QueryType.EQ)
private Integer orderStatus;
@ApiModelProperty(value = "优惠类型0无、1抵扣优惠券、2折扣优惠券、3、VIP月卡、4VIP年卡5VIP次卡、6VIP会员卡、7IC月卡、8IC年卡、9IC次卡、10IC会员卡、11免费订单、12VIP充值卡、13IC充值卡、14VIP季卡、15IC季卡")
@QueryField(type = QueryType.EQ)
private Integer couponType;
@ApiModelProperty(value = "优惠说明")
private String couponDesc;
@ApiModelProperty(value = "二维码地址,保存订单号,支付成功后才生成")
private String qrcode;
@ApiModelProperty(value = "预约详情开始时间数组")
private String startTime;
@ApiModelProperty(value = "是否已开具发票0未开发票1已开发票2不能开具发票")
@QueryField(type = QueryType.EQ)
private Boolean isInvoice;
@ApiModelProperty(value = "发票流水号")
private String invoiceNo;
@ApiModelProperty(value = "支付时间")
private String payTime; private String payTime;
@ApiModelProperty(value = "支付流水号") @ApiModelProperty(value = "退款时间")
private String transactionId; private String refundTime;
@ApiModelProperty(value = "付款状态(10未付款 20已付款)") @ApiModelProperty(value = "申请退款时间")
@QueryField(type = QueryType.EQ) private String refundApplyTime;
private Integer payStatus;
@ApiModelProperty(value = "支付方式(余额/微信/支付宝)") @ApiModelProperty(value = "过期时间")
private String payMethod;
@ApiModelProperty(value = "到期时间")
private String expirationTime; private String expirationTime;
@ApiModelProperty(value = "所在省份") @ApiModelProperty(value = "对账情况0=未对账1=已对账3=已对账金额对不上4=未查询到该订单")
private String province; @QueryField(type = QueryType.EQ)
private Integer checkBill;
@ApiModelProperty(value = "所在城市")
private String city;
@ApiModelProperty(value = "所在辖区")
private String region;
@ApiModelProperty(value = "所在地区")
private String area;
@ApiModelProperty(value = "街道地址")
private String address;
@ApiModelProperty(value = "退款凭证")
private String refundImage;
@ApiModelProperty(value = "退款理由")
private String refundContent;
@ApiModelProperty(value = "订单是否已结算(0未结算 1已结算)") @ApiModelProperty(value = "订单是否已结算(0未结算 1已结算)")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer isSettled; private Integer isSettled;
@ApiModelProperty(value = "排序(数字越小越靠前)") @ApiModelProperty(value = "系统版本号 0当前版本 value=其他版本")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer sortNumber; private Integer version;
@ApiModelProperty(value = "商户ID") @ApiModelProperty(value = "用户id")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Long merchantId; private Integer userId;
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String comments; private String comments;
@ApiModelProperty(value = "状态, 0正常, 1冻结") @ApiModelProperty(value = "排序号")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer status; private Integer sortNumber;
@ApiModelProperty(value = "是否删除, 0否, 1是") @ApiModelProperty(value = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)

View File

@@ -0,0 +1,42 @@
package com.gxwebsoft.common.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Cart;
import com.gxwebsoft.common.system.param.CartParam;
import java.util.List;
/**
* 购物车Service
*
* @author 科技小王子
* @since 2024-10-26 10:54:51
*/
public interface CartService extends IService<Cart> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<Cart>
*/
PageResult<Cart> pageRel(CartParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<Cart>
*/
List<Cart> listRel(CartParam param);
/**
* 根据id查询
*
* @param id 购物车表ID
* @return Cart
*/
Cart getByIdRel(Long id);
}

View File

@@ -0,0 +1,42 @@
package com.gxwebsoft.common.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.OrderGoods;
import com.gxwebsoft.common.system.param.OrderGoodsParam;
import java.util.List;
/**
* 订单商品Service
*
* @author 科技小王子
* @since 2024-10-26 12:18:05
*/
public interface OrderGoodsService extends IService<OrderGoods> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<OrderGoods>
*/
PageResult<OrderGoods> pageRel(OrderGoodsParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<OrderGoods>
*/
List<OrderGoods> listRel(OrderGoodsParam param);
/**
* 根据id查询
*
* @param id 订单号
* @return OrderGoods
*/
OrderGoods getByIdRel(Integer id);
}

View File

@@ -5,14 +5,13 @@ import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Order; import com.gxwebsoft.common.system.entity.Order;
import com.gxwebsoft.common.system.param.OrderParam; import com.gxwebsoft.common.system.param.OrderParam;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
* 订单Service * 订单Service
* *
* @author 科技小王子 * @author 科技小王子
* @since 2024-04-24 13:46:21 * @since 2024-10-16 12:32:52
*/ */
public interface OrderService extends IService<Order> { public interface OrderService extends IService<Order> {
@@ -35,14 +34,10 @@ public interface OrderService extends IService<Order> {
/** /**
* 根据id查询 * 根据id查询
* *
* @param orderId ID * @param orderId 订单号
* @return Order * @return Order
*/ */
Order getByIdRel(Integer orderId); Order getByIdRel(Integer orderId);
HashMap<String, String> createWxOrder(Order order); void paySuccess(Order order);
Order getByOutTradeNo(String outTradeNo);
void updateByOutTradeNo(Order order);
} }

View File

@@ -0,0 +1,47 @@
package com.gxwebsoft.common.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Cart;
import com.gxwebsoft.common.system.mapper.CartMapper;
import com.gxwebsoft.common.system.param.CartParam;
import com.gxwebsoft.common.system.service.CartService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 购物车Service实现
*
* @author 科技小王子
* @since 2024-10-26 10:54:51
*/
@Service
public class CartServiceImpl extends ServiceImpl<CartMapper, Cart> implements CartService {
@Override
public PageResult<Cart> pageRel(CartParam param) {
PageParam<Cart, CartParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
List<Cart> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<Cart> listRel(CartParam param) {
List<Cart> list = baseMapper.selectListRel(param);
// 排序
PageParam<Cart, CartParam> page = new PageParam<>();
page.setDefaultOrder("create_time desc");
return page.sortRecords(list);
}
@Override
public Cart getByIdRel(Long id) {
CartParam param = new CartParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}

View File

@@ -0,0 +1,47 @@
package com.gxwebsoft.common.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.OrderGoods;
import com.gxwebsoft.common.system.mapper.OrderGoodsMapper;
import com.gxwebsoft.common.system.param.OrderGoodsParam;
import com.gxwebsoft.common.system.service.OrderGoodsService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 订单商品Service实现
*
* @author 科技小王子
* @since 2024-10-26 12:18:05
*/
@Service
public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGoods> implements OrderGoodsService {
@Override
public PageResult<OrderGoods> pageRel(OrderGoodsParam param) {
PageParam<OrderGoods, OrderGoodsParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
List<OrderGoods> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<OrderGoods> listRel(OrderGoodsParam param) {
List<OrderGoods> list = baseMapper.selectListRel(param);
// 排序
PageParam<OrderGoods, OrderGoodsParam> page = new PageParam<>();
page.setDefaultOrder("create_time desc");
return page.sortRecords(list);
}
@Override
public OrderGoods getByIdRel(Integer id) {
OrderGoodsParam param = new OrderGoodsParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
}

View File

@@ -1,171 +1,99 @@
package com.gxwebsoft.common.system.service.impl; package com.gxwebsoft.common.system.service.impl;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.config.ConfigProperties;
import com.gxwebsoft.common.core.utils.RedisUtil;
import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.Company;
import com.gxwebsoft.common.system.entity.Order; import com.gxwebsoft.common.system.entity.Order;
import com.gxwebsoft.common.system.entity.Payment; import com.gxwebsoft.common.system.entity.OrderGoods;
import com.gxwebsoft.common.system.mapper.OrderMapper; import com.gxwebsoft.common.system.mapper.OrderMapper;
import com.gxwebsoft.common.system.param.OrderParam; import com.gxwebsoft.common.system.param.OrderParam;
import com.gxwebsoft.common.system.service.CompanyService;
import com.gxwebsoft.common.system.service.MenuService;
import com.gxwebsoft.common.system.service.OrderGoodsService;
import com.gxwebsoft.common.system.service.OrderService; import com.gxwebsoft.common.system.service.OrderService;
import com.gxwebsoft.common.system.service.PaymentService;
import com.gxwebsoft.common.system.service.SettingService;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAConfig;
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import com.wechat.pay.java.service.payments.jsapi.model.Amount;
import com.wechat.pay.java.service.payments.jsapi.model.Payer;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
* 订单Service实现 * 订单Service实现
* *
* @author 科技小王子 * @author 科技小王子
* @since 2024-04-24 13:46:21 * @since 2024-10-16 12:32:52
*/ */
@Service @Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService { public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
@Value("${spring.profiles.active}") @Resource
String active; private MenuService menuService;
@Resource @Resource
private ConfigProperties config; private OrderGoodsService orderGoodsService;
@Resource @Resource
private SettingService settingService; private CompanyService companyService;
@Resource
private RedisUtil redisUtil;
@Resource
private PaymentService paymentService;
public static String privateKeyPath = "/Users/gxwebsoft/JAVA/com.gxwebsoft.core/src/main/resources/cert/apiclient_key.pem";
public static String privateCertPath = "/Users/gxwebsoft/JAVA/com.gxwebsoft.core/src/main/resources/cert/apiclient_cert.pem";
public static String serialNumber = "48749613B40AA8F1D768583FC352358E13EB5AF0";
public static String merchantId = "1246610101";
public static String appId = "wx541db955e7a62709";
public static String apiV3Key = "zGufUcqa7ovgxRL0kF5OlPr482EZwtn9";
/** @Override
* 平台证书生成命令(勿删) public PageResult<Order> pageRel(OrderParam param) {
* java -jar CertificateDownloader.jar -k zGufUcqa7ovgxRL0kF5OlPr482EZwtn9 -m 1246610101 -f /www/wwwroot/file.ws//file/20240511/280fb6cf7eec4c2d9661c2508123c6a8.pem -s 48749613B40AA8F1D768583FC352358E13EB5AF0 -o /www/cert/ PageParam<Order, OrderParam> page = new PageParam<>(param);
*/ page.setDefaultOrder("create_time desc");
public static String wechatpayCertPath = "/Users/gxwebsoft/JAVA/com.gxwebsoft.core/src/main/resources/cert/wechatpay_4A3231584E93B6AE77820074D07EADEACCB7E223.pem"; // 平台证书 List<Order> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
@Override
public PageResult<Order> pageRel(OrderParam param) {
PageParam<Order, OrderParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
List<Order> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<Order> listRel(OrderParam param) {
List<Order> list = baseMapper.selectListRel(param);
// 排序
PageParam<Order, OrderParam> page = new PageParam<>();
return page.sortRecords(list);
}
@Override
public Order getByIdRel(Integer orderId) {
OrderParam param = new OrderParam();
param.setOrderId(orderId);
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public Order getByOutTradeNo(String outTradeNo) {
System.out.println("outTradeNo = " + outTradeNo);
OrderParam param = new OrderParam();
param.setOrderNo(outTradeNo);
return param.getOne(baseMapper.getByOutTradeNo(param));
}
@Override
public void updateByOutTradeNo(Order order) {
baseMapper.updateByOutTradeNo(order);
}
/**
* 创建微信支付
*
* @param order
* @return
*/
@Override
public HashMap<String, String> createWxOrder(Order order) {
// 服务器本地路径
final String uploadPath = config.getUploadPath();
final HashMap<String, String> orderInfo = new HashMap<>();
// 微信小程序(微信支付)
String key = "Payment:wxPay:".concat(order.getTenantId().toString());
final Payment payment = redisUtil.get(key, Payment.class);
final JSONObject mpWx = settingService.getBySettingKey("mp-weixin");
// 计算金额
BigDecimal decimal = order.getTotalPrice();
final BigDecimal multiply = decimal.multiply(new BigDecimal(100));
// 将 BigDecimal 转换为 Integer
Integer money = multiply.intValue();
String privateKey = uploadPath.concat("/file").concat(payment.getApiclientKey()); // 秘钥证书
String apiclientCert = uploadPath.concat("/file").concat(payment.getApiclientCert());
// 开发环境配置
if(active.equals("dev")){
privateKey = privateKeyPath;
apiclientCert = wechatpayCertPath;
} }
Config config =
new RSAConfig.Builder()
.merchantId(payment.getMchId())
.privateKeyFromPath(privateKey)
.merchantSerialNumber(payment.getMerchantSerialNumber())
.wechatPayCertificatesFromPath(apiclientCert)
.build();
// 构建service @Override
JsapiServiceExtension service = new JsapiServiceExtension.Builder().config(config).build(); public List<Order> listRel(OrderParam param) {
// 跟之前下单示例一样,填充预下单参数 List<Order> list = baseMapper.selectListRel(param);
PrepayRequest request = new PrepayRequest(); // 排序
Amount amount = new Amount(); PageParam<Order, OrderParam> page = new PageParam<>();
amount.setTotal(money); page.setDefaultOrder("create_time desc");
amount.setCurrency("CNY"); return page.sortRecords(list);
request.setAmount(amount);
request.setAppid(mpWx.getString("appId"));
request.setMchid(payment.getMchId());
request.setDescription(order.getComments());
request.setNotifyUrl("https://server.gxwebsoft.com/api/system/wx-pay/notify/" + order.getTenantId());
request.setOutTradeNo(order.getOrderNo());
request.setAttach(order.getTenantId().toString());
final Payer payer = new Payer();
payer.setOpenid(order.getOpenid());
request.setPayer(payer);
if (StrUtil.isNotBlank(payment.getNotifyUrl())) {
request.setNotifyUrl(payment.getNotifyUrl().concat("/").concat(order.getTenantId().toString()));
} }
// 测试金额
if(active.equals("dev")){ @Override
amount.setTotal(1); public Order getByIdRel(Integer orderId) {
request.setAmount(amount); OrderParam param = new OrderParam();
param.setOrderId(orderId);
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public void paySuccess(Order order) {
System.out.println("order = " + order);
// 安装插件
menuService.cloneMenu(order.getMenuParam());
order.setPayStatus(true);
// 实际支付金额
if (order.getPayType().equals(0)) {
order.setPayPrice(order.getPayPrice());
}
order.setPayTime(DateUtil.date());
order.setStartTime(System.currentTimeMillis());
order.setExpirationTime(DateUtil.offsetMonth(DateUtil.date(), order.getMonth()));
updateById(order);
// orderGoodsService.update(new LambdaUpdateWrapper<OrderGoods>().eq(OrderGoods::getOrderId, order.getOrderId())
// .set(OrderGoods::getPayStatus, 1)
// .set(OrderGoods::getPayTime, DateUtil.date())
// .set(OrderGoods::getExpirationTime, DateUtil.offsetMonth(DateUtil.date(), order.getMonth()))
// );
final List<OrderGoods> list = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderId, order.getOrderId()));
if (!CollectionUtils.isEmpty(list)) {
list.forEach(d -> {
d.setPayStatus(true);
d.setPayTime(DateUtil.date());
d.setExpirationTime(DateUtil.offsetMonth(DateUtil.date(), order.getMonth()));
});
// 更新订单商品状态
orderGoodsService.updateBatchById(list);
// 累计销量
Company company = companyService.getById(list.get(0).getItemId());
company.setBuys(company.getBuys() + list.size());
System.out.println("company = " + company);
companyService.updateById(company);
} }
System.out.println("request = " + request);
PrepayWithRequestPaymentResponse response = service.prepayWithRequestPayment(request);
orderInfo.put("provider", "wxpay");
orderInfo.put("timeStamp", response.getTimeStamp());
orderInfo.put("nonceStr", response.getNonceStr());
orderInfo.put("package", response.getPackageVal());
orderInfo.put("signType", "RSA");
orderInfo.put("paySign", response.getPaySign());
return orderInfo;
} }
} }