Compare commits

...

7 Commits

Author SHA1 Message Date
梁欣 02cf28ca13 Merge remote-tracking branch 'origin/dev' into dev 2 weeks ago
梁欣 ba97d65f34 1、新增礼品卡模块 2 weeks ago
梁欣 753821c442 Merge remote-tracking branch 'origin/dev' into dev 2 weeks ago
梁欣 5d55376ea7 新增分佣 2 weeks ago
科技小王子 668486c9d4 修复支付证书的拼接规则。 2 weeks ago
科技小王子 22dbd529a6 Merge remote-tracking branch 'origin/dev' into dev 2 weeks ago
科技小王子 3cfc32aae2 修复支付证书的拼接规则。 2 weeks ago
  1. 2
      pom.xml
  2. 3
      src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java
  3. 50
      src/main/java/com/gxwebsoft/common/core/utils/RequestUtil.java
  4. 2
      src/main/java/com/gxwebsoft/common/system/entity/User.java
  5. 124
      src/main/java/com/gxwebsoft/shop/controller/ShopCouponApplyCateController.java
  6. 125
      src/main/java/com/gxwebsoft/shop/controller/ShopCouponApplyItemController.java
  7. 93
      src/main/java/com/gxwebsoft/shop/controller/ShopCouponController.java
  8. 259
      src/main/java/com/gxwebsoft/shop/controller/ShopGiftController.java
  9. 1
      src/main/java/com/gxwebsoft/shop/controller/ShopGoodsCategoryController.java
  10. 94
      src/main/java/com/gxwebsoft/shop/controller/ShopUserCouponController.java
  11. 24
      src/main/java/com/gxwebsoft/shop/entity/ShopCoupon.java
  12. 50
      src/main/java/com/gxwebsoft/shop/entity/ShopCouponApplyCate.java
  13. 50
      src/main/java/com/gxwebsoft/shop/entity/ShopCouponApplyItem.java
  14. 2
      src/main/java/com/gxwebsoft/shop/entity/ShopDealerOrder.java
  15. 75
      src/main/java/com/gxwebsoft/shop/entity/ShopGift.java
  16. 3
      src/main/java/com/gxwebsoft/shop/entity/ShopGoods.java
  17. 16
      src/main/java/com/gxwebsoft/shop/entity/ShopUserCoupon.java
  18. 37
      src/main/java/com/gxwebsoft/shop/mapper/ShopCouponApplyCateMapper.java
  19. 37
      src/main/java/com/gxwebsoft/shop/mapper/ShopCouponApplyItemMapper.java
  20. 37
      src/main/java/com/gxwebsoft/shop/mapper/ShopGiftMapper.java
  21. 54
      src/main/java/com/gxwebsoft/shop/mapper/xml/ShopCouponApplyCateMapper.xml
  22. 54
      src/main/java/com/gxwebsoft/shop/mapper/xml/ShopCouponApplyItemMapper.xml
  23. 72
      src/main/java/com/gxwebsoft/shop/mapper/xml/ShopGiftMapper.xml
  24. 46
      src/main/java/com/gxwebsoft/shop/param/ShopCouponApplyCateParam.java
  25. 46
      src/main/java/com/gxwebsoft/shop/param/ShopCouponApplyItemParam.java
  26. 67
      src/main/java/com/gxwebsoft/shop/param/ShopGiftParam.java
  27. 43
      src/main/java/com/gxwebsoft/shop/service/ShopCouponApplyCateService.java
  28. 43
      src/main/java/com/gxwebsoft/shop/service/ShopCouponApplyItemService.java
  29. 43
      src/main/java/com/gxwebsoft/shop/service/ShopGiftService.java
  30. 1
      src/main/java/com/gxwebsoft/shop/service/ShopOrderGoodsService.java
  31. 21
      src/main/java/com/gxwebsoft/shop/service/ShopOrderUpdate10550Service.java
  32. 1
      src/main/java/com/gxwebsoft/shop/service/ShopUserCouponService.java
  33. 56
      src/main/java/com/gxwebsoft/shop/service/impl/ShopCouponApplyCateServiceImpl.java
  34. 56
      src/main/java/com/gxwebsoft/shop/service/impl/ShopCouponApplyItemServiceImpl.java
  35. 24
      src/main/java/com/gxwebsoft/shop/service/impl/ShopCouponServiceImpl.java
  36. 71
      src/main/java/com/gxwebsoft/shop/service/impl/ShopGiftServiceImpl.java
  37. 9
      src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderGoodsServiceImpl.java
  38. 1151
      src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderServiceImpl.java
  39. 90
      src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderUpdate10550ServiceImpl.java
  40. 10
      src/main/java/com/gxwebsoft/shop/service/impl/ShopUserCouponServiceImpl.java
  41. 2
      src/main/resources/application-dev.yml
  42. 2
      src/main/resources/application-prod.yml
  43. 2
      src/main/resources/application.yml
  44. 7
      src/test/java/com/gxwebsoft/generator/ShopGenerator.java
  45. 79
      src/test/java/com/gxwebsoft/shop/CertificatePathTest.java

2
pom.xml

@ -370,7 +370,7 @@
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<groupId>org.project-lombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>

3
src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java

@ -73,7 +73,8 @@ public class SecurityConfig {
"/api/cms/form-record",
"/api/shop/merchant-account/getMerchantAccountByPhone",
"/api/hjm/hjm-car/**",
"/api/chat/**"
"/api/chat/**",
"/api/shop/shop-order/test"
)
.permitAll()
.anyRequest()

50
src/main/java/com/gxwebsoft/common/core/utils/RequestUtil.java

