diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..a263ee1 --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/.idea/webServers.xml b/.idea/webServers.xml new file mode 100644 index 0000000..ae7d8cb --- /dev/null +++ b/.idea/webServers.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/file/qr/friendPay_583486.png b/file/qr/friendPay_583486.png new file mode 100644 index 0000000..6777c44 Binary files /dev/null and b/file/qr/friendPay_583486.png differ diff --git a/pom.xml b/pom.xml index 33a70ea..55c451f 100644 --- a/pom.xml +++ b/pom.xml @@ -88,9 +88,9 @@ - com.github.yulichang - mybatis-plus-join-boot-starter - 1.4.5 + com.github.yulichang + mybatis-plus-join-boot-starter + 1.4.5 @@ -190,108 +190,113 @@ - org.springframework.boot - spring-boot-starter-data-redis + org.springframework.boot + spring-boot-starter-data-redis - com.aliyun - aliyun-java-sdk-core - 4.4.3 + com.aliyun + aliyun-java-sdk-core + 4.4.3 - com.alipay.sdk - alipay-sdk-java - 4.35.0.ALL + com.alipay.sdk + alipay-sdk-java + 4.35.0.ALL + + + + org.bouncycastle + bcprov-jdk15on + 1.70 + + + + commons-logging + commons-logging + 1.2 + + + + com.alibaba + fastjson + 2.0.20 - - - org.bouncycastle - bcprov-jdk15on - 1.70 - - - - commons-logging - commons-logging - 1.2 - - - - com.alibaba - fastjson - 2.0.20 - - - - com.google.zxing - core - 3.3.3 - + + + com.google.zxing + core + 3.3.3 + - - com.google.code.gson - gson - 2.8.0 - + + com.google.code.gson + gson + 2.8.0 + - - com.vaadin.external.google - android-json - 0.0.20131108.vaadin1 - compile - + + com.vaadin.external.google + android-json + 0.0.20131108.vaadin1 + compile + - - - com.corundumstudio.socketio - netty-socketio - 2.0.2 - + + + com.corundumstudio.socketio + netty-socketio + 2.0.2 + - - - com.github.wechatpay-apiv3 - wechatpay-java - 0.2.9 - + + + com.github.wechatpay-apiv3 + wechatpay-java + 0.2.9 + - - com.github.binarywang - weixin-java-miniapp - 4.5.0 - + + com.github.binarywang + weixin-java-miniapp + 4.6.0 + - - - com.aliyun.oss - aliyun-sdk-oss - 3.17.0 - + + + com.aliyun.oss + aliyun-sdk-oss + 3.17.0 + + + + com.github.kuaidi100-api + sdk + 1.0.13 + - - - com.nuonuo - open-sdk - 1.0.5.2 - + + + com.nuonuo + open-sdk + 1.0.5.2 + - - - com.github.xiaoymin - knife4j-spring-boot-starter - 3.0.3 - - - - com.belerweb - pinyin4j - 2.5.1 - + + + com.github.xiaoymin + knife4j-spring-boot-starter + 3.0.3 + + + com.belerweb + pinyin4j + 2.5.1 + diff --git a/src/main/java/com/gxwebsoft/cms/controller/DesignCollectController.java b/src/main/java/com/gxwebsoft/cms/controller/DesignCollectController.java new file mode 100644 index 0000000..24e59c3 --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/controller/DesignCollectController.java @@ -0,0 +1,114 @@ +package com.gxwebsoft.cms.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.cms.service.DesignCollectService; +import com.gxwebsoft.cms.entity.DesignCollect; +import com.gxwebsoft.cms.param.DesignCollectParam; +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.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-08 15:21:56 + */ +@Api(tags = "设计征集管理") +@RestController +@RequestMapping("/api/cms/design-collect") +public class DesignCollectController extends BaseController { + @Resource + private DesignCollectService designCollectService; + + @ApiOperation("分页查询设计征集") + @GetMapping("/page") + public ApiResult> page(DesignCollectParam param) { + // 使用关联查询 + return success(designCollectService.pageRel(param)); + } + + @ApiOperation("查询全部设计征集") + @GetMapping() + public ApiResult> list(DesignCollectParam param) { + // 使用关联查询 + return success(designCollectService.listRel(param)); + } + + @ApiOperation("根据id查询设计征集") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(designCollectService.getByIdRel(id)); + } + + @ApiOperation("添加设计征集") + @PostMapping() + public ApiResult save(@RequestBody DesignCollect designCollect) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + designCollect.setUserId(loginUser.getUserId()); + } + if (designCollectService.save(designCollect)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("修改设计征集") + @PutMapping() + public ApiResult update(@RequestBody DesignCollect designCollect) { + if (designCollectService.updateById(designCollect)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除设计征集") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (designCollectService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加设计征集") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (designCollectService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改设计征集") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(designCollectService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除设计征集") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (designCollectService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/cms/controller/DesignSignUpController.java b/src/main/java/com/gxwebsoft/cms/controller/DesignSignUpController.java new file mode 100644 index 0000000..dcb1b76 --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/controller/DesignSignUpController.java @@ -0,0 +1,115 @@ +package com.gxwebsoft.cms.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.cms.service.DesignSignUpService; +import com.gxwebsoft.cms.entity.DesignSignUp; +import com.gxwebsoft.cms.param.DesignSignUpParam; +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.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-08 15:21:56 + */ +@Api(tags = "设计征集报名管理") +@RestController +@RequestMapping("/api/cms/design-sign-up") +public class DesignSignUpController extends BaseController { + @Resource + private DesignSignUpService designSignUpService; + + @ApiOperation("分页查询设计征集报名") + @GetMapping("/page") + public ApiResult> page(DesignSignUpParam param) { + // 使用关联查询 + return success(designSignUpService.pageRel(param)); + } + + @ApiOperation("查询全部设计征集报名") + @GetMapping() + public ApiResult> list(DesignSignUpParam param) { + // 使用关联查询 + return success(designSignUpService.listRel(param)); + } + + @PreAuthorize("hasAuthority('cms:designSignUp:list')") + @ApiOperation("根据id查询设计征集报名") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(designSignUpService.getByIdRel(id)); + } + + @ApiOperation("添加设计征集报名") + @PostMapping() + public ApiResult save(@RequestBody DesignSignUp designSignUp) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + designSignUp.setUserId(loginUser.getUserId()); + } + if (designSignUpService.save(designSignUp)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("修改设计征集报名") + @PutMapping() + public ApiResult update(@RequestBody DesignSignUp designSignUp) { + if (designSignUpService.updateById(designSignUp)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除设计征集报名") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (designSignUpService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加设计征集报名") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (designSignUpService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改设计征集报名") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(designSignUpService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除设计征集报名") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (designSignUpService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/cms/controller/MpController.java b/src/main/java/com/gxwebsoft/cms/controller/MpController.java index 9d1856a..917887f 100644 --- a/src/main/java/com/gxwebsoft/cms/controller/MpController.java +++ b/src/main/java/com/gxwebsoft/cms/controller/MpController.java @@ -41,279 +41,298 @@ import java.util.stream.Collectors; @RestController @RequestMapping("/api/cms/mp") public class MpController extends BaseController { - @Resource - private MpService mpService; - @Resource - private MpPagesService mpPagesService; - @Resource - private AdService adService; - @Resource - private MpMenuService mpMenuService; - @Resource - private MpFieldService mpFieldService; - @Resource - private GoodsService goodsService; - @Resource - private RedisUtil redisUtil; + @Resource + private MpService mpService; + @Resource + private MpPagesService mpPagesService; + @Resource + private AdService adService; + @Resource + private MpMenuService mpMenuService; + @Resource + private MpFieldService mpFieldService; + @Resource + private GoodsService goodsService; + @Resource + private RedisUtil redisUtil; - @ApiOperation("分页查询小程序") - @GetMapping("/page") - public ApiResult> page(MpParam param) { - // 使用关联查询 - return success(mpService.pageRel(param)); - } - - @ApiOperation("查询全部小程序") - @GetMapping() - public ApiResult> list(MpParam param) { - // 使用关联查询 - return success(mpService.listRel(param)); - } - - @PreAuthorize("hasAuthority('cms:mp:list')") - @ApiOperation("根据id查询小程序") - @GetMapping("/{id}") - public ApiResult get(@PathVariable("id") Integer id) { - // 使用关联查询 - return success(mpService.getByIdRel(id)); - } - - @PreAuthorize("hasAuthority('cms:mp:save')") - @ApiOperation("添加小程序") - @PostMapping() - public ApiResult save(@RequestBody Mp mp) { - // 记录当前登录用户id - User loginUser = getLoginUser(); - if (loginUser != null) { - mp.setUserId(loginUser.getUserId()); - } - if (mpService.save(mp)) { - return success("添加成功"); - } - return fail("添加失败"); - } - - @PreAuthorize("hasAuthority('cms:mp:update')") - @ApiOperation("修改小程序") - @PutMapping() - public ApiResult update(@RequestBody Mp mp) { - // 只允许一个主账号 - if (mp.getType().equals(1)) { - mpService.update(new LambdaUpdateWrapper().eq(Mp::getType, 1).set(Mp::getType, 0)); - } - if (mpService.updateById(mp)) { - return success("修改成功"); - } - return fail("修改失败"); - } - - @PreAuthorize("hasAuthority('cms:mp:remove')") - @ApiOperation("删除小程序") - @DeleteMapping("/{id}") - public ApiResult remove(@PathVariable("id") Integer id) { - if (mpService.removeById(id)) { - return success("删除成功"); - } - return fail("删除失败"); - } - - @PreAuthorize("hasAuthority('cms:mp:save')") - @ApiOperation("批量添加小程序") - @PostMapping("/batch") - public ApiResult saveBatch(@RequestBody List list) { - if (mpService.saveBatch(list)) { - return success("添加成功"); - } - return fail("添加失败"); - } - - @PreAuthorize("hasAuthority('cms:mp:update')") - @ApiOperation("批量修改小程序") - @PutMapping("/batch") - public ApiResult removeBatch(@RequestBody BatchParam batchParam) { - if (batchParam.update(mpService, "mp_id")) { - return success("修改成功"); - } - return fail("修改失败"); - } - - @PreAuthorize("hasAuthority('cms:mp:remove')") - @ApiOperation("批量删除小程序") - @DeleteMapping("/batch") - public ApiResult removeBatch(@RequestBody List ids) { - if (mpService.removeByIds(ids)) { - return success("删除成功"); - } - return fail("删除失败"); - } - - - - @ApiOperation("小程序基本信息") - @GetMapping("/getMpInfo") - public ApiResult getMpInfo() { - final Integer tenantId = getTenantId(); - String key = "MpInfo:" + tenantId; - System.out.println("key = " + key); - final String mpInfo = redisUtil.get(key); - - if (tenantId.equals(0)) { - return fail("租户ID不存在", null); - } - System.out.println("mpInfo = " + mpInfo); - // 从缓存读取信息 - if (StrUtil.isNotBlank(mpInfo)) { - final Object object = JSONUtil.parseObject(mpInfo, Object.class); - System.out.println("object = " + object); - return success(object); + @ApiOperation("分页查询小程序") + @GetMapping("/page") + public ApiResult> page(MpParam param) { + // 使用关联查询 + return success(mpService.pageRel(param)); } - // 获取小程序 - if (mpService.count(new LambdaUpdateWrapper().eq(Mp::getDeleted, 0)) == 0) { - // 创建小程序 - createMp(); + @ApiOperation("查询全部小程序") + @GetMapping() + public ApiResult> list(MpParam param) { + // 使用关联查询 + return success(mpService.listRel(param)); } - HashMap map = new HashMap<>(); - - // 获取小程序 - final Mp mp = mpService.getOne(new LambdaQueryWrapper().eq(Mp::getTenantId, tenantId).last("limit 1")); - mp.setAppSecret(null); - map.put("mp", mp); - - // 原生导航条 - final List tabBar = mpPagesService.list(new LambdaQueryWrapper().eq(MpPages::getSubpackage, "MainPackage").last("limit 5")); - map.put("tabBar", tabBar); - - // 配置信息 - HashMap config = new HashMap<>(); - config.put("LICENSE_CODE", ""); - config.put("MAP_KEY", ""); - final List fields = mpFieldService.list(); - fields.forEach(d -> { - config.put(d.getName(), d.getValue()); - }); - map.put("config", config); - - // 服务器时间 - HashMap serverTime = new HashMap<>(); - // 今天日期 - DateTime date = DateUtil.date(); - String today = DateUtil.today(); - // 明天日期 - final DateTime dateTime = DateUtil.tomorrow(); - String tomorrow = DateUtil.format(dateTime, "yyyy-MM-dd"); - // 后天日期 - final DateTime dateTime2 = DateUtil.offsetDay(date, 2); - final String afterDay = DateUtil.format(dateTime2, "yyyy-MM-dd"); - // 今天星期几 - final int week = DateUtil.thisDayOfWeek(); - final DateTime nextWeek = DateUtil.nextWeek(); - serverTime.put("now", DateUtil.now()); // 2024-07-18 22:06:36 - serverTime.put("today", today); // 2024-07-18 - serverTime.put("tomorrow", tomorrow); // 2024-07-19 - serverTime.put("afterDay", afterDay); // 2024-07-20 - serverTime.put("nextWeek", nextWeek); // 2024-07-25 22:06:36 - serverTime.put("week", week); // 5 - map.put("serverTime", serverTime); - redisUtil.set(key, map, 1L, TimeUnit.DAYS); - return success(map); - } - - private void createMp() { - System.out.println("创建小程序 = "); - final User loginUser = getLoginUser(); - final Integer tenantId = getTenantId(); - // 创建网站记录 - final Mp mp = new Mp(); - mp.setTenantId(tenantId); - mp.setAppId("小程序ID"); - mp.setMpName("小程序名称"); - mp.setMainPath("/pages/index"); - if (loginUser != null) { - mp.setUserId(getLoginUserId()); + @PreAuthorize("hasAuthority('cms:mp:list')") + @ApiOperation("根据id查询小程序") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(mpService.getByIdRel(id)); } - mp.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.YEAR, 1)); - mpService.save(mp); - // 创建底部导航栏 - final MpPages mpPages = new MpPages(); - mpPages.setHome(1); - mpPages.setTitle("首页"); - mpPages.setPath("/pages/index"); - mpPages.setSubpackage("MainPackage"); - mpPages.setIcon("HomeOutlined"); - mpPages.setSortNumber(0); - mpPages.setTenantId(tenantId); - mpPagesService.save(mpPages); - mpPages.setHome(0); - mpPages.setTitle("分类"); - mpPages.setPath("/pages/category"); - mpPages.setSubpackage("MainPackage"); - mpPages.setIcon("AppstoreOutlined"); - mpPages.setSortNumber(0); - mpPagesService.save(mpPages); - mpPages.setTitle("购物车"); - mpPages.setPath("/pages/category"); - mpPages.setSubpackage("MainPackage"); - mpPages.setIcon("ShoppingCartOutlined"); - mpPages.setSortNumber(0); - mpPagesService.save(mpPages); - mpPages.setTitle("我的"); - mpPages.setPath("/pages/user"); - mpPages.setSubpackage("MainPackage"); - mpPages.setIcon("UserOutlined"); - mpPages.setSortNumber(0); - mpPagesService.save(mpPages); + @PreAuthorize("hasAuthority('cms:mp:save')") + @ApiOperation("添加小程序") + @PostMapping() + public ApiResult save(@RequestBody Mp mp) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + mp.setUserId(loginUser.getUserId()); + } + if (mpService.save(mp)) { + return success("添加成功"); + } + return fail("添加失败"); + } - // 创建导航图标 - final MpMenu mpMenu = new MpMenu(); - mpMenu.setTenantId(tenantId); - mpMenu.setTitle("分类1"); - mpMenu.setIcon("PictureOutlined"); - mpMenu.setPath("/package/order"); - mpMenu.setTarget("uni.navigateTo"); - mpMenuService.save(mpMenu); - mpMenu.setTitle("分类2"); - mpMenu.setIcon("PictureOutlined"); - mpMenu.setPath("/package/order"); - mpMenuService.save(mpMenu); - mpMenu.setTitle("分类3"); - mpMenu.setIcon("PictureOutlined"); - mpMenu.setPath("/package/order"); - mpMenuService.save(mpMenu); - mpMenu.setTitle("分类4"); - mpMenu.setIcon("PictureOutlined"); - mpMenu.setPath("/package/order"); - mpMenuService.save(mpMenu); + @PreAuthorize("hasAuthority('cms:mp:update')") + @ApiOperation("修改小程序") + @PutMapping() + public ApiResult update(@RequestBody Mp mp) { + // 只允许一个主账号 + if (mp.getType().equals(1)) { + mpService.update(new LambdaUpdateWrapper().eq(Mp::getType, 1).set(Mp::getType, 0)); + } + if (mpService.updateById(mp)) { + return success("修改成功"); + } + return fail("修改失败"); + } - // 小程序配置信息 - MpField field = new MpField(); - field.setName("mpLogo"); - mpFieldService.save(field); - } + @PreAuthorize("hasAuthority('cms:mp:remove')") + @ApiOperation("删除小程序") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (mpService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } - @ApiOperation("首页数据") - @GetMapping("/index") - public ApiResult index(GoodsParam param) { - // 使用关联查询 - final HashMap layout = new HashMap<>(); - // 瀑布流商品数据 (type:0 商城商品,1 外卖商品) + @PreAuthorize("hasAuthority('cms:mp:save')") + @ApiOperation("批量添加小程序") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (mpService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @PreAuthorize("hasAuthority('cms:mp:update')") + @ApiOperation("批量修改小程序") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(mpService, "mp_id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @PreAuthorize("hasAuthority('cms:mp:remove')") + @ApiOperation("批量删除小程序") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (mpService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + + @ApiOperation("小程序基本信息") + @GetMapping("/getMpInfo") + public ApiResult getMpInfo() { + final Integer tenantId = getTenantId(); + String key = "MpInfo:" + tenantId; + System.out.println("key = " + key); + final String mpInfo = redisUtil.get(key); + + if (tenantId.equals(0)) { + return fail("租户ID不存在", null); + } + System.out.println("mpInfo = " + mpInfo); + // 从缓存读取信息 + if (StrUtil.isNotBlank(mpInfo)) { + final Object object = JSONUtil.parseObject(mpInfo, Object.class); + System.out.println("object = " + object); + return success(object); + } + + // 获取小程序 + if (mpService.count(new LambdaUpdateWrapper().eq(Mp::getDeleted, 0)) == 0) { + // 创建小程序 + createMp(); + } + + HashMap map = new HashMap<>(); + + // 获取小程序 + final Mp mp = mpService.getOne(new LambdaQueryWrapper().eq(Mp::getTenantId, tenantId).last("limit 1")); + mp.setAppSecret(null); + map.put("mp", mp); + + // 原生导航条 + final List tabBar = mpPagesService.list(new LambdaQueryWrapper().eq(MpPages::getSubpackage, "MainPackage").last("limit 5")); + map.put("tabBar", tabBar); + + // 配置信息 + HashMap config = new HashMap<>(); + config.put("LICENSE_CODE", ""); + config.put("MAP_KEY", ""); + final List fields = mpFieldService.list(); + fields.forEach(d -> { + config.put(d.getName(), d.getValue()); + }); + map.put("config", config); + + // 服务器时间 + HashMap serverTime = new HashMap<>(); + // 今天日期 + DateTime date = DateUtil.date(); + String today = DateUtil.today(); + // 明天日期 + final DateTime dateTime = DateUtil.tomorrow(); + String tomorrow = DateUtil.format(dateTime, "yyyy-MM-dd"); + // 后天日期 + final DateTime dateTime2 = DateUtil.offsetDay(date, 2); + final String afterDay = DateUtil.format(dateTime2, "yyyy-MM-dd"); + // 今天星期几 + final int week = DateUtil.thisDayOfWeek(); + final DateTime nextWeek = DateUtil.nextWeek(); + serverTime.put("now", DateUtil.now()); // 2024-07-18 22:06:36 + serverTime.put("today", today); // 2024-07-18 + serverTime.put("tomorrow", tomorrow); // 2024-07-19 + serverTime.put("afterDay", afterDay); // 2024-07-20 + serverTime.put("nextWeek", nextWeek); // 2024-07-25 22:06:36 + serverTime.put("week", week); // 5 + map.put("serverTime", serverTime); + redisUtil.set(key, map, 1L, TimeUnit.DAYS); + return success(map); + } + + private void createMp() { + System.out.println("创建小程序 = "); + final User loginUser = getLoginUser(); + final Integer tenantId = getTenantId(); + // 创建网站记录 + final Mp mp = new Mp(); + mp.setTenantId(tenantId); + mp.setAppId("小程序ID"); + mp.setMpName("小程序名称"); + mp.setMainPath("/pages/index"); + if (loginUser != null) { + mp.setUserId(getLoginUserId()); + } + mp.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.YEAR, 1)); + mpService.save(mp); + + // 创建底部导航栏 + final MpPages mpPages = new MpPages(); + mpPages.setHome(1); + mpPages.setTitle("首页"); + mpPages.setPath("/pages/index"); + mpPages.setSubpackage("MainPackage"); + mpPages.setIcon("HomeOutlined"); + mpPages.setSortNumber(0); + mpPages.setTenantId(tenantId); + mpPagesService.save(mpPages); + mpPages.setHome(0); + mpPages.setTitle("分类"); + mpPages.setPath("/pages/category"); + mpPages.setSubpackage("MainPackage"); + mpPages.setIcon("AppstoreOutlined"); + mpPages.setSortNumber(0); + mpPagesService.save(mpPages); + mpPages.setTitle("购物车"); + mpPages.setPath("/pages/category"); + mpPages.setSubpackage("MainPackage"); + mpPages.setIcon("ShoppingCartOutlined"); + mpPages.setSortNumber(0); + mpPagesService.save(mpPages); + mpPages.setTitle("我的"); + mpPages.setPath("/pages/user"); + mpPages.setSubpackage("MainPackage"); + mpPages.setIcon("UserOutlined"); + mpPages.setSortNumber(0); + mpPagesService.save(mpPages); + + // 创建导航图标 + final MpMenu mpMenu = new MpMenu(); + mpMenu.setTenantId(tenantId); + mpMenu.setTitle("分类1"); + mpMenu.setIcon("PictureOutlined"); + mpMenu.setPath("/package/order"); + mpMenu.setTarget("uni.navigateTo"); + mpMenuService.save(mpMenu); + mpMenu.setTitle("分类2"); + mpMenu.setIcon("PictureOutlined"); + mpMenu.setPath("/package/order"); + mpMenuService.save(mpMenu); + mpMenu.setTitle("分类3"); + mpMenu.setIcon("PictureOutlined"); + mpMenu.setPath("/package/order"); + mpMenuService.save(mpMenu); + mpMenu.setTitle("分类4"); + mpMenu.setIcon("PictureOutlined"); + mpMenu.setPath("/package/order"); + mpMenuService.save(mpMenu); + + // 小程序配置信息 + MpField field = new MpField(); + field.setName("mpLogo"); + mpFieldService.save(field); + } + + @ApiOperation("首页数据") + @GetMapping("/index") + public ApiResult index(GoodsParam param) { + // 使用关联查询 + final HashMap layout = new HashMap<>(); + // 瀑布流商品数据 (type:0 商城商品,1 外卖商品) // final List goods = goodsService.list(new LambdaQueryWrapper().ne(Goods::getType, 0).last("limit 10")); // final List foods = goodsService.list(new LambdaQueryWrapper().eq(Goods::getType, 1).last("limit 10")); - layout.put("goods",goodsService.getGoodsSpecType0()); - layout.put("foods", goodsService.getGoodsSpecType1()); + List goodsList = goodsService.getGoodsSpecType0(param); + if (getLoginUser() != null) { + for (Goods goods : goodsList) { + if (getLoginUser().getGradeId().equals(33)) { + if (goods.getDealerGift()) goods.setShowGift(true); + goods.setPrice(goods.getDealerPrice()); + } + // 会员店 + if (getLoginUser().getGradeId().equals(31)) { + if (goods.getPriceGift()) goods.setShowGift(true); + } + if (getLoginUser().getGradeId().equals(0)) { + goods.setPrice(goods.getSalePrice()); + } + } + }else { + for (Goods goods : goodsList) { + goods.setPrice(goods.getSalePrice()); + } + } + layout.put("goods", goodsList); + layout.put("foods", goodsService.getGoodsSpecType1()); - return success(layout); - } + return success(layout); + } - @PreAuthorize("hasAuthority('cms:mp:remove')") - @ApiOperation("清除缓存") - @DeleteMapping("/clearMpInfo/{key}") - public ApiResult clearSiteInfo(@PathVariable("key") String key) { - redisUtil.delete("MpInfo:" + getTenantId()); - return success("清除成功"); - } + @PreAuthorize("hasAuthority('cms:mp:remove')") + @ApiOperation("清除缓存") + @DeleteMapping("/clearMpInfo/{key}") + public ApiResult clearSiteInfo(@PathVariable("key") String key) { + redisUtil.delete("MpInfo:" + getTenantId()); + return success("清除成功"); + } } diff --git a/src/main/java/com/gxwebsoft/cms/entity/Article.java b/src/main/java/com/gxwebsoft/cms/entity/Article.java index 03dd84b..c0d9ed6 100644 --- a/src/main/java/com/gxwebsoft/cms/entity/Article.java +++ b/src/main/java/com/gxwebsoft/cms/entity/Article.java @@ -46,6 +46,10 @@ public class Article implements Serializable { @ApiModelProperty(value = "封面图") private String image; + private Integer imageWidth; + + private Integer imageHeight; + @ApiModelProperty(value = "来源") private String source; diff --git a/src/main/java/com/gxwebsoft/cms/entity/DesignCollect.java b/src/main/java/com/gxwebsoft/cms/entity/DesignCollect.java new file mode 100644 index 0000000..a9cbd9c --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/entity/DesignCollect.java @@ -0,0 +1,61 @@ +package com.gxwebsoft.cms.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +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.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 设计征集 + * + * @author 科技小王子 + * @since 2024-10-08 15:21:56 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "DesignCollect对象", description = "设计征集") +@TableName("cms_design_collect") +public class DesignCollect implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private String title; + + private String content; + + private String image; + + @ApiModelProperty(value = "用户ID") + private Integer userId; + + @ApiModelProperty(value = "排序(数字越小越靠前)") + private Integer sortNumber; + + @ApiModelProperty(value = "备注") + private String comments; + + @ApiModelProperty(value = "状态, 0已发布, 1待审核 2已驳回 3违规内容") + private Integer status; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @TableLogic + private Integer deleted; + + @ApiModelProperty(value = "租户id") + private Integer tenantId; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "修改时间") + private LocalDateTime updateTime; + +} diff --git a/src/main/java/com/gxwebsoft/cms/entity/DesignSignUp.java b/src/main/java/com/gxwebsoft/cms/entity/DesignSignUp.java new file mode 100644 index 0000000..e5013f9 --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/entity/DesignSignUp.java @@ -0,0 +1,63 @@ +package com.gxwebsoft.cms.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +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.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 设计征集报名 + * + * @author 科技小王子 + * @since 2024-10-08 15:21:56 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "DesignSignUp对象", description = "设计征集报名") +@TableName("cms_design_sign_up") +public class DesignSignUp implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private Integer designId; + + private String name; + + private String phone; + + private String content; + + @ApiModelProperty(value = "用户ID") + private Integer userId; + + @ApiModelProperty(value = "排序(数字越小越靠前)") + private Integer sortNumber; + + @ApiModelProperty(value = "备注") + private String comments; + + @ApiModelProperty(value = "状态, 0已发布, 1待审核 2已驳回 3违规内容") + private Integer status; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @TableLogic + private Integer deleted; + + @ApiModelProperty(value = "租户id") + private Integer tenantId; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "修改时间") + private LocalDateTime updateTime; + +} diff --git a/src/main/java/com/gxwebsoft/cms/mapper/DesignCollectMapper.java b/src/main/java/com/gxwebsoft/cms/mapper/DesignCollectMapper.java new file mode 100644 index 0000000..e045b50 --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/mapper/DesignCollectMapper.java @@ -0,0 +1,37 @@ +package com.gxwebsoft.cms.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gxwebsoft.cms.entity.DesignCollect; +import com.gxwebsoft.cms.param.DesignCollectParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 设计征集Mapper + * + * @author 科技小王子 + * @since 2024-10-08 15:21:56 + */ +public interface DesignCollectMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") DesignCollectParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") DesignCollectParam param); + +} diff --git a/src/main/java/com/gxwebsoft/cms/mapper/DesignSignUpMapper.java b/src/main/java/com/gxwebsoft/cms/mapper/DesignSignUpMapper.java new file mode 100644 index 0000000..d7c2045 --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/mapper/DesignSignUpMapper.java @@ -0,0 +1,37 @@ +package com.gxwebsoft.cms.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.gxwebsoft.cms.entity.DesignSignUp; +import com.gxwebsoft.cms.param.DesignSignUpParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 设计征集报名Mapper + * + * @author 科技小王子 + * @since 2024-10-08 15:21:56 + */ +public interface DesignSignUpMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") DesignSignUpParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") DesignSignUpParam param); + +} diff --git a/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleMapper.xml b/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleMapper.xml index d7830e6..2a8510e 100644 --- a/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleMapper.xml +++ b/src/main/java/com/gxwebsoft/cms/mapper/xml/ArticleMapper.xml @@ -110,12 +110,10 @@ AND (a.title LIKE CONCAT('%', #{param.keywords}, '%') - OR a.phone LIKE CONCAT('%', #{param.keywords}, '%') - OR a.region LIKE CONCAT('%', #{param.keywords}, '%') - OR a.user_id = #{param.keywords} ) + ORDER BY a.sort_number ASC, a.create_time DESC diff --git a/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignCollectMapper.xml b/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignCollectMapper.xml new file mode 100644 index 0000000..0a2fe3a --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignCollectMapper.xml @@ -0,0 +1,63 @@ + + + + + + + SELECT a.* + FROM cms_design_collect a + + + AND a.id = #{param.id} + + + AND a.title LIKE CONCAT('%', #{param.title}, '%') + + + AND a.content LIKE CONCAT('%', #{param.content}, '%') + + + AND a.image LIKE CONCAT('%', #{param.image}, '%') + + + AND a.user_id = #{param.userId} + + + AND a.sort_number = #{param.sortNumber} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.status = #{param.status} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignSignUpMapper.xml b/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignSignUpMapper.xml new file mode 100644 index 0000000..9f287d3 --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/mapper/xml/DesignSignUpMapper.xml @@ -0,0 +1,66 @@ + + + + + + + SELECT a.* + FROM cms_design_sign_up a + + + AND a.id = #{param.id} + + + AND a.design_id = #{param.designId} + + + AND a.name LIKE CONCAT('%', #{param.name}, '%') + + + AND a.phone LIKE CONCAT('%', #{param.phone}, '%') + + + AND a.content LIKE CONCAT('%', #{param.content}, '%') + + + AND a.user_id = #{param.userId} + + + AND a.sort_number = #{param.sortNumber} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.status = #{param.status} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/cms/param/DesignCollectParam.java b/src/main/java/com/gxwebsoft/cms/param/DesignCollectParam.java new file mode 100644 index 0000000..42447fc --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/param/DesignCollectParam.java @@ -0,0 +1,54 @@ +package com.gxwebsoft.cms.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.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 设计征集查询参数 + * + * @author 科技小王子 + * @since 2024-10-08 15:21:56 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(value = "DesignCollectParam对象", description = "设计征集查询参数") +public class DesignCollectParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @QueryField(type = QueryType.EQ) + private Integer id; + + private String title; + + private String content; + + private String image; + + @ApiModelProperty(value = "用户ID") + @QueryField(type = QueryType.EQ) + private Integer userId; + + @ApiModelProperty(value = "排序(数字越小越靠前)") + @QueryField(type = QueryType.EQ) + private Integer sortNumber; + + @ApiModelProperty(value = "备注") + private String comments; + + @ApiModelProperty(value = "状态, 0已发布, 1待审核 2已驳回 3违规内容") + @QueryField(type = QueryType.EQ) + private Integer status; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @QueryField(type = QueryType.EQ) + private Integer deleted; + +} diff --git a/src/main/java/com/gxwebsoft/cms/param/DesignSignUpParam.java b/src/main/java/com/gxwebsoft/cms/param/DesignSignUpParam.java new file mode 100644 index 0000000..ead3928 --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/param/DesignSignUpParam.java @@ -0,0 +1,57 @@ +package com.gxwebsoft.cms.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.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 设计征集报名查询参数 + * + * @author 科技小王子 + * @since 2024-10-08 15:21:56 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(value = "DesignSignUpParam对象", description = "设计征集报名查询参数") +public class DesignSignUpParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @QueryField(type = QueryType.EQ) + private Integer id; + + @QueryField(type = QueryType.EQ) + private Integer designId; + + private String name; + + private String phone; + + private String content; + + @ApiModelProperty(value = "用户ID") + @QueryField(type = QueryType.EQ) + private Integer userId; + + @ApiModelProperty(value = "排序(数字越小越靠前)") + @QueryField(type = QueryType.EQ) + private Integer sortNumber; + + @ApiModelProperty(value = "备注") + private String comments; + + @ApiModelProperty(value = "状态, 0已发布, 1待审核 2已驳回 3违规内容") + @QueryField(type = QueryType.EQ) + private Integer status; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @QueryField(type = QueryType.EQ) + private Integer deleted; + +} diff --git a/src/main/java/com/gxwebsoft/cms/service/DesignCollectService.java b/src/main/java/com/gxwebsoft/cms/service/DesignCollectService.java new file mode 100644 index 0000000..5b143c7 --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/service/DesignCollectService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.cms.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.cms.entity.DesignCollect; +import com.gxwebsoft.cms.param.DesignCollectParam; + +import java.util.List; + +/** + * 设计征集Service + * + * @author 科技小王子 + * @since 2024-10-08 15:21:56 + */ +public interface DesignCollectService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(DesignCollectParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(DesignCollectParam param); + + /** + * 根据id查询 + * + * @param id + * @return DesignCollect + */ + DesignCollect getByIdRel(Integer id); + +} diff --git a/src/main/java/com/gxwebsoft/cms/service/DesignSignUpService.java b/src/main/java/com/gxwebsoft/cms/service/DesignSignUpService.java new file mode 100644 index 0000000..326d81a --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/service/DesignSignUpService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.cms.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.cms.entity.DesignSignUp; +import com.gxwebsoft.cms.param.DesignSignUpParam; + +import java.util.List; + +/** + * 设计征集报名Service + * + * @author 科技小王子 + * @since 2024-10-08 15:21:56 + */ +public interface DesignSignUpService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(DesignSignUpParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(DesignSignUpParam param); + + /** + * 根据id查询 + * + * @param id + * @return DesignSignUp + */ + DesignSignUp getByIdRel(Integer id); + +} diff --git a/src/main/java/com/gxwebsoft/cms/service/impl/DesignCollectServiceImpl.java b/src/main/java/com/gxwebsoft/cms/service/impl/DesignCollectServiceImpl.java new file mode 100644 index 0000000..7c72f61 --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/service/impl/DesignCollectServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.cms.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.cms.mapper.DesignCollectMapper; +import com.gxwebsoft.cms.service.DesignCollectService; +import com.gxwebsoft.cms.entity.DesignCollect; +import com.gxwebsoft.cms.param.DesignCollectParam; +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 2024-10-08 15:21:56 + */ +@Service +public class DesignCollectServiceImpl extends ServiceImpl implements DesignCollectService { + + @Override + public PageResult pageRel(DesignCollectParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(DesignCollectParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public DesignCollect getByIdRel(Integer id) { + DesignCollectParam param = new DesignCollectParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + +} diff --git a/src/main/java/com/gxwebsoft/cms/service/impl/DesignSignUpServiceImpl.java b/src/main/java/com/gxwebsoft/cms/service/impl/DesignSignUpServiceImpl.java new file mode 100644 index 0000000..b397586 --- /dev/null +++ b/src/main/java/com/gxwebsoft/cms/service/impl/DesignSignUpServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.cms.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.cms.mapper.DesignSignUpMapper; +import com.gxwebsoft.cms.service.DesignSignUpService; +import com.gxwebsoft.cms.entity.DesignSignUp; +import com.gxwebsoft.cms.param.DesignSignUpParam; +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 2024-10-08 15:21:56 + */ +@Service +public class DesignSignUpServiceImpl extends ServiceImpl implements DesignSignUpService { + + @Override + public PageResult pageRel(DesignSignUpParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(DesignSignUpParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public DesignSignUp getByIdRel(Integer id) { + DesignSignUpParam param = new DesignSignUpParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + +} diff --git a/src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java b/src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java index 5d42e0d..6f5857b 100644 --- a/src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java +++ b/src/main/java/com/gxwebsoft/common/core/security/SecurityConfig.java @@ -67,7 +67,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { "/5zbYEPkyV4.txt", "/api/love/user-plan-log/wx-pay/**", "/api/cms/form-record", - "/api/shop/merchant-account/getMerchantAccountByPhone" + "/api/shop/merchant-account/getMerchantAccountByPhone", + "/api/shop/order-delivery/notify" ) .permitAll() .anyRequest() diff --git a/src/main/java/com/gxwebsoft/common/core/utils/RequestUtil.java b/src/main/java/com/gxwebsoft/common/core/utils/RequestUtil.java index e56067f..2f6a6b1 100644 --- a/src/main/java/com/gxwebsoft/common/core/utils/RequestUtil.java +++ b/src/main/java/com/gxwebsoft/common/core/utils/RequestUtil.java @@ -24,222 +24,256 @@ import java.util.HashMap; @Component public class RequestUtil { - private static final String host = "https://server.gxwebsoft.com/api"; - private static String ACCESS_TOKEN; - private static String TENANT_ID; + private static final String host = "https://server.gxwebsoft.com/api"; + private static String ACCESS_TOKEN; + private static String TENANT_ID; - public void setTenantId(String tenantId) { - TENANT_ID = tenantId; - } - - public void setAccessToken(String token) { - ACCESS_TOKEN = token; - } - - // 预付请求付款(余额支付) - public Object balancePay(Order order){ - // 设置租户ID - setTenantId(order.getTenantId().toString()); - // 设置token - setAccessToken(order.getAccessToken()); - // 余额支付接口 - String path = "/system/payment/balancePay"; - try { - // 链式构建请求 - final String body = HttpRequest.post(host.concat(path)) - .header("Tenantid", TENANT_ID) - .header("Authorization", ACCESS_TOKEN) - .body(JSONUtil.toJSONString(order))//表单内容 - .timeout(20000)//超时,毫秒 - .execute().body(); - - return JSONUtil.parseObject(body, ApiResult.class).getData(); - - } catch (Exception e) { - e.printStackTrace(); + public void setTenantId(String tenantId) { + TENANT_ID = tenantId; } - return null; - } - // 微信支付通知 - public String pushWxPayNotify(Transaction transaction, Payment payment){ - // 设置租户ID - setTenantId(payment.getTenantId().toString()); - // 推送支付通知地址 - String path = payment.getNotifyUrl(); - try { - // 链式构建请求 - return HttpRequest.post(path) - .header("Tenantid", TENANT_ID) - .body(JSONUtil.toJSONString(transaction))//表单内容 - .timeout(20000)//超时,毫秒 - .execute().body(); - - } catch (Exception e) { - e.printStackTrace(); + public void setAccessToken(String token) { + ACCESS_TOKEN = token; } - return "支付失败"; - } + // 预付请求付款(余额支付) + public Object balancePay(Order order) { + // 设置租户ID + setTenantId(order.getTenantId().toString()); + // 设置token + setAccessToken(order.getAccessToken()); + // 余额支付接口 + String path = "/system/payment/balancePay"; + try { + // 链式构建请求 + final String body = HttpRequest.post(host.concat(path)) + .header("Tenantid", TENANT_ID) + .header("Authorization", ACCESS_TOKEN) + .body(JSONUtil.toJSONString(order))//表单内容 + .timeout(20000)//超时,毫秒 + .execute().body(); + System.out.println("body:" + body); + return JSONUtil.parseObject(body, ApiResult.class).getData(); - public User getUserByPhone(String phone) { - String path = "/system/user/getByPhone/" + phone; - try { - // 链式构建请求 - String result = HttpRequest.get(host.concat(path)) - .header("Authorization", ACCESS_TOKEN) - .header("Tenantid", TENANT_ID) - .timeout(20000)//超时,毫秒 - .execute().body(); - - JSONObject jsonObject = JSONObject.parseObject(result); - final String data = jsonObject.getString("data"); - return JSONObject.parseObject(data, User.class); - } catch (Exception e) { - e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; } - return null; - } - public User getByUserId(Integer userId) { - String path = "/system/user/" + userId; - try { - // 链式构建请求 - String result = HttpRequest.get(host.concat(path)) - .header("Authorization", ACCESS_TOKEN) - .header("Tenantid", TENANT_ID) - .timeout(20000)//超时,毫秒 - .execute().body(); + // 微信支付通知 + public String pushWxPayNotify(Transaction transaction, Payment payment) { + // 设置租户ID + setTenantId(payment.getTenantId().toString()); + // 推送支付通知地址 + String path = payment.getNotifyUrl(); + try { + // 链式构建请求 + return HttpRequest.post(path) + .header("Tenantid", TENANT_ID) + .body(JSONUtil.toJSONString(transaction))//表单内容 + .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(); + } catch (Exception e) { + e.printStackTrace(); + } + return "支付失败"; } - return null; - } - // 新增用户 - public boolean saveUserByPhone(MerchantAccount merchantAccount) { - String path = "/system/user/"; - try { - HashMap map = new HashMap<>(); - map.put("nickname", merchantAccount.getRealName()); - map.put("username", merchantAccount.getPhone()); - map.put("realName", merchantAccount.getRealName()); - map.put("phone", merchantAccount.getPhone()); - map.put("password", merchantAccount.getPassword()); - map.put("merchantId",merchantAccount.getMerchantId()); - map.put("merchantName",merchantAccount.getMerchantName()); - map.put("merchantAvatar",merchantAccount.getMerchantAvatar()); - final ArrayList roles = new ArrayList<>(); - final UserRole userRole = new UserRole(); - userRole.setUserId(merchantAccount.getUserId()); - userRole.setRoleId(merchantAccount.getRoleId()); - userRole.setTenantId(merchantAccount.getTenantId()); - roles.add(userRole); - map.put("roles", roles); - map.put("tenantId", TENANT_ID); - // 链式构建请求 - String result = HttpRequest.post(host.concat(path)) - .header("Authorization", ACCESS_TOKEN) - .header("Tenantid", TENANT_ID) - .body(JSONUtil.toJSONString(map))//表单内容 - .timeout(20000)//超时,毫秒 - .execute().body(); - } catch (Exception e) { - e.printStackTrace(); + public User getUserByPhone(String phone) { + String path = "/system/user/getByPhone/" + phone; + try { + // 链式构建请求 + String result = HttpRequest.get(host.concat(path)) + .header("Authorization", ACCESS_TOKEN) + .header("Tenantid", TENANT_ID) + .timeout(20000)//超时,毫秒 + .execute().body(); + + JSONObject jsonObject = JSONObject.parseObject(result); + final String data = jsonObject.getString("data"); + return JSONObject.parseObject(data, User.class); + } catch (Exception e) { + e.printStackTrace(); + } + return null; } - return true; - } - public ApiResult updateUserBalance(String path,User user) { - try { - // 链式构建请求 - final String body = HttpRequest.put(host.concat(path)) - .header("Authorization", ACCESS_TOKEN) - .header("Tenantid", TENANT_ID) - .body(JSONUtil.toJSONString(user)) - .timeout(20000) - .execute().body(); - return JSONUtil.parseObject(body, ApiResult.class); - } catch (Exception e) { - e.printStackTrace(); + public User getByUserId(Integer userId) { + String path = "/system/user/" + userId; + try { + // 链式构建请求 + String result = HttpRequest.get(host.concat(path)) + .header("Authorization", ACCESS_TOKEN) + .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; } - return null; - } - // 更新用户信息 - public void updateUser(User user) { - String path = "/system/user/"; - try { - // 链式构建请求 - final String body = HttpRequest.put(host.concat(path)) - .header("Authorization", ACCESS_TOKEN) - .header("Tenantid", TENANT_ID) - .body(JSONUtil.toJSONString(user)) - .timeout(20000) - .execute().body(); + // 新增用户 + public boolean saveUserByPhone(MerchantAccount merchantAccount) { + String path = "/system/user/"; + try { + HashMap map = new HashMap<>(); + map.put("nickname", merchantAccount.getRealName()); + map.put("username", merchantAccount.getPhone()); + map.put("realName", merchantAccount.getRealName()); + map.put("phone", merchantAccount.getPhone()); + map.put("password", merchantAccount.getPassword()); + map.put("merchantId", merchantAccount.getMerchantId()); + map.put("merchantName", merchantAccount.getMerchantName()); + map.put("merchantAvatar", merchantAccount.getMerchantAvatar()); + final ArrayList roles = new ArrayList<>(); + final UserRole userRole = new UserRole(); + userRole.setUserId(merchantAccount.getUserId()); + userRole.setRoleId(merchantAccount.getRoleId()); + userRole.setTenantId(merchantAccount.getTenantId()); + roles.add(userRole); + map.put("roles", roles); + map.put("tenantId", TENANT_ID); + // 链式构建请求 + String result = HttpRequest.post(host.concat(path)) + .header("Authorization", ACCESS_TOKEN) + .header("Tenantid", TENANT_ID) + .body(JSONUtil.toJSONString(map))//表单内容 + .timeout(20000)//超时,毫秒 + .execute().body(); - } catch (Exception e) { - e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return true; } - } - public String getMpOrderQrCode(String orderNo) { - String path = "/wx-login/getOrderQRCode/"; - try { - // 链式构建请求 - final String body = HttpRequest.get(host.concat(path).concat(orderNo)) - .header("Authorization", ACCESS_TOKEN) - .header("tenantId", TENANT_ID) - .timeout(20000) - .execute().body(); - final JSONObject jsonObject = JSONObject.parseObject(body); - final String qrCode = jsonObject.getString("message"); - return qrCode; - } catch (Exception e) { - e.printStackTrace(); + public ApiResult updateUserBalance(String path, User user) { + try { + // 链式构建请求 + final String body = HttpRequest.put(host.concat(path)) + .header("Authorization", ACCESS_TOKEN) + .header("Tenantid", TENANT_ID) + .body(JSONUtil.toJSONString(user)) + .timeout(20000) + .execute().body(); + return JSONUtil.parseObject(body, ApiResult.class); + } catch (Exception e) { + e.printStackTrace(); + } + return null; } - return null; - } - public String getOrderQRCodeUnlimited(String orderNo) { - String path = "/wx-login/getOrderQRCodeUnlimited/"; - try { - // 链式构建请求 - final String body = HttpRequest.get(host.concat(path).concat(orderNo)) - .header("Authorization", ACCESS_TOKEN) - .header("tenantId", TENANT_ID) - .timeout(20000) - .execute().body(); - System.out.println("body = " + body); - final JSONObject jsonObject = JSONObject.parseObject(body); - final String qrCode = jsonObject.getString("message"); - System.out.println("qrCode = " + qrCode); - return qrCode; - } catch (Exception e) { - e.printStackTrace(); + public User getParent(Integer userId) { + try { + // 链式构建请求 + final String result = HttpRequest.get(host.concat("/system/user-referee/getReferee/" + userId)) + .header("Authorization", ACCESS_TOKEN) + .header("Tenantid", TENANT_ID) + .timeout(20000) + .execute().body(); + JSONObject jsonObject = JSONObject.parseObject(result); + final String data = jsonObject.getString("data"); + return JSONObject.parseObject(data, User.class); + } catch (Exception e) { + e.printStackTrace(); + } + return null; } - return null; - } - public void updateUserMerchantId(User user) { - String path = "/system/user/updateUserMerchantId"; - try { - // 链式构建请求 - final String body = HttpRequest.put(host.concat(path)) - .header("Authorization", ACCESS_TOKEN) - .header("tenantId", TENANT_ID) - .body(JSONUtil.toJSONString(user)) - .timeout(20000) - .execute().body(); - System.out.println("body = " + body); - } catch (Exception e) { - e.printStackTrace(); - } - } + // 更新用户信息 + public void updateUser(User user) { + String path = "/system/user/"; + try { + // 链式构建请求 + final String body = HttpRequest.put(host.concat(path)) + .header("Authorization", ACCESS_TOKEN) + .header("Tenantid", TENANT_ID) + .body(JSONUtil.toJSONString(user)) + .timeout(20000) + .execute().body(); + System.out.println("body = " + body); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public String getMpOrderQrCode(String orderNo) { + String path = "/wx-login/getOrderQRCode/"; + try { + // 链式构建请求 + final String body = HttpRequest.get(host.concat(path).concat(orderNo)) + .header("Authorization", ACCESS_TOKEN) + .header("tenantId", TENANT_ID) + .timeout(20000) + .execute().body(); + final JSONObject jsonObject = JSONObject.parseObject(body); + final String qrCode = jsonObject.getString("message"); + return qrCode; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public String getOrderQRCodeUnlimited(String orderNo) { + String path = "/wx-login/getOrderQRCodeUnlimited/"; + try { + // 链式构建请求 + final String body = HttpRequest.get(host.concat(path).concat(orderNo)) + .header("Authorization", ACCESS_TOKEN) + .header("tenantId", TENANT_ID) + .timeout(20000) + .execute().body(); + System.out.println("body = " + body); + final JSONObject jsonObject = JSONObject.parseObject(body); + final String qrCode = jsonObject.getString("message"); + System.out.println("qrCode = " + qrCode); + return qrCode; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public void updateUserMerchantId(User user) { + String path = "/system/user/updateUserMerchantId"; + try { + // 链式构建请求 + final String body = HttpRequest.put(host.concat(path)) + .header("Authorization", ACCESS_TOKEN) + .header("tenantId", TENANT_ID) + .body(JSONUtil.toJSONString(user)) + .timeout(20000) + .execute().body(); + System.out.println("body = " + body); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public ApiResult getWxConfig() { + String path = "/system/setting?settingKey=mp-weixin"; + try { + // 链式构建请求 + final String body = HttpRequest.get(host.concat(path)) + .header("Authorization", ACCESS_TOKEN) + .header("tenantId", TENANT_ID) + .timeout(20000) + .execute().body(); + System.out.println("body = " + body); + return JSONUtil.parseObject(body, ApiResult.class); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } } diff --git a/src/main/java/com/gxwebsoft/common/system/controller/FileController.java b/src/main/java/com/gxwebsoft/common/system/controller/FileController.java index 12b5a7e..c5480c1 100644 --- a/src/main/java/com/gxwebsoft/common/system/controller/FileController.java +++ b/src/main/java/com/gxwebsoft/common/system/controller/FileController.java @@ -280,7 +280,7 @@ public class FileController extends BaseController { * 文件上传位置(服务器) */ private String getUploadDir() { - return config.getUploadPath() + "file/"; + return config.getUploadPath(); } /** diff --git a/src/main/java/com/gxwebsoft/shop/config/WxMaProperties.java b/src/main/java/com/gxwebsoft/shop/config/WxMaProperties.java new file mode 100644 index 0000000..db25e5c --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/config/WxMaProperties.java @@ -0,0 +1,43 @@ +package com.gxwebsoft.shop.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +@Data +@ConfigurationProperties(prefix = "wx.miniapp") +@Configuration +public class WxMaProperties { + private List configs; + + @Data + public static class Config { + /** + * 设置微信小程序的appid + */ + private String appid; + + /** + * 设置微信小程序的Secret + */ + private String secret; + + /** + * 设置微信小程序消息服务器配置的token + */ + private String token; + + /** + * 设置微信小程序消息服务器配置的EncodingAESKey + */ + private String aesKey; + + /** + * 消息格式,XML或者JSON + */ + private String msgDataFormat; + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/consts/BalanceScene.java b/src/main/java/com/gxwebsoft/shop/consts/BalanceScene.java new file mode 100644 index 0000000..69bbe6b --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/consts/BalanceScene.java @@ -0,0 +1,8 @@ +package com.gxwebsoft.shop.consts; + +public class BalanceScene { + public static final Integer BALANCE_SCENE_DIRECT_INCOME = 0; + public static final Integer BALANCE_SCENE_SUPPLIER = 1; + public static final Integer BALANCE_SCENE_DIFF = 2; + public static final Integer BALANCE_SCENE_OUT_TAKE = 3; +} diff --git a/src/main/java/com/gxwebsoft/shop/consts/OrderPayType.java b/src/main/java/com/gxwebsoft/shop/consts/OrderPayType.java new file mode 100644 index 0000000..248097f --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/consts/OrderPayType.java @@ -0,0 +1,8 @@ +package com.gxwebsoft.shop.consts; + +public class OrderPayType { + public static final Integer PAY_TYPE_BALANCE = 0; + public static final Integer PAY_TYPE_WECHAT = 1; + // 朋友代付 + public static final Integer PAY_TYPE_FRIEND = 18; +} diff --git a/src/main/java/com/gxwebsoft/shop/controller/CartController.java b/src/main/java/com/gxwebsoft/shop/controller/CartController.java index 1112338..091ebf3 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/CartController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/CartController.java @@ -40,133 +40,144 @@ import java.util.stream.Collectors; @RestController @RequestMapping("/api/shop/cart") public class CartController extends BaseController { - @Resource - private CartService cartService; - @Resource - private MerchantService merchantService; + @Resource + private CartService cartService; + @Resource + private MerchantService merchantService; - @ApiOperation("分页查询购物车") - @GetMapping("/page") - public ApiResult> page(CartParam param) { - // 使用关联查询 - return success(cartService.pageRel(param)); - } - - @ApiOperation("查询全部购物车") - @GetMapping() - public ApiResult list(CartParam param) { - if (ObjectUtil.isEmpty(getLoginUser())) { - return success("请先登录",new CartVo()); - } - // 附加用户ID - param.setUserId(getLoginUserId()); - return success(cartService.listRel(param)); - } - - @PreAuthorize("hasAuthority('shop:cart:list')") - @ApiOperation("根据id查询购物车") - @GetMapping("/{id}") - public ApiResult get(@PathVariable("id") Integer id) { - // 使用关联查询 - return success(cartService.getByIdRel(id)); - } - - @ApiOperation("添加购物车") - @PostMapping() - public ApiResult save(@RequestBody Cart cart) { - if (ObjectUtil.isEmpty(getLoginUser())) { - return success("请先登录",null); + @ApiOperation("分页查询购物车") + @GetMapping("/page") + public ApiResult> page(CartParam param) { + // 使用关联查询 + return success(cartService.pageRel(param)); } - // 修正用户ID - cart.setUserId(getLoginUserId()); - // 修正购买数量 - if (ObjectUtil.isEmpty(cart.getCartNum())) { - cart.setCartNum(1); - } - // 超出最大限制 - if (cartService.count(new LambdaUpdateWrapper().eq(Cart::getUserId,cart.getUserId())) > 50) { - return fail("购物车宝贝数量已满,建议您先去结算或清理~"); - } - // 叠加 - final Cart one = cartService.getOne(new LambdaQueryWrapper().eq(Cart::getGoodsId, cart.getGoodsId()).eq(Cart::getSpec, cart.getSpec()).eq(Cart::getUserId, cart.getUserId()).eq(Cart::getType, cart.getType()).last("limit 1")); - if (ObjectUtil.isNotEmpty(one)) { - one.setCartNum(one.getCartNum() + cart.getCartNum()); - cartService.updateById(one); - return success("添加成功",one.getId()); - } - if (cartService.save(cart)) { - return success("添加成功",cart.getId()); + @ApiOperation("查询全部购物车") + @GetMapping() + public ApiResult list(CartParam param) { + param.setIsShow(true); + if (ObjectUtil.isEmpty(getLoginUser())) { + return success("请先登录", new CartVo()); + } + // 附加用户ID + param.setUserId(getLoginUserId()); + param.setLoginUser(getLoginUser()); + return success(cartService.listRel(param)); } - return fail("添加失败"); - } - - @ApiOperation("修改购物车") - @PutMapping() - public ApiResult update(@RequestBody Cart cart) { - if (cartService.updateById(cart)) { - final CartParam param = new CartParam(); - param.setType(cart.getType()); - return success("修改成功"); + @PreAuthorize("hasAuthority('shop:cart:list')") + @ApiOperation("根据id查询购物车") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(cartService.getByIdRel(id)); } - return fail("修改失败"); - } - @PreAuthorize("hasAuthority('shop:cart:remove')") - @ApiOperation("删除购物车") - @DeleteMapping("/{id}") - public ApiResult remove(@PathVariable("id") Integer id) { - if (cartService.removeById(id)) { - return success("删除成功"); - } - return fail("删除失败"); - } + @ApiOperation("添加购物车") + @PostMapping() + public ApiResult save(@RequestBody Cart cart) { + if (ObjectUtil.isEmpty(getLoginUser())) { + return success("请先登录", null); + } - @PreAuthorize("hasAuthority('shop:cart:save')") - @ApiOperation("批量添加购物车") - @PostMapping("/batch") - public ApiResult saveBatch(@RequestBody List list) { - if (cartService.saveBatch(list)) { - return success("添加成功"); - } - return fail("添加失败"); - } + // 修正用户ID + cart.setUserId(getLoginUserId()); + // 修正购买数量 + if (ObjectUtil.isEmpty(cart.getCartNum())) { + cart.setCartNum(1); + } + // 超出最大限制 + if (cartService.count(new LambdaUpdateWrapper().eq(Cart::getUserId, cart.getUserId())) > 50) { + return fail("购物车宝贝数量已满,建议您先去结算或清理~"); + } + // 叠加 + if (!cart.getIsNew()) { + LambdaQueryWrapper cartLambdaQueryWrapper = new LambdaQueryWrapper() + .eq(Cart::getGoodsId, cart.getGoodsId()) + .eq(Cart::getUserId, cart.getUserId()) + .eq(Cart::getType, cart.getType()); + if (cart.getSpec() != null) cartLambdaQueryWrapper.eq(Cart::getSpec, cart.getSpec()); + cartLambdaQueryWrapper.last("limit 1"); + final Cart one = cartService.getOne(cartLambdaQueryWrapper); + if (ObjectUtil.isNotEmpty(one)) { + one.setIsNew(false); + one.setCartNum(one.getCartNum() + cart.getCartNum()); + cartService.updateById(one); + return success("添加成功", one.getId()); + } + } + if (cartService.save(cart)) { + return success("添加成功", cart.getId()); + } - @PreAuthorize("hasAuthority('shop:cart:update')") - @ApiOperation("批量修改购物车") - @PutMapping("/batch") - public ApiResult removeBatch(@RequestBody BatchParam batchParam) { - if (batchParam.update(cartService, "id")) { - return success("修改成功"); + return fail("添加失败"); } - return fail("修改失败"); - } - @PreAuthorize("hasAuthority('shop:cart:remove')") - @ApiOperation("批量删除购物车") - @DeleteMapping("/batch") - public ApiResult removeBatch(@RequestBody List ids) { - if (cartService.removeByIds(ids)) { - return success("删除成功"); + @ApiOperation("修改购物车") + @PutMapping() + public ApiResult update(@RequestBody Cart cart) { + if (cartService.updateById(cart)) { + final CartParam param = new CartParam(); + param.setType(cart.getType()); + return success("修改成功"); + } + return fail("修改失败"); } - return fail("删除失败"); - } - @ApiOperation("全选操作") - @PutMapping("/onSelectAll/{yes}") - public ApiResult onSelectAll(@PathVariable("yes") Boolean yes) { - if (ObjectUtil.isEmpty(getLoginUser())) { - return success("请先登录",null); + @PreAuthorize("hasAuthority('shop:cart:remove')") + @ApiOperation("删除购物车") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (cartService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @PreAuthorize("hasAuthority('shop:cart:save')") + @ApiOperation("批量添加购物车") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (cartService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @PreAuthorize("hasAuthority('shop:cart:update')") + @ApiOperation("批量修改购物车") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(cartService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @PreAuthorize("hasAuthority('shop:cart:remove')") + @ApiOperation("批量删除购物车") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (cartService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("全选操作") + @PutMapping("/onSelectAll/{yes}") + public ApiResult onSelectAll(@PathVariable("yes") Boolean yes) { + if (ObjectUtil.isEmpty(getLoginUser())) { + return success("请先登录", null); + } + final List carts = cartService.list(new LambdaUpdateWrapper() + .eq(Cart::getSelected, !yes) + .eq(Cart::getUserId, getLoginUserId())); + carts.forEach(d -> { + d.setSelected(yes); + }); + return success("修改成功", cartService.updateBatchById(carts)); } - final List carts = cartService.list(new LambdaUpdateWrapper() - .eq(Cart::getSelected,!yes) - .eq(Cart::getUserId, getLoginUserId())); - carts.forEach(d -> { - d.setSelected(yes); - }); - return success("修改成功", cartService.updateBatchById(carts)); - } // @ApiOperation("我的购物车") diff --git a/src/main/java/com/gxwebsoft/shop/controller/GoodsCategoryController.java b/src/main/java/com/gxwebsoft/shop/controller/GoodsCategoryController.java index 9a42595..d6c0383 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/GoodsCategoryController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/GoodsCategoryController.java @@ -26,9 +26,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; import static com.gxwebsoft.common.core.utils.CommonUtil.toTreeData; @@ -43,235 +41,242 @@ import static com.gxwebsoft.common.core.utils.CommonUtil.toTreeData; @RestController @RequestMapping("/api/shop/goods-category") public class GoodsCategoryController extends BaseController { - @Resource - private GoodsCategoryService goodsCategoryService; - @Resource - private GoodsSpecService goodsSpecService; - @Resource - private GoodsService goodsService; - @Resource - private CartService cartService; + @Resource + private GoodsCategoryService goodsCategoryService; + @Resource + private GoodsSpecService goodsSpecService; + @Resource + private GoodsService goodsService; + @Resource + private CartService cartService; - @ApiOperation("查询商城菜单分类级商品数据(不联动)") - @GetMapping("/listCategoryTree") - public ApiResult> listCategoryTree(GoodsCategoryParam param) { - // 查询非店铺分类 - param.setMerchantId(0); - final List goodsCategoryList = goodsCategoryService.listRel(param); - // 收集分类ID - final Set categoryIds = goodsCategoryList.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet()); - if (categoryIds.isEmpty()) { - return success("分类为空",goodsCategoryList); - } - // List转为树形结构 - final List list = toTreeData(goodsCategoryList, 0, GoodsCategory::getParentId, GoodsCategory::getCategoryId, GoodsCategory::setChildren); - // 查询所有商品 - final List goods = goodsService.list(new LambdaQueryWrapper() - .in(Goods::getCategoryId, categoryIds) - .eq(Goods::getIsShow, 1) - .eq(Goods::getDeleted, 0)); + @ApiOperation("查询商城菜单分类级商品数据(不联动)") + @GetMapping("/listCategoryTree") + public ApiResult> listCategoryTree(GoodsCategoryParam param) { + // 查询非店铺分类 + param.setMerchantId(0); + final List goodsCategoryList = goodsCategoryService.listRel(param); + // 收集分类ID + final Set categoryIds = goodsCategoryList.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet()); + if (categoryIds.isEmpty()) { + return success("分类为空", goodsCategoryList); + } + // List转为树形结构 + final List list = toTreeData(goodsCategoryList, 0, GoodsCategory::getParentId, GoodsCategory::getCategoryId, GoodsCategory::setChildren); + // 查询所有商品 + final List goods = goodsService.list(new LambdaQueryWrapper() + .in(Goods::getCategoryId, categoryIds) + .eq(Goods::getIsShow, 1) + .eq(Goods::getDeleted, 0)); - System.out.println("goods.size() = " + goods.size()); + System.out.println("goods.size() = " + goods.size()); - final Map> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId)); + final Map> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId)); - final Set goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet()); + final Set goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet()); - final List specs = goodsSpecService.list(new LambdaQueryWrapper().in(GoodsSpec::getGoodsId, goodsIds)); + final List specs = goodsSpecService.list(new LambdaQueryWrapper().in(GoodsSpec::getGoodsId, goodsIds)); - final Map> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId)); + final Map> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId)); - list.forEach(d -> { - d.setName(d.getTitle()); - final List goodsList = collectGoods.get(d.getCategoryId()); - if (!CollectionUtils.isEmpty(goodsList)) { - goodsList.forEach(v -> { - final List goodsSpecs = collectGoodsSpec.get(v.getGoodsId()); - if (!CollectionUtils.isEmpty(goodsSpecs)) { - final GoodsSpec spec = goodsSpecs.get(0); - v.setSpecValue(spec.getSpecValue()); - v.setGoodsSpecValue(JSONUtil.parseObject(spec.getSpecValue(), Object.class)); - } + list.forEach(d -> { + d.setName(d.getTitle()); + final List goodsList = collectGoods.get(d.getCategoryId()); + if (!CollectionUtils.isEmpty(goodsList)) { + goodsList.forEach(v -> { + final List goodsSpecs = collectGoodsSpec.get(v.getGoodsId()); + if (!CollectionUtils.isEmpty(goodsSpecs)) { + final GoodsSpec spec = goodsSpecs.get(0); + v.setSpecValue(spec.getSpecValue()); + v.setGoodsSpecValue(JSONUtil.parseObject(spec.getSpecValue(), Object.class)); + } + }); + d.setGoods(collectGoods.get(d.getCategoryId())); + } }); - d.setGoods(collectGoods.get(d.getCategoryId())); - } - }); - return success(list); - } - - @ApiOperation("查询商城菜单分类级商品数据(不联动)") - @GetMapping("/listCategoryParentIdTree/{parentId}") - public ApiResult> listCategoryParentIdTree(@PathVariable("parentId") Integer parentId) { - // 查询非店铺分类 - final List list = goodsCategoryService.list(new LambdaQueryWrapper() - .eq(GoodsCategory::getParentId,parentId) - .eq(GoodsCategory::getType,0) - .eq(GoodsCategory::getMerchantId,0)); - - final Set categoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet()); - final List goods = goodsService.list(new LambdaQueryWrapper().in(Goods::getCategoryId, categoryIds)); - final Map> collect = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId)); - - final Map> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId)); - - final Set goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet()); - - final List specs = goodsSpecService.list(new LambdaQueryWrapper().in(GoodsSpec::getGoodsId, goodsIds)); - - final Map> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId)); - - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(Cart::getGoodsId, goodsIds).eq(Cart::getSelected,1); - if(ObjectUtil.isNotEmpty(getLoginUser())){ - wrapper.eq(Cart::getUserId,getLoginUser().getUserId()); + return success(list); } - final List carts = cartService.list(); - final Map> collectCart = carts.stream().collect(Collectors.groupingBy(Cart::getGoodsId)); - list.forEach(d -> { - d.setName(d.getTitle()); - final List goodsList = collectGoods.get(d.getCategoryId()); - if (!CollectionUtils.isEmpty(goodsList)) { - goodsList.forEach(v -> { - final List goodsSpecs = collectGoodsSpec.get(v.getGoodsId()); - if (!CollectionUtils.isEmpty(goodsSpecs)) { - final GoodsSpec spec = goodsSpecs.get(0); - v.setSpecValue(spec.getSpecValue()); - v.setGoodsSpecValue(JSONUtil.parseObject(spec.getSpecValue(), Object.class)); - } - final List carts1 = collectCart.get(v.getGoodsId()); + @ApiOperation("查询商城菜单分类级商品数据(不联动)") + @GetMapping("/listCategoryParentIdTree/{parentId}") + public ApiResult> listCategoryParentIdTree(@PathVariable("parentId") Integer parentId) { + // 查询非店铺分类 + final List list = goodsCategoryService.list(new LambdaQueryWrapper() + .eq(GoodsCategory::getParentId, parentId) + .eq(GoodsCategory::getType, 0) + .eq(GoodsCategory::getMerchantId, 0)); - if (ArrayUtil.isNotEmpty(carts1)) { - final Cart cart = carts1.get(0); + final Set categoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet()); + final List goods = goodsService.list(new LambdaQueryWrapper().in(Goods::getCategoryId, categoryIds)); + final Map> collect = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId)); - if (getLoginUser() != null && cart.getUserId().equals(getLoginUserId())) { - v.setTotalNums(cart.getCartNum()); - } + final Map> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId)); - } + final Set goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet()); + final List specs = goodsSpecService.list(new LambdaQueryWrapper().in(GoodsSpec::getGoodsId, goodsIds)); + + final Map> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId)); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(Cart::getGoodsId, goodsIds).eq(Cart::getSelected, 1); + if (ObjectUtil.isNotEmpty(getLoginUser())) { + wrapper.eq(Cart::getUserId, getLoginUser().getUserId()); + } + final List carts = cartService.list(); + final Map> collectCart = carts.stream().collect(Collectors.groupingBy(Cart::getGoodsId)); + + list.forEach(d -> { + d.setName(d.getTitle()); + final List goodsList = collectGoods.get(d.getCategoryId()); + if (!CollectionUtils.isEmpty(goodsList)) { + goodsList.forEach(v -> { + final List goodsSpecs = collectGoodsSpec.get(v.getGoodsId()); + if (!CollectionUtils.isEmpty(goodsSpecs)) { + final GoodsSpec spec = goodsSpecs.get(0); + v.setSpecValue(spec.getSpecValue()); + v.setGoodsSpecValue(JSONUtil.parseObject(spec.getSpecValue(), Object.class)); + } + final List carts1 = collectCart.get(v.getGoodsId()); + + if (ArrayUtil.isNotEmpty(carts1)) { + final Cart cart = carts1.get(0); + + if (getLoginUser() != null && cart.getUserId().equals(getLoginUserId())) { + v.setTotalNums(cart.getCartNum()); + } + + } + + }); + d.setGoods(goodsList); + } }); - d.setGoods(goodsList); - } - }); - return success("请求成功",list); - } - - @ApiOperation("查询门店菜单分类及菜品数据(联动)") - @GetMapping("/listShopCategoryTree") - public ApiResult> listShopCategoryTree(GoodsCategoryParam param) { - final List list = goodsCategoryService.listRel(param); - final Set categoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet()); - if (categoryIds.isEmpty()) { - return success(list); + return success("请求成功", list); } - final List goods = goodsService.list(new LambdaQueryWrapper().in(Goods::getCategoryId, categoryIds).eq(Goods::getIsShow, 1).eq(Goods::getDeleted, 0)); - final Map> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId)); + @ApiOperation("查询门店菜单分类及菜品数据(联动)") + @GetMapping("/listShopCategoryTree") + public ApiResult> listShopCategoryTree(GoodsCategoryParam param) { + final List list = goodsCategoryService.listRel(param); + final Set categoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet()); + if (categoryIds.isEmpty()) { + return success(list); + } - final Set goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet()); + final List goods = goodsService.list(new LambdaQueryWrapper().in(Goods::getCategoryId, categoryIds).eq(Goods::getIsShow, 1).eq(Goods::getDeleted, 0)); + final Map> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId)); - final List specs = goodsSpecService.list(new LambdaQueryWrapper().in(GoodsSpec::getGoodsId, goodsIds)); + final Set goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet()); - final Map> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId)); + List specs = new ArrayList<>(); + Map> collectGoodsSpec; + if (!goodsIds.isEmpty()) { + specs = goodsSpecService.list(new LambdaQueryWrapper().in(GoodsSpec::getGoodsId, goodsIds)); + collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId)); + } else { + collectGoodsSpec = null; + } - list.forEach(d -> { - d.setName(d.getTitle()); - final List goodsList = collectGoods.get(d.getCategoryId()); - if (!CollectionUtils.isEmpty(goodsList)) { - goodsList.forEach(v -> { - final List goodsSpecs = collectGoodsSpec.get(v.getGoodsId()); - if (!CollectionUtils.isEmpty(goodsSpecs)) { - final GoodsSpec spec = goodsSpecs.get(0); - v.setSpecValue(spec.getSpecValue()); - v.setGoodsSpecValue(JSONUtil.parseObject(spec.getSpecValue(), Object.class)); - } + list.forEach(d -> { + d.setName(d.getTitle()); + final List goodsList = collectGoods.get(d.getCategoryId()); + if (!CollectionUtils.isEmpty(goodsList)) { + goodsList.forEach(v -> { + if (collectGoodsSpec != null) { + final List goodsSpecs = collectGoodsSpec.get(v.getGoodsId()); + if (!CollectionUtils.isEmpty(goodsSpecs)) { + final GoodsSpec spec = goodsSpecs.get(0); + v.setSpecValue(spec.getSpecValue()); + v.setGoodsSpecValue(JSONUtil.parseObject(spec.getSpecValue(), Object.class)); + } + } + }); + d.setGoods(collectGoods.get(d.getCategoryId())); + } }); - d.setGoods(collectGoods.get(d.getCategoryId())); - } - }); - return success(list); - } - - - @ApiOperation("分页查询商品分类") - @GetMapping("/page") - public ApiResult> page(GoodsCategoryParam param) { - // 使用关联查询 - return success(goodsCategoryService.pageRel(param)); - } - - @ApiOperation("查询全部商品分类") - @GetMapping() - public ApiResult> list(GoodsCategoryParam param) { - // 使用关联查询 - return success(goodsCategoryService.listRel(param)); - } - - @ApiOperation("根据id查询商品分类") - @GetMapping("/{id}") - public ApiResult get(@PathVariable("id") Integer id) { - // 使用关联查询 - return success(goodsCategoryService.getByIdRel(id)); - } - - @ApiOperation("添加商品分类") - @PostMapping() - public ApiResult save(@RequestBody GoodsCategory goodsCategory) { - // 记录当前登录用户id - User loginUser = getLoginUser(); - if (loginUser != null) { - goodsCategory.setUserId(loginUser.getUserId()); + return success(list); } - if (goodsCategoryService.save(goodsCategory)) { - return success("添加成功"); - } - return fail("添加失败"); - } - @ApiOperation("修改商品分类") - @PutMapping() - public ApiResult update(@RequestBody GoodsCategory goodsCategory) { - if (goodsCategoryService.updateById(goodsCategory)) { - return success("修改成功"); - } - return fail("修改失败"); - } - @ApiOperation("删除商品分类") - @DeleteMapping("/{id}") - public ApiResult remove(@PathVariable("id") Integer id) { - if (goodsCategoryService.removeById(id)) { - return success("删除成功"); + @ApiOperation("分页查询商品分类") + @GetMapping("/page") + public ApiResult> page(GoodsCategoryParam param) { + // 使用关联查询 + return success(goodsCategoryService.pageRel(param)); } - return fail("删除失败"); - } - @ApiOperation("批量添加商品分类") - @PostMapping("/batch") - public ApiResult saveBatch(@RequestBody List list) { - if (goodsCategoryService.saveBatch(list)) { - return success("添加成功"); + @ApiOperation("查询全部商品分类") + @GetMapping() + public ApiResult> list(GoodsCategoryParam param) { + // 使用关联查询 + return success(goodsCategoryService.listRel(param)); } - return fail("添加失败"); - } - @ApiOperation("批量修改商品分类") - @PutMapping("/batch") - public ApiResult removeBatch(@RequestBody BatchParam batchParam) { - if (batchParam.update(goodsCategoryService, "category_id")) { - return success("修改成功"); + @ApiOperation("根据id查询商品分类") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(goodsCategoryService.getByIdRel(id)); } - return fail("修改失败"); - } - @ApiOperation("批量删除商品分类") - @DeleteMapping("/batch") - public ApiResult removeBatch(@RequestBody List ids) { - if (goodsCategoryService.removeByIds(ids)) { - return success("删除成功"); + @ApiOperation("添加商品分类") + @PostMapping() + public ApiResult save(@RequestBody GoodsCategory goodsCategory) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + goodsCategory.setUserId(loginUser.getUserId()); + } + if (goodsCategoryService.save(goodsCategory)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("修改商品分类") + @PutMapping() + public ApiResult update(@RequestBody GoodsCategory goodsCategory) { + if (goodsCategoryService.updateById(goodsCategory)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除商品分类") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (goodsCategoryService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加商品分类") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (goodsCategoryService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改商品分类") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(goodsCategoryService, "category_id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除商品分类") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (goodsCategoryService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); } - return fail("删除失败"); - } } diff --git a/src/main/java/com/gxwebsoft/shop/controller/GoodsController.java b/src/main/java/com/gxwebsoft/shop/controller/GoodsController.java index 3071965..56fb72b 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/GoodsController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/GoodsController.java @@ -65,6 +65,16 @@ public class GoodsController extends BaseController { public ApiResult get(@PathVariable("id") Integer id) { // 使用关联查询 final Goods goods = goodsService.getByIdRel(id); + if (getLoginUser() != null) { + // 经销商 + if (getLoginUser().getGradeId().equals(33)) { + if (goods.getDealerGift()) goods.setShowGift(true); + } + // 会员店 + if (getLoginUser().getGradeId().equals(31)) { + if (goods.getPriceGift()) goods.setShowGift(true); + } + } // 提取specValue final GoodsSpec spec = goodsSpecService.getOne(new LambdaQueryWrapper().eq(GoodsSpec::getGoodsId, id).last("limit 1")); @@ -82,6 +92,8 @@ public class GoodsController extends BaseController { if(loginUser.getGradeId().equals(0)){ goods.setPrice(goods.getSalePrice()); } + }else { + goods.setPrice(goods.getSalePrice()); } // 店铺信息 goods.setMerchant(merchantService.getOne(new LambdaUpdateWrapper().eq(Merchant::getMerchantId, goods.getMerchantId()))); diff --git a/src/main/java/com/gxwebsoft/shop/controller/GoodsIncomeConfigController.java b/src/main/java/com/gxwebsoft/shop/controller/GoodsIncomeConfigController.java new file mode 100644 index 0000000..a31afda --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/controller/GoodsIncomeConfigController.java @@ -0,0 +1,119 @@ +package com.gxwebsoft.shop.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.shop.service.GoodsIncomeConfigService; +import com.gxwebsoft.shop.entity.GoodsIncomeConfig; +import com.gxwebsoft.shop.param.GoodsIncomeConfigParam; +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.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-06 17:55:50 + */ +@Api(tags = "分润配置管理") +@RestController +@RequestMapping("/api/shop/goods-income-config") +public class GoodsIncomeConfigController extends BaseController { + @Resource + private GoodsIncomeConfigService goodsIncomeConfigService; + + @ApiOperation("分页查询分润配置") + @GetMapping("/page") + public ApiResult> page(GoodsIncomeConfigParam param) { + // 使用关联查询 + return success(goodsIncomeConfigService.pageRel(param)); + } + + @ApiOperation("查询全部分润配置") + @GetMapping() + public ApiResult> list(GoodsIncomeConfigParam param) { + // 使用关联查询 + return success(goodsIncomeConfigService.listRel(param)); + } + + @PreAuthorize("hasAuthority('shop:goodsIncomeConfig:list')") + @ApiOperation("根据id查询分润配置") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(goodsIncomeConfigService.getByIdRel(id)); + } + + @ApiOperation("添加分润配置") + @PostMapping() + public ApiResult save(@RequestBody GoodsIncomeConfig goodsIncomeConfig) { + GoodsIncomeConfig check = goodsIncomeConfigService.check(goodsIncomeConfig.getGoodsId(), goodsIncomeConfig.getSkuId(), goodsIncomeConfig.getMerchantShopType()); + if (check != null) return fail("该配置已存在"); + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + goodsIncomeConfig.setUserId(loginUser.getUserId()); + } + if (goodsIncomeConfigService.save(goodsIncomeConfig)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("修改分润配置") + @PutMapping() + public ApiResult update(@RequestBody GoodsIncomeConfig goodsIncomeConfig) { + GoodsIncomeConfig check = goodsIncomeConfigService.check(goodsIncomeConfig.getGoodsId(), goodsIncomeConfig.getSkuId(), goodsIncomeConfig.getMerchantShopType()); + if (check != null && !check.getId().equals(goodsIncomeConfig.getId())) return fail("该配置已存在"); + if (goodsIncomeConfigService.updateById(goodsIncomeConfig)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除分润配置") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (goodsIncomeConfigService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加分润配置") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (goodsIncomeConfigService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改分润配置") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(goodsIncomeConfigService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除分润配置") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (goodsIncomeConfigService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/controller/GoodsStockInMerchantController.java b/src/main/java/com/gxwebsoft/shop/controller/GoodsStockInMerchantController.java new file mode 100644 index 0000000..79145d2 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/controller/GoodsStockInMerchantController.java @@ -0,0 +1,122 @@ +package com.gxwebsoft.shop.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.shop.service.GoodsStockInMerchantService; +import com.gxwebsoft.shop.entity.GoodsStockInMerchant; +import com.gxwebsoft.shop.param.GoodsStockInMerchantParam; +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.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-05 02:33:23 + */ +@Api(tags = "商户商品库存管理") +@RestController +@RequestMapping("/api/shop/goods-stock-in-merchant") +public class GoodsStockInMerchantController extends BaseController { + @Resource + private GoodsStockInMerchantService goodsStockInMerchantService; + + @ApiOperation("分页查询商户商品库存") + @GetMapping("/page") + public ApiResult> page(GoodsStockInMerchantParam param) { + // 使用关联查询 + return success(goodsStockInMerchantService.pageRel(param)); + } + + @ApiOperation("查询全部商户商品库存") + @GetMapping() + public ApiResult> list(GoodsStockInMerchantParam param) { + // 使用关联查询 + return success(goodsStockInMerchantService.listRel(param)); + } + + @PreAuthorize("hasAuthority('shop:goodsStockInMerchant:list')") + @ApiOperation("根据id查询商户商品库存") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(goodsStockInMerchantService.getByIdRel(id)); + } + + @ApiOperation("添加商户商品库存") + @PostMapping() + public ApiResult save(@RequestBody GoodsStockInMerchant goodsStockInMerchant) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + goodsStockInMerchant.setUserId(loginUser.getUserId()); + goodsStockInMerchant.setMerchantId(loginUser.getMerchantId()); + GoodsStockInMerchant check = goodsStockInMerchantService.check(loginUser.getMerchantId(), goodsStockInMerchant.getGoodsId(), goodsStockInMerchant.getSkuId()); + if (check != null) { + check.setStock(goodsStockInMerchant.getStock()); + goodsStockInMerchantService.updateById(goodsStockInMerchant); + return success("操作成功"); + } + } + if (goodsStockInMerchantService.save(goodsStockInMerchant)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("修改商户商品库存") + @PutMapping() + public ApiResult update(@RequestBody GoodsStockInMerchant goodsStockInMerchant) { + if (goodsStockInMerchantService.updateById(goodsStockInMerchant)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除商户商品库存") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (goodsStockInMerchantService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加商户商品库存") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (goodsStockInMerchantService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改商户商品库存") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(goodsStockInMerchantService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除商户商品库存") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (goodsStockInMerchantService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/controller/MerchantApplyController.java b/src/main/java/com/gxwebsoft/shop/controller/MerchantApplyController.java index c58ede2..bd89af3 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/MerchantApplyController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/MerchantApplyController.java @@ -2,6 +2,7 @@ package com.gxwebsoft.shop.controller; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.gxwebsoft.common.core.security.JwtUtil; import com.gxwebsoft.common.core.utils.RequestUtil; import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.shop.entity.Merchant; @@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.client.RestTemplate; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import java.util.List; /** @@ -39,128 +41,149 @@ import java.util.List; @RestController @RequestMapping("/api/shop/merchant-apply") public class MerchantApplyController extends BaseController { - @Resource - private MerchantApplyService merchantApplyService; - @Resource - private MerchantService merchantService; - @Resource - private RequestUtil requestUtil; + @Resource + private MerchantApplyService merchantApplyService; + @Resource + private MerchantService merchantService; + @Resource + private RequestUtil requestUtil; - @ApiOperation("分页查询商户入驻申请") - @GetMapping("/page") - public ApiResult> page(MerchantApplyParam param) { - // 使用关联查询 - return success(merchantApplyService.pageRel(param)); - } - - @ApiOperation("查询全部商户入驻申请") - @GetMapping() - public ApiResult> list(MerchantApplyParam param) { - // 使用关联查询 - return success(merchantApplyService.listRel(param)); - } - - @ApiOperation("根据id查询商户入驻申请") - @GetMapping("/{id}") - public ApiResult get(@PathVariable("id") Integer id) { - // 使用关联查询 - return success(merchantApplyService.getByIdRel(id)); - } - - @ApiOperation("添加商户入驻申请") - @PostMapping() - public ApiResult save(@RequestBody MerchantApply merchantApply) { - // 记录当前登录用户id - User loginUser = getLoginUser(); - if (loginUser != null) { - merchantApply.setUserId(loginUser.getUserId()); + @ApiOperation("分页查询商户入驻申请") + @GetMapping("/page") + public ApiResult> page(MerchantApplyParam param) { + // 使用关联查询 + return success(merchantApplyService.pageRel(param)); } - if (merchantService.count(new LambdaQueryWrapper().eq(Merchant::getPhone, merchantApply.getPhone())) > 0) { - return fail("该手机号码已存在"); - } - if (merchantApplyService.count(new LambdaQueryWrapper().eq(MerchantApply::getPhone, merchantApply.getPhone())) > 0) { - return fail("该手机号码已存在"); - } - if (merchantApplyService.save(merchantApply)) { - return success("添加成功"); - } - return fail("添加失败"); - } - - @ApiOperation("修改商户入驻申请") - @PutMapping() - public ApiResult update(@RequestBody MerchantApply merchantApply) { - if (merchantApply.getStatus().equals(1)) { - // TODO 审核通过则创建商户 - final Merchant one = merchantService.getOne(new LambdaQueryWrapper().eq(Merchant::getPhone, merchantApply.getPhone()).last("limit 1")); - final MerchantAccount merchantAccount = new MerchantAccount(); - BeanUtils.copyProperties(merchantApply, merchantAccount); - - final User user = new User(); - - if(ObjectUtil.isNotEmpty(one)){ - BeanUtils.copyProperties(merchantApply, one); - one.setStatus(0); - merchantService.updateById(one); - user.setMerchantId(one.getMerchantId()); - user.setMerchantName(one.getMerchantName()); - }else { - final Merchant merchant = new Merchant(); - BeanUtils.copyProperties(merchantApply, merchant); - merchant.setStatus(0); - merchantService.save(merchant); - user.setMerchantId(merchant.getMerchantId()); - user.setMerchantName(merchant.getMerchantName()); - } - // TODO 创建商户账号 - merchantAccount.setRealName(merchantApply.getRealName()); - requestUtil.saveUserByPhone(merchantAccount); - // TODO 更新用户表的商户ID - requestUtil.updateUserMerchantId(user); + @ApiOperation("查询全部商户入驻申请") + @GetMapping() + public ApiResult> list(MerchantApplyParam param) { + // 使用关联查询 + return success(merchantApplyService.listRel(param)); } - // TODO 驳回 - if (merchantApplyService.updateById(merchantApply)) { - return success("修改成功"); + @ApiOperation("根据id查询商户入驻申请") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(merchantApplyService.getByIdRel(id)); } - return fail("修改失败"); - } - @ApiOperation("删除商户入驻申请") - @DeleteMapping("/{id}") - public ApiResult remove(@PathVariable("id") Integer id) { - if (merchantApplyService.removeById(id)) { - return success("删除成功"); + @ApiOperation("添加商户入驻申请") + @PostMapping() + public ApiResult save(@RequestBody MerchantApply merchantApply) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + merchantApply.setUserId(loginUser.getUserId()); + } + if (merchantService.count(new LambdaQueryWrapper().eq(Merchant::getPhone, merchantApply.getPhone())) > 0) { + return fail("该手机号码已存在"); + } + if (merchantApplyService.count(new LambdaQueryWrapper().eq(MerchantApply::getPhone, merchantApply.getPhone())) > 0) { + return fail("该手机号码已存在"); + } + if (merchantApplyService.save(merchantApply)) { + return success("添加成功"); + } + return fail("添加失败"); } - return fail("删除失败"); - } - @ApiOperation("批量添加商户入驻申请") - @PostMapping("/batch") - public ApiResult saveBatch(@RequestBody List list) { - if (merchantApplyService.saveBatch(list)) { - return success("添加成功"); - } - return fail("添加失败"); - } + @ApiOperation("修改商户入驻申请") + @PutMapping() + public ApiResult update(@RequestBody MerchantApply merchantApply, HttpServletRequest request) { + if (merchantApply.getStatus().equals(1)) { + // TODO 审核通过则创建商户 + final Merchant one = merchantService.getOne(new LambdaQueryWrapper().eq(Merchant::getPhone, merchantApply.getPhone()).last("limit 1")); + final MerchantAccount merchantAccount = new MerchantAccount(); + BeanUtils.copyProperties(merchantApply, merchantAccount); + final User user = new User(); + final User loingUser = new User(); + loingUser.setUserId(merchantAccount.getUserId()); - @ApiOperation("批量修改商户入驻申请") - @PutMapping("/batch") - public ApiResult removeBatch(@RequestBody BatchParam batchParam) { - if (batchParam.update(merchantApplyService, "apply_id")) { - return success("修改成功"); - } - return fail("修改失败"); - } + Integer gradeId = 30; + if (ObjectUtil.isNotEmpty(one)) { + BeanUtils.copyProperties(merchantApply, one); + one.setStatus(0); + merchantService.updateById(one); + user.setMerchantId(one.getMerchantId()); + user.setMerchantName(one.getMerchantName()); + gradeId = switch (one.getShopType()) { + case "会员店" -> 31; + case "实体连锁店" -> 32; + case "经销商" -> 33; + case "供应商" -> 34; + default -> gradeId; + }; + } else { + final Merchant merchant = new Merchant(); + BeanUtils.copyProperties(merchantApply, merchant); + merchant.setStatus(0); + merchantService.save(merchant); + user.setMerchantId(merchant.getMerchantId()); + user.setMerchantName(merchant.getMerchantName()); + gradeId = switch (merchant.getShopType()) { + case "会员店" -> 31; + case "实体连锁店" -> 32; + case "经销商" -> 33; + case "供应商" -> 34; + default -> gradeId; + }; + } + loingUser.setGradeId(gradeId); - @ApiOperation("批量删除商户入驻申请") - @DeleteMapping("/batch") - public ApiResult removeBatch(@RequestBody List ids) { - if (merchantApplyService.removeByIds(ids)) { - return success("删除成功"); + // TODO 创建商户账号 + requestUtil.setAccessToken(JwtUtil.getAccessToken(request)); + requestUtil.setTenantId(getTenantId().toString()); + merchantAccount.setRealName(merchantApply.getRealName()); + requestUtil.saveUserByPhone(merchantAccount); + requestUtil.updateUser(loingUser); + // TODO 更新用户表的商户ID + requestUtil.updateUserMerchantId(user); + + } + // TODO 驳回 + + if (merchantApplyService.updateById(merchantApply)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除商户入驻申请") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (merchantApplyService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加商户入驻申请") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (merchantApplyService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改商户入驻申请") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(merchantApplyService, "apply_id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除商户入驻申请") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (merchantApplyService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); } - return fail("删除失败"); - } } diff --git a/src/main/java/com/gxwebsoft/shop/controller/OrderController.java b/src/main/java/com/gxwebsoft/shop/controller/OrderController.java index 85e70f5..b0e4902 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/OrderController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/OrderController.java @@ -2,25 +2,22 @@ package com.gxwebsoft.shop.controller; import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.gxwebsoft.cms.entity.Ad; import com.gxwebsoft.common.core.exception.BusinessException; import com.gxwebsoft.common.core.security.JwtUtil; import com.gxwebsoft.common.core.utils.CommonUtil; import com.gxwebsoft.common.core.utils.RequestUtil; import com.gxwebsoft.common.core.web.BaseController; import com.gxwebsoft.common.system.entity.Role; -import com.gxwebsoft.shop.entity.Cart; -import com.gxwebsoft.shop.entity.OrderGoods; -import com.gxwebsoft.shop.entity.OrderInfo; -import com.gxwebsoft.shop.service.CartService; -import com.gxwebsoft.shop.service.OrderGoodsService; -import com.gxwebsoft.shop.service.OrderInfoService; -import com.gxwebsoft.shop.service.OrderService; -import com.gxwebsoft.shop.entity.Order; +import com.gxwebsoft.shop.entity.*; +import com.gxwebsoft.shop.service.*; import com.gxwebsoft.shop.param.OrderParam; import com.gxwebsoft.common.core.web.ApiResult; import com.gxwebsoft.common.core.web.PageResult; @@ -28,15 +25,21 @@ import com.gxwebsoft.common.core.web.BatchParam; import com.gxwebsoft.common.system.entity.User; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import me.chanjar.weixin.common.error.WxErrorException; +import org.springframework.beans.factory.annotation.Autowired; +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.HttpServletRequest; +import java.io.IOException; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; +import static com.gxwebsoft.shop.consts.OrderPayType.*; + /** * 订单控制器 * @@ -47,310 +50,392 @@ import java.util.stream.Collectors; @RestController @RequestMapping("/api/shop/order") public class OrderController extends BaseController { - @Resource - private OrderService orderService; - @Resource - private OrderInfoService orderInfoService; - @Resource - private OrderGoodsService orderGoodsService; - @Resource - private CartService cartService; - @Resource - private RequestUtil requestUtil; + @Resource + private OrderService orderService; + @Resource + private OrderInfoService orderInfoService; + @Resource + private OrderGoodsService orderGoodsService; + @Resource + private CartService cartService; + @Resource + private RequestUtil requestUtil; + @Resource + private ExpressService expressService; + @Resource + private OrderDeliveryService orderDeliveryService; + @Autowired + private WeChatController weChatController; + @Autowired + private MerchantService merchantService; - @ApiOperation("分页查询订单") - @GetMapping("/page") - public ApiResult> page(OrderParam param) { - // 使用关联查询 - return success(orderService.pageRel(param)); - } + @Value("${config.upload-path}") + private String uploadPath; - @ApiOperation("查询全部订单") - @GetMapping() - public ApiResult> list(OrderParam param) { - // 使用关联查询 - return success(orderService.listRel(param)); - } - - @PreAuthorize("hasAuthority('shop:order:list')") - @ApiOperation("根据id查询订单") - @GetMapping("/{id}") - public ApiResult get(@PathVariable("id") Integer id) { - // 使用关联查询 - return success(orderService.getByIdRel(id)); - } - - @ApiOperation("根据orderNo查询订单") - @GetMapping("/getByOrderNo/{orderNo}") - public ApiResult getByOrderNo(@PathVariable("orderNo") String orderNo){ - final User loginUser = getLoginUser(); - if(loginUser == null){ - return fail("请先登录",null); + @ApiOperation("分页查询订单") + @GetMapping("/page") + public ApiResult> page(OrderParam param) { + // 使用关联查询 + if (getLoginUser() != null) { + param.setLoginUser(getLoginUser()); + } + return success(orderService.pageRel(param)); } - final Order order = orderService.getByOutTradeNo(orderNo); - if(order != null){ - final List orderInfoList = orderInfoService.list(new LambdaQueryWrapper().eq(OrderInfo::getOrderId, order.getOrderId())); - order.setOrderInfo(orderInfoList); - } - return success(order); - } - - - @PreAuthorize("hasAuthority('shop:order:verification')") - @ApiOperation("根据orderNo核销订单") - @GetMapping("/verification/{orderNo}") - public ApiResult verification(@PathVariable("orderNo") String orderNo){ - final User loginUser = getLoginUser(); - if(loginUser == null){ - return fail("请先登录",null); + @ApiOperation("查询全部订单") + @GetMapping() + public ApiResult> list(OrderParam param) { + // 使用关联查询 + return success(orderService.listRel(param)); } - final Set collect = loginUser.getRoles().stream().map(Role::getRoleCode).collect(Collectors.toSet()); - final boolean merchant = Arrays.asList(collect).contains("merchant"); - final boolean merchantClerk = Arrays.asList(collect).contains("merchantClerk"); - - if(merchant || merchantClerk){ - System.out.println("merchant = " + merchant); - System.out.println("merchantClerk = " + merchantClerk); - final Order order = orderService.getByOutTradeNo(orderNo); - if(order != null){ - final List orderInfoList = orderInfoService.list(new LambdaQueryWrapper().eq(OrderInfo::getOrderId, order.getOrderId())); - order.setOrderInfo(orderInfoList); - } - return success(order); - } - return fail("核销失败",null); - } - - @ApiOperation("下单") - @PostMapping() - public ApiResult save(@RequestBody Order order, HttpServletRequest request) { - String access_token = JwtUtil.getAccessToken(request); - // 记录当前登录用户id - User loginUser = getLoginUser(); - if (loginUser == null) { - return fail("请先登录"); - } - // 微信openid(必填) - if (StrUtil.isBlank(loginUser.getOpenid())) { - return fail("微信openid(必填)"); - } - // 商品描述(必填) - if (StrUtil.isBlank(order.getComments())) { - return fail("商品描述(必填)"); - } - // 判断场地是否被抢占 - if (order.getType().equals(1)) { - if (ObjectUtil.isNotEmpty(order.getOrderInfo())) { - order.getOrderInfo().forEach(d -> { - if (orderInfoService.count(new LambdaUpdateWrapper() - .eq(OrderInfo::getPayStatus,1) - .eq(OrderInfo::getOrderCode,d.getOrderCode())) > 0) { - order.setScene(1234); + @PreAuthorize("hasAuthority('shop:order:list')") + @ApiOperation("根据id查询订单") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + Order order = orderService.getByIdRel(id); + if (getLoginUser() != null) { + for (OrderGoods orderGoods : order.getGoodsList()) { + Goods goods = orderGoods.getGoods(); + if (getLoginUser().getGradeId().equals(33)) { + if (goods.getDealerGift()) goods.setShowGift(true); + } + // 会员店 + if (getLoginUser().getGradeId().equals(31)) { + if (goods.getPriceGift()) goods.setShowGift(true); + } } - }); - if(order.getScene() != null && order.getScene().equals(1234)){ - return fail("场地不存在"); - } - } - } - // 微信支付(商品金额不能为0) - if (order.getPayType().equals(1)) { - if (order.getTotalPrice().compareTo(BigDecimal.ZERO) == 0) { - return fail("商品金额不能为0"); - } + } + if (order.getType().equals(0)) { + if (order.getDeliveryType().equals(0)) { + OrderDelivery orderDelivery = orderDeliveryService.getByOrderId(order.getOrderId()); + if (orderDelivery != null) { + orderDelivery.setExpress(expressService.getById(orderDelivery.getExpressId())); + order.setOrderDelivery(orderDelivery); + } + } else if (order.getDeliveryType().equals(1) && order.getSelfTakeMerchantId() != null) { + Merchant merchant = merchantService.getById(order.getSelfTakeMerchantId()); + order.setMerchant(merchant); + } + }else if (order.getType().equals(1)) { + Merchant merchant = merchantService.getById(order.getMerchantId()); + order.setMerchant(merchant); + } + return success(order); } - // 已下过订单 - if(order.getOrderId() != null){ - Order order1 = orderService.getByIdRel(order.getOrderId()); - order1.setPayType(order.getPayType()); - order1.setOpenid(loginUser.getOpenid()); - order1.setOrderNo(Long.toString(IdUtil.getSnowflakeNextId())); - order1.setAccessToken(access_token); - order1.setLoginUser(loginUser); - // 调起支付 - return onPay(order1); - } - - // 创建订单 - long timeMillis = System.currentTimeMillis(); - long orderNo = IdUtil.getSnowflakeNextId(); - order.setOrderNo(Long.toString(orderNo)); - order.setUserId(loginUser.getUserId()); - order.setOpenid(loginUser.getOpenid()); - order.setRealName(loginUser.getRealName()); - order.setPhone(loginUser.getPhone()); - order.setUserId(loginUser.getUserId()); - order.setLoginUser(loginUser); - order.setAccessToken(access_token); - order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.MINUTE, 1)); - if (order.getOrderInfo() != null) { - order.setTotalNum(order.getOrderInfo().size()); - } - if (order.getGoodsList() != null) { - order.setTotalNum(order.getGoodsList().size()); - } - - if (orderService.save(order)) { - // 商城订单 - if (ObjectUtil.isNotEmpty(order.getGoodsList())) { - order.getGoodsList().forEach(d -> { - d.setOrderId(order.getOrderId()); - d.setTimeFlag(timeMillis); - d.setVersion(10); - d.setDateTime(DateUtil.date()); - d.setUserId(getLoginUser().getUserId()); - d.setExpirationTime(order.getExpirationTime()); - }); - orderGoodsService.saveBatch(order.getGoodsList()); - } - // 预定订单 - if (ObjectUtil.isNotEmpty(order.getOrderInfo())) { - if (ObjectUtil.isNotEmpty(order.getOrderInfo())) { - order.getOrderInfo().forEach(d -> { - d.setOrderId(order.getOrderId()); - d.setTimeFlag(timeMillis); - d.setVersion(10); - d.setUserId(getLoginUser().getUserId()); - d.setDateTime(d.getDateTime()); - d.setExpirationTime(order.getExpirationTime()); - d.setTenantId(order.getTenantId()); - }); - orderInfoService.saveBatch(order.getOrderInfo()); + @ApiOperation("根据orderNo查询订单") + @GetMapping("/getByOrderNo/{orderNo}") + public ApiResult getByOrderNo(@PathVariable("orderNo") String orderNo) { + final User loginUser = getLoginUser(); + if (loginUser == null) { + return fail("请先登录", null); } - } - // 会员卡订单 -// if (order.getType().equals(2)) { -// // 会员卡信息 -// final Card card = cardService.getByIdRel(Integer.valueOf(order.getCardId())); -// final UserCard userCard = new UserCard(); -// userCard.setPhone(loginUser.getPhone()); -// userCard.setSid(card.getMerchantIds()); -// userCard.setCardNum(CommonUtil.createCardNo()); -// userCard.setName(card.getCardName()); -// userCard.setUsername(loginUser.getRealName()); -// userCard.setPhone(loginUser.getPhone()); -// userCard.setPrice(card.getPrice()); -// userCard.setComments(card.getCardDesc()); -// userCard.setInfo(card.getComments()); -// userCard.setUid(loginUser.getUserId()); -// userCard.setRemainingMoney(card.getPrice()); -// userCard.setVid(0); -// userCard.setAid(0); -// userCard.setCode(CommonUtil.randomUUID8()); -// userCard.setDiscount(card.getDiscount()); -// userCard.setNumber(1); -// userCard.setNum(card.getNumber()); -// userCard.setMonth(card.getMonth()); -// userCard.setPayType(1); -// userCard.setType(card.getType()); -// userCard.setTenantId(card.getTenantId()); -// final long epochMilli = DateUtil.toInstant(DateUtil.offset(DateUtil.date(), DateField.MONTH, card.getMonth())).toEpochMilli(); -// userCard.setExpireTime(epochMilli/1000); -// userCardService.save(userCard); -// order.setCardId(userCard.getId()); -// } - // 调起支付 - return onPay(order); - } - return fail("下单失败"); - } - - private ApiResult onPay(Order order) { - // TODO 余额支付 - if (order.getPayType().equals(0)) { - order.setAccessToken(order.getAccessToken()); - final User loginUser = order.getLoginUser(); - if (loginUser.getBalance().compareTo(order.getTotalPrice()) < 0) { - throw new BusinessException("余额不足"); - } - // 清空购物车 - final Set cartIds = order.getGoodsList().stream().map(OrderGoods::getGoodsId).collect(Collectors.toSet()); - cartService.remove(new LambdaQueryWrapper().eq(Cart::getUserId,order.getUserId()).in(Cart::getGoodsId,cartIds)); - // 外卖订单 - if(!order.getMerchantId().equals(0)){ - cartService.remove(new LambdaQueryWrapper().eq(Cart::getUserId,order.getUserId()).eq(Cart::getType,1)); - } - return success("下单成功", requestUtil.balancePay(order)); + final Order order = orderService.getByOutTradeNo(orderNo); + if (order != null) { + final List orderInfoList = orderInfoService.list(new LambdaQueryWrapper().eq(OrderInfo::getOrderId, order.getOrderId())); + order.setOrderInfo(orderInfoList); + } + return success(order); } - // TODO 微信统一下单接口 - if (order.getPayType().equals(1)) { - // 清空购物车 - final Set cartIds = order.getGoodsList().stream().map(OrderGoods::getGoodsId).collect(Collectors.toSet()); - cartService.remove(new LambdaQueryWrapper().eq(Cart::getUserId,order.getUserId()).in(Cart::getGoodsId,cartIds)); - // 外卖订单 - if(!order.getMerchantId().equals(0)){ - cartService.remove(new LambdaQueryWrapper().eq(Cart::getUserId,order.getUserId()).eq(Cart::getType,1)); - } - return success("下单成功", orderService.createWxOrder(order)); + + @PreAuthorize("hasAuthority('shop:order:verification')") + @ApiOperation("根据orderNo核销订单") + @GetMapping("/verification/{orderNo}") + public ApiResult verification(@PathVariable("orderNo") String orderNo, HttpServletRequest request) { + final User loginUser = getLoginUser(); + if (loginUser == null) { + return fail("请先登录", null); + } + + final Set collect = loginUser.getRoles().stream().map(Role::getRoleCode).collect(Collectors.toSet()); + final boolean merchant = Arrays.asList(collect).contains("merchant"); + final boolean merchantClerk = Arrays.asList(collect).contains("merchantClerk"); + + if (merchant || merchantClerk) { + System.out.println("merchant = " + merchant); + System.out.println("merchantClerk = " + merchantClerk); + final Order order = orderService.getByOutTradeNo(orderNo); + if (order != null) { + final List orderInfoList = orderInfoService.list(new LambdaQueryWrapper().eq(OrderInfo::getOrderId, order.getOrderId())); + order.setOrderInfo(orderInfoList); + } + return success(order); + } + return fail("核销失败", null); } -// // TODO 微信Native支付 -// if(order.getPayType().equals(102)){ -// order.setAccessToken(access_token); -// order.setLoginUser(loginUser); -// return success("下单成功", orderService.payByWxNative(order)); -// } - - // TODO 会员卡支付 -// if(order.getPayType().equals(2)){ -// order.setAccessToken(order.getAccessToken()); -// System.out.println("getAccessToken = " + order.getAccessToken()); -// return success("下单成功", orderService.payByUserCard(order)); -// } - return fail("支付失败"); - } - - @ApiOperation("修改订单") - @PutMapping() - public ApiResult update(@RequestBody Order order) { - if(order.getOrderStatus().equals(2)){ - order.setExpirationTime(DateUtil.date()); - orderInfoService.update(new LambdaUpdateWrapper().eq(OrderInfo::getOrderId,order.getOrderId()).set(OrderInfo::getExpirationTime,DateUtil.date())); + @ApiOperation("代付") + @PostMapping("/friend-pay") + public ApiResult friendPay(@RequestBody Order orderTmp, HttpServletRequest request) throws IOException, WxErrorException { + Order order = orderService.getById(orderTmp.getOrderId()); + String access_token = JwtUtil.getAccessToken(request); + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser == null) { + return fail("请先登录"); + } + // 微信openid(必填) + if (StrUtil.isBlank(loginUser.getOpenid())) { + return fail("微信openid(必填)"); + } + // 微信支付(商品金额不能为0) + if (order.getPayType().equals(PAY_TYPE_WECHAT)) { + if (order.getTotalPrice().compareTo(BigDecimal.ZERO) == 0) { + return fail("商品金额不能为0"); + } + } + order.setFriendPayType(orderTmp.getFriendPayType()); + order.setOpenid(loginUser.getOpenid()); + order.setOrderNo(Long.toString(IdUtil.getSnowflakeNextId())); + order.setAccessToken(access_token); + order.setPayUserId(loginUser.getUserId()); + orderService.updateById(order); + order.setLoginUser(loginUser); + // 调起支付 + order.setNotClearData(true); + return onPay(request, order); } - if (orderService.updateById(order)) { - return success("操作成功"); - } - return fail("操作失败"); - } - @ApiOperation("删除订单") - @DeleteMapping("/{id}") - public ApiResult remove(@PathVariable("id") Integer id) { - if (orderService.removeById(id)) { - return success("删除成功"); - } - return fail("删除失败"); - } + @ApiOperation("下单") + @PostMapping() + public ApiResult save(@RequestBody Order order, HttpServletRequest request) throws IOException, WxErrorException { + String access_token = JwtUtil.getAccessToken(request); + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser == null) { + return fail("请先登录"); + } + // 微信openid(必填) + if (StrUtil.isBlank(loginUser.getOpenid())) { + return fail("微信openid(必填)"); + } + // 商品描述(必填) + if (StrUtil.isBlank(order.getComments())) { + return fail("商品描述(必填)"); + } + // 微信支付(商品金额不能为0) + if (order.getPayType().equals(PAY_TYPE_WECHAT)) { + if (order.getTotalPrice().compareTo(BigDecimal.ZERO) == 0) { + return fail("商品金额不能为0"); + } + } - @ApiOperation("批量添加订单") - @PostMapping("/batch") - public ApiResult saveBatch(@RequestBody List list) { - if (orderService.saveBatch(list)) { - return success("添加成功"); - } - return fail("添加失败"); - } + // 已下过订单 + if (order.getOrderId() != null) { + Order order1 = orderService.getByIdRel(order.getOrderId()); + order1.setPayType(order.getPayType()); + order1.setOpenid(loginUser.getOpenid()); + order1.setOrderNo(Long.toString(IdUtil.getSnowflakeNextId())); + order1.setAccessToken(access_token); + order1.setLoginUser(loginUser); + order1.setPayUserId(loginUser.getUserId()); + // 调起支付 + return onPay(request, order1); + } - @ApiOperation("批量修改订单") - @PutMapping("/batch") - public ApiResult removeBatch(@RequestBody BatchParam batchParam) { - if (batchParam.update(orderService, "order_id")) { - return success("修改成功"); - } - return fail("修改失败"); - } + // 创建订单 + long timeMillis = System.currentTimeMillis(); + long orderNo = IdUtil.getSnowflakeNextId(); + String name = loginUser.getRealName(); + String phone = loginUser.getPhone(); + String address = ""; + if (order.getRealName() != null) { + name = order.getRealName(); + } + if (order.getPhone() != null) { + phone = order.getPhone(); + } + if (order.getAddress() != null) { + address = order.getAddress(); + } + order.setOrderNo(Long.toString(orderNo)); + order.setUserId(loginUser.getUserId()); + order.setOpenid(loginUser.getOpenid()); + order.setRealName(name); + order.setPhone(phone); + order.setAddress(address); + order.setUserId(loginUser.getUserId()); + order.setLoginUser(loginUser); + order.setPayUserId(loginUser.getUserId()); + order.setAccessToken(access_token); + order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.MINUTE, 1)); + if (order.getOrderInfo() != null) { + order.setTotalNum(order.getOrderInfo().size()); + } + if (order.getGoodsList() != null) { + order.setTotalNum(order.getGoodsList().size()); + } + if (order.getDeliveryType().equals(1)) { + order.setSelfTakeCode(RandomUtil.randomString(4)); + } - @ApiOperation("批量删除订单") - @DeleteMapping("/batch") - public ApiResult removeBatch(@RequestBody List ids) { - if (orderService.removeByIds(ids)) { - return success("删除成功"); + if (orderService.save(order)) { + // 商城订单 + if (ObjectUtil.isNotEmpty(order.getGoodsList())) { + order.getGoodsList().forEach(d -> { + d.setOrderId(order.getOrderId()); + d.setTimeFlag(timeMillis); + d.setVersion(10); + d.setDateTime(DateUtil.date()); + d.setUserId(getLoginUser().getUserId()); + d.setExpirationTime(order.getExpirationTime()); + }); + orderGoodsService.saveBatch(order.getGoodsList()); + } + // 预定订单 + if (ObjectUtil.isNotEmpty(order.getOrderInfo())) { + if (ObjectUtil.isNotEmpty(order.getOrderInfo())) { + order.getOrderInfo().forEach(d -> { + d.setOrderId(order.getOrderId()); + d.setTimeFlag(timeMillis); + d.setVersion(10); + d.setUserId(getLoginUser().getUserId()); + d.setDateTime(d.getDateTime()); + d.setExpirationTime(order.getExpirationTime()); + d.setTenantId(order.getTenantId()); + }); + orderInfoService.saveBatch(order.getOrderInfo()); + } + } + // 调起支付 + return onPay(request, order); + } + return fail("下单失败"); + } + + private ApiResult onPay(HttpServletRequest request, Order order) throws IOException, WxErrorException { + // 余额支付 + if (order.getPayType().equals(PAY_TYPE_BALANCE)) { + order.setAccessToken(order.getAccessToken()); + final User loginUser = order.getLoginUser(); + if (loginUser.getBalance().compareTo(order.getTotalPrice()) < 0) { + throw new BusinessException("余额不足"); + } + if (order.getNotClearData() == null) { + // 清空购物车 + final Set cartIds = order.getGoodsList().stream().map(OrderGoods::getGoodsId).collect(Collectors.toSet()); + cartService.remove(new LambdaQueryWrapper().eq(Cart::getUserId, order.getUserId()).in(Cart::getGoodsId, cartIds)); + // 外卖订单 + if (!order.getMerchantId().equals(0)) { + cartService.remove(new LambdaQueryWrapper().eq(Cart::getUserId, order.getUserId()).eq(Cart::getType, 1)); + } + } + return success("下单成功", requestUtil.balancePay(order)); + } + + // 微信统一下单接口 + if (order.getPayType().equals(PAY_TYPE_WECHAT)) { + // 清空购物车 + if (order.getNotClearData() == null) { + final Set cartIds = order.getGoodsList().stream().map(OrderGoods::getGoodsId).collect(Collectors.toSet()); + cartService.remove(new LambdaQueryWrapper().eq(Cart::getUserId, order.getUserId()).in(Cart::getGoodsId, cartIds)); + // 外卖订单 + if (!order.getMerchantId().equals(0)) { + cartService.remove(new LambdaQueryWrapper().eq(Cart::getUserId, order.getUserId()).eq(Cart::getType, 1)); + } + } + return success("下单成功", orderService.createWxOrder(order)); + } + + // 代付 + if (order.getPayType().equals(PAY_TYPE_FRIEND)) { + if (order.getFriendPayType() != null) { + if (order.getFriendPayType().equals(PAY_TYPE_BALANCE)) { + order.setAccessToken(order.getAccessToken()); + final User loginUser = order.getLoginUser(); + if (loginUser.getBalance().compareTo(order.getTotalPrice()) < 0) { + throw new BusinessException("余额不足"); + } + return success("下单成功", requestUtil.balancePay(order)); + } + if (order.getFriendPayType().equals(PAY_TYPE_WECHAT)) { + return success("下单成功", orderService.createWxOrder(order)); + } + } + String filepath = uploadPath + "qrcode/" + getTenantId(); + if (!FileUtil.exist(filepath)) FileUtil.mkdir(filepath); + String filename = "/friendPay_" + order.getOrderId() + ".png"; + weChatController.makeQr(request, filepath + filename, "orderId=" + order.getOrderId(), "package/order/friendPay"); + return success("下单成功", "file/qrcode/" + getTenantId() + filename); + } + return fail("支付失败"); + } + + @ApiOperation("自提") + @PostMapping("/self-take") + public ApiResult selfTake(@RequestBody Order order, HttpServletRequest request) { + String access_token = JwtUtil.getAccessToken(request); + Order order1 = orderService.getById(order.getOrderId()); +// if (!order1.getSelfTakeCode().equals(order.getSelfTakeCode())) return fail("自提码不正确"); + if (order1.getOrderStatus().equals(1)) return fail("订单已完成"); + order1.setOrderStatus(1); + orderService.updateById(order1); + orderService.settle(access_token, getTenantId().toString(), order1); + return success("提货成功"); + } + + @ApiOperation("外卖确认收货") + @PostMapping("/out-take-confirm") + public ApiResult outTakeConfirm(@RequestBody Order order, HttpServletRequest request) { + String access_token = JwtUtil.getAccessToken(request); + Order order1 = orderService.getById(order.getOrderId()); + if (order1.getOrderStatus().equals(1)) return fail("订单已完成"); + order1.setOrderStatus(1); + order1.setHasTakeGift(order.getHasTakeGift()); + orderService.updateById(order1); + orderService.settle(access_token, getTenantId().toString(), order1); + return success("外卖确认收货"); + } + + @ApiOperation("修改订单") + @PutMapping() + public ApiResult update(@RequestBody Order order) { + if (order.getOrderStatus().equals(2)) { + order.setExpirationTime(DateUtil.date()); + orderInfoService.update(new LambdaUpdateWrapper().eq(OrderInfo::getOrderId, order.getOrderId()).set(OrderInfo::getExpirationTime, DateUtil.date())); + } + if (orderService.updateById(order)) { + return success("操作成功"); + } + return fail("操作失败"); + } + + @ApiOperation("删除订单") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (orderService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加订单") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (orderService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改订单") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(orderService, "order_id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除订单") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (orderService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); } - return fail("删除失败"); - } } diff --git a/src/main/java/com/gxwebsoft/shop/controller/OrderDeliveryController.java b/src/main/java/com/gxwebsoft/shop/controller/OrderDeliveryController.java index b5be2e2..853a6b4 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/OrderDeliveryController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/OrderDeliveryController.java @@ -1,10 +1,14 @@ package com.gxwebsoft.shop.controller; import cn.hutool.core.date.DateUtil; +import cn.hutool.http.HttpUtil; +import com.google.gson.JsonObject; +import com.gxwebsoft.common.core.security.JwtUtil; +import com.gxwebsoft.common.core.utils.JSONUtil; import com.gxwebsoft.common.core.web.BaseController; -import com.gxwebsoft.shop.entity.Order; -import com.gxwebsoft.shop.service.OrderDeliveryService; -import com.gxwebsoft.shop.entity.OrderDelivery; +import com.gxwebsoft.shop.entity.*; +import com.gxwebsoft.shop.param.GoodsStockInMerchantParam; +import com.gxwebsoft.shop.service.*; import com.gxwebsoft.shop.param.OrderDeliveryParam; import com.gxwebsoft.common.core.web.ApiResult; import com.gxwebsoft.common.core.web.PageResult; @@ -12,7 +16,10 @@ 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.OrderService; +import com.kuaidi100.sdk.pojo.HttpResult; +import com.kuaidi100.sdk.request.BOrderReq; +import com.kuaidi100.sdk.response.BOrderResp; +import com.kuaidi100.sdk.response.SubscribeResp; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.security.access.prepost.PreAuthorize; @@ -20,7 +27,11 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * 发货单控制器 @@ -36,6 +47,16 @@ public class OrderDeliveryController extends BaseController { private OrderDeliveryService orderDeliveryService; @Resource private OrderService orderService; + @Resource + private KuaiDi100 kuaiDi100; + @Resource + private ExpressService expressService; + @Resource + private OrderGoodsService orderGoodsService; + @Resource + private GoodsStockInMerchantService goodsStockInMerchantService; + @Resource + private MerchantService merchantService; @ApiOperation("分页查询发货单") @GetMapping("/page") @@ -44,6 +65,18 @@ public class OrderDeliveryController extends BaseController { return success(orderDeliveryService.pageRel(param)); } + @ApiOperation("发货回调") + @PostMapping("/notify") + @GetMapping("/notify") + public SubscribeResp notify(@RequestBody Map data) { + System.out.println("快递100回调:" + data); + SubscribeResp subscribeResp = new SubscribeResp(); + subscribeResp.setResult(Boolean.TRUE); + subscribeResp.setReturnCode("200"); + subscribeResp.setMessage("成功"); + return subscribeResp; + } + @ApiOperation("查询全部发货单") @GetMapping() public ApiResult> list(OrderDeliveryParam param) { @@ -63,13 +96,56 @@ public class OrderDeliveryController extends BaseController { @PreAuthorize("hasAuthority('shop:orderDelivery:list')") @ApiOperation("添加发货单") @PostMapping() - public ApiResult save(@RequestBody OrderDelivery orderDelivery) { - if (orderDeliveryService.save(orderDelivery)) { - final Order order = orderService.getById(orderDelivery.getOrderId()); - order.setDeliveryStatus(20); - order.setDeliveryTime(DateUtil.date()); - orderService.updateById(order); - return success("操作成功"); + public ApiResult save(@RequestBody OrderDelivery orderDelivery, HttpServletRequest request) throws Exception { + String access_token = JwtUtil.getAccessToken(request); + String tenantId = getTenantId().toString(); + Order order = orderService.getById(orderDelivery.getOrderId()); + Merchant merchant = null; + // 根据最近的库存分配发货 + List orderGoodsList = orderGoodsService.listByOrderId(orderDelivery.getOrderId()); + List goodsStockInMerchantList = + goodsStockInMerchantService.canExpressList(orderGoodsList.get(0).getGoodsId(), orderGoodsList.get(0).getTotalNum(), order.getAddressLat(), order.getAddressLng()); + if (goodsStockInMerchantList.isEmpty()) return fail("暂无可发货店铺"); + for (OrderGoods orderGoods : orderGoodsList) { + if (!goodsStockInMerchantList.isEmpty()) { + GoodsStockInMerchant usable = goodsStockInMerchantList.get(0); + GoodsStockInMerchant goodsStockInMerchant = goodsStockInMerchantService.check(usable.getMerchantId(), orderGoods.getGoodsId(), orderGoods.getSkuId()); + if (goodsStockInMerchant == null || goodsStockInMerchant.getStock() < orderGoods.getTotalNum()) + return fail("库存不足"); + } + } + merchant = merchantService.getById(goodsStockInMerchantList.get(0).getMerchantId()); + if (merchant != null) { + // 商家发货 + Express express = expressService.getByIdRel(orderDelivery.getExpressId()); + BOrderReq bOrderReq = new BOrderReq(); + bOrderReq.setKuaidicom(express.getKuaidi100Code()); + bOrderReq.setSendManName(merchant.getMerchantName()); + bOrderReq.setSendManMobile(merchant.getPhone()); + bOrderReq.setSendManPrintAddr(merchant.getProvince() + merchant.getCity() + merchant.getRegion() + merchant.getAddress()); + bOrderReq.setRecManName(order.getRealName()); + bOrderReq.setRecManMobile(order.getPhone()); + bOrderReq.setRecManPrintAddr(order.getAddress()); + bOrderReq.setCallBackUrl("https://modules.gxwebsoft.com/api/shop/order-delivery/notify"); + HttpResult res = kuaiDi100.border(bOrderReq); +// System.out.println("res.getBody():" + res.getBody()); + if (res.getStatus() != 200) return fail("快递100接口异常"); + KuaiDi100Resp kuaiDi100Resp = JSONUtil.parseObject(res.getBody(), KuaiDi100Resp.class); + if (kuaiDi100Resp == null) return fail("快递100接口异常"); + if (!kuaiDi100Resp.getResult()) return fail(kuaiDi100Resp.getMessage()); + Map bOrderData = (Map) kuaiDi100Resp.getData(); +// System.out.println("kuaidinum:" + bOrderData.get("kuaidinum")); + orderDelivery.setExpressNo((String) bOrderData.get("kuaidinum")); + if (orderDeliveryService.save(orderDelivery)) { + order.setExpressMerchantId(merchant.getMerchantId()); + order.setExpressMerchantName(merchant.getMerchantName()); + order.setDeliveryStatus(20); + order.setDeliveryTime(DateUtil.date()); + orderService.updateById(order); + // 结算 + orderService.settle(access_token, tenantId, order); + return success("操作成功"); + } } return fail("操作失败"); } @@ -83,6 +159,7 @@ public class OrderDeliveryController extends BaseController { } return fail("修改失败"); } + @PreAuthorize("hasAuthority('shop:orderDelivery:list')") @ApiOperation("删除发货单") @DeleteMapping("/{id}") @@ -112,6 +189,7 @@ public class OrderDeliveryController extends BaseController { } return fail("修改失败"); } + @PreAuthorize("hasAuthority('shop:orderDelivery:list')") @ApiOperation("批量删除发货单") @DeleteMapping("/batch") diff --git a/src/main/java/com/gxwebsoft/shop/controller/SplashController.java b/src/main/java/com/gxwebsoft/shop/controller/SplashController.java new file mode 100644 index 0000000..675bf3c --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/controller/SplashController.java @@ -0,0 +1,115 @@ +package com.gxwebsoft.shop.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.shop.service.SplashService; +import com.gxwebsoft.shop.entity.Splash; +import com.gxwebsoft.shop.param.SplashParam; +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.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-09-30 22:07:41 + */ +@Api(tags = "开屏广告管理") +@RestController +@RequestMapping("/api/shop/splash") +public class SplashController extends BaseController { + @Resource + private SplashService splashService; + + @ApiOperation("分页查询开屏广告") + @GetMapping("/page") + public ApiResult> page(SplashParam param) { + // 使用关联查询 + return success(splashService.pageRel(param)); + } + + @ApiOperation("查询全部开屏广告") + @GetMapping() + public ApiResult> list(SplashParam param) { + // 使用关联查询 + return success(splashService.listRel(param)); + } + + @PreAuthorize("hasAuthority('shop:splash:list')") + @ApiOperation("根据id查询开屏广告") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(splashService.getByIdRel(id)); + } + + @ApiOperation("添加开屏广告") + @PostMapping() + public ApiResult save(@RequestBody Splash splash) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + splash.setUserId(loginUser.getUserId()); + } + if (splashService.save(splash)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("修改开屏广告") + @PutMapping() + public ApiResult update(@RequestBody Splash splash) { + if (splashService.updateById(splash)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除开屏广告") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (splashService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加开屏广告") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (splashService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改开屏广告") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(splashService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除开屏广告") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (splashService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/controller/SwiperController.java b/src/main/java/com/gxwebsoft/shop/controller/SwiperController.java new file mode 100644 index 0000000..aa422a5 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/controller/SwiperController.java @@ -0,0 +1,115 @@ +package com.gxwebsoft.shop.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.shop.service.SwiperService; +import com.gxwebsoft.shop.entity.Swiper; +import com.gxwebsoft.shop.param.SwiperParam; +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.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-09-30 22:07:41 + */ +@Api(tags = "轮播图管理") +@RestController +@RequestMapping("/api/shop/swiper") +public class SwiperController extends BaseController { + @Resource + private SwiperService swiperService; + + @ApiOperation("分页查询轮播图") + @GetMapping("/page") + public ApiResult> page(SwiperParam param) { + // 使用关联查询 + return success(swiperService.pageRel(param)); + } + + @ApiOperation("查询全部轮播图") + @GetMapping() + public ApiResult> list(SwiperParam param) { + // 使用关联查询 + return success(swiperService.listRel(param)); + } + + @PreAuthorize("hasAuthority('shop:swiper:list')") + @ApiOperation("根据id查询轮播图") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(swiperService.getByIdRel(id)); + } + + @ApiOperation("添加轮播图") + @PostMapping() + public ApiResult save(@RequestBody Swiper swiper) { + // 记录当前登录用户id + User loginUser = getLoginUser(); + if (loginUser != null) { + swiper.setUserId(loginUser.getUserId()); + } + if (swiperService.save(swiper)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("修改轮播图") + @PutMapping() + public ApiResult update(@RequestBody Swiper swiper) { + if (swiperService.updateById(swiper)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("删除轮播图") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (swiperService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @ApiOperation("批量添加轮播图") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (swiperService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @ApiOperation("批量修改轮播图") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(swiperService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @ApiOperation("批量删除轮播图") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (swiperService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/controller/UserAddressController.java b/src/main/java/com/gxwebsoft/shop/controller/UserAddressController.java index 6b1e077..66c9907 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/UserAddressController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/UserAddressController.java @@ -60,7 +60,10 @@ public class UserAddressController extends BaseController { // 记录当前登录用户id User loginUser = getLoginUser(); if (loginUser != null) { - userAddress.setUserId(loginUser.getUserId()); + userAddress.setUserId(loginUser.getUserId()); + } + if (userAddress.getIsDefault() != null && userAddress.getIsDefault()) { + userAddressService.clearDefault(userAddress.getUserId()); } if (userAddressService.save(userAddress)) { return success("添加成功"); @@ -72,7 +75,7 @@ public class UserAddressController extends BaseController { @PutMapping() public ApiResult update(@RequestBody UserAddress userAddress) { if (userAddress.getIsDefault() != null && userAddress.getIsDefault().equals(true)) { - final boolean update = userAddressService.update(new LambdaUpdateWrapper().eq(UserAddress::getUserId, getLoginUserId()).set(UserAddress::getIsDefault, 0)); + userAddressService.clearDefault(userAddress.getUserId()); } if (userAddressService.updateById(userAddress)) { return success("修改成功"); diff --git a/src/main/java/com/gxwebsoft/shop/controller/UserCollectionController.java b/src/main/java/com/gxwebsoft/shop/controller/UserCollectionController.java index 1218ec9..aefa4da 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/UserCollectionController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/UserCollectionController.java @@ -22,7 +22,7 @@ import java.util.List; * 我的收藏控制器 * * @author 科技小王子 - * @since 2024-04-28 18:17:37 + * @since 2024-10-03 01:51:46 */ @Api(tags = "我的收藏管理") @RestController @@ -31,6 +31,13 @@ public class UserCollectionController extends BaseController { @Resource private UserCollectionService userCollectionService; + @ApiOperation("检查收藏") + @PostMapping("/has-collect") + public ApiResult check(@RequestBody UserCollection userCollection) { + UserCollection check = userCollectionService.check(getLoginUserId(), userCollection.getType(), userCollection.getTid()); + return success(check != null); + } + @ApiOperation("分页查询我的收藏") @GetMapping("/page") public ApiResult> page(UserCollectionParam param) { @@ -40,8 +47,10 @@ public class UserCollectionController extends BaseController { @ApiOperation("查询全部我的收藏") @GetMapping() - public ApiResult> list(UserCollectionParam param) { + public ApiResult list(UserCollectionParam param) { + if (getLoginUser() == null) return fail("请先登录"); // 使用关联查询 + param.setUserId(getLoginUserId()); return success(userCollectionService.listRel(param)); } @@ -57,10 +66,15 @@ public class UserCollectionController extends BaseController { @PostMapping() public ApiResult save(@RequestBody UserCollection userCollection) { // 记录当前登录用户id - // User loginUser = getLoginUser(); - // if (loginUser != null) { - // userCollection.setUserId(loginUser.getUserId()); - // } + User loginUser = getLoginUser(); + if (loginUser != null) { + userCollection.setUserId(loginUser.getUserId()); + } + UserCollection check = userCollectionService.check(getLoginUserId(), userCollection.getType(), userCollection.getTid()); + if (check != null) { + userCollectionService.removeById(check.getId()); + return success("取消成功"); + } if (userCollectionService.save(userCollection)) { return success("添加成功"); } diff --git a/src/main/java/com/gxwebsoft/shop/controller/WeChatController.java b/src/main/java/com/gxwebsoft/shop/controller/WeChatController.java new file mode 100644 index 0000000..65e2b0c --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/controller/WeChatController.java @@ -0,0 +1,97 @@ +package com.gxwebsoft.shop.controller; + +import cn.binarywang.wx.miniapp.api.WxMaQrcodeService; +import cn.binarywang.wx.miniapp.api.WxMaService; +import cn.binarywang.wx.miniapp.api.impl.WxMaQrcodeServiceImpl; +import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl; +import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor; +import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl; +import cn.hutool.core.io.FileUtil; +import cn.hutool.http.HttpRequest; +import com.gxwebsoft.common.core.security.JwtUtil; +import com.gxwebsoft.common.core.utils.RequestUtil; +import com.gxwebsoft.common.core.web.ApiResult; +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.shop.config.WxMaProperties; +import com.gxwebsoft.shop.entity.Order; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import me.chanjar.weixin.common.error.WxErrorException; +import me.chanjar.weixin.common.error.WxRuntimeException; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +@Api(tags = "微信相关") +@RestController +@RequestMapping("/api/wechat") +public class WeChatController extends BaseController { + @Resource + private WxMaProperties wxMaProperties; + + @Value("${config.upload-path}") + private String uploadPath; + + @ApiOperation("好友代付二维码") + @PostMapping("/friend-pay-qr") + public ApiResult makeFriendPayQr(@RequestBody Order order, HttpServletRequest request){ + String filepath = uploadPath + "qrcode/" + getTenantId(); + if (!FileUtil.exist(filepath)) FileUtil.mkdir(filepath); + String filename = "/friendPay_" + order.getOrderId() + ".png"; + if (FileUtil.exist(filepath + "/" + filename)) return success("生成成功", "file/qrcode/" + getTenantId() + filename); + try { + makeQr(request, filename, order.getOrderId().toString(), "pages/index/index"); + } catch (IOException | WxErrorException e) { + e.printStackTrace(); + } + return success("生成成功", "file/qrcode/" + getTenantId() + filename); + } + + public void makeQr(HttpServletRequest request, String filename, String scene, String page) throws IOException, WxErrorException { +// final RequestUtil requestUtil = new RequestUtil(); +// String access_token = JwtUtil.getAccessToken(request); +// requestUtil.setAccessToken(access_token); +// requestUtil.setTenantId(getTenantId().toString()); +// ApiResult res = requestUtil.getWxConfig(); +// System.out.println(res); + WxMaService wxMaService = wxMaService(); + WxMaQrcodeService wxMaQrcodeService = new WxMaQrcodeServiceImpl(wxMaService); + WxMaCodeLineColor lineColor = new WxMaCodeLineColor(); + lineColor.setR("0"); + lineColor.setG("0"); + lineColor.setB("0"); + File file = wxMaQrcodeService.createWxaCodeUnlimit(scene, page, false, "develop", 200, false, + lineColor, false); + file.renameTo(new File(filename)); + } + + public WxMaService wxMaService() { + List configs = wxMaProperties.getConfigs(); + if (configs == null) { + throw new WxRuntimeException("大哥,拜托先看下项目首页的说明(readme文件),添加下相关配置,注意别配错了!"); + } + WxMaService maService = new WxMaServiceImpl(); + maService.setMultiConfigs( + configs.stream() + .map(a -> { + WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl(); + config.setAppid(a.getAppid()); + config.setSecret(a.getSecret()); + config.setToken(a.getToken()); + config.setAesKey(a.getAesKey()); + config.setMsgDataFormat(a.getMsgDataFormat()); + return config; + }).collect(Collectors.toMap(WxMaDefaultConfigImpl::getAppid, a -> a, (o, n) -> o))); + return maService; + } +} diff --git a/src/main/java/com/gxwebsoft/shop/controller/WxPayNotifyNbgController.java b/src/main/java/com/gxwebsoft/shop/controller/WxPayNotifyNbgController.java index 97d253c..08f57d6 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/WxPayNotifyNbgController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/WxPayNotifyNbgController.java @@ -82,7 +82,6 @@ public class WxPayNotifyNbgController extends BaseController { if (g.getStock().compareTo(0) >= 0) { g.setStock(g.getStock() - goods2.getTotalNum()); } - } final boolean batchById = goodsService.updateBatchById(goods); System.out.println("batchById = " + batchById); diff --git a/src/main/java/com/gxwebsoft/shop/entity/Cart.java b/src/main/java/com/gxwebsoft/shop/entity/Cart.java index e53f2dd..7c662ee 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/Cart.java +++ b/src/main/java/com/gxwebsoft/shop/entity/Cart.java @@ -108,4 +108,7 @@ public class Cart implements Serializable { @TableField(exist = false) private List children; + @TableField(exist = false) + private Goods goods; + } diff --git a/src/main/java/com/gxwebsoft/shop/entity/Goods.java b/src/main/java/com/gxwebsoft/shop/entity/Goods.java index cf488b2..172d75d 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/Goods.java +++ b/src/main/java/com/gxwebsoft/shop/entity/Goods.java @@ -59,6 +59,12 @@ public class Goods implements Serializable { @ApiModelProperty(value = "商品分类ID") private Integer categoryId; + @ApiModelProperty(value = "供应商") + private Integer supplierMerchantId; + + @ApiModelProperty(value = "供应商") + private String supplierName; + @ApiModelProperty(value = "商品规格 0单规格 1多规格") private Integer specs; @@ -83,12 +89,36 @@ public class Goods implements Serializable { @ApiModelProperty(value = "经销商价格") private BigDecimal dealerPrice; + @ApiModelProperty(value = "连锁店价格") + private BigDecimal chainStorePrice; + private BigDecimal chainStoreRate; + + @ApiModelProperty(value = "会员店价格") + private BigDecimal memberStorePrice; + private BigDecimal memberStoreRate; + + @ApiModelProperty(value = "会员超市价格") + private BigDecimal memberMarketPrice; + private BigDecimal memberMarketRate; + @ApiModelProperty(value = "有赠品(经销商)") private Boolean buyingGift; @ApiModelProperty(value = "有赠品(会员店)") private Boolean priceGift; + @ApiModelProperty(value = "有赠品(经销商)") + private Boolean dealerGift; + + @ApiModelProperty(value = "赠品数(经销商)") + private Integer buyingGiftNum; + + @ApiModelProperty(value = "赠品数(会员店)") + private Integer priceGiftNum; + + @ApiModelProperty(value = "赠品数(经销商)") + private Integer dealerGiftNum; + @ApiModelProperty(value = "库存计算方式(10下单减库存 20付款减库存)") private Integer deductStockType; @@ -132,6 +162,9 @@ public class Goods implements Serializable { @ApiModelProperty(value = "用户ID") private Integer userId; + @ApiModelProperty(value = "是否新品") + private Integer isNew; + @ApiModelProperty(value = "是否删除, 0否, 1是") @TableLogic private Integer deleted; @@ -188,6 +221,10 @@ public class Goods implements Serializable { @TableField(exist = false) private String parentPath; + @ApiModelProperty(value = "是否显示赠品") + @TableField(exist = false) + private Boolean showGift; + @ApiModelProperty(value = "当前栏目名称") private String categoryName; diff --git a/src/main/java/com/gxwebsoft/shop/entity/GoodsIncomeConfig.java b/src/main/java/com/gxwebsoft/shop/entity/GoodsIncomeConfig.java new file mode 100644 index 0000000..8d05727 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/entity/GoodsIncomeConfig.java @@ -0,0 +1,67 @@ +package com.gxwebsoft.shop.entity; + +import java.math.BigDecimal; + +import com.baomidou.mybatisplus.annotation.*; + +import java.time.LocalDateTime; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 分润配置 + * + * @author 科技小王子 + * @since 2024-10-06 17:55:50 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "GoodsIncomeConfig对象", description = "分润配置") +@TableName("shop_goods_income_config") +public class GoodsIncomeConfig implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private Integer goodsId; + + @ApiModelProperty(value = "店铺类型") + private String merchantShopType; + + private Integer skuId; + + @ApiModelProperty(value = "比例") + private BigDecimal rate; + + @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 LocalDateTime updateTime; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + + @TableField(exist = false) + private Goods goods; + + @TableField(exist = false) + private GoodsSku goodsSku; +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/GoodsStockInMerchant.java b/src/main/java/com/gxwebsoft/shop/entity/GoodsStockInMerchant.java new file mode 100644 index 0000000..be5eb52 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/entity/GoodsStockInMerchant.java @@ -0,0 +1,66 @@ +package com.gxwebsoft.shop.entity; + +import com.baomidou.mybatisplus.annotation.*; + +import java.time.LocalDateTime; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 商户商品库存 + * + * @author 科技小王子 + * @since 2024-10-05 02:33:23 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "GoodsStockInMerchant对象", description = "商户商品库存") +@TableName("shop_goods_stock_in_merchant") +public class GoodsStockInMerchant implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + private Integer goodsId; + + private Integer skuId; + + private Integer num; + + private Integer merchantId; + + private Integer stock; + + @ApiModelProperty(value = "状态, 0上架 1待上架 2待审核 3审核不通过") + private Integer status; + + @ApiModelProperty(value = "备注") + private String comments; + + @ApiModelProperty(value = "排序号") + private Integer sortNumber; + + @ApiModelProperty(value = "用户ID") + private Integer userId; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @TableLogic + private Integer deleted; + + @ApiModelProperty(value = "租户id") + private Integer tenantId; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "修改时间") + private LocalDateTime updateTime; + + @TableField(exist = false) + private Goods goods; + +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/KuaiDi100Resp.java b/src/main/java/com/gxwebsoft/shop/entity/KuaiDi100Resp.java new file mode 100644 index 0000000..c1348ad --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/entity/KuaiDi100Resp.java @@ -0,0 +1,11 @@ +package com.gxwebsoft.shop.entity; + +import lombok.Data; + +@Data +public class KuaiDi100Resp { + private String message; + private Integer returnCode; + private Boolean result; + private Object data; +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/Merchant.java b/src/main/java/com/gxwebsoft/shop/entity/Merchant.java index a2c82cc..385326f 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/Merchant.java +++ b/src/main/java/com/gxwebsoft/shop/entity/Merchant.java @@ -57,6 +57,8 @@ public class Merchant implements Serializable { private Integer merchantCategoryId; + private Integer canExpress; + private String merchantCategoryTitle; @ApiModelProperty(value = "经纬度") @@ -66,6 +68,12 @@ public class Merchant implements Serializable { private String lat; + private String startTime; + + private String endTime; + + private Integer isOn; + @ApiModelProperty(value = "所在省份") private String province; diff --git a/src/main/java/com/gxwebsoft/shop/entity/Order.java b/src/main/java/com/gxwebsoft/shop/entity/Order.java index 6b99de7..55ded53 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/Order.java +++ b/src/main/java/com/gxwebsoft/shop/entity/Order.java @@ -36,6 +36,9 @@ public class Order implements Serializable { @ApiModelProperty(value = "订单类型,0商城订单 1预定订单 2会员卡") private Integer type; + @ApiModelProperty(value = "类型,0快递 1自提") + private Integer deliveryType; + @ApiModelProperty(value = "下单渠道,0普通预定 1俱乐部训练场 3活动订场") private Integer channel; @@ -82,6 +85,16 @@ public class Order implements Serializable { @ApiModelProperty(value = "手机号码") private String phone; + @ApiModelProperty(value = "收货地址") + private String address; + + private String addressLat; + + private String addressLng; + + @ApiModelProperty(value = "自提码") + private String selfTakeCode; + @ApiModelProperty(value = "订单总额") private BigDecimal totalPrice; @@ -113,6 +126,8 @@ public class Order implements Serializable { @ApiModelProperty(value = "0余额支付, 1微信支付,2积分,3支付宝,4现金,5POS机,6VIP月卡,7VIP年卡,8VIP次卡,9IC月卡,10IC年卡,11IC次卡,12免费,13VIP充值卡,14IC充值卡,15积分支付,16VIP季卡,17IC季卡") private Integer payType; + private Integer friendPayType; + @ApiModelProperty(value = "0未付款,1已付款") private Integer payStatus; @@ -149,6 +164,12 @@ public class Order implements Serializable { @ApiModelProperty(value = "发票流水号") private String invoiceNo; + @ApiModelProperty(value = "外卖开始时间") + private String sendStartTime; + + @ApiModelProperty(value = "外卖结束时间") + private String sendEndTime; + @ApiModelProperty(value = "支付时间") private Date payTime; @@ -177,6 +198,21 @@ public class Order implements Serializable { @ApiModelProperty(value = "用户id") private Integer userId; + private Integer payUserId; + + private Integer selfTakeMerchantId; + + @TableField(exist = false) + private Merchant selfTakeMerchant; + + private String selfTakeMerchantName; + + private Integer expressMerchantId; + + private String expressMerchantName; + + private Integer hasTakeGift; + @ApiModelProperty(value = "备注") private String comments; @@ -220,4 +256,13 @@ public class Order implements Serializable { @TableField(exist = false) private List goodsList; + @ApiModelProperty(value = "不清数据") + @TableField(exist = false) + private Boolean notClearData; + + @TableField(exist = false) + private OrderDelivery orderDelivery; + + @TableField(exist = false) + private Merchant merchant; } diff --git a/src/main/java/com/gxwebsoft/shop/entity/OrderDelivery.java b/src/main/java/com/gxwebsoft/shop/entity/OrderDelivery.java index 7bf98ad..5b2c575 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/OrderDelivery.java +++ b/src/main/java/com/gxwebsoft/shop/entity/OrderDelivery.java @@ -1,10 +1,8 @@ package com.gxwebsoft.shop.entity; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.*; + import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.TableLogic; import java.io.Serializable; import java.util.Date; @@ -64,4 +62,8 @@ public class OrderDelivery implements Serializable { @ApiModelProperty(value = "修改时间") private Date updateTime; + @TableField(exist = false) + private Express express; + + } diff --git a/src/main/java/com/gxwebsoft/shop/entity/OrderGoods.java b/src/main/java/com/gxwebsoft/shop/entity/OrderGoods.java index ebf32e6..5faf4a5 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/OrderGoods.java +++ b/src/main/java/com/gxwebsoft/shop/entity/OrderGoods.java @@ -52,6 +52,8 @@ public class OrderGoods implements Serializable { @ApiModelProperty(value = "关联商品id") private Integer goodsId; + private Integer skuId; + @ApiModelProperty(value = "商品名称") private String goodsName; @@ -108,4 +110,7 @@ public class OrderGoods implements Serializable { @ApiModelProperty(value = "创建时间") private Date createTime; + + @TableField(exist = false) + private Goods goods; } diff --git a/src/main/java/com/gxwebsoft/shop/entity/Splash.java b/src/main/java/com/gxwebsoft/shop/entity/Splash.java new file mode 100644 index 0000000..f155702 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/entity/Splash.java @@ -0,0 +1,64 @@ +package com.gxwebsoft.shop.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +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.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 开屏广告 + * + * @author 科技小王子 + * @since 2024-09-30 22:07:41 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "Splash对象", description = "开屏广告") +@TableName("shop_splash") +public class Splash implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "图片") + private String image; + + @ApiModelProperty(value = "跳转类型") + private String jumpType; + + @ApiModelProperty(value = "跳转主键") + private Integer jumpPk; + + @ApiModelProperty(value = "备注") + private String comments; + + @ApiModelProperty(value = "排序号") + private Integer sortNumber; + + @ApiModelProperty(value = "用户ID") + private Integer userId; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @TableLogic + private Integer deleted; + + @ApiModelProperty(value = "租户id") + private Integer tenantId; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "修改时间") + private LocalDateTime updateTime; + +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/Swiper.java b/src/main/java/com/gxwebsoft/shop/entity/Swiper.java new file mode 100644 index 0000000..2347091 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/entity/Swiper.java @@ -0,0 +1,68 @@ +package com.gxwebsoft.shop.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +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.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 轮播图 + * + * @author 科技小王子 + * @since 2024-09-30 22:07:41 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value = "Swiper对象", description = "轮播图") +@TableName("shop_swiper") +public class Swiper implements Serializable { + private static final long serialVersionUID = 1L; + + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "所属页面") + private String type; + + @ApiModelProperty(value = "图片") + private String image; + + @ApiModelProperty(value = "跳转类型") + private String jumpType; + + @ApiModelProperty(value = "跳转主键") + private Integer jumpPk; + + @ApiModelProperty(value = "备注") + private String comments; + + private String color; + + private String color1; + + @ApiModelProperty(value = "排序号") + private Integer sortNumber; + + @ApiModelProperty(value = "用户ID") + private Integer userId; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @TableLogic + private Integer deleted; + + @ApiModelProperty(value = "租户id") + private Integer tenantId; + + @ApiModelProperty(value = "创建时间") + private LocalDateTime createTime; + + @ApiModelProperty(value = "修改时间") + private LocalDateTime updateTime; + +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/UserAddress.java b/src/main/java/com/gxwebsoft/shop/entity/UserAddress.java index 370b059..f41029c 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/UserAddress.java +++ b/src/main/java/com/gxwebsoft/shop/entity/UserAddress.java @@ -50,6 +50,12 @@ public class UserAddress implements Serializable { @ApiModelProperty(value = "收货地址") private String address; + private String fullAddress; + + private String lat; + + private String lng; + @ApiModelProperty(value = "1先生 2女士") private Integer gender; diff --git a/src/main/java/com/gxwebsoft/shop/entity/UserCollection.java b/src/main/java/com/gxwebsoft/shop/entity/UserCollection.java index cf2c2fe..e48eb25 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/UserCollection.java +++ b/src/main/java/com/gxwebsoft/shop/entity/UserCollection.java @@ -1,5 +1,6 @@ package com.gxwebsoft.shop.entity; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; @@ -14,7 +15,7 @@ import lombok.EqualsAndHashCode; * 我的收藏 * * @author 科技小王子 - * @since 2024-04-28 18:17:37 + * @since 2024-10-03 01:51:46 */ @Data @EqualsAndHashCode(callSuper = false) @@ -27,6 +28,9 @@ public class UserCollection implements Serializable { @TableId(value = "id", type = IdType.AUTO) private Integer id; + @ApiModelProperty(value = "0店铺,1商品") + private Integer type; + @ApiModelProperty(value = "租户ID") private Integer tid; @@ -39,4 +43,6 @@ public class UserCollection implements Serializable { @ApiModelProperty(value = "注册时间") private LocalDateTime createTime; + @TableField(exist = false) + private Merchant merchant; } diff --git a/src/main/java/com/gxwebsoft/shop/mapper/GoodsIncomeConfigMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/GoodsIncomeConfigMapper.java new file mode 100644 index 0000000..d56af7d --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/GoodsIncomeConfigMapper.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.GoodsIncomeConfig; +import com.gxwebsoft.shop.param.GoodsIncomeConfigParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 分润配置Mapper + * + * @author 科技小王子 + * @since 2024-10-06 17:55:50 + */ +public interface GoodsIncomeConfigMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") GoodsIncomeConfigParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") GoodsIncomeConfigParam param); + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/GoodsStockInMerchantMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/GoodsStockInMerchantMapper.java new file mode 100644 index 0000000..eb3e85c --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/GoodsStockInMerchantMapper.java @@ -0,0 +1,38 @@ +package com.gxwebsoft.shop.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.yulichang.base.MPJBaseMapper; +import com.gxwebsoft.shop.entity.GoodsStockInMerchant; +import com.gxwebsoft.shop.param.GoodsStockInMerchantParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 商户商品库存Mapper + * + * @author 科技小王子 + * @since 2024-10-05 02:33:23 + */ +public interface GoodsStockInMerchantMapper extends MPJBaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") GoodsStockInMerchantParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") GoodsStockInMerchantParam param); + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/MerchantMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/MerchantMapper.java index 06c5ab3..ce93b22 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/MerchantMapper.java +++ b/src/main/java/com/gxwebsoft/shop/mapper/MerchantMapper.java @@ -2,6 +2,7 @@ package com.gxwebsoft.shop.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.yulichang.base.MPJBaseMapper; import com.gxwebsoft.shop.entity.Merchant; import com.gxwebsoft.shop.param.MerchantParam; import org.apache.ibatis.annotations.Param; @@ -14,7 +15,7 @@ import java.util.List; * @author 科技小王子 * @since 2024-04-05 00:03:54 */ -public interface MerchantMapper extends BaseMapper { +public interface MerchantMapper extends MPJBaseMapper { /** * 分页查询 diff --git a/src/main/java/com/gxwebsoft/shop/mapper/SplashMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/SplashMapper.java new file mode 100644 index 0000000..1cde619 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/SplashMapper.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.Splash; +import com.gxwebsoft.shop.param.SplashParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 开屏广告Mapper + * + * @author 科技小王子 + * @since 2024-09-30 22:07:41 + */ +public interface SplashMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") SplashParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") SplashParam param); + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/SwiperMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/SwiperMapper.java new file mode 100644 index 0000000..d85a740 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/SwiperMapper.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.Swiper; +import com.gxwebsoft.shop.param.SwiperParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 轮播图Mapper + * + * @author 科技小王子 + * @since 2024-09-30 22:07:41 + */ +public interface SwiperMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") SwiperParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") SwiperParam param); + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/UserCollectionMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/UserCollectionMapper.java index ba08881..114096e 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/UserCollectionMapper.java +++ b/src/main/java/com/gxwebsoft/shop/mapper/UserCollectionMapper.java @@ -12,7 +12,7 @@ import java.util.List; * 我的收藏Mapper * * @author 科技小王子 - * @since 2024-04-28 18:17:37 + * @since 2024-10-03 01:51:46 */ public interface UserCollectionMapper extends BaseMapper { diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/CartMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/CartMapper.xml index 4f85852..751d22b 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/xml/CartMapper.xml +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/CartMapper.xml @@ -30,6 +30,9 @@ AND a.is_new = #{param.isNew} + + AND a.is_show = #{param.isShow} + AND a.combination_id = #{param.combinationId} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/GoodsIncomeConfigMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/GoodsIncomeConfigMapper.xml new file mode 100644 index 0000000..461e31a --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/GoodsIncomeConfigMapper.xml @@ -0,0 +1,63 @@ + + + + + + + SELECT a.* + FROM shop_goods_income_config a + + + AND a.id = #{param.id} + + + AND a.goods_id = #{param.goodsId} + + + AND a.merchant_shop_type LIKE CONCAT('%', #{param.merchantShopType}, '%') + + + AND a.spec LIKE CONCAT('%', #{param.spec}, '%') + + + AND a.rate = #{param.rate} + + + AND a.user_id = #{param.userId} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.sort_number = #{param.sortNumber} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/GoodsMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/GoodsMapper.xml index b34e594..028eec0 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/xml/GoodsMapper.xml +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/GoodsMapper.xml @@ -69,16 +69,16 @@ AND a.merchant_id = #{param.merchantId} - AND a.category_id IN (SELECT category_id FROM shop_goods_category WHERE parent_id=#{param.parentId}) + AND a.category_id IN (SELECT category_id FROM shop_goods_category WHERE parent_id=#{param.parentId}) - - - + + + - AND a.merchant_id IN - - #{item} - + AND a.merchant_id IN + + #{item} + AND a.merchant_name LIKE CONCAT('%', #{param.merchantName}, '%') @@ -115,14 +115,20 @@ AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') - OR a.goods_name LIKE CONCAT('%', #{param.keywords}, '%') - OR a.parent_name LIKE CONCAT('%', #{param.keywords}, '%') - OR a.category_name LIKE CONCAT('%', #{param.keywords}, '%') - OR a.goods_id = #{param.keywords} - OR a.code = #{param.keywords} + OR a.goods_name LIKE CONCAT('%', #{param.keywords}, '%') + OR a.parent_name LIKE CONCAT('%', #{param.keywords}, '%') + OR a.category_name LIKE CONCAT('%', #{param.keywords}, '%') + OR a.goods_id = #{param.keywords} + OR a.code = #{param.keywords} ) - + + + ORDER BY ${param.orderBy} + + + ORDER BY a.sort_number ASC, a.create_time DESC + diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/GoodsStockInMerchantMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/GoodsStockInMerchantMapper.xml new file mode 100644 index 0000000..f141eba --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/GoodsStockInMerchantMapper.xml @@ -0,0 +1,69 @@ + + + + + + + SELECT a.* + FROM shop_goods_stock_in_merchant a + + + AND a.id = #{param.id} + + + AND a.goods_id = #{param.goodsId} + + + AND a.sku_id = #{param.skuId} + + + AND a.num = #{param.num} + + + AND a.merchant_id = #{param.merchantId} + + + AND a.stock = #{param.stock} + + + AND a.status = #{param.status} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.sort_number = #{param.sortNumber} + + + AND a.user_id = #{param.userId} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/OrderMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/OrderMapper.xml index 3f77a67..405950c 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/xml/OrderMapper.xml +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/OrderMapper.xml @@ -165,6 +165,7 @@ ) + ORDER BY a.order_id DESC diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/SplashMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/SplashMapper.xml new file mode 100644 index 0000000..06dc9cb --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/SplashMapper.xml @@ -0,0 +1,63 @@ + + + + + + + SELECT a.* + FROM shop_splash a + + + AND a.id = #{param.id} + + + AND a.title LIKE CONCAT('%', #{param.title}, '%') + + + AND a.image LIKE CONCAT('%', #{param.image}, '%') + + + AND a.jump_type LIKE CONCAT('%', #{param.jumpType}, '%') + + + AND a.jump_pk = #{param.jumpPk} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.sort_number = #{param.sortNumber} + + + AND a.user_id = #{param.userId} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/SwiperMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/SwiperMapper.xml new file mode 100644 index 0000000..ca2abed --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/SwiperMapper.xml @@ -0,0 +1,63 @@ + + + + + + + SELECT a.* + FROM shop_swiper a + + + AND a.id = #{param.id} + + + AND a.type LIKE CONCAT('%', #{param.type}, '%') + + + AND a.image LIKE CONCAT('%', #{param.image}, '%') + + + AND a.jump_type LIKE CONCAT('%', #{param.jumpType}, '%') + + + AND a.jump_pk = #{param.jumpPk} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.sort_number = #{param.sortNumber} + + + AND a.user_id = #{param.userId} + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/UserCollectionMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/UserCollectionMapper.xml index e5e3fe5..289ec55 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/xml/UserCollectionMapper.xml +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/UserCollectionMapper.xml @@ -10,6 +10,9 @@ AND a.id = #{param.id} + + AND a.type = #{param.type} + AND a.tid = #{param.tid} diff --git a/src/main/java/com/gxwebsoft/shop/param/CartParam.java b/src/main/java/com/gxwebsoft/shop/param/CartParam.java index 2bd375f..c1d07c3 100644 --- a/src/main/java/com/gxwebsoft/shop/param/CartParam.java +++ b/src/main/java/com/gxwebsoft/shop/param/CartParam.java @@ -1,10 +1,13 @@ package com.gxwebsoft.shop.param; import java.math.BigDecimal; + +import com.baomidou.mybatisplus.annotation.TableField; 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 com.gxwebsoft.common.system.entity.User; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import io.swagger.models.auth.In; @@ -55,6 +58,8 @@ public class CartParam extends BaseParam { @QueryField(type = QueryType.EQ) private Boolean isNew; + private Boolean isShow; + @ApiModelProperty(value = "拼团id") @QueryField(type = QueryType.EQ) private Integer combinationId; @@ -70,6 +75,9 @@ public class CartParam extends BaseParam { @ApiModelProperty(value = "用户ID") private Integer userId; + @TableField(exist = false) + private User loginUser; + @ApiModelProperty(value = "是否选中") private Boolean selected; @@ -84,4 +92,6 @@ public class CartParam extends BaseParam { @QueryField(type = QueryType.EQ) private Integer shopId; + @TableField(exist = false) + private Boolean withMerchantInfo; } diff --git a/src/main/java/com/gxwebsoft/shop/param/GoodsIncomeConfigParam.java b/src/main/java/com/gxwebsoft/shop/param/GoodsIncomeConfigParam.java new file mode 100644 index 0000000..c9acd40 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/param/GoodsIncomeConfigParam.java @@ -0,0 +1,56 @@ +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.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 分润配置查询参数 + * + * @author 科技小王子 + * @since 2024-10-06 17:55:50 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(value = "GoodsIncomeConfigParam对象", description = "分润配置查询参数") +public class GoodsIncomeConfigParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @QueryField(type = QueryType.EQ) + private Integer id; + + @QueryField(type = QueryType.EQ) + private Integer goodsId; + + @ApiModelProperty(value = "店铺类型") + private String merchantShopType; + + private String spec; + + @ApiModelProperty(value = "比例") + @QueryField(type = QueryType.EQ) + private BigDecimal rate; + + @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; + +} diff --git a/src/main/java/com/gxwebsoft/shop/param/GoodsParam.java b/src/main/java/com/gxwebsoft/shop/param/GoodsParam.java index c483415..5ff5152 100644 --- a/src/main/java/com/gxwebsoft/shop/param/GoodsParam.java +++ b/src/main/java/com/gxwebsoft/shop/param/GoodsParam.java @@ -145,4 +145,10 @@ public class GoodsParam extends BaseParam { @TableField(exist = false) private User loginUser; + @TableField(exist = false) + private String orderBy; + + @TableField(exist = false) + private String orderDir; + } diff --git a/src/main/java/com/gxwebsoft/shop/param/GoodsStockInMerchantParam.java b/src/main/java/com/gxwebsoft/shop/param/GoodsStockInMerchantParam.java new file mode 100644 index 0000000..64d6ba0 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/param/GoodsStockInMerchantParam.java @@ -0,0 +1,63 @@ +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.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 商户商品库存查询参数 + * + * @author 科技小王子 + * @since 2024-10-05 02:33:23 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(value = "GoodsStockInMerchantParam对象", description = "商户商品库存查询参数") +public class GoodsStockInMerchantParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @QueryField(type = QueryType.EQ) + private Integer id; + + @QueryField(type = QueryType.EQ) + private Integer goodsId; + + @QueryField(type = QueryType.EQ) + private Integer skuId; + + @QueryField(type = QueryType.EQ) + private Integer num; + + @QueryField(type = QueryType.EQ) + private Integer merchantId; + + @QueryField(type = QueryType.EQ) + private Integer stock; + + @ApiModelProperty(value = "状态, 0上架 1待上架 2待审核 3审核不通过") + @QueryField(type = QueryType.EQ) + private Integer status; + + @ApiModelProperty(value = "备注") + private String comments; + + @ApiModelProperty(value = "排序号") + @QueryField(type = QueryType.EQ) + private Integer sortNumber; + + @ApiModelProperty(value = "用户ID") + @QueryField(type = QueryType.EQ) + private Integer userId; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @QueryField(type = QueryType.EQ) + private Integer deleted; + +} diff --git a/src/main/java/com/gxwebsoft/shop/param/OrderParam.java b/src/main/java/com/gxwebsoft/shop/param/OrderParam.java index 774995c..cdbb252 100644 --- a/src/main/java/com/gxwebsoft/shop/param/OrderParam.java +++ b/src/main/java/com/gxwebsoft/shop/param/OrderParam.java @@ -3,10 +3,12 @@ package com.gxwebsoft.shop.param; import java.math.BigDecimal; import java.util.Date; +import com.baomidou.mybatisplus.annotation.TableField; 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 com.gxwebsoft.common.system.entity.User; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -210,4 +212,6 @@ public class OrderParam extends BaseParam { @QueryField(type = QueryType.GT) private Date expirationTime; + @TableField(exist = false) + private User loginUser; } diff --git a/src/main/java/com/gxwebsoft/shop/param/SplashParam.java b/src/main/java/com/gxwebsoft/shop/param/SplashParam.java new file mode 100644 index 0000000..ddbb5e3 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/param/SplashParam.java @@ -0,0 +1,57 @@ +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.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 开屏广告查询参数 + * + * @author 科技小王子 + * @since 2024-09-30 22:07:41 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(value = "SplashParam对象", description = "开屏广告查询参数") +public class SplashParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @QueryField(type = QueryType.EQ) + private Integer id; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "图片") + private String image; + + @ApiModelProperty(value = "跳转类型") + private String jumpType; + + @ApiModelProperty(value = "跳转主键") + @QueryField(type = QueryType.EQ) + private Integer jumpPk; + + @ApiModelProperty(value = "备注") + private String comments; + + @ApiModelProperty(value = "排序号") + @QueryField(type = QueryType.EQ) + private Integer sortNumber; + + @ApiModelProperty(value = "用户ID") + @QueryField(type = QueryType.EQ) + private Integer userId; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @QueryField(type = QueryType.EQ) + private Integer deleted; + +} diff --git a/src/main/java/com/gxwebsoft/shop/param/SwiperParam.java b/src/main/java/com/gxwebsoft/shop/param/SwiperParam.java new file mode 100644 index 0000000..ea11b89 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/param/SwiperParam.java @@ -0,0 +1,57 @@ +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.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 轮播图查询参数 + * + * @author 科技小王子 + * @since 2024-09-30 22:07:41 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@ApiModel(value = "SwiperParam对象", description = "轮播图查询参数") +public class SwiperParam extends BaseParam { + private static final long serialVersionUID = 1L; + + @QueryField(type = QueryType.EQ) + private Integer id; + + @ApiModelProperty(value = "所属页面") + private String type; + + @ApiModelProperty(value = "图片") + private String image; + + @ApiModelProperty(value = "跳转类型") + private String jumpType; + + @ApiModelProperty(value = "跳转主键") + @QueryField(type = QueryType.EQ) + private Integer jumpPk; + + @ApiModelProperty(value = "备注") + private String comments; + + @ApiModelProperty(value = "排序号") + @QueryField(type = QueryType.EQ) + private Integer sortNumber; + + @ApiModelProperty(value = "用户ID") + @QueryField(type = QueryType.EQ) + private Integer userId; + + @ApiModelProperty(value = "是否删除, 0否, 1是") + @QueryField(type = QueryType.EQ) + private Integer deleted; + +} diff --git a/src/main/java/com/gxwebsoft/shop/param/UserCollectionParam.java b/src/main/java/com/gxwebsoft/shop/param/UserCollectionParam.java index 99a2013..6cf163a 100644 --- a/src/main/java/com/gxwebsoft/shop/param/UserCollectionParam.java +++ b/src/main/java/com/gxwebsoft/shop/param/UserCollectionParam.java @@ -14,7 +14,7 @@ import lombok.EqualsAndHashCode; * 我的收藏查询参数 * * @author 科技小王子 - * @since 2024-04-28 18:17:37 + * @since 2024-10-03 01:51:46 */ @Data @EqualsAndHashCode(callSuper = false) @@ -27,6 +27,10 @@ public class UserCollectionParam extends BaseParam { @QueryField(type = QueryType.EQ) private Integer id; + @ApiModelProperty(value = "0店铺,1商品") + @QueryField(type = QueryType.EQ) + private Integer type; + @ApiModelProperty(value = "租户ID") @QueryField(type = QueryType.EQ) private Integer tid; diff --git a/src/main/java/com/gxwebsoft/shop/service/GoodsIncomeConfigService.java b/src/main/java/com/gxwebsoft/shop/service/GoodsIncomeConfigService.java new file mode 100644 index 0000000..391e420 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/GoodsIncomeConfigService.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.GoodsIncomeConfig; +import com.gxwebsoft.shop.param.GoodsIncomeConfigParam; + +import java.util.List; + +/** + * 分润配置Service + * + * @author 科技小王子 + * @since 2024-10-06 17:55:50 + */ +public interface GoodsIncomeConfigService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(GoodsIncomeConfigParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(GoodsIncomeConfigParam param); + + /** + * 根据id查询 + * + * @param id + * @return GoodsIncomeConfig + */ + GoodsIncomeConfig getByIdRel(Integer id); + + GoodsIncomeConfig check(Integer goodsId, Integer skuId, String merchantShopType); +} diff --git a/src/main/java/com/gxwebsoft/shop/service/GoodsService.java b/src/main/java/com/gxwebsoft/shop/service/GoodsService.java index e100827..e5eb57c 100644 --- a/src/main/java/com/gxwebsoft/shop/service/GoodsService.java +++ b/src/main/java/com/gxwebsoft/shop/service/GoodsService.java @@ -45,7 +45,7 @@ public interface GoodsService extends IService { List getGoodsSpec(); // 商城商品 - List getGoodsSpecType0(); + List getGoodsSpecType0(GoodsParam param); // 外卖商品 List getGoodsSpecType1(); diff --git a/src/main/java/com/gxwebsoft/shop/service/GoodsSkuService.java b/src/main/java/com/gxwebsoft/shop/service/GoodsSkuService.java index 2adadc1..de248a9 100644 --- a/src/main/java/com/gxwebsoft/shop/service/GoodsSkuService.java +++ b/src/main/java/com/gxwebsoft/shop/service/GoodsSkuService.java @@ -31,6 +31,8 @@ public interface GoodsSkuService extends IService { */ List listRel(GoodsSkuParam param); + List listByGoods(Integer goodsId); + /** * 根据id查询 * diff --git a/src/main/java/com/gxwebsoft/shop/service/GoodsStockInMerchantService.java b/src/main/java/com/gxwebsoft/shop/service/GoodsStockInMerchantService.java new file mode 100644 index 0000000..bcb6db3 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/GoodsStockInMerchantService.java @@ -0,0 +1,45 @@ +package com.gxwebsoft.shop.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.shop.entity.GoodsStockInMerchant; +import com.gxwebsoft.shop.param.GoodsStockInMerchantParam; + +import java.util.List; + +/** + * 商户商品库存Service + * + * @author 科技小王子 + * @since 2024-10-05 02:33:23 + */ +public interface GoodsStockInMerchantService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(GoodsStockInMerchantParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(GoodsStockInMerchantParam param); + + /** + * 根据id查询 + * + * @param id + * @return GoodsStockInMerchant + */ + GoodsStockInMerchant getByIdRel(Integer id); + + GoodsStockInMerchant check(Integer merchantId, Integer goodsId, Integer skuId); + + List canExpressList(Integer goodsId, Integer stock, String lat, String lng); +} diff --git a/src/main/java/com/gxwebsoft/shop/service/KuaiDi100.java b/src/main/java/com/gxwebsoft/shop/service/KuaiDi100.java new file mode 100644 index 0000000..005f77d --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/KuaiDi100.java @@ -0,0 +1,17 @@ +package com.gxwebsoft.shop.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.kuaidi100.sdk.pojo.HttpResult; +import com.kuaidi100.sdk.request.BOrderReq; + +import java.util.Map; + +public interface KuaiDi100 { + /** + * 商家寄件 + * @param bOrderReq + * @return + * @throws Exception + */ + HttpResult border(BOrderReq bOrderReq) throws Exception; +} diff --git a/src/main/java/com/gxwebsoft/shop/service/MerchantService.java b/src/main/java/com/gxwebsoft/shop/service/MerchantService.java index 503ffb3..241c9ba 100644 --- a/src/main/java/com/gxwebsoft/shop/service/MerchantService.java +++ b/src/main/java/com/gxwebsoft/shop/service/MerchantService.java @@ -39,4 +39,5 @@ public interface MerchantService extends IService { */ Merchant getByIdRel(Integer merchantId); + Merchant getByUserId(Integer userId); } diff --git a/src/main/java/com/gxwebsoft/shop/service/OrderDeliveryService.java b/src/main/java/com/gxwebsoft/shop/service/OrderDeliveryService.java index baaa547..613280d 100644 --- a/src/main/java/com/gxwebsoft/shop/service/OrderDeliveryService.java +++ b/src/main/java/com/gxwebsoft/shop/service/OrderDeliveryService.java @@ -39,4 +39,5 @@ public interface OrderDeliveryService extends IService { */ OrderDelivery getByIdRel(Integer deliveryId); + OrderDelivery getByOrderId(Integer orderId); } diff --git a/src/main/java/com/gxwebsoft/shop/service/OrderGoodsService.java b/src/main/java/com/gxwebsoft/shop/service/OrderGoodsService.java index d2e9049..f8c601b 100644 --- a/src/main/java/com/gxwebsoft/shop/service/OrderGoodsService.java +++ b/src/main/java/com/gxwebsoft/shop/service/OrderGoodsService.java @@ -31,6 +31,8 @@ public interface OrderGoodsService extends IService { */ List listRel(OrderGoodsParam param); + List listByOrderId(Integer orderId); + /** * 根据id查询 * diff --git a/src/main/java/com/gxwebsoft/shop/service/OrderService.java b/src/main/java/com/gxwebsoft/shop/service/OrderService.java index cea09c2..c5ecd21 100644 --- a/src/main/java/com/gxwebsoft/shop/service/OrderService.java +++ b/src/main/java/com/gxwebsoft/shop/service/OrderService.java @@ -17,37 +17,39 @@ import java.util.List; */ public interface OrderService extends IService { - /** - * 分页关联查询 - * - * @param param 查询参数 - * @return PageResult - */ - PageResult pageRel(OrderParam param); + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(OrderParam param); - /** - * 关联查询全部 - * - * @param param 查询参数 - * @return List - */ - List listRel(OrderParam param); + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(OrderParam param); - /** - * 根据id查询 - * - * @param orderId 订单号 - * @return Order - */ - Order getByIdRel(Integer orderId); + /** + * 根据id查询 + * + * @param orderId 订单号 + * @return Order + */ + Order getByIdRel(Integer orderId); - HashMap createWxOrder(Order order); + HashMap createWxOrder(Order order); - Order getByOutTradeNo(String outTradeNo); + Order getByOutTradeNo(String outTradeNo); - Boolean updateByOutTradeNo(Order order); + Boolean updateByOutTradeNo(Order order); - Boolean payByBalance(Order order); + Boolean payByBalance(Order order); + + void settle(String token, String tenantId, Order order); // String payByWxNative(Order order); } diff --git a/src/main/java/com/gxwebsoft/shop/service/SplashService.java b/src/main/java/com/gxwebsoft/shop/service/SplashService.java new file mode 100644 index 0000000..9a8f151 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/SplashService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.shop.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.shop.entity.Splash; +import com.gxwebsoft.shop.param.SplashParam; + +import java.util.List; + +/** + * 开屏广告Service + * + * @author 科技小王子 + * @since 2024-09-30 22:07:41 + */ +public interface SplashService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(SplashParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(SplashParam param); + + /** + * 根据id查询 + * + * @param id + * @return Splash + */ + Splash getByIdRel(Integer id); + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/SwiperService.java b/src/main/java/com/gxwebsoft/shop/service/SwiperService.java new file mode 100644 index 0000000..27f8edd --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/SwiperService.java @@ -0,0 +1,42 @@ +package com.gxwebsoft.shop.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.shop.entity.Swiper; +import com.gxwebsoft.shop.param.SwiperParam; + +import java.util.List; + +/** + * 轮播图Service + * + * @author 科技小王子 + * @since 2024-09-30 22:07:41 + */ +public interface SwiperService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(SwiperParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(SwiperParam param); + + /** + * 根据id查询 + * + * @param id + * @return Swiper + */ + Swiper getByIdRel(Integer id); + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/UserAddressService.java b/src/main/java/com/gxwebsoft/shop/service/UserAddressService.java index 8944668..7795115 100644 --- a/src/main/java/com/gxwebsoft/shop/service/UserAddressService.java +++ b/src/main/java/com/gxwebsoft/shop/service/UserAddressService.java @@ -39,4 +39,5 @@ public interface UserAddressService extends IService { */ UserAddress getByIdRel(Integer id); + void clearDefault(Integer userId); } diff --git a/src/main/java/com/gxwebsoft/shop/service/UserCollectionService.java b/src/main/java/com/gxwebsoft/shop/service/UserCollectionService.java index 96556d8..967302b 100644 --- a/src/main/java/com/gxwebsoft/shop/service/UserCollectionService.java +++ b/src/main/java/com/gxwebsoft/shop/service/UserCollectionService.java @@ -11,7 +11,7 @@ import java.util.List; * 我的收藏Service * * @author 科技小王子 - * @since 2024-04-28 18:17:37 + * @since 2024-10-03 01:51:46 */ public interface UserCollectionService extends IService { @@ -39,4 +39,5 @@ public interface UserCollectionService extends IService { */ UserCollection getByIdRel(Integer id); + UserCollection check(Integer userId, Integer type, Integer tid); } diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/CartServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/CartServiceImpl.java index 798c35f..466c47f 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/CartServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/CartServiceImpl.java @@ -9,17 +9,22 @@ import com.gxwebsoft.common.system.entity.Dict; import com.gxwebsoft.common.system.entity.DictData; import com.gxwebsoft.shop.entity.Goods; import com.gxwebsoft.shop.entity.GoodsSpec; +import com.gxwebsoft.shop.entity.Merchant; import com.gxwebsoft.shop.mapper.CartMapper; import com.gxwebsoft.shop.service.CartService; import com.gxwebsoft.shop.entity.Cart; import com.gxwebsoft.shop.param.CartParam; import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.shop.service.GoodsService; +import com.gxwebsoft.shop.service.MerchantService; import com.gxwebsoft.shop.vo.CartShopVo; import com.gxwebsoft.shop.vo.CartVo; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestMapping; +import javax.annotation.Resource; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -33,95 +38,115 @@ import java.util.stream.Stream; */ @Service public class CartServiceImpl extends ServiceImpl implements CartService { + @Resource + private GoodsService goodsService; + @Resource + private MerchantService merchantService; - @Override - public PageResult pageRel(CartParam param) { - PageParam page = new PageParam<>(param); - page.setDefaultOrder("create_time desc"); - List list = baseMapper.selectPageRel(page, param); - return new PageResult<>(list, page.getTotal()); - } - - @Override - @Transactional(rollbackFor = {Exception.class}) - public CartVo listRel(CartParam param) { - List list = baseMapper.selectListRel(param); - // 排序 - PageParam page = new PageParam<>(); - page.setDefaultOrder("create_time desc"); - final List carts = page.sortRecords(list); - System.out.println("carts = " + carts.size()); - // 整理数据 - final CartVo vo = new CartVo(); - // 计算单品总价 - for (Cart cart : carts) { - cart.setTotalPrice(cart.getPrice().multiply(BigDecimal.valueOf(cart.getCartNum()))); + @Override + public PageResult pageRel(CartParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); } - // 计算购物车金额 - final Integer cartNum = carts.stream().map(Cart::getCartNum).reduce(Integer::sum).orElse(0); - final Integer selectNums = carts.stream().filter(d -> d.getSelected().equals(true)).map(Cart::getCartNum).reduce(Integer::sum).orElse(0); - final BigDecimal totalPrice = carts.stream().filter(d -> d.getSelected().equals(true)).map(Cart::getTotalPrice).reduce(BigDecimal.ZERO, BigDecimal::add); - // 按店铺ID分组 - final Map> collectCart = carts.stream().collect(Collectors.groupingBy(Cart::getMerchantId)); - final ArrayList shops = new ArrayList<>(); - if (MapUtil.isNotEmpty(collectCart)) { - for (Integer shopId : collectCart.keySet()) { - final CartShopVo shopVo = new CartShopVo(); - shopVo.setShopId(shopId); - shopVo.setCarts(collectCart.get(shopId)); - if (ObjectUtil.isNotEmpty(collectCart.get(shopId).get(0))) { - final Cart cart = collectCart.get(shopId).get(0); - shopVo.setShopName(cart.getMerchantName()); - shopVo.setShopLogo(cart.getImage()); + + @Override + @Transactional(rollbackFor = {Exception.class}) + public CartVo listRel(CartParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("create_time desc"); + final List carts = page.sortRecords(list); + System.out.println("carts = " + carts.size()); + // 整理数据 + final CartVo vo = new CartVo(); + // 计算单品总价 + for (Cart cart : carts) { + cart.setTotalPrice(cart.getPrice().multiply(BigDecimal.valueOf(cart.getCartNum()))); + Goods goods = goodsService.getById(cart.getGoodsId()); + if (param.getLoginUser() != null) { + // 经销商 + if (param.getLoginUser().getGradeId().equals(33)) { + if (goods.getDealerGift()) goods.setShowGift(true); + } + // 会员店 + if (param.getLoginUser().getGradeId().equals(31)) { + if (goods.getPriceGift()) goods.setShowGift(true); + } + } + cart.setGoods(goods); + } + // 计算购物车金额 + final Integer cartNum = carts.stream().map(Cart::getCartNum).reduce(Integer::sum).orElse(0); + final Integer selectNums = carts.stream().filter(d -> d.getSelected().equals(true)).map(Cart::getCartNum).reduce(Integer::sum).orElse(0); + final BigDecimal totalPrice = carts.stream().filter(d -> d.getSelected().equals(true)).map(Cart::getTotalPrice).reduce(BigDecimal.ZERO, BigDecimal::add); + // 按店铺ID分组 + final Map> collectCart = carts.stream().collect(Collectors.groupingBy(Cart::getMerchantId)); + final ArrayList shops = new ArrayList<>(); + if (MapUtil.isNotEmpty(collectCart)) { + for (Integer shopId : collectCart.keySet()) { + final CartShopVo shopVo = new CartShopVo(); + shopVo.setShopId(shopId); + shopVo.setCarts(collectCart.get(shopId)); + if (ObjectUtil.isNotEmpty(collectCart.get(shopId).get(0))) { + final Cart cart = collectCart.get(shopId).get(0); + shopVo.setShopName(cart.getMerchantName()); + shopVo.setShopLogo(cart.getImage()); + } + if (param.getWithMerchantInfo() != null) { + Merchant merchant = merchantService.getById(shopId); + shopVo.setMerchant(merchant); + } + shops.add(shopVo); + } } - shops.add(shopVo); - } - } - vo.setShops(shops); - vo.setTotalPrice(totalPrice); - vo.setTotalNums(Long.valueOf(cartNum)); - vo.setSelectNums(Long.valueOf(selectNums)); + vo.setShops(shops); + vo.setTotalPrice(totalPrice); + vo.setTotalNums(Long.valueOf(cartNum)); + vo.setSelectNums(Long.valueOf(selectNums)); // updateBatchById(carts); - return vo; - } + return vo; + } - @Override - public Cart getByIdRel(Integer id) { - CartParam param = new CartParam(); - param.setId(id); - return param.getOne(baseMapper.selectListRel(param)); - } + @Override + public Cart getByIdRel(Integer id) { + CartParam param = new CartParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } - @Override - public List listRelMpj(CartParam param) { + @Override + public List listRelMpj(CartParam param) { - // 多表查询 - MPJLambdaWrapper mpjLambdaWrapper = new MPJLambdaWrapper<>(); - mpjLambdaWrapper.selectAll(Cart.class) - .select(Goods::getGoodsName) - .select(Goods::getImage) - .leftJoin(Goods.class,Goods::getGoodsId,Cart::getGoodsId).eq(Cart::getUserId,param.getUserId()); + // 多表查询 + MPJLambdaWrapper mpjLambdaWrapper = new MPJLambdaWrapper<>(); + mpjLambdaWrapper.selectAll(Cart.class) + .select(Goods::getGoodsName) + .select(Goods::getImage) + .leftJoin(Goods.class, Goods::getGoodsId, Cart::getGoodsId).eq(Cart::getUserId, param.getUserId()); - // 查询选中状态 - if(param.getSelected() != null){ - mpjLambdaWrapper.eq(Cart::getSelected, param.getSelected()); - } - // 商品类型 0商城 1预定 - if(param.getType() != null){ - mpjLambdaWrapper.eq(Cart::getType,param.getType()); - } - // 是否为立即购买 - if(param.getIsNew() != null){ - mpjLambdaWrapper.eq(Cart::getIsNew,param.getIsNew()); - } - // 指定cartId - if(param.getId() != null){ - mpjLambdaWrapper.eq(Cart::getId,param.getId()); - } - System.out.println("mpjLambdaWrapper = " + mpjLambdaWrapper); - return baseMapper.selectJoinList(Cart.class, mpjLambdaWrapper); - } + // 查询选中状态 + if (param.getSelected() != null) { + mpjLambdaWrapper.eq(Cart::getSelected, param.getSelected()); + } + // 商品类型 0商城 1预定 + if (param.getType() != null) { + mpjLambdaWrapper.eq(Cart::getType, param.getType()); + } + // 是否为立即购买 + if (param.getIsNew() != null) { + mpjLambdaWrapper.eq(Cart::getIsNew, param.getIsNew()); + } + // 指定cartId + if (param.getId() != null) { + mpjLambdaWrapper.eq(Cart::getId, param.getId()); + } + System.out.println("mpjLambdaWrapper = " + mpjLambdaWrapper); + return baseMapper.selectJoinList(Cart.class, mpjLambdaWrapper); + } } diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/GoodsIncomeConfigServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/GoodsIncomeConfigServiceImpl.java new file mode 100644 index 0000000..4237d5c --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/impl/GoodsIncomeConfigServiceImpl.java @@ -0,0 +1,71 @@ +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.GoodsIncomeConfigMapper; +import com.gxwebsoft.shop.service.GoodsIncomeConfigService; +import com.gxwebsoft.shop.entity.GoodsIncomeConfig; +import com.gxwebsoft.shop.param.GoodsIncomeConfigParam; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.shop.service.GoodsService; +import com.gxwebsoft.shop.service.GoodsSkuService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 分润配置Service实现 + * + * @author 科技小王子 + * @since 2024-10-06 17:55:50 + */ +@Service +public class GoodsIncomeConfigServiceImpl extends ServiceImpl implements GoodsIncomeConfigService { + @Resource + private GoodsSkuService goodsSkuService; + @Resource + private GoodsService goodsService; + + @Override + public PageResult pageRel(GoodsIncomeConfigParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + for (GoodsIncomeConfig goodsIncomeConfig : list) { + goodsIncomeConfig.setGoods(goodsService.getById(goodsIncomeConfig.getGoodsId())); + if (goodsIncomeConfig.getSkuId() != null) { + goodsIncomeConfig.setGoodsSku(goodsSkuService.getById(goodsIncomeConfig.getSkuId())); + } + } + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(GoodsIncomeConfigParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public GoodsIncomeConfig getByIdRel(Integer id) { + GoodsIncomeConfigParam param = new GoodsIncomeConfigParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + + @Override + public GoodsIncomeConfig check(Integer goodsId, Integer skuId, String merchantShopType) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GoodsIncomeConfig::getGoodsId, goodsId); + wrapper.eq(GoodsIncomeConfig::getMerchantShopType, merchantShopType); + if (skuId != null) wrapper.eq(GoodsIncomeConfig::getSkuId, skuId); + wrapper.last("limit 1"); + return getOne(wrapper); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/GoodsServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/GoodsServiceImpl.java index 678250e..1910367 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/GoodsServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/GoodsServiceImpl.java @@ -48,9 +48,9 @@ public class GoodsServiceImpl extends ServiceImpl implements public PageResult pageRel(GoodsParam param) { // 按行业名称查找店铺ID if (ObjectUtil.isNotEmpty(param.getIndustryName())) { - final List merchants = merchantService.list(new LambdaQueryWrapper().like(Merchant::getCategory, param.getIndustryName())); - final Set merchantIds = merchants.stream().map(Merchant::getMerchantId).collect(Collectors.toSet()); - param.setShopIdsByIndustry(merchantIds); + final List merchants = merchantService.list(new LambdaQueryWrapper().like(Merchant::getCategory, param.getIndustryName())); + final Set merchantIds = merchants.stream().map(Merchant::getMerchantId).collect(Collectors.toSet()); + param.setShopIdsByIndustry(merchantIds); } PageParam page = new PageParam<>(param); page.setDefaultOrder("sort_number asc, create_time desc"); @@ -58,30 +58,43 @@ public class GoodsServiceImpl extends ServiceImpl implements final Set goodsIds = list.stream().map(Goods::getGoodsId).collect(Collectors.toSet()); if (!CollectionUtils.isEmpty(goodsIds)) { - final User loginUser = param.getLoginUser(); - final List specs = goodsSpecService.list(new LambdaQueryWrapper().in(GoodsSpec::getGoodsId, goodsIds)); - final List skus = goodsSkuService.list(new LambdaQueryWrapper().in(GoodsSku::getGoodsId, goodsIds)); - final Map> collectSpecs = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId)); - final Map> collectSkus = skus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId)); - list.forEach(d -> { - final List goodsSpecs = collectSpecs.get(d.getGoodsId()); - if (!CollectionUtils.isEmpty(goodsSpecs)) { - final GoodsSpec spec = goodsSpecs.get(0); - final String value = spec.getSpecValue(); - final Object object = JSONUtil.parseObject(value,Object.class); - d.setGoodsSpecValue(object); - // 整理商品价格 - if (loginUser != null) { - if(loginUser.getGradeId().equals(33)){ - d.setPrice(d.getDealerPrice()); + final User loginUser = param.getLoginUser(); + final List specs = goodsSpecService.list(new LambdaQueryWrapper().in(GoodsSpec::getGoodsId, goodsIds)); + final List skus = goodsSkuService.list(new LambdaQueryWrapper().in(GoodsSku::getGoodsId, goodsIds)); + final Map> collectSpecs = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId)); + final Map> collectSkus = skus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId)); + list.forEach(d -> { + final List goodsSpecs = collectSpecs.get(d.getGoodsId()); + if (!CollectionUtils.isEmpty(goodsSpecs)) { + final GoodsSpec spec = goodsSpecs.get(0); + final String value = spec.getSpecValue(); + final Object object = JSONUtil.parseObject(value, Object.class); + d.setGoodsSpecValue(object); + // 整理商品价格 + if (loginUser != null) { + // 经销商 + if (loginUser.getGradeId().equals(33)) { + d.setPrice(d.getDealerPrice()); + } + if (loginUser.getGradeId().equals(0)) { + d.setPrice(d.getSalePrice()); + } + }else { + d.setPrice(d.getSalePrice()); + } } - if(loginUser.getGradeId().equals(0)){ - d.setPrice(d.getSalePrice()); + if (loginUser != null) { + // 经销商 + if (loginUser.getGradeId().equals(33)) { + if (d.getDealerGift()) d.setShowGift(true); + } + // 会员店 + if (loginUser.getGradeId().equals(31)) { + if (d.getPriceGift()) d.setShowGift(true); + } } - } - } // d.setGoodsSkus(collectSkus.get(d.getGoodsId())); - }); + }); } return new PageResult<>(list, page.getTotal()); @@ -90,6 +103,9 @@ public class GoodsServiceImpl extends ServiceImpl implements @Override public List listRel(GoodsParam param) { List list = baseMapper.selectListRel(param); + for (Goods goods : list) { + goods.setGoodsSkus(goodsSkuService.listByGoods(goods.getGoodsId())); + } // 排序 PageParam page = new PageParam<>(); page.setDefaultOrder("sort_number asc, create_time desc"); @@ -105,63 +121,66 @@ public class GoodsServiceImpl extends ServiceImpl implements @Override public void saveBatchByAsync(Goods goods) { - // 保存商品多规格 - if (goods.getSpecs().equals(1)) { - final GoodsSpec spec = goods.getGoodsSpec(); - if (spec != null) { - spec.setGoodsId(goods.getGoodsId()); - if(spec.getSpecValue() == null){ - spec.setSpecValue(JSON.toJSONString(new ArrayList<>())); - } - goodsSpecService.save(spec); + // 保存商品多规格 + if (goods.getSpecs().equals(1)) { + final GoodsSpec spec = goods.getGoodsSpec(); + if (spec != null) { + spec.setGoodsId(goods.getGoodsId()); + if (spec.getSpecValue() == null) { + spec.setSpecValue(JSON.toJSONString(new ArrayList<>())); + } + goodsSpecService.save(spec); - // 保存商品sku表 - final List goodsSkus = goods.getGoodsSkus(); - if (!CollectionUtils.isEmpty(goodsSkus)) { - goodsSkus.forEach(d -> { - d.setGoodsId(goods.getGoodsId()); - }); - goodsSkuService.saveBatch(goodsSkus); - } + // 保存商品sku表 + final List goodsSkus = goods.getGoodsSkus(); + if (!CollectionUtils.isEmpty(goodsSkus)) { + goodsSkus.forEach(d -> { + d.setGoodsId(goods.getGoodsId()); + }); + goodsSkuService.saveBatch(goodsSkus); + } + } } - } } - @Override - public List getGoodsSpec() { - // 多表查询 - MPJLambdaWrapper mpjLambdaWrapper = new MPJLambdaWrapper<>(); - mpjLambdaWrapper.selectAll(Goods.class) - .select(GoodsSpec::getSpecValue) - .select(GoodsSpec::getSpecName) - .leftJoin(GoodsSpec.class,GoodsSpec::getGoodsId,GoodsSpec::getGoodsId); - return baseMapper.selectJoinList(Goods.class, mpjLambdaWrapper); - } + @Override + public List getGoodsSpec() { + // 多表查询 + MPJLambdaWrapper mpjLambdaWrapper = new MPJLambdaWrapper<>(); + mpjLambdaWrapper.selectAll(Goods.class) + .select(GoodsSpec::getSpecValue) + .select(GoodsSpec::getSpecName) + .leftJoin(GoodsSpec.class, GoodsSpec::getGoodsId, GoodsSpec::getGoodsId); + return baseMapper.selectJoinList(Goods.class, mpjLambdaWrapper); + } - @Override - public List getGoodsSpecType0() { - // 多表查询 - MPJLambdaWrapper mpjLambdaWrapper = new MPJLambdaWrapper<>(); - mpjLambdaWrapper.selectAll(Goods.class) - .select(GoodsSpec::getSpecValue) - .select(GoodsSpec::getSpecName) - .leftJoin(GoodsSpec.class,GoodsSpec::getGoodsId,GoodsSpec::getGoodsId) - .gt(Goods::getStock,0) - .eq(Goods::getType,0); - return baseMapper.selectJoinList(Goods.class, mpjLambdaWrapper); - } + @Override + public List getGoodsSpecType0(GoodsParam param) { + // 多表查询 + MPJLambdaWrapper mpjLambdaWrapper = new MPJLambdaWrapper<>(); + mpjLambdaWrapper.selectAll(Goods.class) + .select(GoodsSpec::getSpecValue) + .select(GoodsSpec::getSpecName) + .leftJoin(GoodsSpec.class, GoodsSpec::getGoodsId, GoodsSpec::getGoodsId) + .gt(Goods::getStock, 0) + .eq(Goods::getType, 0); + if (param.getOrderBy() != null && param.getOrderDir() != null) { + mpjLambdaWrapper.orderBy(true, param.getOrderDir().equals("asc"), param.getOrderBy()); + } + return baseMapper.selectJoinList(Goods.class, mpjLambdaWrapper); + } - @Override - public List getGoodsSpecType1() { - // 多表查询 - MPJLambdaWrapper mpjLambdaWrapper = new MPJLambdaWrapper<>(); - mpjLambdaWrapper.selectAll(Goods.class) - .select(GoodsSpec::getSpecValue) - .select(GoodsSpec::getSpecName) - .leftJoin(GoodsSpec.class,GoodsSpec::getGoodsId,GoodsSpec::getGoodsId) - .gt(Goods::getStock,0) - .eq(Goods::getType,1); - return baseMapper.selectJoinList(Goods.class, mpjLambdaWrapper); - } + @Override + public List getGoodsSpecType1() { + // 多表查询 + MPJLambdaWrapper mpjLambdaWrapper = new MPJLambdaWrapper<>(); + mpjLambdaWrapper.selectAll(Goods.class) + .select(GoodsSpec::getSpecValue) + .select(GoodsSpec::getSpecName) + .leftJoin(GoodsSpec.class, GoodsSpec::getGoodsId, GoodsSpec::getGoodsId) + .gt(Goods::getStock, 0) + .eq(Goods::getType, 1); + return baseMapper.selectJoinList(Goods.class, mpjLambdaWrapper); + } } diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/GoodsSkuServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/GoodsSkuServiceImpl.java index 47adc40..a806f9b 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/GoodsSkuServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/GoodsSkuServiceImpl.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.GoodsSkuMapper; import com.gxwebsoft.shop.service.GoodsSkuService; @@ -37,6 +38,14 @@ public class GoodsSkuServiceImpl extends ServiceImpl i return page.sortRecords(list); } + @Override + public List listByGoods(Integer goodsId) { + return list( + new LambdaQueryWrapper() + .eq(GoodsSku::getGoodsId, goodsId) + ); + } + @Override public GoodsSku getByIdRel(Integer id) { GoodsSkuParam param = new GoodsSkuParam(); diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/GoodsStockInMerchantServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/GoodsStockInMerchantServiceImpl.java new file mode 100644 index 0000000..3535052 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/impl/GoodsStockInMerchantServiceImpl.java @@ -0,0 +1,86 @@ +package com.gxwebsoft.shop.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.yulichang.query.MPJQueryWrapper; +import com.gxwebsoft.shop.entity.Goods; +import com.gxwebsoft.shop.entity.Merchant; +import com.gxwebsoft.shop.mapper.GoodsStockInMerchantMapper; +import com.gxwebsoft.shop.service.GoodsService; +import com.gxwebsoft.shop.service.GoodsStockInMerchantService; +import com.gxwebsoft.shop.entity.GoodsStockInMerchant; +import com.gxwebsoft.shop.param.GoodsStockInMerchantParam; +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; + +/** + * 商户商品库存Service实现 + * + * @author 科技小王子 + * @since 2024-10-05 02:33:23 + */ +@Service +public class GoodsStockInMerchantServiceImpl extends ServiceImpl implements GoodsStockInMerchantService { + + @Resource + private GoodsService goodsService; + @Override + public PageResult pageRel(GoodsStockInMerchantParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + for (GoodsStockInMerchant goodsStockInMerchant : list) { + Goods goods = goodsService.getById(goodsStockInMerchant.getGoodsId()); + goodsStockInMerchant.setGoods(goods); + } + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(GoodsStockInMerchantParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public GoodsStockInMerchant getByIdRel(Integer id) { + GoodsStockInMerchantParam param = new GoodsStockInMerchantParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + + @Override + public GoodsStockInMerchant check(Integer merchantId, Integer goodsId, Integer skuId) { + GoodsStockInMerchantParam param = new GoodsStockInMerchantParam(); + param.setMerchantId(merchantId); + param.setGoodsId(goodsId); + param.setSkuId(skuId); + return param.getOne(baseMapper.selectListRel(param)); + } + + @Override + public List canExpressList(Integer goodsId, Integer stock, String lat, String lng) { + String distanceSql = "ACOS(SIN(( " + lat + " * 3.1415) / 180 ) * SIN((lat * 3.1415) / 180 ) + " + + "COS(( " + lat + " * 3.1415) / 180) * COS((b.lat * 3.1415) / 180 ) * COS(( " + lng + " * 3.1415) / 180 - " + + "(b.lng * 3.1415) / 180 ) ) * 6380" + + " as distance"; + return list( + new MPJQueryWrapper() + .leftJoin("shop_merchant AS b ON b.merchant_id = t.merchant_id") + .select("t.*", distanceSql) + .eq("goods_id", goodsId) + .eq("can_express", 1) + .ge("stock", stock) + .orderByDesc("distance") + ); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/KuaiDi100Impl.java b/src/main/java/com/gxwebsoft/shop/service/impl/KuaiDi100Impl.java new file mode 100644 index 0000000..bb89c15 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/impl/KuaiDi100Impl.java @@ -0,0 +1,43 @@ +package com.gxwebsoft.shop.service.impl; + +import cn.hutool.crypto.SecureUtil; +import com.google.gson.Gson; +import com.gxwebsoft.shop.service.KuaiDi100; +import com.kuaidi100.sdk.api.BOrderOfficial; +import com.kuaidi100.sdk.contant.ApiInfoConstant; +import com.kuaidi100.sdk.core.BaseClient; +import com.kuaidi100.sdk.core.IBaseClient; +import com.kuaidi100.sdk.pojo.HttpResult; +import com.kuaidi100.sdk.request.BOrderReq; +import com.kuaidi100.sdk.request.BaseRequest; +import com.kuaidi100.sdk.request.PrintReq; +import com.kuaidi100.sdk.utils.SignUtils; +import org.springframework.stereotype.Service; + +@Service +public class KuaiDi100Impl implements KuaiDi100 { + private String key = "QIfOPROg5054"; + private String secret = "09401b3c56f54175bcacc74d0519e4ef"; + @Override + public HttpResult border(BOrderReq bOrderReq) throws Exception { + PrintReq printReq = new PrintReq(); + + String t = String.valueOf(System.currentTimeMillis()); + String param = new Gson().toJson(bOrderReq); + + printReq.setKey(key); + printReq.setSign(SignUtils.printSign(param,t,key,secret)); + printReq.setT(t); + printReq.setParam(param); + printReq.setMethod(ApiInfoConstant.B_ORDER_OFFICIAL_ORDER_METHOD); + System.out.println(printReq); +// IBaseClient bOrder = new BOrderOfficial(); + IBaseClient bOrder = new BaseClient() { + @Override + public String getApiUrl(BaseRequest baseRequest) { + return "https://api.kuaidi100.com/apiMock/border"; + } + }; + return bOrder.execute(printReq); + } +} diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/MerchantServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/MerchantServiceImpl.java index cf0f860..034bf97 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/MerchantServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/MerchantServiceImpl.java @@ -32,6 +32,11 @@ public class MerchantServiceImpl extends ServiceImpl i PageParam page = new PageParam<>(param); page.setDefaultOrder("sort_number asc, create_time desc"); List list = baseMapper.selectPageRel(page, param); + for (Merchant merchant : list) { + if (param.getWithOrderNum() != null && param.getWithOrderNum()) { + merchant.setOrderNum(orderGoodsService.countByMerchant(merchant.getMerchantId())); + } + } return new PageResult<>(list, page.getTotal()); } @@ -64,4 +69,11 @@ public class MerchantServiceImpl extends ServiceImpl i return param.getOne(baseMapper.selectListRel(param)); } + @Override + public Merchant getByUserId(Integer userId) { + MerchantParam param = new MerchantParam(); + param.setUserId(userId); + return param.getOne(baseMapper.selectListRel(param)); + } + } diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/OrderDeliveryServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/OrderDeliveryServiceImpl.java index 349330a..b014647 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/OrderDeliveryServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/OrderDeliveryServiceImpl.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.OrderDeliveryMapper; import com.gxwebsoft.shop.service.OrderDeliveryService; @@ -44,4 +45,14 @@ public class OrderDeliveryServiceImpl extends ServiceImpl() + .eq(OrderDelivery::getOrderId, orderId) + .orderByDesc(OrderDelivery::getCreateTime) + .last("limit 1") + ); + } + } diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/OrderGoodsServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/OrderGoodsServiceImpl.java index 8b05f3a..535fc53 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/OrderGoodsServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/OrderGoodsServiceImpl.java @@ -1,8 +1,11 @@ package com.gxwebsoft.shop.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.shop.entity.Goods; import com.gxwebsoft.shop.mapper.OrderGoodsMapper; +import com.gxwebsoft.shop.service.GoodsService; import com.gxwebsoft.shop.service.OrderGoodsService; import com.gxwebsoft.shop.entity.OrderGoods; import com.gxwebsoft.shop.param.OrderGoodsParam; @@ -10,6 +13,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; /** @@ -20,6 +24,8 @@ import java.util.List; */ @Service public class OrderGoodsServiceImpl extends ServiceImpl implements OrderGoodsService { + @Resource + private GoodsService goodsService; @Override public PageResult pageRel(OrderGoodsParam param) { @@ -38,6 +44,21 @@ public class OrderGoodsServiceImpl extends ServiceImpl listByOrderId(Integer orderId) { + List list = list( + new LambdaQueryWrapper() + .eq(OrderGoods::getOrderId, orderId) + ); + List goodsList = goodsService.listByIds(list.stream().map(OrderGoods::getGoodsId).toList()); + for (OrderGoods orderGoods : list) { + for (Goods goods : goodsList) { + if (orderGoods.getGoodsId().equals(goods.getGoodsId())) orderGoods.setGoods(goods); + } + } + return list; + } + @Override public OrderGoods getByIdRel(Integer id) { OrderGoodsParam param = new OrderGoodsParam(); diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/OrderServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/OrderServiceImpl.java index 8c43a0e..3edd985 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/OrderServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/OrderServiceImpl.java @@ -12,12 +12,14 @@ import com.gxwebsoft.cms.entity.Website; import com.gxwebsoft.cms.entity.WebsiteField; import com.gxwebsoft.common.core.config.ConfigProperties; import com.gxwebsoft.common.core.exception.BusinessException; +import com.gxwebsoft.common.core.security.JwtUtil; import com.gxwebsoft.common.core.utils.RedisUtil; import com.gxwebsoft.common.core.utils.RequestUtil; import com.gxwebsoft.common.core.web.ApiResult; import com.gxwebsoft.common.core.web.PageParam; import com.gxwebsoft.common.core.web.PageResult; import com.gxwebsoft.common.system.entity.User; +import com.gxwebsoft.shop.consts.BalanceScene; import com.gxwebsoft.shop.entity.*; import com.gxwebsoft.shop.mapper.OrderMapper; import com.gxwebsoft.shop.param.OrderParam; @@ -37,12 +39,16 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import static com.gxwebsoft.shop.consts.OrderPayType.PAY_TYPE_FRIEND; +import static com.gxwebsoft.shop.consts.OrderPayType.PAY_TYPE_WECHAT; + /** * 订单Service实现 * @@ -51,254 +57,450 @@ import java.util.stream.Collectors; */ @Service public class OrderServiceImpl extends ServiceImpl implements OrderService { - @Value("${spring.profiles.active}") - String active; - @Resource - private OrderInfoService orderInfoService; - @Resource - private OrderGoodsService orderGoodsService; - @Resource - private ConfigProperties config; - @Resource - private RequestUtil requestUtil; - @Resource - private OrderService orderService; - @Resource - private UsersService usersService; - @Resource - private RedisUtil redisUtil; + @Value("${spring.profiles.active}") + String active; + @Resource + private OrderInfoService orderInfoService; + @Resource + private OrderGoodsService orderGoodsService; + @Resource + private ConfigProperties config; + @Resource + private RequestUtil requestUtil; + @Resource + private OrderService orderService; + @Resource + private UsersService usersService; + @Resource + private RedisUtil redisUtil; + @Resource + private GoodsService goodsService; + @Resource + private ExpressService expressService; + @Resource + private OrderDeliveryService orderDeliveryService; + @Resource + private MerchantService merchantService; + @Resource + private GoodsIncomeConfigService goodsIncomeConfigService; + @Resource + private UserBalanceLogService userBalanceLogService; + + // public static String privateKeyPath = "/Users/gxwebsoft/JAVA/com.gxwebsoft.modules/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 wechatpayCertPath = "/Users/gxwebsoft/JAVA/com.gxwebsoft.modules/src/main/resources/cert/wechatpay_2DD5A0669263BAE55E52BF3F35BF4A4006A2DAA6.pem"; // 平台证书 - public static String privateKeyPath = "/Users/gxwebsoft/Downloads/ef7f7e0430cb47019d06b93f885bf95f/apiclient_key.pem"; - public static String privateCertPath = "/Users/gxwebsoft/JAVA/com.gxwebsoft.core/src/main/resources/cert/apiclient_cert.pem"; - public static String wechatpayCertPath = "/Users/gxwebsoft/Downloads/ef7f7e0430cb47019d06b93f885bf95f/wechatpay_55729BDEC2502C301BA02CDC28E4CEE4DE4D1DB9.pem"; // 平台证书 + public static String privateKeyPath = "/Users/gxwebsoft/Downloads/ef7f7e0430cb47019d06b93f885bf95f/apiclient_key.pem"; + public static String privateCertPath = "/Users/gxwebsoft/JAVA/com.gxwebsoft.core/src/main/resources/cert/apiclient_cert.pem"; + public static String wechatpayCertPath = "/Users/gxwebsoft/Downloads/ef7f7e0430cb47019d06b93f885bf95f/wechatpay_55729BDEC2502C301BA02CDC28E4CEE4DE4D1DB9.pem"; // 平台证书 - @Override - public PageResult pageRel(OrderParam param) { - PageParam page = new PageParam<>(param); - page.setDefaultOrder("sort_number asc, create_time desc"); - List list = baseMapper.selectPageRel(page, param); + @Override + public PageResult pageRel(OrderParam param) { + PageParam page = new PageParam<>(param); +// page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); - if (param.getSceneType() != null) { - final Set orderIds = list.stream().map(Order::getOrderId).collect(Collectors.toSet()); - if (!CollectionUtils.isEmpty(orderIds)) { - // 查询预定订单信息 - if (param.getSceneType().equals("showOrderInfo")) { - final List orderInfoList = orderInfoService.list(new LambdaQueryWrapper().in(OrderInfo::getOrderId, orderIds)); - final Map> collect = orderInfoList.stream().collect(Collectors.groupingBy(OrderInfo::getOrderId)); - list.forEach(d -> { - final DateTime date = DateUtil.date(d.getExpirationTime()); - final DateTime now = DateUtil.date(); - d.setTimestamp(date.getTime() - now.getTime()); - if (!collect.isEmpty()) { - final List orderInfos = collect.get(d.getOrderId()); - if (!CollectionUtils.isEmpty(orderInfos)) { - d.setOrderInfo(orderInfos); - } + if (param.getSceneType() != null) { + final Set orderIds = list.stream().map(Order::getOrderId).collect(Collectors.toSet()); + if (!CollectionUtils.isEmpty(orderIds)) { + // 查询预定订单信息 + if (param.getSceneType().equals("showOrderInfo")) { + final List orderInfoList = orderInfoService.list(new LambdaQueryWrapper().in(OrderInfo::getOrderId, orderIds)); + final Map> collect = orderInfoList.stream().collect(Collectors.groupingBy(OrderInfo::getOrderId)); + list.forEach(d -> { + final DateTime date = DateUtil.date(d.getExpirationTime()); + final DateTime now = DateUtil.date(); + d.setTimestamp(date.getTime() - now.getTime()); + if (!collect.isEmpty()) { + final List orderInfos = collect.get(d.getOrderId()); + if (!CollectionUtils.isEmpty(orderInfos)) { + d.setOrderInfo(orderInfos); + } + } + }); + } + // 查询商品信息 + if (param.getSceneType().equals("showOrderGoods")) { + final List goodsList = orderGoodsService.list(new LambdaQueryWrapper().in(OrderGoods::getOrderId, orderIds)); + final Map> collect = goodsList.stream().collect(Collectors.groupingBy(OrderGoods::getOrderId)); + list.forEach(d -> { + final DateTime date = DateUtil.date(d.getExpirationTime()); + final DateTime now = DateUtil.date(); + d.setTimestamp(date.getTime() - now.getTime()); + if (!collect.isEmpty()) { + final List orderGoodsList = collect.get(d.getOrderId()); + if (!CollectionUtils.isEmpty(orderGoodsList)) { + for (OrderGoods orderGoods : orderGoodsList) { + Goods goods = goodsService.getById(orderGoods.getGoodsId()); + if (param.getLoginUser() != null) { + // 经销商 + if (param.getLoginUser().getGradeId().equals(33)) { + if (goods.getDealerGift()) goods.setShowGift(true); + } + // 会员店 + if (param.getLoginUser().getGradeId().equals(31)) { + if (goods.getPriceGift()) goods.setShowGift(true); + } + } + orderGoods.setGoods(goods); + } + d.setGoodsList(orderGoodsList); + } + } + }); + } } - }); - } - // 查询商品信息 - if (param.getSceneType().equals("showOrderGoods")) { - final List goodsList = orderGoodsService.list(new LambdaQueryWrapper().in(OrderGoods::getOrderId, orderIds)); - final Map> collect = goodsList.stream().collect(Collectors.groupingBy(OrderGoods::getOrderId)); - list.forEach(d -> { - final DateTime date = DateUtil.date(d.getExpirationTime()); - final DateTime now = DateUtil.date(); - d.setTimestamp(date.getTime() - now.getTime()); - if (!collect.isEmpty()) { - final List goods = collect.get(d.getOrderId()); - if (!CollectionUtils.isEmpty(goods)) { - d.setGoodsList(goods); - } + } else { + for (Order order : list) { + if (order.getType().equals(0)) { + if (order.getDeliveryType() != null && order.getDeliveryType().equals(0)) { + OrderDelivery orderDelivery = orderDeliveryService.getByOrderId(order.getOrderId()); + if (orderDelivery != null) { + orderDelivery.setExpress(expressService.getById(orderDelivery.getExpressId())); + order.setOrderDelivery(orderDelivery); + } + } + if (order.getDeliveryType() != null && order.getDeliveryType().equals(1)) { + Merchant merchant = merchantService.getById(order.getSelfTakeMerchantId()); + order.setSelfTakeMerchant(merchant); + } + } else if (order.getType().equals(1)) { + Merchant merchant = merchantService.getById(order.getMerchantId()); + order.setMerchant(merchant); + } } - }); } - } + + return new PageResult<>(list, page.getTotal()); } - return new PageResult<>(list, page.getTotal()); - } + @Override + public List listRel(OrderParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } - @Override - public List listRel(OrderParam param) { - List list = baseMapper.selectListRel(param); - // 排序 - PageParam page = new PageParam<>(); - page.setDefaultOrder("sort_number asc, create_time desc"); - return page.sortRecords(list); - } + @Override + public Order getByIdRel(Integer orderId) { + OrderParam param = new OrderParam(); + param.setOrderId(orderId); + Order order = param.getOne(baseMapper.selectListRel(param)); + if (order != null) { + final List list = orderInfoService.list(new LambdaQueryWrapper().eq(OrderInfo::getOrderId, orderId)); - @Override - public Order getByIdRel(Integer orderId) { - OrderParam param = new OrderParam(); - param.setOrderId(orderId); - Order order = param.getOne(baseMapper.selectListRel(param)); - if (order != null) { - final List list = orderInfoService.list(new LambdaQueryWrapper().eq(OrderInfo::getOrderId, orderId)); - - // 订单信息 - order.setOrderInfo(list); - if (!CollectionUtils.isEmpty(list)) { - final OrderInfo orderInfo = list.get(0); - final int i = orderInfo.getDateTime().compareTo(DateUtil.today()); - } - // 订单商品 - final List orderGoods = orderGoodsService.list(new LambdaQueryWrapper().eq(OrderGoods::getOrderId, orderId)); - order.setGoodsList(orderGoods); - // 生成订单核销码 + // 订单信息 + order.setOrderInfo(list); + if (!CollectionUtils.isEmpty(list)) { + final OrderInfo orderInfo = list.get(0); + final int i = orderInfo.getDateTime().compareTo(DateUtil.today()); + } + // 订单商品 + final List orderGoodsList = orderGoodsService.list(new LambdaQueryWrapper().eq(OrderGoods::getOrderId, orderId)); + for (OrderGoods orderGoods : orderGoodsList) { + orderGoods.setGoods(goodsService.getById(orderGoods.getGoodsId())); + } + order.setGoodsList(orderGoodsList); + // 生成订单核销码 // requestUtil.setTenantId(order.getTenantId().toString()); // order.setQrcode(requestUtil.getOrderQRCodeUnlimited(order.getOrderNo())); - return order; + return order; + } + return null; } - return null; - } - /** - * 创建微信支付 - * - * @param order - * @return - */ - @Override - public HashMap createWxOrder(Order order) { - final String uploadPath = config.getUploadPath(); // 服务器本地路径 - final HashMap orderInfo = new HashMap<>(); - // 微信小程序(微信支付) - String key = "mp-weixin:".concat(order.getTenantId().toString()); - final String string = redisUtil.get(key); + /** + * 创建微信支付 + * + * @param order + * @return + */ + @Override + public HashMap createWxOrder(Order order) { + Integer payType = order.getPayType(); + if (order.getPayType().equals(PAY_TYPE_FRIEND) && order.getFriendPayType().equals(PAY_TYPE_WECHAT)) + payType = PAY_TYPE_WECHAT; + final String uploadPath = config.getUploadPath(); // 服务器本地路径 + final HashMap orderInfo = new HashMap<>(); + // 微信小程序(微信支付) + String key = "mp-weixin:".concat(order.getTenantId().toString()); + final String string = redisUtil.get(key); // System.out.println("string = " + string); - final JSONObject mpWx = JSONObject.parseObject(string); + final JSONObject mpWx = JSONObject.parseObject(string); // System.out.println("mpWx = " + mpWx); - String key2 = "Payment:".concat(order.getPayType().toString()).concat(":").concat(order.getTenantId().toString()); - final Payment payment = redisUtil.get(key2, Payment.class); + String key2 = "Payment:".concat(payType.toString()).concat(":").concat(order.getTenantId().toString()); + final Payment payment = redisUtil.get(key2, Payment.class); // System.out.println("payment = " + payment); - // 计算金额 - 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(); + // 计算金额 + 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 - JsapiServiceExtension service = new JsapiServiceExtension.Builder().config(config).build(); - // 跟之前下单示例一样,填充预下单参数 - PrepayRequest request = new PrepayRequest(); - Amount amount = new Amount(); - amount.setTotal(money); - amount.setCurrency("CNY"); - request.setAmount(amount); - request.setAppid(mpWx.getString("appId")); - request.setMchid(payment.getMchId()); - request.setDescription(order.getComments()); - request.setOutTradeNo(order.getOrderNo()); - request.setAttach(order.getTenantId().toString()); - final Payer payer = new Payer(); - payer.setOpenid(order.getOpenid()); - request.setPayer(payer); - // 测试环境 - if (active.equals("dev")) { - amount.setTotal(1); - request.setAmount(amount); - request.setNotifyUrl("http://jimei-api.natapp1.cc/api/shop/wx-pay/notify/" + order.getTenantId()); // 默认回调地址 - } - // 生成环境 - if (active.equals("prod")) { - amount.setTotal(2); - request.setAmount(amount); - request.setNotifyUrl("https://server.gxwebsoft.com/api/system/wx-pay/notify/" + order.getTenantId()); // 默认回调地址 - } + // 构建service + JsapiServiceExtension service = new JsapiServiceExtension.Builder().config(config).build(); + // 跟之前下单示例一样,填充预下单参数 + PrepayRequest request = new PrepayRequest(); + Amount amount = new Amount(); + amount.setTotal(money); + amount.setCurrency("CNY"); + request.setAmount(amount); + request.setAppid(mpWx.getString("appId")); + request.setMchid(payment.getMchId()); + request.setDescription(order.getComments()); + request.setOutTradeNo(order.getOrderNo()); + request.setAttach(order.getTenantId().toString()); + final Payer payer = new Payer(); + payer.setOpenid(order.getOpenid()); + request.setPayer(payer); + // 测试环境 + if (active.equals("dev")) { + amount.setTotal(1); + request.setAmount(amount); + request.setNotifyUrl("http://jimei-api.natapp1.cc/api/shop/wx-pay/notify/" + order.getTenantId()); // 默认回调地址 + } + // 生成环境 + if (active.equals("prod")) { + amount.setTotal(2); + request.setAmount(amount); + request.setNotifyUrl("https://server.gxwebsoft.com/api/system/wx-pay/notify/" + order.getTenantId()); // 默认回调地址 + } // if (StrUtil.isNotBlank(payment.getNotifyUrl())) { - // 后台配置的回调地址 + // 后台配置的回调地址 // request.setNotifyUrl(payment.getNotifyUrl().concat("/").concat(order.getTenantId().toString())); // } - 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; - } - - - @Override - public Order getByOutTradeNo(String outTradeNo) { - OrderParam param = new OrderParam(); - param.setOrderNo(outTradeNo); - baseMapper.getByOutTradeNo(param); - return param.getOne(baseMapper.getByOutTradeNo(param)); - } - - @Override - public Boolean updateByOutTradeNo(Order order) { - baseMapper.updateByOutTradeNo(order); - return true; - } - - @Override - @Transactional(rollbackFor = {Exception.class}) - public Boolean payByBalance(Order order) { - final User loginUser = order.getLoginUser(); - - if (loginUser.getBalance().compareTo(order.getTotalPrice()) < 0) { - throw new BusinessException("余额不足"); + 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; } - // 发起网络请求(更新余额接口) - final RequestUtil requestUtil = new RequestUtil(); - requestUtil.setAccessToken(order.getAccessToken()); - requestUtil.setTenantId(order.getTenantId().toString()); - String api = "/system/user/updateUserBalance"; // 更新余额接口 - final BigDecimal subtract = loginUser.getBalance().subtract(order.getTotalPrice()); - loginUser.setBalance(subtract); - // 累加会员积分 - String key = "SiteInfo:" + order.getTenantId(); - final String siteInfo = redisUtil.get(key); - // 从缓存读取信息 - if (StrUtil.isNotBlank(siteInfo)) { - final Website website = JSONObject.parseObject(siteInfo, Website.class); - final List fields = website.getFields(); - if (!CollectionUtils.isEmpty(fields)) { - fields.forEach(d -> { - if (d.getName().equals("integral_enabled") && d.getValue().equals("1")) { - loginUser.setPoints(loginUser.getPoints() + order.getPayPrice().intValue()); - } - }); - } + @Override + public Order getByOutTradeNo(String outTradeNo) { + OrderParam param = new OrderParam(); + param.setOrderNo(outTradeNo); + baseMapper.getByOutTradeNo(param); + return param.getOne(baseMapper.getByOutTradeNo(param)); } - final ApiResult apiResult = requestUtil.updateUserBalance(api, loginUser); - if (apiResult.getCode().equals(0)) { - // 修改订单状态 - order.setPayStatus(1); - order.setPayTime(DateUtil.date()); - order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.YEAR, 10)); - orderService.updateById(order); - orderInfoService.update(new LambdaUpdateWrapper().eq(OrderInfo::getOrderId, order.getOrderId()).set(OrderInfo::getPayStatus, 1)); - // 发放积分 - usersService.addIntegral(order); - return true; + + @Override + public Boolean updateByOutTradeNo(Order order) { + baseMapper.updateByOutTradeNo(order); + return true; + } + + @Override + @Transactional(rollbackFor = {Exception.class}) + public Boolean payByBalance(Order order) { + final User loginUser = order.getLoginUser(); + + if (loginUser.getBalance().compareTo(order.getTotalPrice()) < 0) { + throw new BusinessException("余额不足"); + } + + // 发起网络请求(更新余额接口) + final RequestUtil requestUtil = new RequestUtil(); + requestUtil.setAccessToken(order.getAccessToken()); + requestUtil.setTenantId(order.getTenantId().toString()); + String api = "/system/user/updateUserBalance"; // 更新余额接口 + final BigDecimal subtract = loginUser.getBalance().subtract(order.getTotalPrice()); + + loginUser.setBalance(subtract); + // 累加会员积分 + String key = "SiteInfo:" + order.getTenantId(); + final String siteInfo = redisUtil.get(key); + // 从缓存读取信息 + if (StrUtil.isNotBlank(siteInfo)) { + final Website website = JSONObject.parseObject(siteInfo, Website.class); + final List fields = website.getFields(); + if (!CollectionUtils.isEmpty(fields)) { + fields.forEach(d -> { + if (d.getName().equals("integral_enabled") && d.getValue().equals("1")) { + loginUser.setPoints(loginUser.getPoints() + order.getPayPrice().intValue()); + } + }); + } + } + final ApiResult apiResult = requestUtil.updateUserBalance(api, loginUser); + if (apiResult.getCode().equals(0)) { + // 修改订单状态 + order.setPayStatus(1); + order.setPayTime(DateUtil.date()); + order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.YEAR, 10)); + orderService.updateById(order); + orderInfoService.update(new LambdaUpdateWrapper().eq(OrderInfo::getOrderId, order.getOrderId()).set(OrderInfo::getPayStatus, 1)); + // 发放积分 + usersService.addIntegral(order); + return true; + } + return true; + } + + /*** + * 结算 + * @param order + */ + @Override + public void settle(String token, String tenantId, Order order) { + List orderGoodsList = orderGoodsService.listByOrderId(order.getOrderId()); + RequestUtil requestUtil = new RequestUtil(); + requestUtil.setAccessToken(token); + requestUtil.setTenantId(tenantId); + String balanceApi = "/system/user/updateUserBalance"; + if (order.getType().equals(0)) { + User parentUser = requestUtil.getParent(order.getUserId()); +// System.out.println(parentRes); + // 上级收入 + if (parentUser != null) { +// User parentUser = requestUtil.getUserByPhone(parentRes); + Merchant parentMerchant = merchantService.getByUserId(parentUser.getUserId()); + if (parentMerchant != null) { + for (OrderGoods orderGoods : orderGoodsList) { + Goods goods = orderGoods.getGoods(); + GoodsIncomeConfig goodsIncomeConfig = goodsIncomeConfigService.check(goods.getGoodsId(), orderGoods.getSkuId(), parentMerchant.getShopType()); + if (goodsIncomeConfig != null) { + BigDecimal rate = goodsIncomeConfig.getRate().divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP); + BigDecimal amountTotal = orderGoods.getPrice().multiply(BigDecimal.valueOf(orderGoods.getTotalNum())); + BigDecimal incomeTotal = amountTotal.multiply(rate); + BigDecimal newBalance = parentUser.getBalance().add(incomeTotal); + parentUser.setBalance(newBalance); + requestUtil.updateUserBalance(balanceApi, parentUser); + userBalanceLogService.save(new UserBalanceLog() {{ + setUserId(parentUser.getUserId()); + setScene(BalanceScene.BALANCE_SCENE_DIRECT_INCOME); + setMoney(incomeTotal); + setBalance(newBalance); + setMerchantId(parentMerchant.getMerchantId()); + setMerchantCode(parentMerchant.getMerchantCode()); + setOrderNo(order.getOrderNo()); + setTenantId(getTenantId()); + }}); + } + } + } + } + + // 供应商收入 + for (OrderGoods orderGoods : orderGoodsList) { + Goods goods = orderGoods.getGoods(); + Merchant supplier = merchantService.getById(goods.getSupplierMerchantId()); + if (supplier != null) { + User supplierUser = requestUtil.getByUserId(supplier.getUserId()); + BigDecimal incomeTotal = goods.getBuyingPrice().multiply(BigDecimal.valueOf(orderGoods.getTotalNum())); + BigDecimal newBalance = supplierUser.getBalance().add(incomeTotal); + supplierUser.setBalance(newBalance); + requestUtil.updateUserBalance(balanceApi, supplierUser); + userBalanceLogService.save(new UserBalanceLog() {{ + setUserId(supplier.getUserId()); + setScene(BalanceScene.BALANCE_SCENE_SUPPLIER); + setMoney(incomeTotal); + setBalance(newBalance); + setOrderNo(order.getOrderNo()); + setMerchantId(supplier.getMerchantId()); + setMerchantCode(supplier.getMerchantCode()); + setTenantId(getTenantId()); + }}); + } + } + // 发货门店/提货门店收入 + Merchant merchant = null; + if (order.getDeliveryType().equals(0)) merchant = merchantService.getById(order.getExpressMerchantId()); + else merchant = merchantService.getById(order.getSelfTakeMerchantId()); + if (merchant != null) { + BigDecimal diffAmountTotal = BigDecimal.ZERO; + BigDecimal buyAmountTotal = BigDecimal.ZERO; + User merchantUser = requestUtil.getByUserId(merchant.getUserId()); + for (OrderGoods orderGoods : orderGoodsList) { + Goods goods = orderGoods.getGoods(); + BigDecimal merchantAmount = BigDecimal.ZERO; + BigDecimal rate = BigDecimal.ZERO; + switch (merchant.getShopType()) { + case "会员店": { + merchantAmount = goods.getMemberStorePrice(); + rate = goods.getMemberStoreRate().divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP); + } + break; + case "实体连锁店": { + merchantAmount = goods.getChainStorePrice(); + rate = goods.getChainStoreRate().divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP); + } + break; + case "会员超市": { + merchantAmount = goods.getMemberMarketPrice(); + rate = goods.getMemberMarketRate().divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP); + } + break; + } + BigDecimal amountDiff = orderGoods.getPrice().subtract(merchantAmount); + buyAmountTotal = buyAmountTotal.add(merchantAmount.multiply(BigDecimal.valueOf(orderGoods.getTotalNum()))); + if (amountDiff.compareTo(BigDecimal.ZERO) > 0) { + diffAmountTotal = diffAmountTotal.add(amountDiff.multiply(BigDecimal.valueOf(orderGoods.getTotalNum()))); + diffAmountTotal = diffAmountTotal.multiply(rate); + } + } + BigDecimal incomeTotal = diffAmountTotal.add(buyAmountTotal); + BigDecimal newBalance = merchantUser.getBalance().add(incomeTotal); + merchantUser.setBalance(newBalance); + requestUtil.updateUserBalance(balanceApi, merchantUser); + Merchant finalMerchant = merchant; + userBalanceLogService.save(new UserBalanceLog() {{ + setUserId(merchantUser.getUserId()); + setScene(BalanceScene.BALANCE_SCENE_DIFF); + setMoney(incomeTotal); + setBalance(newBalance); + setOrderNo(order.getOrderNo()); + setMerchantId(finalMerchant.getMerchantId()); + setMerchantCode(finalMerchant.getMerchantCode()); + setTenantId(getTenantId()); + }}); + } + } else if (order.getPayType().equals(1)) { + // 外卖 + Merchant merchant = merchantService.getById(order.getMerchantId()); + User merchantUser = requestUtil.getByUserId(merchant.getUserId()); + + BigDecimal rate = BigDecimal.ONE.subtract(merchant.getCommission().divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)); + BigDecimal amountTotal = order.getTotalPrice(); + BigDecimal incomeTotal = amountTotal.multiply(rate); + BigDecimal newBalance = merchantUser.getBalance().add(incomeTotal); + merchantUser.setBalance(newBalance); + requestUtil.updateUserBalance(balanceApi, merchantUser); + userBalanceLogService.save(new UserBalanceLog() {{ + setUserId(merchantUser.getUserId()); + setScene(BalanceScene.BALANCE_SCENE_OUT_TAKE); + setMoney(incomeTotal); + setBalance(newBalance); + setMerchantId(merchant.getMerchantId()); + setMerchantCode(merchant.getMerchantCode()); + setOrderNo(order.getOrderNo()); + setTenantId(getTenantId()); + }}); + + } } - return true; - } } diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/SplashServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/SplashServiceImpl.java new file mode 100644 index 0000000..30274d0 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/impl/SplashServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.shop.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.shop.mapper.SplashMapper; +import com.gxwebsoft.shop.service.SplashService; +import com.gxwebsoft.shop.entity.Splash; +import com.gxwebsoft.shop.param.SplashParam; +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 2024-09-30 22:07:41 + */ +@Service +public class SplashServiceImpl extends ServiceImpl implements SplashService { + + @Override + public PageResult pageRel(SplashParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(SplashParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public Splash getByIdRel(Integer id) { + SplashParam param = new SplashParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/SwiperServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/SwiperServiceImpl.java new file mode 100644 index 0000000..ce3b7e1 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/impl/SwiperServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.shop.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.shop.mapper.SwiperMapper; +import com.gxwebsoft.shop.service.SwiperService; +import com.gxwebsoft.shop.entity.Swiper; +import com.gxwebsoft.shop.param.SwiperParam; +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 2024-09-30 22:07:41 + */ +@Service +public class SwiperServiceImpl extends ServiceImpl implements SwiperService { + + @Override + public PageResult pageRel(SwiperParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(SwiperParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public Swiper getByIdRel(Integer id) { + SwiperParam param = new SwiperParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/UserAddressServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/UserAddressServiceImpl.java index 3ba085a..309f053 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/UserAddressServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/UserAddressServiceImpl.java @@ -1,5 +1,6 @@ package com.gxwebsoft.shop.service.impl; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gxwebsoft.shop.mapper.UserAddressMapper; import com.gxwebsoft.shop.service.UserAddressService; @@ -10,7 +11,6 @@ import com.gxwebsoft.common.core.web.PageResult; import org.springframework.stereotype.Service; import java.util.List; -import java.util.stream.Collectors; /** * 收货地址Service实现 @@ -24,7 +24,7 @@ public class UserAddressServiceImpl extends ServiceImpl pageRel(UserAddressParam param) { PageParam page = new PageParam<>(param); - page.setDefaultOrder("is_default desc"); + page.setDefaultOrder("is_default desc, id desc"); List list = baseMapper.selectPageRel(page, param); return new PageResult<>(list, page.getTotal()); } @@ -34,7 +34,7 @@ public class UserAddressServiceImpl extends ServiceImpl list = baseMapper.selectListRel(param); // 排序 PageParam page = new PageParam<>(); - page.setDefaultOrder("is_default desc"); + page.setDefaultOrder("is_default desc, id desc"); return page.sortRecords(list); } @@ -45,4 +45,13 @@ public class UserAddressServiceImpl extends ServiceImpl() + .eq(UserAddress::getUserId, userId) + .eq(UserAddress::getIsDefault, 1) + .set(UserAddress::getIsDefault, 0) + ); + } } diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/UserCollectionServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/UserCollectionServiceImpl.java index b65ad72..a42cef1 100644 --- a/src/main/java/com/gxwebsoft/shop/service/impl/UserCollectionServiceImpl.java +++ b/src/main/java/com/gxwebsoft/shop/service/impl/UserCollectionServiceImpl.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.Merchant; import com.gxwebsoft.shop.mapper.UserCollectionMapper; +import com.gxwebsoft.shop.service.MerchantService; +import com.gxwebsoft.shop.service.OrderGoodsService; +import com.gxwebsoft.shop.service.OrderService; import com.gxwebsoft.shop.service.UserCollectionService; import com.gxwebsoft.shop.entity.UserCollection; import com.gxwebsoft.shop.param.UserCollectionParam; @@ -9,16 +14,21 @@ 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; /** * 我的收藏Service实现 * * @author 科技小王子 - * @since 2024-04-28 18:17:37 + * @since 2024-10-03 01:51:46 */ @Service public class UserCollectionServiceImpl extends ServiceImpl implements UserCollectionService { + @Resource + private MerchantService merchantService; + @Resource + private OrderGoodsService orderGoodsService; @Override public PageResult pageRel(UserCollectionParam param) { @@ -30,11 +40,20 @@ public class UserCollectionServiceImpl extends ServiceImpl listRel(UserCollectionParam param) { - List list = baseMapper.selectListRel(param); - // 排序 - PageParam page = new PageParam<>(); - page.setDefaultOrder("sort_number asc, create_time desc"); - return page.sortRecords(list); + List list = list( + new LambdaQueryWrapper() + .eq(UserCollection::getUserId, param.getUserId()) + .eq(UserCollection::getType, param.getType()) + .orderByDesc(UserCollection::getCreateTime) + ); + for (UserCollection userCollection : list) { + if (userCollection.getType().equals(0)) { + Merchant merchant = merchantService.getById(userCollection.getTid()); + merchant.setOrderNum(orderGoodsService.countByMerchant(merchant.getMerchantId())); + userCollection.setMerchant(merchant); + } + } + return list; } @Override @@ -44,4 +63,13 @@ public class UserCollectionServiceImpl extends ServiceImpl carts; + @Data public static class Payload { private Integer shopId; private Integer shopName; + private Merchant merchant; private List carts; } } diff --git a/src/main/resources/account.properties b/src/main/resources/account.properties new file mode 100644 index 0000000..dbb7ff9 --- /dev/null +++ b/src/main/resources/account.properties @@ -0,0 +1,9 @@ +key = QIfOPROg5054 +#customer = +secret = 09401b3c56f54175bcacc74d0519e4ef +#userid = + +#??????100??????????????????????????????true:?? false: ?? ? +log.return.record = true +#????????????????? +logPath = /Users/liangxin/Project/JAVA/nbg-java \ No newline at end of file diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index f5538db..c0943eb 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -22,4 +22,5 @@ socketio: config: # 开发环境接口 server-url: http://127.0.0.1:9091/api - upload-path: /Users/gxwebsoft/Documents/uploads/ # window(D:\Temp) + upload-path: /Users/liangxin/Project/JAVA/nbg-java/file/ + local-upload-path: /Users/liangxin/Project/JAVA/nbg-java/file/ diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index bbaa999..8af862f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -4,7 +4,8 @@ server: # 多环境配置 spring: profiles: - active: dev +# active: dev + active: prod application: name: server @@ -89,8 +90,8 @@ config: server-url: https://server.gxwebsoft.com/api # 文件服务器 file-server: https://file.gxwebsoft.com - upload-path: /Users/gxwebsoft/Documents/uploads/ - local-upload-path: /Users/gxwebsoft/Documents/uploads/ +# upload-path: /Users/gxwebsoft/Documents/uploads/ +# local-upload-path: /Users/gxwebsoft/Documents/uploads/ # 阿里云OSS云存储 endpoint: https://oss-cn-shenzhen.aliyuncs.com @@ -100,4 +101,10 @@ config: bucketDomain: https://oss.wsdns.cn aliyunDomain: https://oss-gxwebsoft.oss-cn-shenzhen.aliyuncs.com +wx: + miniapp: + configs: + - appid: wx309c034f7556aeb1 + secret: c8fa9e5ee2edc8c0bbd5f9c38df244ec + msgDataFormat: JSON diff --git a/src/test/java/com/gxwebsoft/generator/CmsGenerator.java b/src/test/java/com/gxwebsoft/generator/CmsGenerator.java index 4fc9b70..970d5cc 100644 --- a/src/test/java/com/gxwebsoft/generator/CmsGenerator.java +++ b/src/test/java/com/gxwebsoft/generator/CmsGenerator.java @@ -21,32 +21,32 @@ import java.util.Map; * @since 2021-09-05 00:31:14 */ public class CmsGenerator { - // 输出位置 - private static final String OUTPUT_LOCATION = System.getProperty("user.dir"); - //private static final String OUTPUT_LOCATION = "D:/codegen"; // 不想生成到项目中可以写磁盘路径 - // 输出目录 - private static final String OUTPUT_DIR = "/src/main/java"; - // Vue文件输出位置 - private static final String OUTPUT_LOCATION_VUE = "/Users/gxwebsoft/VUE/gxtyzx-admin-vue"; - // Vue文件输出目录 - private static final String OUTPUT_LOCATION_UNIAPP = "/Users/gxwebsoft/VUE/nbg"; - // Vue文件输出目录 - private static final String OUTPUT_DIR_VUE = "/src"; - // 作者名称 - private static final String AUTHOR = "科技小王子"; - // 是否在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_DRIVER = "com.mysql.cj.jdbc.Driver"; - private static final String DB_USERNAME = "modules"; - private static final String DB_PASSWORD = "8YdLnk7KsPAyDXGA"; - // 包名 - private static final String PACKAGE_NAME = "com.gxwebsoft"; - // 模块名 - private static final String MODULE_NAME = "cms"; - // 需要生成的表 - private static final String[] TABLE_NAMES = new String[]{ + // 输出位置 + private static final String OUTPUT_LOCATION = System.getProperty("user.dir"); + //private static final String OUTPUT_LOCATION = "D:/codegen"; // 不想生成到项目中可以写磁盘路径 + // 输出目录 + private static final String OUTPUT_DIR = "/src/main/java"; + // Vue文件输出位置 + private static final String OUTPUT_LOCATION_VUE = "/Users/liangxin/Project/Html/web/nbg-admin"; + // Vue文件输出目录 + private static final String OUTPUT_LOCATION_UNIAPP = "/Users/liangxin/Project/Html/miniProgram/nbg-uniapp"; + // Vue文件输出目录 + private static final String OUTPUT_DIR_VUE = "/src"; + // 作者名称 + private static final String AUTHOR = "科技小王子"; + // 是否在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_DRIVER = "com.mysql.cj.jdbc.Driver"; + private static final String DB_USERNAME = "modules"; + private static final String DB_PASSWORD = "8YdLnk7KsPAyDXGA"; + // 包名 + private static final String PACKAGE_NAME = "com.gxwebsoft"; + // 模块名 + private static final String MODULE_NAME = "cms"; + // 需要生成的表 + private static final String[] TABLE_NAMES = new String[]{ // "cms_article", // "cms_article_category", // "cms_article_like", @@ -71,200 +71,201 @@ public class CmsGenerator { // "cms_mp_field" // "cms_mp_ad" // "cms_components" - "cms_mp_official_menu" + "cms_design_collect", + "cms_design_sign_up" - }; - // 需要去除的表前缀 - private static final String[] TABLE_PREFIX = new String[]{ - "cms_", - "tb_" - }; - // 不需要作为查询参数的字段 - private static final String[] PARAM_EXCLUDE_FIELDS = new String[]{ - "tenant_id", - "create_time", - "update_time" - }; - // 查询参数使用String的类型 - private static final String[] PARAM_TO_STRING_TYPE = new String[]{ - "Date", - "LocalDate", - "LocalTime", - "LocalDateTime" - }; - // 查询参数使用EQ的类型 - private static final String[] PARAM_EQ_TYPE = new String[]{ - "Integer", - "Boolean", - "BigDecimal" - }; - // 是否添加权限注解 - private static final boolean AUTH_ANNOTATION = false; - // 是否添加日志注解 - private static final boolean LOG_ANNOTATION = false; - // controller的mapping前缀 - private static final String CONTROLLER_MAPPING_PREFIX = "/api"; - // 模板所在位置 - private static final String TEMPLATES_DIR = "/src/test/java/com/gxwebsoft/generator/templates"; - - public static void main(String[] args) { - // 代码生成器 - AutoGenerator mpg = new AutoGenerator(); - - // 全局配置 - GlobalConfig gc = new GlobalConfig(); - gc.setOutputDir(OUTPUT_LOCATION + OUTPUT_DIR); - gc.setAuthor(AUTHOR); - gc.setOpen(false); - gc.setFileOverride(true); - gc.setEnableCache(ENABLE_CACHE); - gc.setSwagger2(true); - gc.setIdType(IdType.AUTO); - gc.setServiceName("%sService"); - mpg.setGlobalConfig(gc); - - // 数据源配置 - DataSourceConfig dsc = new DataSourceConfig(); - dsc.setUrl(DB_URL); - // dsc.setSchemaName("public"); - dsc.setDriverName(DB_DRIVER); - dsc.setUsername(DB_USERNAME); - dsc.setPassword(DB_PASSWORD); - mpg.setDataSource(dsc); - - // 包配置 - PackageConfig pc = new PackageConfig(); - pc.setModuleName(MODULE_NAME); - pc.setParent(PACKAGE_NAME); - mpg.setPackageInfo(pc); - - // 策略配置 - StrategyConfig strategy = new StrategyConfig(); - strategy.setNaming(NamingStrategy.underline_to_camel); - strategy.setColumnNaming(NamingStrategy.underline_to_camel); - strategy.setInclude(TABLE_NAMES); - strategy.setTablePrefix(TABLE_PREFIX); - strategy.setSuperControllerClass(PACKAGE_NAME + ".common.core.web.BaseController"); - strategy.setEntityLombokModel(true); - strategy.setRestControllerStyle(true); - strategy.setControllerMappingHyphenStyle(true); - strategy.setLogicDeleteFieldName("deleted"); - mpg.setStrategy(strategy); - - // 模板配置 - TemplateConfig templateConfig = new TemplateConfig(); - templateConfig.setController(TEMPLATES_DIR + "/controller.java"); - templateConfig.setEntity(TEMPLATES_DIR + "/entity.java"); - templateConfig.setMapper(TEMPLATES_DIR + "/mapper.java"); - templateConfig.setXml(TEMPLATES_DIR + "/mapper.xml"); - templateConfig.setService(TEMPLATES_DIR + "/service.java"); - templateConfig.setServiceImpl(TEMPLATES_DIR + "/serviceImpl.java"); - mpg.setTemplate(templateConfig); - mpg.setTemplateEngine(new BeetlTemplateEnginePlus()); - - // 自定义模板配置 - InjectionConfig cfg = new InjectionConfig() { - @Override - public void initMap() { - Map map = new HashMap<>(); - map.put("packageName", PACKAGE_NAME); - map.put("paramExcludeFields", PARAM_EXCLUDE_FIELDS); - map.put("paramToStringType", PARAM_TO_STRING_TYPE); - map.put("paramEqType", PARAM_EQ_TYPE); - map.put("authAnnotation", AUTH_ANNOTATION); - map.put("logAnnotation", LOG_ANNOTATION); - map.put("controllerMappingPrefix", CONTROLLER_MAPPING_PREFIX); - this.setMap(map); - } }; - String templatePath = TEMPLATES_DIR + "/param.java.btl"; - List focList = new ArrayList<>(); - focList.add(new FileOutConfig(templatePath) { - @Override - public String outputFile(TableInfo tableInfo) { - return OUTPUT_LOCATION + OUTPUT_DIR + "/" - + PACKAGE_NAME.replace(".", "/") - + "/" + pc.getModuleName() + "/param/" - + tableInfo.getEntityName() + "Param" + StringPool.DOT_JAVA; - } - }); - /** - * 以下是生成VUE项目代码 - * 生成文件的路径 /api/shop/goods/index.ts - */ - templatePath = TEMPLATES_DIR + "/index.ts.btl"; + // 需要去除的表前缀 + private static final String[] TABLE_PREFIX = new String[]{ + "cms_", + "tb_" + }; + // 不需要作为查询参数的字段 + private static final String[] PARAM_EXCLUDE_FIELDS = new String[]{ + "tenant_id", + "create_time", + "update_time" + }; + // 查询参数使用String的类型 + private static final String[] PARAM_TO_STRING_TYPE = new String[]{ + "Date", + "LocalDate", + "LocalTime", + "LocalDateTime" + }; + // 查询参数使用EQ的类型 + private static final String[] PARAM_EQ_TYPE = new String[]{ + "Integer", + "Boolean", + "BigDecimal" + }; + // 是否添加权限注解 + private static final boolean AUTH_ANNOTATION = false; + // 是否添加日志注解 + private static final boolean LOG_ANNOTATION = false; + // controller的mapping前缀 + private static final String CONTROLLER_MAPPING_PREFIX = "/api"; + // 模板所在位置 + private static final String TEMPLATES_DIR = "/src/test/java/com/gxwebsoft/generator/templates"; - focList.add(new FileOutConfig(templatePath) { - @Override - public String outputFile(TableInfo tableInfo) { - return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE - + "/api/" + pc.getModuleName() + "/" - + tableInfo.getEntityPath() + "/" + "index.ts"; - } - }); - focList.add(new FileOutConfig() { - @Override - public String outputFile(TableInfo tableInfo) { - return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE - + "/api/" + pc.getModuleName() + "/" - + tableInfo.getEntityPath() + "/" + "index.ts"; - } - }); - // 生成TS文件 (/api/shop/goods/model/index.ts) - templatePath = TEMPLATES_DIR + "/model.ts.btl"; - focList.add(new FileOutConfig(templatePath) { - @Override - public String outputFile(TableInfo tableInfo) { - return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE - + "/api/" + pc.getModuleName() + "/" - + tableInfo.getEntityPath() + "/model/" + "index.ts"; - } - }); - focList.add(new FileOutConfig(templatePath) { - @Override - public String outputFile(TableInfo tableInfo) { - return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE - + "/api/" + pc.getModuleName() + "/" - + tableInfo.getEntityPath() + "/model/" + "index.ts"; - } - }); - // 生成Vue文件(/views/shop/goods/index.vue) - templatePath = TEMPLATES_DIR + "/index.vue.btl"; - focList.add(new FileOutConfig(templatePath) { - @Override - public String outputFile(TableInfo tableInfo) { - return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE - + "/views/" + pc.getModuleName() + "/" - + tableInfo.getEntityPath() + "/" + "index.vue"; - } - }); + public static void main(String[] args) { + // 代码生成器 + AutoGenerator mpg = new AutoGenerator(); - // 生成components文件(/views/shop/goods/components/edit.vue) - templatePath = TEMPLATES_DIR + "/components.edit.vue.btl"; - focList.add(new FileOutConfig(templatePath) { - @Override - public String outputFile(TableInfo tableInfo) { - return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE - + "/views/" + pc.getModuleName() + "/" - + tableInfo.getEntityPath() + "/components/" + tableInfo.getEntityPath() + "Edit.vue"; - } - }); + // 全局配置 + GlobalConfig gc = new GlobalConfig(); + gc.setOutputDir(OUTPUT_LOCATION + OUTPUT_DIR); + gc.setAuthor(AUTHOR); + gc.setOpen(false); + gc.setFileOverride(true); + gc.setEnableCache(ENABLE_CACHE); + gc.setSwagger2(true); + gc.setIdType(IdType.AUTO); + gc.setServiceName("%sService"); + mpg.setGlobalConfig(gc); - // 生成components文件(/views/shop/goods/components/search.vue) - templatePath = TEMPLATES_DIR + "/components.search.vue.btl"; - focList.add(new FileOutConfig(templatePath) { - @Override - public String outputFile(TableInfo tableInfo) { - return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE - + "/views/" + pc.getModuleName() + "/" - + tableInfo.getEntityPath() + "/components/" + "search.vue"; - } - }); + // 数据源配置 + DataSourceConfig dsc = new DataSourceConfig(); + dsc.setUrl(DB_URL); + // dsc.setSchemaName("public"); + dsc.setDriverName(DB_DRIVER); + dsc.setUsername(DB_USERNAME); + dsc.setPassword(DB_PASSWORD); + mpg.setDataSource(dsc); - cfg.setFileOutConfigList(focList); - mpg.setCfg(cfg); + // 包配置 + PackageConfig pc = new PackageConfig(); + pc.setModuleName(MODULE_NAME); + pc.setParent(PACKAGE_NAME); + mpg.setPackageInfo(pc); - mpg.execute(); - } + // 策略配置 + StrategyConfig strategy = new StrategyConfig(); + strategy.setNaming(NamingStrategy.underline_to_camel); + strategy.setColumnNaming(NamingStrategy.underline_to_camel); + strategy.setInclude(TABLE_NAMES); + strategy.setTablePrefix(TABLE_PREFIX); + strategy.setSuperControllerClass(PACKAGE_NAME + ".common.core.web.BaseController"); + strategy.setEntityLombokModel(true); + strategy.setRestControllerStyle(true); + strategy.setControllerMappingHyphenStyle(true); + strategy.setLogicDeleteFieldName("deleted"); + mpg.setStrategy(strategy); + + // 模板配置 + TemplateConfig templateConfig = new TemplateConfig(); + templateConfig.setController(TEMPLATES_DIR + "/controller.java"); + templateConfig.setEntity(TEMPLATES_DIR + "/entity.java"); + templateConfig.setMapper(TEMPLATES_DIR + "/mapper.java"); + templateConfig.setXml(TEMPLATES_DIR + "/mapper.xml"); + templateConfig.setService(TEMPLATES_DIR + "/service.java"); + templateConfig.setServiceImpl(TEMPLATES_DIR + "/serviceImpl.java"); + mpg.setTemplate(templateConfig); + mpg.setTemplateEngine(new BeetlTemplateEnginePlus()); + + // 自定义模板配置 + InjectionConfig cfg = new InjectionConfig() { + @Override + public void initMap() { + Map map = new HashMap<>(); + map.put("packageName", PACKAGE_NAME); + map.put("paramExcludeFields", PARAM_EXCLUDE_FIELDS); + map.put("paramToStringType", PARAM_TO_STRING_TYPE); + map.put("paramEqType", PARAM_EQ_TYPE); + map.put("authAnnotation", AUTH_ANNOTATION); + map.put("logAnnotation", LOG_ANNOTATION); + map.put("controllerMappingPrefix", CONTROLLER_MAPPING_PREFIX); + this.setMap(map); + } + }; + String templatePath = TEMPLATES_DIR + "/param.java.btl"; + List focList = new ArrayList<>(); + focList.add(new FileOutConfig(templatePath) { + @Override + public String outputFile(TableInfo tableInfo) { + return OUTPUT_LOCATION + OUTPUT_DIR + "/" + + PACKAGE_NAME.replace(".", "/") + + "/" + pc.getModuleName() + "/param/" + + tableInfo.getEntityName() + "Param" + StringPool.DOT_JAVA; + } + }); + /** + * 以下是生成VUE项目代码 + * 生成文件的路径 /api/shop/goods/index.ts + */ + templatePath = TEMPLATES_DIR + "/index.ts.btl"; + + focList.add(new FileOutConfig(templatePath) { + @Override + public String outputFile(TableInfo tableInfo) { + return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE + + "/api/" + pc.getModuleName() + "/" + + tableInfo.getEntityPath() + "/" + "index.ts"; + } + }); + focList.add(new FileOutConfig() { + @Override + public String outputFile(TableInfo tableInfo) { + return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE + + "/api/" + pc.getModuleName() + "/" + + tableInfo.getEntityPath() + "/" + "index.ts"; + } + }); + // 生成TS文件 (/api/shop/goods/model/index.ts) + templatePath = TEMPLATES_DIR + "/model.ts.btl"; + focList.add(new FileOutConfig(templatePath) { + @Override + public String outputFile(TableInfo tableInfo) { + return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE + + "/api/" + pc.getModuleName() + "/" + + tableInfo.getEntityPath() + "/model/" + "index.ts"; + } + }); + focList.add(new FileOutConfig(templatePath) { + @Override + public String outputFile(TableInfo tableInfo) { + return OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE + + "/api/" + pc.getModuleName() + "/" + + tableInfo.getEntityPath() + "/model/" + "index.ts"; + } + }); + // 生成Vue文件(/views/shop/goods/index.vue) + templatePath = TEMPLATES_DIR + "/index.vue.btl"; + focList.add(new FileOutConfig(templatePath) { + @Override + public String outputFile(TableInfo tableInfo) { + return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE + + "/views/" + pc.getModuleName() + "/" + + tableInfo.getEntityPath() + "/" + "index.vue"; + } + }); + + // 生成components文件(/views/shop/goods/components/edit.vue) + templatePath = TEMPLATES_DIR + "/components.edit.vue.btl"; + focList.add(new FileOutConfig(templatePath) { + @Override + public String outputFile(TableInfo tableInfo) { + return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE + + "/views/" + pc.getModuleName() + "/" + + tableInfo.getEntityPath() + "/components/" + tableInfo.getEntityPath() + "Edit.vue"; + } + }); + + // 生成components文件(/views/shop/goods/components/search.vue) + templatePath = TEMPLATES_DIR + "/components.search.vue.btl"; + focList.add(new FileOutConfig(templatePath) { + @Override + public String outputFile(TableInfo tableInfo) { + return OUTPUT_LOCATION_VUE + OUTPUT_DIR_VUE + + "/views/" + pc.getModuleName() + "/" + + tableInfo.getEntityPath() + "/components/" + "search.vue"; + } + }); + + cfg.setFileOutConfigList(focList); + mpg.setCfg(cfg); + + mpg.execute(); + } } diff --git a/src/test/java/com/gxwebsoft/generator/ShopGenerator.java b/src/test/java/com/gxwebsoft/generator/ShopGenerator.java index f76616b..412e8e1 100644 --- a/src/test/java/com/gxwebsoft/generator/ShopGenerator.java +++ b/src/test/java/com/gxwebsoft/generator/ShopGenerator.java @@ -92,7 +92,8 @@ public class ShopGenerator { // "shop_order_delivery", // "shop_order_delivery_goods", // "shop_order_extract" - "shop_merchant_category" +// "shop_splash", + "shop_goods_income_config", }; // 需要去除的表前缀 private static final String[] TABLE_PREFIX = new String[]{