@ -4,6 +4,7 @@ import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import com.gxwebsoft.common.core.config.ConfigProperties;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.system.entity.DictData;
import com.gxwebsoft.common.system.entity.Payment;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.entity.UserRole;
@ -121,6 +122,24 @@ public class RequestUtil {
return null;
}
public User getByUserIdWithoutLogin(Integer userId) {
String path = "/system/user/getByUserId/" + userId;
try {
// 链式构建请求
String result = HttpRequest.get(getServerUrl().concat(path))
.header("Tenantid", TENANT_ID)
.timeout(20000)//超时,毫秒
.execute().body();
JSONObject jsonObject = JSONObject.parseObject(result);
System.out.println("jsonObject = " + jsonObject);
final String data = jsonObject.getString("data");
return JSONObject.parseObject(data, User.class);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
// 新增用户
public boolean saveUserByPhone(ShopMerchantAccount merchantAccount) {
String path = "/system/user/";
@ -173,7 +192,6 @@ public class RequestUtil {
try {
// 链式构建请求
final String result = HttpRequest.get(getServerUrl().concat("/system/user-referee/getReferee/" + userId))
.header("Authorization", ACCESS_TOKEN)
.header("Tenantid", TENANT_ID)
.timeout(20000)
.execute().body();
@ -202,6 +220,21 @@ public class RequestUtil {
}
}
// 更新用户信息
public void updateWithoutLogin(User user) {
String path = "/system/user/updateWithoutLogin";
try {
// 链式构建请求
final String body = HttpRequest.put(getServerUrl().concat(path))
.header("Tenantid", TENANT_ID)
.body(JSONUtil.toJSONString(user))
.timeout(20000)
.execute().body();
} catch (Exception e) {
e.printStackTrace();
}
}
public String getMpOrderQrCode(String orderNo) {
String path = "/wx-login/getOrderQRCode/";
try {
@ -271,6 +304,21 @@ public class RequestUtil {
}
}
public ApiResult<?> pageDictData(Integer dictId) {
String path = "/system/dict-data/page";
try {
// 链式构建请求
final String body = HttpRequest.get(getServerUrl().concat(path).concat("?dictId=" + dictId))
.header("tenantId", TENANT_ID)
.timeout(20000)
.execute().body();
return JSONUtil.parseObject(body, ApiResult.class);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
// 余额支付通知
public void pushBalancePayNotify(Transaction transaction, Payment payment) {
System.out.println("payment = " + payment);

2
src/main/java/com/gxwebsoft/common/system/entity/User.java

@ -119,7 +119,7 @@ public class User implements UserDetails {
private String payMoney;
@Schema(description = "实际消费的金额(不含退款)")
private String expendMoney;
private BigDecimal expendMoney;
@Schema(description = "会员等级ID")
private Integer gradeId;

124
src/main/java/com/gxwebsoft/shop/controller/ShopCouponApplyCateController.java

@ -0,0 +1,124 @@
package com.gxwebsoft.shop.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.service.ShopCouponApplyCateService;
import com.gxwebsoft.shop.entity.ShopCouponApplyCate;
import com.gxwebsoft.shop.param.ShopCouponApplyCateParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 优惠券可用分类控制器
*
* @author 科技小王子
* @since 2025-08-11 12:47:49
*/
@Tag(name = "优惠券可用分类管理")
@RestController
@RequestMapping("/api/shop/shop-coupon-apply-cate")
public class ShopCouponApplyCateController extends BaseController {
@Resource
private ShopCouponApplyCateService shopCouponApplyCateService;
@PreAuthorize("hasAuthority('shop:shopCouponApplyCate:list')")
@Operation(summary = "分页查询优惠券可用分类")
@GetMapping("/page")
public ApiResult<PageResult<ShopCouponApplyCate>> page(ShopCouponApplyCateParam param) {
// 使用关联查询
return success(shopCouponApplyCateService.pageRel(param));
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyCate:list')")
@Operation(summary = "查询全部优惠券可用分类")
@GetMapping()
public ApiResult<List<ShopCouponApplyCate>> list(ShopCouponApplyCateParam param) {
// 使用关联查询
return success(shopCouponApplyCateService.listRel(param));
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyCate:list')")
@Operation(summary = "根据id查询优惠券可用分类")
@GetMapping("/{id}")
public ApiResult<ShopCouponApplyCate> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(shopCouponApplyCateService.getByIdRel(id));
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyCate:save')")
@OperationLog
@Operation(summary = "添加优惠券可用分类")
@PostMapping()
public ApiResult<?> save(@RequestBody ShopCouponApplyCate shopCouponApplyCate) {
if (shopCouponApplyCateService.save(shopCouponApplyCate)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyCate:update')")
@OperationLog
@Operation(summary = "修改优惠券可用分类")
@PutMapping()
public ApiResult<?> update(@RequestBody ShopCouponApplyCate shopCouponApplyCate) {
if (shopCouponApplyCateService.updateById(shopCouponApplyCate)) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyCate:remove')")
@OperationLog
@Operation(summary = "删除优惠券可用分类")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (shopCouponApplyCateService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyCate:save')")
@OperationLog
@Operation(summary = "批量添加优惠券可用分类")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<ShopCouponApplyCate> list) {
if (shopCouponApplyCateService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyCate:update')")
@OperationLog
@Operation(summary = "批量修改优惠券可用分类")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<ShopCouponApplyCate> batchParam) {
if (batchParam.update(shopCouponApplyCateService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyCate:remove')")
@OperationLog
@Operation(summary = "批量删除优惠券可用分类")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (shopCouponApplyCateService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}

125
src/main/java/com/gxwebsoft/shop/controller/ShopCouponApplyItemController.java

@ -0,0 +1,125 @@
package com.gxwebsoft.shop.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.service.ShopCouponApplyItemService;
import com.gxwebsoft.shop.entity.ShopCouponApplyItem;
import com.gxwebsoft.shop.param.ShopCouponApplyItemParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* 优惠券可用分类控制器
*
* @author 科技小王子
* @since 2025-08-11 12:47:49
*/
@Tag(name = "优惠券可用分类管理")
@RestController
@RequestMapping("/api/shop/shop-coupon-apply-item")
public class ShopCouponApplyItemController extends BaseController {
@Resource
private ShopCouponApplyItemService shopCouponApplyItemService;
@PreAuthorize("hasAuthority('shop:shopCouponApplyItem:list')")
@Operation(summary = "分页查询优惠券可用分类")
@GetMapping("/page")
public ApiResult<PageResult<ShopCouponApplyItem>> page(ShopCouponApplyItemParam param) {
// 使用关联查询
return success(shopCouponApplyItemService.pageRel(param));
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyItem:list')")
@Operation(summary = "查询全部优惠券可用分类")
@GetMapping()
public ApiResult<List<ShopCouponApplyItem>> list(ShopCouponApplyItemParam param) {
// 使用关联查询
return success(shopCouponApplyItemService.listRel(param));
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyItem:list')")
@Operation(summary = "根据id查询优惠券可用分类")
@GetMapping("/{id}")
public ApiResult<ShopCouponApplyItem> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(shopCouponApplyItemService.getByIdRel(id));
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyItem:save')")
@OperationLog
@Operation(summary = "添加优惠券可用分类")
@PostMapping()
public ApiResult<?> save(@RequestBody ShopCouponApplyItem shopCouponApplyItem) {
if (shopCouponApplyItemService.save(shopCouponApplyItem)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyItem:update')")
@OperationLog
@Operation(summary = "修改优惠券可用分类")
@PutMapping()
public ApiResult<?> update(@RequestBody ShopCouponApplyItem shopCouponApplyItem) {
if (shopCouponApplyItemService.updateById(shopCouponApplyItem)) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyItem:remove')")
@OperationLog
@Operation(summary = "删除优惠券可用分类")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (shopCouponApplyItemService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyItem:save')")
@OperationLog
@Operation(summary = "批量添加优惠券可用分类")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<ShopCouponApplyItem> list) {
if (shopCouponApplyItemService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyItem:update')")
@OperationLog
@Operation(summary = "批量修改优惠券可用分类")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<ShopCouponApplyItem> batchParam) {
if (batchParam.update(shopCouponApplyItemService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('shop:shopCouponApplyItem:remove')")
@OperationLog
@Operation(summary = "批量删除优惠券可用分类")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (shopCouponApplyItemService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}

93
src/main/java/com/gxwebsoft/shop/controller/ShopCouponController.java

@ -1,6 +1,14 @@
package com.gxwebsoft.shop.controller;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.entity.ShopCouponApplyCate;
import com.gxwebsoft.shop.entity.ShopCouponApplyItem;
import com.gxwebsoft.shop.entity.ShopUserCoupon;
import com.gxwebsoft.shop.service.ShopCouponApplyCateService;
import com.gxwebsoft.shop.service.ShopCouponApplyItemService;
import com.gxwebsoft.shop.service.ShopCouponService;
import com.gxwebsoft.shop.entity.ShopCoupon;
import com.gxwebsoft.shop.param.ShopCouponParam;
@ -10,12 +18,14 @@ import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.shop.service.ShopUserCouponService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
@ -30,6 +40,57 @@ import java.util.List;
public class ShopCouponController extends BaseController {
@Resource
private ShopCouponService shopCouponService;
@Resource
private ShopUserCouponService userCouponService;
@Resource
private ShopCouponService couponService;
@Resource
private ShopCouponApplyItemService couponApplyItemService;
@Resource
private ShopCouponApplyCateService couponApplyCateService;
@Operation(summary = "可领取优惠券列表")
@PostMapping("/list")
public ApiResult<List<ShopCoupon>> page() {
Integer uid = getLoginUserId();
// 用户已经领取的优惠券
List<ShopUserCoupon> userCouponList = userCouponService.userList(uid);
List<Integer> hasTakeCouponIdList = new ArrayList<>();
for (ShopUserCoupon userCoupon : userCouponList) {
hasTakeCouponIdList.add(userCoupon.getCouponId());
}
LambdaQueryWrapper<ShopCoupon> queryWrapper = new LambdaQueryWrapper<>();
// if (!hasTakeCouponIdList.isEmpty()) queryWrapper.notIn(Coupon::getCouponId, hasTakeCouponIdList);
queryWrapper.eq(ShopCoupon::getStatus, 0);
queryWrapper.apply("(expire_type = 0 OR (expire_type = 1 AND end_time > '"
+ DateUtil.date() + "'))");
queryWrapper.orderByAsc(ShopCoupon::getSortNumber);
List<ShopCoupon> couponList = couponService.list(queryWrapper);
for (ShopCoupon coupon : couponList) {
coupon.setCouponApplyItemList(couponApplyItemService.list(
new LambdaQueryWrapper<ShopCouponApplyItem>().eq(ShopCouponApplyItem::getCouponId, coupon.getId())
));
coupon.setCouponApplyCateList(couponApplyCateService.list(
new LambdaQueryWrapper<ShopCouponApplyCate>().eq(ShopCouponApplyCate::getCouponId, coupon.getId())
));
boolean hasTake = hasTakeCouponIdList.contains(coupon.getId());
coupon.setHasTake(hasTake);
if (hasTake) {
int userUseNum = 0;
List<ShopUserCoupon> userCouponList1 = userCouponService.list(
new LambdaQueryWrapper<ShopUserCoupon>()
.eq(ShopUserCoupon::getCouponId, coupon.getId())
);
coupon.setUserTakeNum(userCouponList1.size());
for (ShopUserCoupon userCoupon : userCouponList1) {
if (userCoupon.getIsUse().equals(1)) userUseNum++;
}
coupon.setUserUseNum(userUseNum);
}
}
return success(couponList);
}
@PreAuthorize("hasAuthority('shop:shopCoupon:list')")
@Operation(summary = "分页查询优惠券")
@ -63,9 +124,22 @@ public class ShopCouponController extends BaseController {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
shopCoupon.setUserId(loginUser.getUserId());
shopCoupon.setUserId(loginUser.getUserId());
}
if (shopCouponService.save(shopCoupon)) {
if (shopCoupon.getCouponApplyCateList() != null && !shopCoupon.getCouponApplyCateList().isEmpty()) {
for (ShopCouponApplyCate couponApplyCate : shopCoupon.getCouponApplyCateList()) {
couponApplyCate.setCouponId(shopCoupon.getId());
}
couponApplyCateService.saveBatch(shopCoupon.getCouponApplyCateList());
}
if (shopCoupon.getCouponApplyItemList() != null && !shopCoupon.getCouponApplyItemList().isEmpty()) {
for (ShopCouponApplyItem couponApplyItem : shopCoupon.getCouponApplyItemList()) {
couponApplyItem.setCouponId(shopCoupon.getId());
}
couponApplyItemService.saveBatch(shopCoupon.getCouponApplyItemList());
}
return success("添加成功");
}
return fail("添加失败");
@ -77,6 +151,21 @@ public class ShopCouponController extends BaseController {
@PutMapping()
public ApiResult<?> update(@RequestBody ShopCoupon shopCoupon) {
if (shopCouponService.updateById(shopCoupon)) {
couponApplyCateService.removeByCouponId(shopCoupon.getId());
if (shopCoupon.getCouponApplyCateList() != null && !shopCoupon.getCouponApplyCateList().isEmpty()) {
for (ShopCouponApplyCate couponApplyCate : shopCoupon.getCouponApplyCateList()) {
couponApplyCate.setCouponId(shopCoupon.getId());
}
couponApplyCateService.saveBatch(shopCoupon.getCouponApplyCateList());
}
couponApplyItemService.removeByCouponId(shopCoupon.getId());
if (shopCoupon.getCouponApplyItemList() != null && !shopCoupon.getCouponApplyItemList().isEmpty()) {
for (ShopCouponApplyItem couponApplyItem : shopCoupon.getCouponApplyItemList()) {
couponApplyItem.setCouponId(shopCoupon.getId());
}
couponApplyItemService.saveBatch(shopCoupon.getCouponApplyItemList());
}
return success("修改成功");
}
return fail("修改失败");
@ -88,6 +177,8 @@ public class ShopCouponController extends BaseController {
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (shopCouponService.removeById(id)) {
couponApplyCateService.removeByCouponId(id);
couponApplyItemService.removeByCouponId(id);
return success("删除成功");
}
return fail("删除失败");

259
src/main/java/com/gxwebsoft/shop/controller/ShopGiftController.java

@ -0,0 +1,259 @@
package com.gxwebsoft.shop.controller;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gxwebsoft.common.core.config.ConfigProperties;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.system.entity.FileRecord;
import com.gxwebsoft.shop.entity.ShopGoods;
import com.gxwebsoft.shop.service.ShopGiftService;
import com.gxwebsoft.shop.entity.ShopGift;
import com.gxwebsoft.shop.param.ShopGiftParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.shop.service.ShopGoodsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 礼品卡控制器
*
* @author 科技小王子
* @since 2025-08-11 18:07:32
*/
@Tag(name = "礼品卡管理")
@RestController
@RequestMapping("/api/shop/shop-gift")
public class ShopGiftController extends BaseController {
@Resource
private ShopGiftService shopGiftService;
@Value("${config.upload-path}")
private String uploadPath;
@Value("${config.api-url}")
private String apiUrl;
@Resource
private ShopGoodsService shopGoodsService;
@Operation(summary = "根据code查询礼品卡")
@GetMapping("/by-code/{code}")
public ApiResult<ShopGift> get(@PathVariable("code") String code) {
// 使用关联查询
return success(shopGiftService.getByCode(code));
}
@Operation(summary = "礼品卡核销")
@PostMapping("/set-take")
public ApiResult<?> setTake(@RequestBody ShopGift shopGift) {
if (getLoginUser() == null) return fail("请登录");
if (shopGift.getCode() == null) {
return fail("非法请求");
}
ShopGift shopGift1 = shopGiftService.getByCode(shopGift.getCode());
if (shopGift1 == null) return fail("礼品卡不存在");
if (shopGift1.getTakeTime() != null) {
return fail("礼品卡已使用");
}
shopGift1.setTakeTime(LocalDateTime.now());
shopGift1.setOperatorUserId(getLoginUserId());
shopGiftService.updateById(shopGift1);
return success();
}
@PreAuthorize("hasAuthority('shop:shopGift:list')")
@Operation(summary = "分页查询礼品卡")
@GetMapping("/page")
public ApiResult<PageResult<ShopGift>> page(ShopGiftParam param) {
// 使用关联查询
return success(shopGiftService.pageRel(param));
}
@PreAuthorize("hasAuthority('shop:shopGift:list')")
@Operation(summary = "查询全部礼品卡")
@GetMapping()
public ApiResult<List<ShopGift>> list(ShopGiftParam param) {
// 使用关联查询
return success(shopGiftService.listRel(param));
}
@PreAuthorize("hasAuthority('shop:shopGift:list')")
@Operation(summary = "根据id查询礼品卡")
@GetMapping("/{id}")
public ApiResult<ShopGift> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(shopGiftService.getByIdRel(id));
}
@PreAuthorize("hasAuthority('shop:shopGift:save')")
@OperationLog
@Operation(summary = "添加礼品卡")
@PostMapping()
public ApiResult<?> save(@RequestBody ShopGift shopGift) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
shopGift.setUserId(loginUser.getUserId());
}
if (shopGiftService.save(shopGift)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('shop:shopGift:update')")
@OperationLog
@Operation(summary = "修改礼品卡")
@PutMapping()
public ApiResult<?> update(@RequestBody ShopGift shopGift) {
if (shopGiftService.updateById(shopGift)) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('shop:shopGift:save')")
@OperationLog
@Operation(summary = "批量生成礼品卡")
@PostMapping("/make")
public ApiResult<?> make(@RequestBody ShopGift shopGiftData) {
if (shopGiftData.getNum() == null || shopGiftData.getNum() <= 0) {
return fail("请输入正确的数量");
}
if (shopGiftData.getGoodsId() == null || shopGiftData.getGoodsId() <= 0) {
return fail("请选择商品");
}
List<ShopGift> giftList = new ArrayList<>();
for (int i = 0; i < shopGiftData.getNum(); i++) {
ShopGift shopGift = new ShopGift();
shopGift.setName(shopGiftData.getName());
shopGift.setCode(RandomUtil.randomString(8));
shopGift.setGoodsId(shopGiftData.getGoodsId());
giftList.add(shopGift);
}
if (shopGiftService.saveBatch(giftList)) {
return success("生成成功");
}
return fail("生成失败");
}
@PreAuthorize("hasAuthority('shop:shopGift:remove')")
@OperationLog
@Operation(summary = "删除礼品卡")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (shopGiftService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('shop:shopGift:save')")
@OperationLog
@Operation(summary = "批量添加礼品卡")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<ShopGift> list) {
if (shopGiftService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('shop:shopGift:update')")
@OperationLog
@Operation(summary = "批量修改礼品卡")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<ShopGift> batchParam) {
if (batchParam.update(shopGiftService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@PreAuthorize("hasAuthority('shop:shopGift:remove')")
@OperationLog
@Operation(summary = "批量删除礼品卡")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (shopGiftService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('shop:shopGift:list')")
@Operation(summary = "导出礼品卡")
@PostMapping("/export")
public ApiResult<?> export(@RequestBody(required = false) List<Integer> ids) throws IOException {
String filename = "file/excel/礼品卡.xlsx";
if (!FileUtil.exist(uploadPath + "file/excel")) {
FileUtil.mkdir(uploadPath + "file/excel");
}
List<ShopGift> list;
if (ids != null && !ids.isEmpty()) {
list = shopGiftService.listByIds(ids);
} else {
list = shopGiftService.list();
}
if (!list.isEmpty()) {
Set<Integer> goodsIds = list.stream().map(ShopGift::getGoodsId).collect(Collectors.toSet());
List<ShopGoods> goodsList = shopGoodsService.listByIds(goodsIds);
for (ShopGift shopGift : list) {
ShopGoods shopGoods = goodsList.stream().filter(sG -> sG.getGoodsId().equals(shopGift.getGoodsId())).findFirst().orElse(null);
if (shopGoods != null) {
shopGift.setGoods(shopGoods);
}
}
}
String path = uploadPath + filename;
SXSSFWorkbook workbook = new SXSSFWorkbook();
//创建工作表单
SXSSFSheet sheet = workbook.createSheet();
String[] headers = {"名称", "秘钥", "领取时间", "商品"};
SXSSFRow row0 = sheet.createRow(0);
for (int i = 0; i < headers.length; i++) {
row0.createCell(i).setCellValue(headers[i]);
}
if (!list.isEmpty()) {
for (ShopGift shopGift : list) {
SXSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
row.createCell(0).setCellValue(shopGift.getName());
row.createCell(1).setCellValue(shopGift.getCode());
row.createCell(2).setCellValue(shopGift.getTakeTime());
row.createCell(3).setCellValue(shopGift.getGoods() != null ? shopGift.getGoods().getName() : "");
}
}
FileOutputStream output = new FileOutputStream(path);
workbook.write(output);
output.flush();
FileRecord result = new FileRecord();
result.setCreateUserId(getLoginUserId());
result.setName("礼品卡");
result.setPath(filename);
result.setUrl(apiUrl + "/" + filename);
return success(result);
}
}

1
src/main/java/com/gxwebsoft/shop/controller/ShopGoodsCategoryController.java

@ -39,7 +39,6 @@ public class ShopGoodsCategoryController extends BaseController {
return success(shopGoodsCategoryService.pageRel(param));
}
@PreAuthorize("hasAuthority('shop:shopGoodsCategory:list')")
@Operation(summary = "查询全部商品分类")
@GetMapping()
public ApiResult<List<ShopGoodsCategory>> list(ShopGoodsCategoryParam param) {

94
src/main/java/com/gxwebsoft/shop/controller/ShopUserCouponController.java

@ -1,6 +1,16 @@
package com.gxwebsoft.shop.controller;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.entity.ShopCoupon;
import com.gxwebsoft.shop.entity.ShopCouponApplyCate;
import com.gxwebsoft.shop.entity.ShopCouponApplyItem;
import com.gxwebsoft.shop.service.ShopCouponApplyCateService;
import com.gxwebsoft.shop.service.ShopCouponApplyItemService;
import com.gxwebsoft.shop.service.ShopCouponService;
import com.gxwebsoft.shop.service.ShopUserCouponService;
import com.gxwebsoft.shop.entity.ShopUserCoupon;
import com.gxwebsoft.shop.param.ShopUserCouponParam;
@ -16,6 +26,12 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
@ -30,6 +46,82 @@ import java.util.List;
public class ShopUserCouponController extends BaseController {
@Resource
private ShopUserCouponService shopUserCouponService;
@Resource
private ShopCouponService couponService;
@Resource
private ShopCouponApplyCateService couponApplyCateService;
@Resource
private ShopCouponApplyItemService couponApplyItemService;
@Operation(summary = "用户优惠券列表")
@PostMapping("/list")
public ApiResult<List<ShopUserCoupon>> list(@RequestBody ShopUserCoupon userCouponParam) throws ParseException {
MPJLambdaWrapper<ShopUserCoupon> queryWrapper = new MPJLambdaWrapper<ShopUserCoupon>()
.selectAll(ShopUserCoupon.class)
.selectAs(ShopCoupon::getName, ShopCoupon::getName)
.eq(ShopUserCoupon::getUserId, getLoginUserId())
.leftJoin(ShopCoupon.class, ShopCoupon::getId, ShopUserCoupon::getCouponId);
if (userCouponParam.getIsExpire() != null)
queryWrapper.eq(ShopUserCoupon::getIsExpire, userCouponParam.getIsExpire());
if (userCouponParam.getIsUse() != null) queryWrapper.eq(ShopUserCoupon::getIsUse, userCouponParam.getIsUse());
List<ShopUserCoupon> userCouponList = shopUserCouponService.list(queryWrapper);
for (ShopUserCoupon userCoupon : userCouponList) {
if (userCoupon.getEndTime().isBefore(LocalDateTime.now())) {
userCoupon.setIsExpire(1);
shopUserCouponService.updateById(userCoupon);
}
ShopCoupon coupon = couponService.getById(userCoupon.getCouponId());
coupon.setCouponApplyCateList(couponApplyCateService.list(
new LambdaQueryWrapper<ShopCouponApplyCate>()
.eq(ShopCouponApplyCate::getCouponId, userCoupon.getCouponId())
));
coupon.setCouponApplyItemList(couponApplyItemService.list(
new LambdaQueryWrapper<ShopCouponApplyItem>()
.eq(ShopCouponApplyItem::getCouponId, userCoupon.getCouponId())
));
userCoupon.setCouponItem(coupon);
}
return success(userCouponList);
}
@Operation(summary = "领取优惠券")
@PostMapping("/take")
public ApiResult<?> take(@RequestBody ShopUserCoupon userCoupon) {
ShopCoupon coupon = couponService.getByIdRel(userCoupon.getCouponId());
if (coupon.getTotalCount() != -1 && coupon.getReceiveNum() >= coupon.getTotalCount()) return fail("已经被领完了");
List<ShopUserCoupon> userCouponList = shopUserCouponService.list(
new LambdaQueryWrapper<ShopUserCoupon>()
.eq(ShopUserCoupon::getCouponId, userCoupon.getCouponId())
.eq(ShopUserCoupon::getUserId, getLoginUserId())
);
int userNotUsedNum = 0;
for (ShopUserCoupon userCouponItem : userCouponList) {
if (userCouponItem.getIsUse().equals(0)) userNotUsedNum++;
}
if (userNotUsedNum > 0) return fail("您还有未使用的优惠券,无法领取");
if (coupon.getLimitPerUser() > -1) {
if (userCouponList.size() >= coupon.getLimitPerUser())
return fail("每用户最多领取" + coupon.getLimitPerUser() + "张优惠券");
}
userCoupon.setType(coupon.getType());
userCoupon.setReducePrice(coupon.getReducePrice());
userCoupon.setDiscount(coupon.getDiscount());
userCoupon.setMinPrice(coupon.getMinPrice());
Integer expireType = coupon.getExpireType();
userCoupon.setExpireType(expireType);
if (expireType == 10) {
userCoupon.setStartTime(LocalDateTime.now());
userCoupon.setEndTime(LocalDateTimeUtil.offset(userCoupon.getStartTime(), coupon.getExpireDay(), ChronoUnit.DAYS));
} else {
userCoupon.setStartTime(coupon.getStartTime());
userCoupon.setEndTime(coupon.getEndTime());
}
userCoupon.setUserId(getLoginUserId());
shopUserCouponService.save(userCoupon);
coupon.setReceiveNum(coupon.getReceiveNum() + 1);
couponService.updateById(coupon);
return success("领取成功");
}
@PreAuthorize("hasAuthority('shop:shopUserCoupon:list')")
@Operation(summary = "分页查询用户优惠券")
@ -63,7 +155,7 @@ public class ShopUserCouponController extends BaseController {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
shopUserCoupon.setUserId(loginUser.getUserId());
shopUserCoupon.setUserId(loginUser.getUserId());
}
if (shopUserCouponService.save(shopUserCoupon)) {
return success("添加成功");

24
src/main/java/com/gxwebsoft/shop/entity/ShopCoupon.java

@ -3,11 +3,14 @@ package com.gxwebsoft.shop.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDate;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -54,10 +57,10 @@ public class ShopCoupon implements Serializable {
private Integer expireDay;
@Schema(description = "有效期开始时间")
private LocalDate startTime;
private LocalDateTime startTime;
@Schema(description = "有效期结束时间")
private LocalDate endTime;
private LocalDateTime endTime;
@Schema(description = "适用范围(10全部商品 20指定商品 30指定分类)")
private Integer applyRange;
@ -102,4 +105,21 @@ public class ShopCoupon implements Serializable {
@Schema(description = "是否启用(0禁用 1启用)")
private Boolean enabled;
@TableField(exist = false)
private List<ShopCouponApplyItem> couponApplyItemList;
@TableField(exist = false)
private List<ShopCouponApplyCate> couponApplyCateList;
@TableField(exist = false)
private Boolean hasTake;
@TableField(exist = false)
private Integer userTakeNum;
@TableField(exist = false)
private Integer userUseNum;
@TableField(exist = false)
private Integer receiveNum;
}

50
src/main/java/com/gxwebsoft/shop/entity/ShopCouponApplyCate.java

@ -0,0 +1,50 @@
package com.gxwebsoft.shop.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 优惠券可用分类
*
* @author 科技小王子
* @since 2025-08-11 12:47:49
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "ShopCouponApplyCate对象", description = "优惠券可用分类")
public class ShopCouponApplyCate implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Integer couponId;
private Integer cateId;
@Schema(description = "分类等级")
private Integer cateLevel;
@Schema(description = "状态, 0正常, 1冻结")
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@Schema(description = "租户id")
private Integer tenantId;
@Schema(description = "注册时间")
private LocalDateTime createTime;
@Schema(description = "修改时间")
private LocalDateTime updateTime;
}

50
src/main/java/com/gxwebsoft/shop/entity/ShopCouponApplyItem.java

@ -0,0 +1,50 @@
package com.gxwebsoft.shop.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 优惠券可用分类
*
* @author 科技小王子
* @since 2025-08-11 12:47:49
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "ShopCouponApplyItem对象", description = "优惠券可用分类")
public class ShopCouponApplyItem implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Integer couponId;
private Integer type;
@Schema(description = "0服务1需求2闲置")
private Integer pk;
@Schema(description = "状态, 0正常, 1冻结")
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@Schema(description = "租户id")
private Integer tenantId;
@Schema(description = "注册时间")
private LocalDateTime createTime;
@Schema(description = "修改时间")
private LocalDateTime updateTime;
}

2
src/main/java/com/gxwebsoft/shop/entity/ShopDealerOrder.java

@ -61,7 +61,7 @@ public class ShopDealerOrder implements Serializable {
private Integer isSettled;
@Schema(description = "结算时间")
private Integer settleTime;
private Long settleTime;
@Schema(description = "商城ID")
private Integer tenantId;

75
src/main/java/com/gxwebsoft/shop/entity/ShopGift.java

@ -0,0 +1,75 @@
package com.gxwebsoft.shop.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 礼品卡
*
* @author 科技小王子
* @since 2025-08-11 18:07:31
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "ShopGift对象", description = "礼品卡")
public class ShopGift implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private String name;
@Schema(description = "秘钥")
private String code;
@Schema(description = "商品ID")
private Integer goodsId;
@Schema(description = "领取时间")
private LocalDateTime takeTime;
@Schema(description = "操作人")
private Integer operatorUserId;
@Schema(description = "是否展示")
private Boolean isShow;
@Schema(description = "状态, 0上架 1待上架 2待审核 3审核不通过")
private Integer status;
@Schema(description = "备注")
private String comments;
@Schema(description = "排序号")
private Integer sortNumber;
@Schema(description = "用户ID")
private Integer userId;
@Schema(description = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@Schema(description = "租户id")
private Integer tenantId;
@Schema(description = "创建时间")
private LocalDateTime createTime;
@Schema(description = "修改时间")
private LocalDateTime updateTime;
@TableField(exist = false)
private Integer num;
@TableField(exist = false)
private ShopGoods goods;
}

3
src/main/java/com/gxwebsoft/shop/entity/ShopGoods.java

@ -69,6 +69,9 @@ public class ShopGoods implements Serializable {
@Schema(description = "经销商价格")
private BigDecimal dealerPrice;
@Schema(description = "佣金")
private BigDecimal commission;
@Schema(description = "库存计算方式(10下单减库存 20付款减库存)")
private Integer deductStockType;

16
src/main/java/com/gxwebsoft/shop/entity/ShopUserCoupon.java

@ -2,6 +2,7 @@ package com.gxwebsoft.shop.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
@ -53,9 +54,18 @@ public class ShopUserCoupon implements Serializable {
@Schema(description = "适用范围(10全部商品 20指定商品 30指定分类)")
private Integer applyRange;
@Schema(description = "到期类型(10领取后生效 20固定时间)")
private Integer expireType;
@Schema(description = "领取后生效-有效天数")
private Integer expireDay;
@Schema(description = "适用范围配置(json格式)")
private String applyRangeConfig;
@Schema(description = "是否过期(0未过期 1已过期)")
private Integer isExpire;
@Schema(description = "有效期开始时间")
private LocalDateTime startTime;
@ -71,6 +81,9 @@ public class ShopUserCoupon implements Serializable {
@Schema(description = "使用订单ID")
private Long orderId;
@Schema(description = "是否已使用")
private Integer isUse;
@Schema(description = "使用订单号")
private String orderNo;
@ -93,4 +106,7 @@ public class ShopUserCoupon implements Serializable {
@Schema(description = "修改时间")
private LocalDateTime updateTime;
@TableField(exist = false)
private ShopCoupon couponItem;
}

37
src/main/java/com/gxwebsoft/shop/mapper/ShopCouponApplyCateMapper.java

@ -0,0 +1,37 @@
package com.gxwebsoft.shop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.shop.entity.ShopCouponApplyCate;
import com.gxwebsoft.shop.param.ShopCouponApplyCateParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 优惠券可用分类Mapper
*
* @author 科技小王子
* @since 2025-08-11 12:47:49
*/
public interface ShopCouponApplyCateMapper extends BaseMapper<ShopCouponApplyCate> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<ShopCouponApplyCate>
*/
List<ShopCouponApplyCate> selectPageRel(@Param("page") IPage<ShopCouponApplyCate> page,
@Param("param") ShopCouponApplyCateParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<ShopCouponApplyCate> selectListRel(@Param("param") ShopCouponApplyCateParam param);
}

37
src/main/java/com/gxwebsoft/shop/mapper/ShopCouponApplyItemMapper.java

@ -0,0 +1,37 @@
package com.gxwebsoft.shop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.shop.entity.ShopCouponApplyItem;
import com.gxwebsoft.shop.param.ShopCouponApplyItemParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 优惠券可用分类Mapper
*
* @author 科技小王子
* @since 2025-08-11 12:47:49
*/
public interface ShopCouponApplyItemMapper extends BaseMapper<ShopCouponApplyItem> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<ShopCouponApplyItem>
*/
List<ShopCouponApplyItem> selectPageRel(@Param("page") IPage<ShopCouponApplyItem> page,
@Param("param") ShopCouponApplyItemParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<ShopCouponApplyItem> selectListRel(@Param("param") ShopCouponApplyItemParam param);
}

37
src/main/java/com/gxwebsoft/shop/mapper/ShopGiftMapper.java

@ -0,0 +1,37 @@
package com.gxwebsoft.shop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.shop.entity.ShopGift;
import com.gxwebsoft.shop.param.ShopGiftParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 礼品卡Mapper
*
* @author 科技小王子
* @since 2025-08-11 18:07:31
*/
public interface ShopGiftMapper extends BaseMapper<ShopGift> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<ShopGift>
*/
List<ShopGift> selectPageRel(@Param("page") IPage<ShopGift> page,
@Param("param") ShopGiftParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<ShopGift> selectListRel(@Param("param") ShopGiftParam param);
}

54
src/main/java/com/gxwebsoft/shop/mapper/xml/ShopCouponApplyCateMapper.xml

@ -0,0 +1,54 @@
<?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.shop.mapper.ShopCouponApplyCateMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM shop_coupon_apply_cate a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.couponId != null">
AND a.coupon_id = #{param.couponId}
</if>
<if test="param.cateId != null">
AND a.cate_id = #{param.cateId}
</if>
<if test="param.cateLevel != null">
AND a.cate_level = #{param.cateLevel}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</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>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.ShopCouponApplyCate">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.ShopCouponApplyCate">
<include refid="selectSql"></include>
</select>
</mapper>

54
src/main/java/com/gxwebsoft/shop/mapper/xml/ShopCouponApplyItemMapper.xml

@ -0,0 +1,54 @@
<?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.shop.mapper.ShopCouponApplyItemMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM shop_coupon_apply_item a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.couponId != null">
AND a.coupon_id = #{param.couponId}
</if>
<if test="param.type != null">
AND a.type = #{param.type}
</if>
<if test="param.pk != null">
AND a.pk = #{param.pk}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</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>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.ShopCouponApplyItem">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.ShopCouponApplyItem">
<include refid="selectSql"></include>
</select>
</mapper>

72
src/main/java/com/gxwebsoft/shop/mapper/xml/ShopGiftMapper.xml

@ -0,0 +1,72 @@
<?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.shop.mapper.ShopGiftMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM shop_gift a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.name != null">
AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if>
<if test="param.code != null">
AND a.code LIKE CONCAT('%', #{param.code}, '%')
</if>
<if test="param.goodsId != null">
AND a.goods_id = #{param.goodsId}
</if>
<if test="param.takeTime != null">
AND a.take_time LIKE CONCAT('%', #{param.takeTime}, '%')
</if>
<if test="param.operatorUserId != null">
AND a.operator_user_id = #{param.operatorUserId}
</if>
<if test="param.isShow != null">
AND a.is_show = #{param.isShow}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</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.userId != null">
AND a.user_id = #{param.userId}
</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>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.ShopGift">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.ShopGift">
<include refid="selectSql"></include>
</select>
</mapper>

46
src/main/java/com/gxwebsoft/shop/param/ShopCouponApplyCateParam.java

@ -0,0 +1,46 @@
package com.gxwebsoft.shop.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 优惠券可用分类查询参数
*
* @author 科技小王子
* @since 2025-08-11 12:47:48
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(name = "ShopCouponApplyCateParam对象", description = "优惠券可用分类查询参数")
public class ShopCouponApplyCateParam extends BaseParam {
private static final long serialVersionUID = 1L;
@QueryField(type = QueryType.EQ)
private Integer id;
@QueryField(type = QueryType.EQ)
private Integer couponId;
@QueryField(type = QueryType.EQ)
private Integer cateId;
@Schema(description = "分类等级")
@QueryField(type = QueryType.EQ)
private Boolean cateLevel;
@Schema(description = "状态, 0正常, 1冻结")
@QueryField(type = QueryType.EQ)
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
}

46
src/main/java/com/gxwebsoft/shop/param/ShopCouponApplyItemParam.java

@ -0,0 +1,46 @@
package com.gxwebsoft.shop.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 优惠券可用分类查询参数
*
* @author 科技小王子
* @since 2025-08-11 12:47:49
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(name = "ShopCouponApplyItemParam对象", description = "优惠券可用分类查询参数")
public class ShopCouponApplyItemParam extends BaseParam {
private static final long serialVersionUID = 1L;
@QueryField(type = QueryType.EQ)
private Integer id;
@QueryField(type = QueryType.EQ)
private Integer couponId;
@QueryField(type = QueryType.EQ)
private Boolean type;
@Schema(description = "0服务1需求2闲置")
@QueryField(type = QueryType.EQ)
private Integer pk;
@Schema(description = "状态, 0正常, 1冻结")
@QueryField(type = QueryType.EQ)
private Integer status;
@Schema(description = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
}

67
src/main/java/com/gxwebsoft/shop/param/ShopGiftParam.java

@ -0,0 +1,67 @@
package com.gxwebsoft.shop.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 礼品卡查询参数
*
* @author 科技小王子
* @since 2025-08-11 18:07:31
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(name = "ShopGiftParam对象", description = "礼品卡查询参数")
public class ShopGiftParam extends BaseParam {
private static final long serialVersionUID = 1L;
@QueryField(type = QueryType.EQ)
private Integer id;
private String name;
@Schema(description = "秘钥")
private String code;
@Schema(description = "商品ID")
@QueryField(type = QueryType.EQ)
private Integer goodsId;
@Schema(description = "领取时间")
private String takeTime;
@Schema(description = "操作人")
@QueryField(type = QueryType.EQ)
private Integer operatorUserId;
@Schema(description = "是否展示")
@QueryField(type = QueryType.EQ)
private Boolean isShow;
@Schema(description = "状态, 0上架 1待上架 2待审核 3审核不通过")
@QueryField(type = QueryType.EQ)
private Integer status;
@Schema(description = "备注")
private String comments;
@Schema(description = "排序号")
@QueryField(type = QueryType.EQ)
private Integer sortNumber;
@Schema(description = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
@Schema(description = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
}

43
src/main/java/com/gxwebsoft/shop/service/ShopCouponApplyCateService.java

@ -0,0 +1,43 @@
package com.gxwebsoft.shop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.ShopCouponApplyCate;
import com.gxwebsoft.shop.param.ShopCouponApplyCateParam;
import java.util.List;
/**
* 优惠券可用分类Service
*
* @author 科技小王子
* @since 2025-08-11 12:47:49
*/
public interface ShopCouponApplyCateService extends IService<ShopCouponApplyCate> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<ShopCouponApplyCate>
*/
PageResult<ShopCouponApplyCate> pageRel(ShopCouponApplyCateParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<ShopCouponApplyCate>
*/
List<ShopCouponApplyCate> listRel(ShopCouponApplyCateParam param);
/**
* 根据id查询
*
* @param id
* @return ShopCouponApplyCate
*/
ShopCouponApplyCate getByIdRel(Integer id);
void removeByCouponId(Integer couponId);
}

43
src/main/java/com/gxwebsoft/shop/service/ShopCouponApplyItemService.java

@ -0,0 +1,43 @@
package com.gxwebsoft.shop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.ShopCouponApplyItem;
import com.gxwebsoft.shop.param.ShopCouponApplyItemParam;
import java.util.List;
/**
* 优惠券可用分类Service
*
* @author 科技小王子
* @since 2025-08-11 12:47:49
*/
public interface ShopCouponApplyItemService extends IService<ShopCouponApplyItem> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<ShopCouponApplyItem>
*/
PageResult<ShopCouponApplyItem> pageRel(ShopCouponApplyItemParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<ShopCouponApplyItem>
*/
List<ShopCouponApplyItem> listRel(ShopCouponApplyItemParam param);
/**
* 根据id查询
*
* @param id
* @return ShopCouponApplyItem
*/
ShopCouponApplyItem getByIdRel(Integer id);
void removeByCouponId(Integer couponId);
}

43
src/main/java/com/gxwebsoft/shop/service/ShopGiftService.java

@ -0,0 +1,43 @@
package com.gxwebsoft.shop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.ShopGift;
import com.gxwebsoft.shop.param.ShopGiftParam;
import java.util.List;
/**
* 礼品卡Service
*
* @author 科技小王子
* @since 2025-08-11 18:07:31
*/
public interface ShopGiftService extends IService<ShopGift> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<ShopGift>
*/
PageResult<ShopGift> pageRel(ShopGiftParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<ShopGift>
*/
List<ShopGift> listRel(ShopGiftParam param);
/**
* 根据id查询
*
* @param id
* @return ShopGift
*/
ShopGift getByIdRel(Integer id);
ShopGift getByCode(String code);
}

1
src/main/java/com/gxwebsoft/shop/service/ShopOrderGoodsService.java

@ -39,4 +39,5 @@ public interface ShopOrderGoodsService extends IService<ShopOrderGoods> {
*/
ShopOrderGoods getByIdRel(Integer id);
List<ShopOrderGoods> getListByOrderId(Integer orderId);
}

21
src/main/java/com/gxwebsoft/shop/service/ShopOrderUpdate10550Service.java

@ -0,0 +1,21 @@
package com.gxwebsoft.shop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.ShopOrder;
import com.gxwebsoft.shop.entity.ShopOrderDelivery;
import com.gxwebsoft.shop.param.ShopOrderDeliveryParam;
import java.util.List;
/**
* 发货单Service
*
* @author 科技小王子
* @since 2025-01-11 10:45:12
*/
public interface ShopOrderUpdate10550Service {
void update(ShopOrder shopOrder);
}

1
src/main/java/com/gxwebsoft/shop/service/ShopUserCouponService.java

@ -39,4 +39,5 @@ public interface ShopUserCouponService extends IService<ShopUserCoupon> {
*/
ShopUserCoupon getByIdRel(Integer id);
List<ShopUserCoupon> userList(Integer userId);
}

56
src/main/java/com/gxwebsoft/shop/service/impl/ShopCouponApplyCateServiceImpl.java

@ -0,0 +1,56 @@
package com.gxwebsoft.shop.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ShopCouponApplyCateMapper;
import com.gxwebsoft.shop.service.ShopCouponApplyCateService;
import com.gxwebsoft.shop.entity.ShopCouponApplyCate;
import com.gxwebsoft.shop.param.ShopCouponApplyCateParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 优惠券可用分类Service实现
*
* @author 科技小王子
* @since 2025-08-11 12:47:49
*/
@Service
public class ShopCouponApplyCateServiceImpl extends ServiceImpl<ShopCouponApplyCateMapper, ShopCouponApplyCate> implements ShopCouponApplyCateService {
@Override
public PageResult<ShopCouponApplyCate> pageRel(ShopCouponApplyCateParam param) {
PageParam<ShopCouponApplyCate, ShopCouponApplyCateParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<ShopCouponApplyCate> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<ShopCouponApplyCate> listRel(ShopCouponApplyCateParam param) {
List<ShopCouponApplyCate> list = baseMapper.selectListRel(param);
// 排序
PageParam<ShopCouponApplyCate, ShopCouponApplyCateParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public ShopCouponApplyCate getByIdRel(Integer id) {
ShopCouponApplyCateParam param = new ShopCouponApplyCateParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public void removeByCouponId(Integer couponId) {
remove(
new LambdaQueryWrapper<ShopCouponApplyCate>()
.eq(ShopCouponApplyCate::getCouponId, couponId)
);
}
}

56
src/main/java/com/gxwebsoft/shop/service/impl/ShopCouponApplyItemServiceImpl.java

@ -0,0 +1,56 @@
package com.gxwebsoft.shop.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ShopCouponApplyItemMapper;
import com.gxwebsoft.shop.service.ShopCouponApplyItemService;
import com.gxwebsoft.shop.entity.ShopCouponApplyItem;
import com.gxwebsoft.shop.param.ShopCouponApplyItemParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 优惠券可用分类Service实现
*
* @author 科技小王子
* @since 2025-08-11 12:47:49
*/
@Service
public class ShopCouponApplyItemServiceImpl extends ServiceImpl<ShopCouponApplyItemMapper, ShopCouponApplyItem> implements ShopCouponApplyItemService {
@Override
public PageResult<ShopCouponApplyItem> pageRel(ShopCouponApplyItemParam param) {
PageParam<ShopCouponApplyItem, ShopCouponApplyItemParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<ShopCouponApplyItem> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<ShopCouponApplyItem> listRel(ShopCouponApplyItemParam param) {
List<ShopCouponApplyItem> list = baseMapper.selectListRel(param);
// 排序
PageParam<ShopCouponApplyItem, ShopCouponApplyItemParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public ShopCouponApplyItem getByIdRel(Integer id) {
ShopCouponApplyItemParam param = new ShopCouponApplyItemParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public void removeByCouponId(Integer couponId) {
remove(
new LambdaQueryWrapper<ShopCouponApplyItem>()
.eq(ShopCouponApplyItem::getCouponId, couponId)
);
}
}

24
src/main/java/com/gxwebsoft/shop/service/impl/ShopCouponServiceImpl.java

@ -1,7 +1,12 @@
package com.gxwebsoft.shop.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.entity.ShopCouponApplyCate;
import com.gxwebsoft.shop.entity.ShopCouponApplyItem;
import com.gxwebsoft.shop.mapper.ShopCouponMapper;
import com.gxwebsoft.shop.service.ShopCouponApplyCateService;
import com.gxwebsoft.shop.service.ShopCouponApplyItemService;
import com.gxwebsoft.shop.service.ShopCouponService;
import com.gxwebsoft.shop.entity.ShopCoupon;
import com.gxwebsoft.shop.param.ShopCouponParam;
@ -9,6 +14,7 @@ import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
@ -19,12 +25,30 @@ import java.util.List;
*/
@Service
public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCoupon> implements ShopCouponService {
@Resource
private ShopCouponApplyItemService couponApplyItemService;
@Resource
private ShopCouponApplyCateService couponApplyCateService;
@Override
public PageResult<ShopCoupon> pageRel(ShopCouponParam param) {
PageParam<ShopCoupon, ShopCouponParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<ShopCoupon> list = baseMapper.selectPageRel(page, param);
for (ShopCoupon coupon : list) {
coupon.setCouponApplyCateList(
couponApplyCateService.list(
new LambdaQueryWrapper<ShopCouponApplyCate>()
.eq(ShopCouponApplyCate::getCouponId, coupon.getId())
)
);
coupon.setCouponApplyItemList(
couponApplyItemService.list(
new LambdaQueryWrapper<ShopCouponApplyItem>()
.eq(ShopCouponApplyItem::getCouponId, coupon.getId())
)
);
}
return new PageResult<>(list, page.getTotal());
}

71
src/main/java/com/gxwebsoft/shop/service/impl/ShopGiftServiceImpl.java

@ -0,0 +1,71 @@
package com.gxwebsoft.shop.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.entity.ShopGoods;
import com.gxwebsoft.shop.mapper.ShopGiftMapper;
import com.gxwebsoft.shop.service.ShopGiftService;
import com.gxwebsoft.shop.entity.ShopGift;
import com.gxwebsoft.shop.param.ShopGiftParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.service.ShopGoodsService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 礼品卡Service实现
*
* @author 科技小王子
* @since 2025-08-11 18:07:31
*/
@Service
public class ShopGiftServiceImpl extends ServiceImpl<ShopGiftMapper, ShopGift> implements ShopGiftService {
@Resource
private ShopGoodsService shopGoodsService;
@Override
public PageResult<ShopGift> pageRel(ShopGiftParam param) {
PageParam<ShopGift, ShopGiftParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<ShopGift> list = baseMapper.selectPageRel(page, param);
if (!list.isEmpty()) {
Set<Integer> goodsIds = list.stream().map(ShopGift::getGoodsId).collect(Collectors.toSet());
List<ShopGoods> goodsList = shopGoodsService.listByIds(goodsIds);
for (ShopGift shopGift : list) {
ShopGoods shopGoods = goodsList.stream().filter(sG -> sG.getGoodsId().equals(shopGift.getGoodsId())).findFirst().orElse(null);
if (shopGoods != null) {
shopGift.setGoods(shopGoods);
}
}
}
return new PageResult<>(list, page.getTotal());
}
@Override
public List<ShopGift> listRel(ShopGiftParam param) {
List<ShopGift> list = baseMapper.selectListRel(param);
// 排序
PageParam<ShopGift, ShopGiftParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public ShopGift getByIdRel(Integer id) {
ShopGiftParam param = new ShopGiftParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public ShopGift getByCode(String code) {
ShopGiftParam param = new ShopGiftParam();
param.setCode(code);
return param.getOne(baseMapper.selectListRel(param));
}
}

9
src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderGoodsServiceImpl.java

@ -1,5 +1,6 @@
package com.gxwebsoft.shop.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ShopOrderGoodsMapper;
import com.gxwebsoft.shop.service.ShopOrderGoodsService;
@ -44,4 +45,12 @@ public class ShopOrderGoodsServiceImpl extends ServiceImpl<ShopOrderGoodsMapper,
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public List<ShopOrderGoods> getListByOrderId(Integer orderId) {
return list(
new LambdaQueryWrapper<ShopOrderGoods>()
.eq(ShopOrderGoods::getOrderId, orderId)
);
}
}

1151
src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderServiceImpl.java

File diff suppressed because it is too large

90
src/main/java/com/gxwebsoft/shop/service/impl/ShopOrderUpdate10550ServiceImpl.java

@ -0,0 +1,90 @@
package com.gxwebsoft.shop.service.impl;
import cn.hutool.core.date.DateUtil;
import com.gxwebsoft.common.core.utils.RequestUtil;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.shop.entity.*;
import com.gxwebsoft.shop.service.*;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.List;
/**
*
* @author 科技小王子
* @since 2025-01-11 10:45:12
*/
@Service
public class ShopOrderUpdate10550ServiceImpl implements ShopOrderUpdate10550Service {
@Resource
private RequestUtil requestUtil;
@Resource
private ShopDealerOrderService shopDealerOrderService;
@Resource
private ShopDealerCapitalService shopDealerCapitalService;
@Resource
private ShopOrderGoodsService shopOrderGoodsService;
@Resource
private ShopGoodsService shopGoodsService;
@Override
public void update(ShopOrder order){
requestUtil.setTenantId(order.getTenantId().toString());
ApiResult<?> partnerConditionReq = requestUtil.pageDictData(1460);
if (partnerConditionReq.getCode().equals(0) && partnerConditionReq.getData() != null) {
LinkedHashMap<String, Object> dictDataMap = (LinkedHashMap<String, Object>) partnerConditionReq.getData();
List<LinkedHashMap> dictDataList = (List<LinkedHashMap>) dictDataMap.get("list");
String dictDataCode = (String) dictDataList.get(0).get("dictDataCode");
BigDecimal partnerCondition = new BigDecimal(dictDataCode);
User user = requestUtil.getByUserIdWithoutLogin(order.getUserId());
if (user != null) {
user.setExpendMoney(user.getExpendMoney().add(order.getPayPrice()));
if (user.getExpendMoney().compareTo(partnerCondition) >= 0) {
user.setGradeId(3);
}
requestUtil.updateWithoutLogin(user);
// 上级
User parent = requestUtil.getParent(order.getUserId());
if (parent != null) {
List<ShopOrderGoods> shopOrderGoodsList = shopOrderGoodsService.getListByOrderId(order.getOrderId());
List<Integer> goodsIds = shopOrderGoodsList.stream().map(ShopOrderGoods::getGoodsId).toList();
List<ShopGoods> shopGoodsList = shopGoodsService.listByIds(goodsIds);
BigDecimal commission = BigDecimal.ZERO;
for (ShopOrderGoods shopOrderGoods : shopOrderGoodsList) {
ShopGoods shopGoods = shopGoodsList.stream().filter(sG -> sG.getGoodsId().equals(shopOrderGoods.getGoodsId())).findFirst().orElse(null);
if (shopGoods != null) {
commission = commission.add(shopGoods.getCommission().multiply(BigDecimal.valueOf(shopOrderGoods.getTotalNum())));
}
}
parent.setBalance(parent.getBalance().add(commission));
requestUtil.updateWithoutLogin(user);
// 分销订单
ShopDealerOrder shopDealerOrder = new ShopDealerOrder();
shopDealerOrder.setUserId(parent.getUserId());
shopDealerOrder.setOrderId(order.getOrderId());
shopDealerOrder.setOrderPrice(order.getTotalPrice());
shopDealerOrder.setFirstUserId(order.getUserId());
shopDealerOrder.setFirstMoney(commission);
shopDealerOrder.setIsSettled(1);
shopDealerOrder.setSettleTime(DateUtil.currentSeconds());
shopDealerOrderService.save(shopDealerOrder);
// 分销资明细
ShopDealerCapital shopDealerCapital = new ShopDealerCapital();
shopDealerCapital.setUserId(parent.getUserId());
shopDealerCapital.setOrderId(order.getOrderId());
shopDealerCapital.setFlowType(10);
shopDealerCapitalService.save(shopDealerCapital);
}
}
}
}
}

10
src/main/java/com/gxwebsoft/shop/service/impl/ShopUserCouponServiceImpl.java

@ -1,5 +1,6 @@
package com.gxwebsoft.shop.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.shop.mapper.ShopUserCouponMapper;
import com.gxwebsoft.shop.service.ShopUserCouponService;
@ -44,4 +45,13 @@ public class ShopUserCouponServiceImpl extends ServiceImpl<ShopUserCouponMapper,
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public List<ShopUserCoupon> userList(Integer userId) {
return list(
new LambdaQueryWrapper<ShopUserCoupon>()
.eq(ShopUserCoupon::getUserId, userId)
);
}
}

2
src/main/resources/application-dev.yml

@ -46,7 +46,7 @@ mqtt:
config:
# 开发环境接口
server-url: https://server.websoft.top/api
upload-path: /Users/gxwebsoft/JAVA/cms-java-code/src/main/resources/ # 项目资源目录
upload-path: /Users/gxwebsoft/JAVA/mp-java/src/main/resources/ # window(D:\Temp)
# 开发环境证书配置
certificate:

2
src/main/resources/application-prod.yml

@ -45,7 +45,7 @@ mqtt:
config:
# 生产环境接口
server-url: https://server.websoft.top/api
upload-path: /www/wwwroot/file.ws
upload-path: /www/wwwroot/file.ws/
# 阿里云OSS云存储
endpoint: https://oss-cn-shenzhen.aliyuncs.com

2
src/main/resources/application.yml

@ -4,7 +4,7 @@ server:
# 多环境配置
spring:
profiles:
active: dev
active: prod
application:
name: server

7
src/test/java/com/gxwebsoft/generator/ShopGenerator.java

@ -27,9 +27,9 @@ public class ShopGenerator {
// 输出目录
private static final String OUTPUT_DIR = "/src/main/java";
// Vue文件输出位置
private static final String OUTPUT_LOCATION_VUE = "/Users/gxwebsoft/VUE/mp-vue";
private static final String OUTPUT_LOCATION_VUE = "/Users/liangxin/Project/Html/web/mp-vue";
// Vue文件输出目录
private static final String OUTPUT_LOCATION_UNIAPP = "/Users/gxwebsoft/VUE/template-10550";
private static final String OUTPUT_LOCATION_UNIAPP = "/Users/liangxin/Project/Html/miniProgram/template-10550";
// Vue文件输出目录
private static final String OUTPUT_DIR_VUE = "/src";
// 作者名称
@ -37,7 +37,7 @@ public class ShopGenerator {
// 是否在xml中添加二级缓存配置
private static final boolean ENABLE_CACHE = false;
// 数据库连接配置
private static final String DB_URL = "jdbc:mysql://47.119.165.234:3308/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
private static final String DB_URL = "jdbc:mysql://8.134.169.209:13306/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
private static final String DB_USERNAME = "modules";
private static final String DB_PASSWORD = "8YdLnk7KsPAyDXGA";
@ -100,6 +100,7 @@ public class ShopGenerator {
// "shop_express",
// "shop_express_template",
// "shop_express_template_detail"
"shop_gift"
};
// 需要去除的表前缀
private static final String[] TABLE_PREFIX = new String[]{

79
src/test/java/com/gxwebsoft/shop/CertificatePathTest.java

@ -0,0 +1,79 @@
package com.gxwebsoft.shop;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
/**
* 证书路径构建测试
*
* @author 科技小王子
* @since 2025-08-09
*/
public class CertificatePathTest {
@Test
public void testDevCertificatePath() {
// 模拟开发环境配置
String uploadPath = "/Users/gxwebsoft/JAVA/mp-java/src/main/resources/";
Integer tenantId = 10324;
String privateKeyFile = "apiclient_key.pem";
// 构建证书路径
String tenantCertPath = uploadPath + "dev/wechat/" + tenantId;
String privateKeyPath = tenantCertPath + "/" + privateKeyFile;
// 验证路径构建结果
String expectedTenantPath = "/Users/gxwebsoft/JAVA/mp-java/src/main/resources/dev/wechat/10324";
String expectedPrivateKeyPath = "/Users/gxwebsoft/JAVA/mp-java/src/main/resources/dev/wechat/10324/apiclient_key.pem";
assertEquals(expectedTenantPath, tenantCertPath);
assertEquals(expectedPrivateKeyPath, privateKeyPath);
System.out.println("开发环境证书路径测试通过:");
System.out.println("租户证书目录: " + tenantCertPath);
System.out.println("私钥文件路径: " + privateKeyPath);
}
@Test
public void testProdCertificatePath() {
// 模拟生产环境配置
String uploadPath = "/www/wwwroot/file.ws";
Integer tenantId = 10324;
String privateKeyFile = "apiclient_key.pem";
// 构建证书路径(生产环境不使用upload-path,而是从数据库读取)
// 这里只是为了对比展示
String tenantCertPath = uploadPath + "dev/wechat/" + tenantId;
String privateKeyPath = tenantCertPath + "/" + privateKeyFile;
// 验证路径构建结果
String expectedTenantPath = "/www/wwwroot/file.ws/dev/wechat/10324";
String expectedPrivateKeyPath = "/www/wwwroot/file.ws/dev/wechat/10324/apiclient_key.pem";
assertEquals(expectedTenantPath, tenantCertPath);
assertEquals(expectedPrivateKeyPath, privateKeyPath);
System.out.println("生产环境证书路径测试通过:");
System.out.println("租户证书目录: " + tenantCertPath);
System.out.println("私钥文件路径: " + privateKeyPath);
}
@Test
public void testMultipleTenants() {
String uploadPath = "/Users/gxwebsoft/JAVA/mp-java/src/main/resources/";
String privateKeyFile = "apiclient_key.pem";
// 测试多个租户的路径构建
Integer[] tenantIds = {10324, 10325, 10326};
for (Integer tenantId : tenantIds) {
String tenantCertPath = uploadPath + "dev/wechat/" + tenantId;
String privateKeyPath = tenantCertPath + "/" + privateKeyFile;
assertTrue(tenantCertPath.contains(tenantId.toString()));
assertTrue(privateKeyPath.endsWith(privateKeyFile));
System.out.println("租户 " + tenantId + " 证书路径: " + privateKeyPath);
}
}
}
Loading…
Cancel
Save