241009更新
This commit is contained in:
15
.idea/deployment.xml
generated
Normal file
15
.idea/deployment.xml
generated
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PublishConfigData" serverName="nbg" remoteFilesAllowedToDisappearOnAutoupload="false" confirmBeforeUploading="false">
|
||||
<option name="confirmBeforeUploading" value="false" />
|
||||
<serverData>
|
||||
<paths name="nbg">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping deploy="/" local="$PROJECT_DIR$/target" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
</serverData>
|
||||
</component>
|
||||
</project>
|
||||
14
.idea/webServers.xml
generated
Normal file
14
.idea/webServers.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="WebServers">
|
||||
<option name="servers">
|
||||
<webServer id="a8fd968b-4825-43b5-bc54-7470bfb7a789" name="nbg" url="http://47.119.165.234">
|
||||
<fileTransfer host="47.119.165.234" port="21888">
|
||||
<advancedOptions>
|
||||
<advancedOptions dataProtectionLevel="Private" passiveMode="true" shareSSLContext="true" />
|
||||
</advancedOptions>
|
||||
</fileTransfer>
|
||||
</webServer>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
BIN
file/qr/friendPay_583486.png
Normal file
BIN
file/qr/friendPay_583486.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
179
pom.xml
179
pom.xml
@@ -88,9 +88,9 @@
|
||||
|
||||
<!-- mybatis-plus 连表插件-->
|
||||
<dependency>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||
<version>1.4.5</version>
|
||||
<groupId>com.github.yulichang</groupId>
|
||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
||||
<version>1.4.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- mybatis-plus-generator -->
|
||||
@@ -190,108 +190,113 @@
|
||||
|
||||
<!--Redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里SDK -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.4.3</version>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
<version>4.4.3</version>
|
||||
</dependency>
|
||||
<!--阿里支付 老版本 SDK-->
|
||||
<dependency>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.35.0.ALL</version>
|
||||
<groupId>com.alipay.sdk</groupId>
|
||||
<artifactId>alipay-sdk-java</artifactId>
|
||||
<version>4.35.0.ALL</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on -->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.70</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.20</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on -->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.70</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.20</version>
|
||||
</dependency>
|
||||
|
||||
<!--二维码-->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.3</version>
|
||||
</dependency>
|
||||
<!--二维码-->
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>core</artifactId>
|
||||
<version>3.3.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.vaadin.external.google</groupId>
|
||||
<artifactId>android-json</artifactId>
|
||||
<version>0.0.20131108.vaadin1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vaadin.external.google</groupId>
|
||||
<artifactId>android-json</artifactId>
|
||||
<version>0.0.20131108.vaadin1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- socketio -->
|
||||
<dependency>
|
||||
<groupId>com.corundumstudio.socketio</groupId>
|
||||
<artifactId>netty-socketio</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
<!-- socketio -->
|
||||
<dependency>
|
||||
<groupId>com.corundumstudio.socketio</groupId>
|
||||
<artifactId>netty-socketio</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 微信支付 APIv3 Java SDK-->
|
||||
<dependency>
|
||||
<groupId>com.github.wechatpay-apiv3</groupId>
|
||||
<artifactId>wechatpay-java</artifactId>
|
||||
<version>0.2.9</version>
|
||||
</dependency>
|
||||
<!-- 微信支付 APIv3 Java SDK-->
|
||||
<dependency>
|
||||
<groupId>com.github.wechatpay-apiv3</groupId>
|
||||
<artifactId>wechatpay-java</artifactId>
|
||||
<version>0.2.9</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-miniapp</artifactId>
|
||||
<version>4.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
<artifactId>weixin-java-miniapp</artifactId>
|
||||
<version>4.6.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里云 OSS -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.17.0</version>
|
||||
</dependency>
|
||||
<!-- 阿里云 OSS -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.17.0</version>
|
||||
</dependency>
|
||||
<!-- 快递100-->
|
||||
<dependency>
|
||||
<groupId>com.github.kuaidi100-api</groupId>
|
||||
<artifactId>sdk</artifactId>
|
||||
<version>1.0.13</version>
|
||||
</dependency>
|
||||
|
||||
<!--诺诺开票接口-->
|
||||
<dependency>
|
||||
<groupId>com.nuonuo</groupId>
|
||||
<artifactId>open-sdk</artifactId>
|
||||
<version>1.0.5.2</version>
|
||||
</dependency>
|
||||
<!--诺诺开票接口-->
|
||||
<dependency>
|
||||
<groupId>com.nuonuo</groupId>
|
||||
<artifactId>open-sdk</artifactId>
|
||||
<version>1.0.5.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- knife4j -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
<!-- knife4j -->
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -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<PageResult<DesignCollect>> page(DesignCollectParam param) {
|
||||
// 使用关联查询
|
||||
return success(designCollectService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部设计征集")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DesignCollect>> list(DesignCollectParam param) {
|
||||
// 使用关联查询
|
||||
return success(designCollectService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询设计征集")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DesignCollect> 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<DesignCollect> list) {
|
||||
if (designCollectService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改设计征集")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DesignCollect> batchParam) {
|
||||
if (batchParam.update(designCollectService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除设计征集")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (designCollectService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<PageResult<DesignSignUp>> page(DesignSignUpParam param) {
|
||||
// 使用关联查询
|
||||
return success(designSignUpService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部设计征集报名")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DesignSignUp>> list(DesignSignUpParam param) {
|
||||
// 使用关联查询
|
||||
return success(designSignUpService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:designSignUp:list')")
|
||||
@ApiOperation("根据id查询设计征集报名")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DesignSignUp> 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<DesignSignUp> list) {
|
||||
if (designSignUpService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改设计征集报名")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DesignSignUp> batchParam) {
|
||||
if (batchParam.update(designSignUpService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除设计征集报名")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (designSignUpService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<PageResult<Mp>> page(MpParam param) {
|
||||
// 使用关联查询
|
||||
return success(mpService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部小程序")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Mp>> list(MpParam param) {
|
||||
// 使用关联查询
|
||||
return success(mpService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:mp:list')")
|
||||
@ApiOperation("根据id查询小程序")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Mp> 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<Mp>().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<Mp> list) {
|
||||
if (mpService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:mp:update')")
|
||||
@ApiOperation("批量修改小程序")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Mp> batchParam) {
|
||||
if (batchParam.update(mpService, "mp_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:mp:remove')")
|
||||
@ApiOperation("批量删除小程序")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> 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<PageResult<Mp>> page(MpParam param) {
|
||||
// 使用关联查询
|
||||
return success(mpService.pageRel(param));
|
||||
}
|
||||
|
||||
// 获取小程序
|
||||
if (mpService.count(new LambdaUpdateWrapper<Mp>().eq(Mp::getDeleted, 0)) == 0) {
|
||||
// 创建小程序
|
||||
createMp();
|
||||
@ApiOperation("查询全部小程序")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Mp>> list(MpParam param) {
|
||||
// 使用关联查询
|
||||
return success(mpService.listRel(param));
|
||||
}
|
||||
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
// 获取小程序
|
||||
final Mp mp = mpService.getOne(new LambdaQueryWrapper<Mp>().eq(Mp::getTenantId, tenantId).last("limit 1"));
|
||||
mp.setAppSecret(null);
|
||||
map.put("mp", mp);
|
||||
|
||||
// 原生导航条
|
||||
final List<MpPages> tabBar = mpPagesService.list(new LambdaQueryWrapper<MpPages>().eq(MpPages::getSubpackage, "MainPackage").last("limit 5"));
|
||||
map.put("tabBar", tabBar);
|
||||
|
||||
// 配置信息
|
||||
HashMap<String, Object> config = new HashMap<>();
|
||||
config.put("LICENSE_CODE", "");
|
||||
config.put("MAP_KEY", "");
|
||||
final List<MpField> fields = mpFieldService.list();
|
||||
fields.forEach(d -> {
|
||||
config.put(d.getName(), d.getValue());
|
||||
});
|
||||
map.put("config", config);
|
||||
|
||||
// 服务器时间
|
||||
HashMap<String, Object> 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<Mp> 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<Mp>().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<String, Object> layout = new HashMap<>();
|
||||
// 瀑布流商品数据 (type:0 商城商品,1 外卖商品)
|
||||
@PreAuthorize("hasAuthority('cms:mp:save')")
|
||||
@ApiOperation("批量添加小程序")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Mp> list) {
|
||||
if (mpService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:mp:update')")
|
||||
@ApiOperation("批量修改小程序")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Mp> batchParam) {
|
||||
if (batchParam.update(mpService, "mp_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:mp:remove')")
|
||||
@ApiOperation("批量删除小程序")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> 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<Mp>().eq(Mp::getDeleted, 0)) == 0) {
|
||||
// 创建小程序
|
||||
createMp();
|
||||
}
|
||||
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
// 获取小程序
|
||||
final Mp mp = mpService.getOne(new LambdaQueryWrapper<Mp>().eq(Mp::getTenantId, tenantId).last("limit 1"));
|
||||
mp.setAppSecret(null);
|
||||
map.put("mp", mp);
|
||||
|
||||
// 原生导航条
|
||||
final List<MpPages> tabBar = mpPagesService.list(new LambdaQueryWrapper<MpPages>().eq(MpPages::getSubpackage, "MainPackage").last("limit 5"));
|
||||
map.put("tabBar", tabBar);
|
||||
|
||||
// 配置信息
|
||||
HashMap<String, Object> config = new HashMap<>();
|
||||
config.put("LICENSE_CODE", "");
|
||||
config.put("MAP_KEY", "");
|
||||
final List<MpField> fields = mpFieldService.list();
|
||||
fields.forEach(d -> {
|
||||
config.put(d.getName(), d.getValue());
|
||||
});
|
||||
map.put("config", config);
|
||||
|
||||
// 服务器时间
|
||||
HashMap<String, Object> 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<String, Object> layout = new HashMap<>();
|
||||
// 瀑布流商品数据 (type:0 商城商品,1 外卖商品)
|
||||
// final List<Goods> goods = goodsService.list(new LambdaQueryWrapper<Goods>().ne(Goods::getType, 0).last("limit 10"));
|
||||
// final List<Goods> foods = goodsService.list(new LambdaQueryWrapper<Goods>().eq(Goods::getType, 1).last("limit 10"));
|
||||
|
||||
layout.put("goods",goodsService.getGoodsSpecType0());
|
||||
layout.put("foods", goodsService.getGoodsSpecType1());
|
||||
List<Goods> 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("清除成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
61
src/main/java/com/gxwebsoft/cms/entity/DesignCollect.java
Normal file
61
src/main/java/com/gxwebsoft/cms/entity/DesignCollect.java
Normal file
@@ -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;
|
||||
|
||||
}
|
||||
63
src/main/java/com/gxwebsoft/cms/entity/DesignSignUp.java
Normal file
63
src/main/java/com/gxwebsoft/cms/entity/DesignSignUp.java
Normal file
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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<DesignCollect> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<DesignCollect>
|
||||
*/
|
||||
List<DesignCollect> selectPageRel(@Param("page") IPage<DesignCollect> page,
|
||||
@Param("param") DesignCollectParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<DesignCollect> selectListRel(@Param("param") DesignCollectParam param);
|
||||
|
||||
}
|
||||
@@ -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<DesignSignUp> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<DesignSignUp>
|
||||
*/
|
||||
List<DesignSignUp> selectPageRel(@Param("page") IPage<DesignSignUp> page,
|
||||
@Param("param") DesignSignUpParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<DesignSignUp> selectListRel(@Param("param") DesignSignUpParam param);
|
||||
|
||||
}
|
||||
@@ -110,12 +110,10 @@
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
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}
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.sort_number ASC, a.create_time DESC
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.cms.mapper.DesignCollectMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM cms_design_collect a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.title != null">
|
||||
AND a.title LIKE CONCAT('%', #{param.title}, '%')
|
||||
</if>
|
||||
<if test="param.content != null">
|
||||
AND a.content LIKE CONCAT('%', #{param.content}, '%')
|
||||
</if>
|
||||
<if test="param.image != null">
|
||||
AND a.image LIKE CONCAT('%', #{param.image}, '%')
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.cms.entity.DesignCollect">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.cms.entity.DesignCollect">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.cms.mapper.DesignSignUpMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM cms_design_sign_up a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.designId != null">
|
||||
AND a.design_id = #{param.designId}
|
||||
</if>
|
||||
<if test="param.name != null">
|
||||
AND a.name LIKE CONCAT('%', #{param.name}, '%')
|
||||
</if>
|
||||
<if test="param.phone != null">
|
||||
AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
|
||||
</if>
|
||||
<if test="param.content != null">
|
||||
AND a.content LIKE CONCAT('%', #{param.content}, '%')
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.cms.entity.DesignSignUp">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.cms.entity.DesignSignUp">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
57
src/main/java/com/gxwebsoft/cms/param/DesignSignUpParam.java
Normal file
57
src/main/java/com/gxwebsoft/cms/param/DesignSignUpParam.java
Normal file
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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<DesignCollect> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<DesignCollect>
|
||||
*/
|
||||
PageResult<DesignCollect> pageRel(DesignCollectParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<DesignCollect>
|
||||
*/
|
||||
List<DesignCollect> listRel(DesignCollectParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id
|
||||
* @return DesignCollect
|
||||
*/
|
||||
DesignCollect getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -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<DesignSignUp> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<DesignSignUp>
|
||||
*/
|
||||
PageResult<DesignSignUp> pageRel(DesignSignUpParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<DesignSignUp>
|
||||
*/
|
||||
List<DesignSignUp> listRel(DesignSignUpParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id
|
||||
* @return DesignSignUp
|
||||
*/
|
||||
DesignSignUp getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -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<DesignCollectMapper, DesignCollect> implements DesignCollectService {
|
||||
|
||||
@Override
|
||||
public PageResult<DesignCollect> pageRel(DesignCollectParam param) {
|
||||
PageParam<DesignCollect, DesignCollectParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<DesignCollect> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DesignCollect> listRel(DesignCollectParam param) {
|
||||
List<DesignCollect> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<DesignCollect, DesignCollectParam> 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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<DesignSignUpMapper, DesignSignUp> implements DesignSignUpService {
|
||||
|
||||
@Override
|
||||
public PageResult<DesignSignUp> pageRel(DesignSignUpParam param) {
|
||||
PageParam<DesignSignUp, DesignSignUpParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<DesignSignUp> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DesignSignUp> listRel(DesignSignUpParam param) {
|
||||
List<DesignSignUp> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<DesignSignUp, DesignSignUpParam> 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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -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<String, Object> 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<Object> 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<String, Object> 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<Object> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ public class FileController extends BaseController {
|
||||
* 文件上传位置(服务器)
|
||||
*/
|
||||
private String getUploadDir() {
|
||||
return config.getUploadPath() + "file/";
|
||||
return config.getUploadPath();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
43
src/main/java/com/gxwebsoft/shop/config/WxMaProperties.java
Normal file
43
src/main/java/com/gxwebsoft/shop/config/WxMaProperties.java
Normal file
@@ -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<Config> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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<PageResult<Cart>> page(CartParam param) {
|
||||
// 使用关联查询
|
||||
return success(cartService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部购物车")
|
||||
@GetMapping()
|
||||
public ApiResult<CartVo> 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<Cart> 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<PageResult<Cart>> 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<Cart>().eq(Cart::getUserId,cart.getUserId())) > 50) {
|
||||
return fail("购物车宝贝数量已满,建议您先去结算或清理~");
|
||||
}
|
||||
// 叠加
|
||||
final Cart one = cartService.getOne(new LambdaQueryWrapper<Cart>().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<CartVo> 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<Cart> 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<Cart> 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<Cart>().eq(Cart::getUserId, cart.getUserId())) > 50) {
|
||||
return fail("购物车宝贝数量已满,建议您先去结算或清理~");
|
||||
}
|
||||
// 叠加
|
||||
if (!cart.getIsNew()) {
|
||||
LambdaQueryWrapper<Cart> cartLambdaQueryWrapper = new LambdaQueryWrapper<Cart>()
|
||||
.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<Cart> 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<Integer> 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<Cart> list) {
|
||||
if (cartService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:update')")
|
||||
@ApiOperation("批量修改购物车")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Cart> batchParam) {
|
||||
if (batchParam.update(cartService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:remove')")
|
||||
@ApiOperation("批量删除购物车")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> 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<Cart> carts = cartService.list(new LambdaUpdateWrapper<Cart>()
|
||||
.eq(Cart::getSelected, !yes)
|
||||
.eq(Cart::getUserId, getLoginUserId()));
|
||||
carts.forEach(d -> {
|
||||
d.setSelected(yes);
|
||||
});
|
||||
return success("修改成功", cartService.updateBatchById(carts));
|
||||
}
|
||||
final List<Cart> carts = cartService.list(new LambdaUpdateWrapper<Cart>()
|
||||
.eq(Cart::getSelected,!yes)
|
||||
.eq(Cart::getUserId, getLoginUserId()));
|
||||
carts.forEach(d -> {
|
||||
d.setSelected(yes);
|
||||
});
|
||||
return success("修改成功", cartService.updateBatchById(carts));
|
||||
}
|
||||
|
||||
|
||||
// @ApiOperation("我的购物车")
|
||||
|
||||
@@ -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<List<GoodsCategory>> listCategoryTree(GoodsCategoryParam param) {
|
||||
// 查询非店铺分类
|
||||
param.setMerchantId(0);
|
||||
final List<GoodsCategory> goodsCategoryList = goodsCategoryService.listRel(param);
|
||||
// 收集分类ID
|
||||
final Set<Integer> categoryIds = goodsCategoryList.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet());
|
||||
if (categoryIds.isEmpty()) {
|
||||
return success("分类为空",goodsCategoryList);
|
||||
}
|
||||
// List转为树形结构
|
||||
final List<GoodsCategory> list = toTreeData(goodsCategoryList, 0, GoodsCategory::getParentId, GoodsCategory::getCategoryId, GoodsCategory::setChildren);
|
||||
// 查询所有商品
|
||||
final List<Goods> goods = goodsService.list(new LambdaQueryWrapper<Goods>()
|
||||
.in(Goods::getCategoryId, categoryIds)
|
||||
.eq(Goods::getIsShow, 1)
|
||||
.eq(Goods::getDeleted, 0));
|
||||
@ApiOperation("查询商城菜单分类级商品数据(不联动)")
|
||||
@GetMapping("/listCategoryTree")
|
||||
public ApiResult<List<GoodsCategory>> listCategoryTree(GoodsCategoryParam param) {
|
||||
// 查询非店铺分类
|
||||
param.setMerchantId(0);
|
||||
final List<GoodsCategory> goodsCategoryList = goodsCategoryService.listRel(param);
|
||||
// 收集分类ID
|
||||
final Set<Integer> categoryIds = goodsCategoryList.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet());
|
||||
if (categoryIds.isEmpty()) {
|
||||
return success("分类为空", goodsCategoryList);
|
||||
}
|
||||
// List转为树形结构
|
||||
final List<GoodsCategory> list = toTreeData(goodsCategoryList, 0, GoodsCategory::getParentId, GoodsCategory::getCategoryId, GoodsCategory::setChildren);
|
||||
// 查询所有商品
|
||||
final List<Goods> goods = goodsService.list(new LambdaQueryWrapper<Goods>()
|
||||
.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<Integer, List<Goods>> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
final Map<Integer, List<Goods>> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
|
||||
final Set<Integer> goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet());
|
||||
final Set<Integer> goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet());
|
||||
|
||||
final List<GoodsSpec> specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||
final List<GoodsSpec> specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||
|
||||
final Map<Integer, List<GoodsSpec>> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||
final Map<Integer, List<GoodsSpec>> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||
|
||||
list.forEach(d -> {
|
||||
d.setName(d.getTitle());
|
||||
final List<Goods> goodsList = collectGoods.get(d.getCategoryId());
|
||||
if (!CollectionUtils.isEmpty(goodsList)) {
|
||||
goodsList.forEach(v -> {
|
||||
final List<GoodsSpec> 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<Goods> goodsList = collectGoods.get(d.getCategoryId());
|
||||
if (!CollectionUtils.isEmpty(goodsList)) {
|
||||
goodsList.forEach(v -> {
|
||||
final List<GoodsSpec> 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<List<GoodsCategory>> listCategoryParentIdTree(@PathVariable("parentId") Integer parentId) {
|
||||
// 查询非店铺分类
|
||||
final List<GoodsCategory> list = goodsCategoryService.list(new LambdaQueryWrapper<GoodsCategory>()
|
||||
.eq(GoodsCategory::getParentId,parentId)
|
||||
.eq(GoodsCategory::getType,0)
|
||||
.eq(GoodsCategory::getMerchantId,0));
|
||||
|
||||
final Set<Integer> categoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet());
|
||||
final List<Goods> goods = goodsService.list(new LambdaQueryWrapper<Goods>().in(Goods::getCategoryId, categoryIds));
|
||||
final Map<Integer, List<Goods>> collect = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
|
||||
final Map<Integer, List<Goods>> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
|
||||
final Set<Integer> goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet());
|
||||
|
||||
final List<GoodsSpec> specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||
|
||||
final Map<Integer, List<GoodsSpec>> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||
|
||||
LambdaQueryWrapper<Cart> 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<Cart> carts = cartService.list();
|
||||
final Map<Integer, List<Cart>> collectCart = carts.stream().collect(Collectors.groupingBy(Cart::getGoodsId));
|
||||
|
||||
list.forEach(d -> {
|
||||
d.setName(d.getTitle());
|
||||
final List<Goods> goodsList = collectGoods.get(d.getCategoryId());
|
||||
if (!CollectionUtils.isEmpty(goodsList)) {
|
||||
goodsList.forEach(v -> {
|
||||
final List<GoodsSpec> 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<Cart> carts1 = collectCart.get(v.getGoodsId());
|
||||
@ApiOperation("查询商城菜单分类级商品数据(不联动)")
|
||||
@GetMapping("/listCategoryParentIdTree/{parentId}")
|
||||
public ApiResult<List<GoodsCategory>> listCategoryParentIdTree(@PathVariable("parentId") Integer parentId) {
|
||||
// 查询非店铺分类
|
||||
final List<GoodsCategory> list = goodsCategoryService.list(new LambdaQueryWrapper<GoodsCategory>()
|
||||
.eq(GoodsCategory::getParentId, parentId)
|
||||
.eq(GoodsCategory::getType, 0)
|
||||
.eq(GoodsCategory::getMerchantId, 0));
|
||||
|
||||
if (ArrayUtil.isNotEmpty(carts1)) {
|
||||
final Cart cart = carts1.get(0);
|
||||
final Set<Integer> categoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet());
|
||||
final List<Goods> goods = goodsService.list(new LambdaQueryWrapper<Goods>().in(Goods::getCategoryId, categoryIds));
|
||||
final Map<Integer, List<Goods>> collect = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
|
||||
if (getLoginUser() != null && cart.getUserId().equals(getLoginUserId())) {
|
||||
v.setTotalNums(cart.getCartNum());
|
||||
}
|
||||
final Map<Integer, List<Goods>> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
|
||||
}
|
||||
final Set<Integer> goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet());
|
||||
|
||||
final List<GoodsSpec> specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||
|
||||
final Map<Integer, List<GoodsSpec>> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||
|
||||
LambdaQueryWrapper<Cart> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(Cart::getGoodsId, goodsIds).eq(Cart::getSelected, 1);
|
||||
if (ObjectUtil.isNotEmpty(getLoginUser())) {
|
||||
wrapper.eq(Cart::getUserId, getLoginUser().getUserId());
|
||||
}
|
||||
final List<Cart> carts = cartService.list();
|
||||
final Map<Integer, List<Cart>> collectCart = carts.stream().collect(Collectors.groupingBy(Cart::getGoodsId));
|
||||
|
||||
list.forEach(d -> {
|
||||
d.setName(d.getTitle());
|
||||
final List<Goods> goodsList = collectGoods.get(d.getCategoryId());
|
||||
if (!CollectionUtils.isEmpty(goodsList)) {
|
||||
goodsList.forEach(v -> {
|
||||
final List<GoodsSpec> 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<Cart> 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<List<GoodsCategory>> listShopCategoryTree(GoodsCategoryParam param) {
|
||||
final List<GoodsCategory> list = goodsCategoryService.listRel(param);
|
||||
final Set<Integer> categoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet());
|
||||
if (categoryIds.isEmpty()) {
|
||||
return success(list);
|
||||
return success("请求成功", list);
|
||||
}
|
||||
|
||||
final List<Goods> goods = goodsService.list(new LambdaQueryWrapper<Goods>().in(Goods::getCategoryId, categoryIds).eq(Goods::getIsShow, 1).eq(Goods::getDeleted, 0));
|
||||
final Map<Integer, List<Goods>> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
@ApiOperation("查询门店菜单分类及菜品数据(联动)")
|
||||
@GetMapping("/listShopCategoryTree")
|
||||
public ApiResult<List<GoodsCategory>> listShopCategoryTree(GoodsCategoryParam param) {
|
||||
final List<GoodsCategory> list = goodsCategoryService.listRel(param);
|
||||
final Set<Integer> categoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet());
|
||||
if (categoryIds.isEmpty()) {
|
||||
return success(list);
|
||||
}
|
||||
|
||||
final Set<Integer> goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet());
|
||||
final List<Goods> goods = goodsService.list(new LambdaQueryWrapper<Goods>().in(Goods::getCategoryId, categoryIds).eq(Goods::getIsShow, 1).eq(Goods::getDeleted, 0));
|
||||
final Map<Integer, List<Goods>> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
|
||||
final List<GoodsSpec> specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||
final Set<Integer> goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet());
|
||||
|
||||
final Map<Integer, List<GoodsSpec>> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||
List<GoodsSpec> specs = new ArrayList<>();
|
||||
Map<Integer, List<GoodsSpec>> collectGoodsSpec;
|
||||
if (!goodsIds.isEmpty()) {
|
||||
specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||
collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||
} else {
|
||||
collectGoodsSpec = null;
|
||||
}
|
||||
|
||||
list.forEach(d -> {
|
||||
d.setName(d.getTitle());
|
||||
final List<Goods> goodsList = collectGoods.get(d.getCategoryId());
|
||||
if (!CollectionUtils.isEmpty(goodsList)) {
|
||||
goodsList.forEach(v -> {
|
||||
final List<GoodsSpec> 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<Goods> goodsList = collectGoods.get(d.getCategoryId());
|
||||
if (!CollectionUtils.isEmpty(goodsList)) {
|
||||
goodsList.forEach(v -> {
|
||||
if (collectGoodsSpec != null) {
|
||||
final List<GoodsSpec> 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<PageResult<GoodsCategory>> page(GoodsCategoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsCategoryService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商品分类")
|
||||
@GetMapping()
|
||||
public ApiResult<List<GoodsCategory>> list(GoodsCategoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsCategoryService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询商品分类")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<GoodsCategory> 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<PageResult<GoodsCategory>> page(GoodsCategoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsCategoryService.pageRel(param));
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加商品分类")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<GoodsCategory> list) {
|
||||
if (goodsCategoryService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
@ApiOperation("查询全部商品分类")
|
||||
@GetMapping()
|
||||
public ApiResult<List<GoodsCategory>> list(GoodsCategoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsCategoryService.listRel(param));
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商品分类")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<GoodsCategory> batchParam) {
|
||||
if (batchParam.update(goodsCategoryService, "category_id")) {
|
||||
return success("修改成功");
|
||||
@ApiOperation("根据id查询商品分类")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<GoodsCategory> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(goodsCategoryService.getByIdRel(id));
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商品分类")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> 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<GoodsCategory> list) {
|
||||
if (goodsCategoryService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商品分类")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<GoodsCategory> batchParam) {
|
||||
if (batchParam.update(goodsCategoryService, "category_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商品分类")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsCategoryService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,6 +65,16 @@ public class GoodsController extends BaseController {
|
||||
public ApiResult<Goods> 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<GoodsSpec>().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<Merchant>().eq(Merchant::getMerchantId, goods.getMerchantId())));
|
||||
|
||||
@@ -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<PageResult<GoodsIncomeConfig>> page(GoodsIncomeConfigParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsIncomeConfigService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部分润配置")
|
||||
@GetMapping()
|
||||
public ApiResult<List<GoodsIncomeConfig>> list(GoodsIncomeConfigParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsIncomeConfigService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsIncomeConfig:list')")
|
||||
@ApiOperation("根据id查询分润配置")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<GoodsIncomeConfig> 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<GoodsIncomeConfig> list) {
|
||||
if (goodsIncomeConfigService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改分润配置")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<GoodsIncomeConfig> batchParam) {
|
||||
if (batchParam.update(goodsIncomeConfigService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除分润配置")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsIncomeConfigService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<PageResult<GoodsStockInMerchant>> page(GoodsStockInMerchantParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsStockInMerchantService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商户商品库存")
|
||||
@GetMapping()
|
||||
public ApiResult<List<GoodsStockInMerchant>> list(GoodsStockInMerchantParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsStockInMerchantService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsStockInMerchant:list')")
|
||||
@ApiOperation("根据id查询商户商品库存")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<GoodsStockInMerchant> 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<GoodsStockInMerchant> list) {
|
||||
if (goodsStockInMerchantService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商户商品库存")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<GoodsStockInMerchant> batchParam) {
|
||||
if (batchParam.update(goodsStockInMerchantService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商户商品库存")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsStockInMerchantService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<PageResult<MerchantApply>> page(MerchantApplyParam param) {
|
||||
// 使用关联查询
|
||||
return success(merchantApplyService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商户入驻申请")
|
||||
@GetMapping()
|
||||
public ApiResult<List<MerchantApply>> list(MerchantApplyParam param) {
|
||||
// 使用关联查询
|
||||
return success(merchantApplyService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询商户入驻申请")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<MerchantApply> 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<PageResult<MerchantApply>> page(MerchantApplyParam param) {
|
||||
// 使用关联查询
|
||||
return success(merchantApplyService.pageRel(param));
|
||||
}
|
||||
if (merchantService.count(new LambdaQueryWrapper<Merchant>().eq(Merchant::getPhone, merchantApply.getPhone())) > 0) {
|
||||
return fail("该手机号码已存在");
|
||||
}
|
||||
if (merchantApplyService.count(new LambdaQueryWrapper<MerchantApply>().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<Merchant>().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<MerchantApply>> list(MerchantApplyParam param) {
|
||||
// 使用关联查询
|
||||
return success(merchantApplyService.listRel(param));
|
||||
}
|
||||
// TODO 驳回
|
||||
|
||||
if (merchantApplyService.updateById(merchantApply)) {
|
||||
return success("修改成功");
|
||||
@ApiOperation("根据id查询商户入驻申请")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<MerchantApply> 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<Merchant>().eq(Merchant::getPhone, merchantApply.getPhone())) > 0) {
|
||||
return fail("该手机号码已存在");
|
||||
}
|
||||
if (merchantApplyService.count(new LambdaQueryWrapper<MerchantApply>().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<MerchantApply> 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<Merchant>().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<MerchantApply> 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<Integer> 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<MerchantApply> list) {
|
||||
if (merchantApplyService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商户入驻申请")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<MerchantApply> batchParam) {
|
||||
if (batchParam.update(merchantApplyService, "apply_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商户入驻申请")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (merchantApplyService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<PageResult<Order>> page(OrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderService.pageRel(param));
|
||||
}
|
||||
@Value("${config.upload-path}")
|
||||
private String uploadPath;
|
||||
|
||||
@ApiOperation("查询全部订单")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Order>> list(OrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@ApiOperation("根据id查询订单")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Order> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(orderService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("根据orderNo查询订单")
|
||||
@GetMapping("/getByOrderNo/{orderNo}")
|
||||
public ApiResult<Order> getByOrderNo(@PathVariable("orderNo") String orderNo){
|
||||
final User loginUser = getLoginUser();
|
||||
if(loginUser == null){
|
||||
return fail("请先登录",null);
|
||||
@ApiOperation("分页查询订单")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Order>> 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<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getOrderId, order.getOrderId()));
|
||||
order.setOrderInfo(orderInfoList);
|
||||
}
|
||||
return success(order);
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:verification')")
|
||||
@ApiOperation("根据orderNo核销订单")
|
||||
@GetMapping("/verification/{orderNo}")
|
||||
public ApiResult<Order> verification(@PathVariable("orderNo") String orderNo){
|
||||
final User loginUser = getLoginUser();
|
||||
if(loginUser == null){
|
||||
return fail("请先登录",null);
|
||||
@ApiOperation("查询全部订单")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Order>> list(OrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderService.listRel(param));
|
||||
}
|
||||
|
||||
final Set<String> 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<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().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<OrderInfo>()
|
||||
.eq(OrderInfo::getPayStatus,1)
|
||||
.eq(OrderInfo::getOrderCode,d.getOrderCode())) > 0) {
|
||||
order.setScene(1234);
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@ApiOperation("根据id查询订单")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Order> 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<Order> 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<Integer> cartIds = order.getGoodsList().stream().map(OrderGoods::getGoodsId).collect(Collectors.toSet());
|
||||
cartService.remove(new LambdaQueryWrapper<Cart>().eq(Cart::getUserId,order.getUserId()).in(Cart::getGoodsId,cartIds));
|
||||
// 外卖订单
|
||||
if(!order.getMerchantId().equals(0)){
|
||||
cartService.remove(new LambdaQueryWrapper<Cart>().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<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().eq(OrderInfo::getOrderId, order.getOrderId()));
|
||||
order.setOrderInfo(orderInfoList);
|
||||
}
|
||||
return success(order);
|
||||
}
|
||||
|
||||
// TODO 微信统一下单接口
|
||||
if (order.getPayType().equals(1)) {
|
||||
// 清空购物车
|
||||
final Set<Integer> cartIds = order.getGoodsList().stream().map(OrderGoods::getGoodsId).collect(Collectors.toSet());
|
||||
cartService.remove(new LambdaQueryWrapper<Cart>().eq(Cart::getUserId,order.getUserId()).in(Cart::getGoodsId,cartIds));
|
||||
// 外卖订单
|
||||
if(!order.getMerchantId().equals(0)){
|
||||
cartService.remove(new LambdaQueryWrapper<Cart>().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<Order> verification(@PathVariable("orderNo") String orderNo, HttpServletRequest request) {
|
||||
final User loginUser = getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return fail("请先登录", null);
|
||||
}
|
||||
|
||||
final Set<String> 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<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().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<OrderInfo>().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<Order> 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<Order> 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<Integer> 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<Integer> cartIds = order.getGoodsList().stream().map(OrderGoods::getGoodsId).collect(Collectors.toSet());
|
||||
cartService.remove(new LambdaQueryWrapper<Cart>().eq(Cart::getUserId, order.getUserId()).in(Cart::getGoodsId, cartIds));
|
||||
// 外卖订单
|
||||
if (!order.getMerchantId().equals(0)) {
|
||||
cartService.remove(new LambdaQueryWrapper<Cart>().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<Integer> cartIds = order.getGoodsList().stream().map(OrderGoods::getGoodsId).collect(Collectors.toSet());
|
||||
cartService.remove(new LambdaQueryWrapper<Cart>().eq(Cart::getUserId, order.getUserId()).in(Cart::getGoodsId, cartIds));
|
||||
// 外卖订单
|
||||
if (!order.getMerchantId().equals(0)) {
|
||||
cartService.remove(new LambdaQueryWrapper<Cart>().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<OrderInfo>().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<Order> list) {
|
||||
if (orderService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改订单")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Order> batchParam) {
|
||||
if (batchParam.update(orderService, "order_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除订单")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String, Object> 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<OrderDelivery>> 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<OrderGoods> orderGoodsList = orderGoodsService.listByOrderId(orderDelivery.getOrderId());
|
||||
List<GoodsStockInMerchant> 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<String, Object> bOrderData = (Map<String, Object>) 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")
|
||||
|
||||
@@ -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<PageResult<Splash>> page(SplashParam param) {
|
||||
// 使用关联查询
|
||||
return success(splashService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部开屏广告")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Splash>> list(SplashParam param) {
|
||||
// 使用关联查询
|
||||
return success(splashService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:splash:list')")
|
||||
@ApiOperation("根据id查询开屏广告")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Splash> 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<Splash> list) {
|
||||
if (splashService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改开屏广告")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Splash> batchParam) {
|
||||
if (batchParam.update(splashService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除开屏广告")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (splashService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<PageResult<Swiper>> page(SwiperParam param) {
|
||||
// 使用关联查询
|
||||
return success(swiperService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部轮播图")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Swiper>> list(SwiperParam param) {
|
||||
// 使用关联查询
|
||||
return success(swiperService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:swiper:list')")
|
||||
@ApiOperation("根据id查询轮播图")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Swiper> 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<Swiper> list) {
|
||||
if (swiperService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改轮播图")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Swiper> batchParam) {
|
||||
if (batchParam.update(swiperService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除轮播图")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (swiperService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<UserAddress>().eq(UserAddress::getUserId, getLoginUserId()).set(UserAddress::getIsDefault, 0));
|
||||
userAddressService.clearDefault(userAddress.getUserId());
|
||||
}
|
||||
if (userAddressService.updateById(userAddress)) {
|
||||
return success("修改成功");
|
||||
|
||||
@@ -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<PageResult<UserCollection>> page(UserCollectionParam param) {
|
||||
@@ -40,8 +47,10 @@ public class UserCollectionController extends BaseController {
|
||||
|
||||
@ApiOperation("查询全部我的收藏")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserCollection>> 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("添加成功");
|
||||
}
|
||||
|
||||
@@ -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<String> 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<WxMaProperties.Config> 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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -108,4 +108,7 @@ public class Cart implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private List<Cart> children;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Goods goods;
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
11
src/main/java/com/gxwebsoft/shop/entity/KuaiDi100Resp.java
Normal file
11
src/main/java/com/gxwebsoft/shop/entity/KuaiDi100Resp.java
Normal file
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<OrderGoods> goodsList;
|
||||
|
||||
@ApiModelProperty(value = "不清数据")
|
||||
@TableField(exist = false)
|
||||
private Boolean notClearData;
|
||||
|
||||
@TableField(exist = false)
|
||||
private OrderDelivery orderDelivery;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Merchant merchant;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
64
src/main/java/com/gxwebsoft/shop/entity/Splash.java
Normal file
64
src/main/java/com/gxwebsoft/shop/entity/Splash.java
Normal file
@@ -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;
|
||||
|
||||
}
|
||||
68
src/main/java/com/gxwebsoft/shop/entity/Swiper.java
Normal file
68
src/main/java/com/gxwebsoft/shop/entity/Swiper.java
Normal file
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<GoodsIncomeConfig> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<GoodsIncomeConfig>
|
||||
*/
|
||||
List<GoodsIncomeConfig> selectPageRel(@Param("page") IPage<GoodsIncomeConfig> page,
|
||||
@Param("param") GoodsIncomeConfigParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<GoodsIncomeConfig> selectListRel(@Param("param") GoodsIncomeConfigParam param);
|
||||
|
||||
}
|
||||
@@ -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<GoodsStockInMerchant> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<GoodsStockInMerchant>
|
||||
*/
|
||||
List<GoodsStockInMerchant> selectPageRel(@Param("page") IPage<GoodsStockInMerchant> page,
|
||||
@Param("param") GoodsStockInMerchantParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<GoodsStockInMerchant> selectListRel(@Param("param") GoodsStockInMerchantParam param);
|
||||
|
||||
}
|
||||
@@ -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<Merchant> {
|
||||
public interface MerchantMapper extends MPJBaseMapper<Merchant> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
|
||||
37
src/main/java/com/gxwebsoft/shop/mapper/SplashMapper.java
Normal file
37
src/main/java/com/gxwebsoft/shop/mapper/SplashMapper.java
Normal file
@@ -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<Splash> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<Splash>
|
||||
*/
|
||||
List<Splash> selectPageRel(@Param("page") IPage<Splash> page,
|
||||
@Param("param") SplashParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<Splash> selectListRel(@Param("param") SplashParam param);
|
||||
|
||||
}
|
||||
37
src/main/java/com/gxwebsoft/shop/mapper/SwiperMapper.java
Normal file
37
src/main/java/com/gxwebsoft/shop/mapper/SwiperMapper.java
Normal file
@@ -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<Swiper> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<Swiper>
|
||||
*/
|
||||
List<Swiper> selectPageRel(@Param("page") IPage<Swiper> page,
|
||||
@Param("param") SwiperParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<Swiper> selectListRel(@Param("param") SwiperParam param);
|
||||
|
||||
}
|
||||
@@ -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<UserCollection> {
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
<if test="param.isNew != null">
|
||||
AND a.is_new = #{param.isNew}
|
||||
</if>
|
||||
<if test="param.isShow != null">
|
||||
AND a.is_show = #{param.isShow}
|
||||
</if>
|
||||
<if test="param.combinationId != null">
|
||||
AND a.combination_id = #{param.combinationId}
|
||||
</if>
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.shop.mapper.GoodsIncomeConfigMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM shop_goods_income_config a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.goodsId != null">
|
||||
AND a.goods_id = #{param.goodsId}
|
||||
</if>
|
||||
<if test="param.merchantShopType != null">
|
||||
AND a.merchant_shop_type LIKE CONCAT('%', #{param.merchantShopType}, '%')
|
||||
</if>
|
||||
<if test="param.spec != null">
|
||||
AND a.spec LIKE CONCAT('%', #{param.spec}, '%')
|
||||
</if>
|
||||
<if test="param.rate != null">
|
||||
AND a.rate = #{param.rate}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.GoodsIncomeConfig">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.GoodsIncomeConfig">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -69,16 +69,16 @@
|
||||
AND a.merchant_id = #{param.merchantId}
|
||||
</if>
|
||||
<if test="param.parentId != null">
|
||||
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})
|
||||
</if>
|
||||
<!-- <if test="param.merchantIds != null">-->
|
||||
<!-- AND a.category_id IN (SELECT category_id FROM shop_goods_category WHERE parent_id=#{param.parentId})-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="param.merchantIds != null">-->
|
||||
<!-- AND a.category_id IN (SELECT category_id FROM shop_goods_category WHERE parent_id=#{param.parentId})-->
|
||||
<!-- </if>-->
|
||||
<if test="param.shopIdsByIndustry != null">
|
||||
AND a.merchant_id IN
|
||||
<foreach collection="param.shopIdsByIndustry" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
AND a.merchant_id IN
|
||||
<foreach collection="param.shopIdsByIndustry" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="param.merchantName != null">
|
||||
AND a.merchant_name LIKE CONCAT('%', #{param.merchantName}, '%')
|
||||
@@ -115,14 +115,20 @@
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
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}
|
||||
)
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
<if test="param.orderBy != null">
|
||||
ORDER BY ${param.orderBy}
|
||||
</if>
|
||||
<if test="param.orderBy == null">
|
||||
ORDER BY a.sort_number ASC, a.create_time DESC
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.shop.mapper.GoodsStockInMerchantMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM shop_goods_stock_in_merchant a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.goodsId != null">
|
||||
AND a.goods_id = #{param.goodsId}
|
||||
</if>
|
||||
<if test="param.skuId != null">
|
||||
AND a.sku_id = #{param.skuId}
|
||||
</if>
|
||||
<if test="param.num != null">
|
||||
AND a.num = #{param.num}
|
||||
</if>
|
||||
<if test="param.merchantId != null">
|
||||
AND a.merchant_id = #{param.merchantId}
|
||||
</if>
|
||||
<if test="param.stock != null">
|
||||
AND a.stock = #{param.stock}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.GoodsStockInMerchant">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.GoodsStockInMerchant">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -165,6 +165,7 @@
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.order_id DESC
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
|
||||
63
src/main/java/com/gxwebsoft/shop/mapper/xml/SplashMapper.xml
Normal file
63
src/main/java/com/gxwebsoft/shop/mapper/xml/SplashMapper.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.shop.mapper.SplashMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM shop_splash a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.title != null">
|
||||
AND a.title LIKE CONCAT('%', #{param.title}, '%')
|
||||
</if>
|
||||
<if test="param.image != null">
|
||||
AND a.image LIKE CONCAT('%', #{param.image}, '%')
|
||||
</if>
|
||||
<if test="param.jumpType != null">
|
||||
AND a.jump_type LIKE CONCAT('%', #{param.jumpType}, '%')
|
||||
</if>
|
||||
<if test="param.jumpPk != null">
|
||||
AND a.jump_pk = #{param.jumpPk}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.Splash">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.Splash">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
63
src/main/java/com/gxwebsoft/shop/mapper/xml/SwiperMapper.xml
Normal file
63
src/main/java/com/gxwebsoft/shop/mapper/xml/SwiperMapper.xml
Normal file
@@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.shop.mapper.SwiperMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM shop_swiper a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.type != null">
|
||||
AND a.type LIKE CONCAT('%', #{param.type}, '%')
|
||||
</if>
|
||||
<if test="param.image != null">
|
||||
AND a.image LIKE CONCAT('%', #{param.image}, '%')
|
||||
</if>
|
||||
<if test="param.jumpType != null">
|
||||
AND a.jump_type LIKE CONCAT('%', #{param.jumpType}, '%')
|
||||
</if>
|
||||
<if test="param.jumpPk != null">
|
||||
AND a.jump_pk = #{param.jumpPk}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.Swiper">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.Swiper">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -10,6 +10,9 @@
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.type != null">
|
||||
AND a.type = #{param.type}
|
||||
</if>
|
||||
<if test="param.tid != null">
|
||||
AND a.tid = #{param.tid}
|
||||
</if>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
57
src/main/java/com/gxwebsoft/shop/param/SplashParam.java
Normal file
57
src/main/java/com/gxwebsoft/shop/param/SplashParam.java
Normal file
@@ -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;
|
||||
|
||||
}
|
||||
57
src/main/java/com/gxwebsoft/shop/param/SwiperParam.java
Normal file
57
src/main/java/com/gxwebsoft/shop/param/SwiperParam.java
Normal file
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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<GoodsIncomeConfig> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<GoodsIncomeConfig>
|
||||
*/
|
||||
PageResult<GoodsIncomeConfig> pageRel(GoodsIncomeConfigParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<GoodsIncomeConfig>
|
||||
*/
|
||||
List<GoodsIncomeConfig> listRel(GoodsIncomeConfigParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id
|
||||
* @return GoodsIncomeConfig
|
||||
*/
|
||||
GoodsIncomeConfig getByIdRel(Integer id);
|
||||
|
||||
GoodsIncomeConfig check(Integer goodsId, Integer skuId, String merchantShopType);
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public interface GoodsService extends IService<Goods> {
|
||||
List<Goods> getGoodsSpec();
|
||||
|
||||
// 商城商品
|
||||
List<Goods> getGoodsSpecType0();
|
||||
List<Goods> getGoodsSpecType0(GoodsParam param);
|
||||
// 外卖商品
|
||||
List<Goods> getGoodsSpecType1();
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
*/
|
||||
List<GoodsSku> listRel(GoodsSkuParam param);
|
||||
|
||||
List<GoodsSku> listByGoods(Integer goodsId);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
|
||||
@@ -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<GoodsStockInMerchant> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<GoodsStockInMerchant>
|
||||
*/
|
||||
PageResult<GoodsStockInMerchant> pageRel(GoodsStockInMerchantParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<GoodsStockInMerchant>
|
||||
*/
|
||||
List<GoodsStockInMerchant> listRel(GoodsStockInMerchantParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id
|
||||
* @return GoodsStockInMerchant
|
||||
*/
|
||||
GoodsStockInMerchant getByIdRel(Integer id);
|
||||
|
||||
GoodsStockInMerchant check(Integer merchantId, Integer goodsId, Integer skuId);
|
||||
|
||||
List<GoodsStockInMerchant> canExpressList(Integer goodsId, Integer stock, String lat, String lng);
|
||||
}
|
||||
17
src/main/java/com/gxwebsoft/shop/service/KuaiDi100.java
Normal file
17
src/main/java/com/gxwebsoft/shop/service/KuaiDi100.java
Normal file
@@ -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;
|
||||
}
|
||||
@@ -39,4 +39,5 @@ public interface MerchantService extends IService<Merchant> {
|
||||
*/
|
||||
Merchant getByIdRel(Integer merchantId);
|
||||
|
||||
Merchant getByUserId(Integer userId);
|
||||
}
|
||||
|
||||
@@ -39,4 +39,5 @@ public interface OrderDeliveryService extends IService<OrderDelivery> {
|
||||
*/
|
||||
OrderDelivery getByIdRel(Integer deliveryId);
|
||||
|
||||
OrderDelivery getByOrderId(Integer orderId);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ public interface OrderGoodsService extends IService<OrderGoods> {
|
||||
*/
|
||||
List<OrderGoods> listRel(OrderGoodsParam param);
|
||||
|
||||
List<OrderGoods> listByOrderId(Integer orderId);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
|
||||
@@ -17,37 +17,39 @@ import java.util.List;
|
||||
*/
|
||||
public interface OrderService extends IService<Order> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<Order>
|
||||
*/
|
||||
PageResult<Order> pageRel(OrderParam param);
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<Order>
|
||||
*/
|
||||
PageResult<Order> pageRel(OrderParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<Order>
|
||||
*/
|
||||
List<Order> listRel(OrderParam param);
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<Order>
|
||||
*/
|
||||
List<Order> listRel(OrderParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param orderId 订单号
|
||||
* @return Order
|
||||
*/
|
||||
Order getByIdRel(Integer orderId);
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param orderId 订单号
|
||||
* @return Order
|
||||
*/
|
||||
Order getByIdRel(Integer orderId);
|
||||
|
||||
HashMap<String, String> createWxOrder(Order order);
|
||||
HashMap<String, String> 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);
|
||||
}
|
||||
|
||||
42
src/main/java/com/gxwebsoft/shop/service/SplashService.java
Normal file
42
src/main/java/com/gxwebsoft/shop/service/SplashService.java
Normal file
@@ -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<Splash> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<Splash>
|
||||
*/
|
||||
PageResult<Splash> pageRel(SplashParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<Splash>
|
||||
*/
|
||||
List<Splash> listRel(SplashParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id
|
||||
* @return Splash
|
||||
*/
|
||||
Splash getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
42
src/main/java/com/gxwebsoft/shop/service/SwiperService.java
Normal file
42
src/main/java/com/gxwebsoft/shop/service/SwiperService.java
Normal file
@@ -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<Swiper> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<Swiper>
|
||||
*/
|
||||
PageResult<Swiper> pageRel(SwiperParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<Swiper>
|
||||
*/
|
||||
List<Swiper> listRel(SwiperParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id
|
||||
* @return Swiper
|
||||
*/
|
||||
Swiper getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -39,4 +39,5 @@ public interface UserAddressService extends IService<UserAddress> {
|
||||
*/
|
||||
UserAddress getByIdRel(Integer id);
|
||||
|
||||
void clearDefault(Integer userId);
|
||||
}
|
||||
|
||||
@@ -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<UserCollection> {
|
||||
|
||||
@@ -39,4 +39,5 @@ public interface UserCollectionService extends IService<UserCollection> {
|
||||
*/
|
||||
UserCollection getByIdRel(Integer id);
|
||||
|
||||
UserCollection check(Integer userId, Integer type, Integer tid);
|
||||
}
|
||||
|
||||
@@ -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<CartMapper, Cart> implements CartService {
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
@Resource
|
||||
private MerchantService merchantService;
|
||||
|
||||
@Override
|
||||
public PageResult<Cart> pageRel(CartParam param) {
|
||||
PageParam<Cart, CartParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<Cart> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public CartVo listRel(CartParam param) {
|
||||
List<Cart> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Cart, CartParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time desc");
|
||||
final List<Cart> 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<Cart> pageRel(CartParam param) {
|
||||
PageParam<Cart, CartParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<Cart> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
// 计算购物车金额
|
||||
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<Integer, List<Cart>> collectCart = carts.stream().collect(Collectors.groupingBy(Cart::getMerchantId));
|
||||
final ArrayList<CartShopVo> 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<Cart> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Cart, CartParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time desc");
|
||||
final List<Cart> 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<Integer, List<Cart>> collectCart = carts.stream().collect(Collectors.groupingBy(Cart::getMerchantId));
|
||||
final ArrayList<CartShopVo> 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<Cart> listRelMpj(CartParam param) {
|
||||
@Override
|
||||
public List<Cart> listRelMpj(CartParam param) {
|
||||
|
||||
// 多表查询
|
||||
MPJLambdaWrapper<Cart> 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<Cart> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<GoodsIncomeConfigMapper, GoodsIncomeConfig> implements GoodsIncomeConfigService {
|
||||
@Resource
|
||||
private GoodsSkuService goodsSkuService;
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
@Override
|
||||
public PageResult<GoodsIncomeConfig> pageRel(GoodsIncomeConfigParam param) {
|
||||
PageParam<GoodsIncomeConfig, GoodsIncomeConfigParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<GoodsIncomeConfig> 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<GoodsIncomeConfig> listRel(GoodsIncomeConfigParam param) {
|
||||
List<GoodsIncomeConfig> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<GoodsIncomeConfig, GoodsIncomeConfigParam> 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<GoodsIncomeConfig> 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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -48,9 +48,9 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
public PageResult<Goods> pageRel(GoodsParam param) {
|
||||
// 按行业名称查找店铺ID
|
||||
if (ObjectUtil.isNotEmpty(param.getIndustryName())) {
|
||||
final List<Merchant> merchants = merchantService.list(new LambdaQueryWrapper<Merchant>().like(Merchant::getCategory, param.getIndustryName()));
|
||||
final Set<Integer> merchantIds = merchants.stream().map(Merchant::getMerchantId).collect(Collectors.toSet());
|
||||
param.setShopIdsByIndustry(merchantIds);
|
||||
final List<Merchant> merchants = merchantService.list(new LambdaQueryWrapper<Merchant>().like(Merchant::getCategory, param.getIndustryName()));
|
||||
final Set<Integer> merchantIds = merchants.stream().map(Merchant::getMerchantId).collect(Collectors.toSet());
|
||||
param.setShopIdsByIndustry(merchantIds);
|
||||
}
|
||||
PageParam<Goods, GoodsParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
@@ -58,30 +58,43 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
|
||||
final Set<Integer> goodsIds = list.stream().map(Goods::getGoodsId).collect(Collectors.toSet());
|
||||
if (!CollectionUtils.isEmpty(goodsIds)) {
|
||||
final User loginUser = param.getLoginUser();
|
||||
final List<GoodsSpec> specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||
final List<GoodsSku> skus = goodsSkuService.list(new LambdaQueryWrapper<GoodsSku>().in(GoodsSku::getGoodsId, goodsIds));
|
||||
final Map<Integer, List<GoodsSpec>> collectSpecs = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||
final Map<Integer, List<GoodsSku>> collectSkus = skus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId));
|
||||
list.forEach(d -> {
|
||||
final List<GoodsSpec> 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<GoodsSpec> specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||
final List<GoodsSku> skus = goodsSkuService.list(new LambdaQueryWrapper<GoodsSku>().in(GoodsSku::getGoodsId, goodsIds));
|
||||
final Map<Integer, List<GoodsSpec>> collectSpecs = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||
final Map<Integer, List<GoodsSku>> collectSkus = skus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId));
|
||||
list.forEach(d -> {
|
||||
final List<GoodsSpec> 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<GoodsMapper, Goods> implements
|
||||
@Override
|
||||
public List<Goods> listRel(GoodsParam param) {
|
||||
List<Goods> list = baseMapper.selectListRel(param);
|
||||
for (Goods goods : list) {
|
||||
goods.setGoodsSkus(goodsSkuService.listByGoods(goods.getGoodsId()));
|
||||
}
|
||||
// 排序
|
||||
PageParam<Goods, GoodsParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
@@ -105,63 +121,66 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> 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<GoodsSku> goodsSkus = goods.getGoodsSkus();
|
||||
if (!CollectionUtils.isEmpty(goodsSkus)) {
|
||||
goodsSkus.forEach(d -> {
|
||||
d.setGoodsId(goods.getGoodsId());
|
||||
});
|
||||
goodsSkuService.saveBatch(goodsSkus);
|
||||
}
|
||||
// 保存商品sku表
|
||||
final List<GoodsSku> goodsSkus = goods.getGoodsSkus();
|
||||
if (!CollectionUtils.isEmpty(goodsSkus)) {
|
||||
goodsSkus.forEach(d -> {
|
||||
d.setGoodsId(goods.getGoodsId());
|
||||
});
|
||||
goodsSkuService.saveBatch(goodsSkus);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Goods> getGoodsSpec() {
|
||||
// 多表查询
|
||||
MPJLambdaWrapper<Goods> 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<Goods> getGoodsSpec() {
|
||||
// 多表查询
|
||||
MPJLambdaWrapper<Goods> 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<Goods> getGoodsSpecType0() {
|
||||
// 多表查询
|
||||
MPJLambdaWrapper<Goods> 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<Goods> getGoodsSpecType0(GoodsParam param) {
|
||||
// 多表查询
|
||||
MPJLambdaWrapper<Goods> 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<Goods> getGoodsSpecType1() {
|
||||
// 多表查询
|
||||
MPJLambdaWrapper<Goods> 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<Goods> getGoodsSpecType1() {
|
||||
// 多表查询
|
||||
MPJLambdaWrapper<Goods> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<GoodsSkuMapper, GoodsSku> i
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GoodsSku> listByGoods(Integer goodsId) {
|
||||
return list(
|
||||
new LambdaQueryWrapper<GoodsSku>()
|
||||
.eq(GoodsSku::getGoodsId, goodsId)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GoodsSku getByIdRel(Integer id) {
|
||||
GoodsSkuParam param = new GoodsSkuParam();
|
||||
|
||||
@@ -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<GoodsStockInMerchantMapper, GoodsStockInMerchant> implements GoodsStockInMerchantService {
|
||||
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
@Override
|
||||
public PageResult<GoodsStockInMerchant> pageRel(GoodsStockInMerchantParam param) {
|
||||
PageParam<GoodsStockInMerchant, GoodsStockInMerchantParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<GoodsStockInMerchant> 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<GoodsStockInMerchant> listRel(GoodsStockInMerchantParam param) {
|
||||
List<GoodsStockInMerchant> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<GoodsStockInMerchant, GoodsStockInMerchantParam> 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<GoodsStockInMerchant> 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<GoodsStockInMerchant>()
|
||||
.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")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,11 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
||||
PageParam<Merchant, MerchantParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<Merchant> 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<MerchantMapper, Merchant> 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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<OrderDeliveryMapper, O
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderDelivery getByOrderId(Integer orderId) {
|
||||
return getOne(
|
||||
new LambdaQueryWrapper<OrderDelivery>()
|
||||
.eq(OrderDelivery::getOrderId, orderId)
|
||||
.orderByDesc(OrderDelivery::getCreateTime)
|
||||
.last("limit 1")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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<OrderGoodsMapper, OrderGoods> implements OrderGoodsService {
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
@Override
|
||||
public PageResult<OrderGoods> pageRel(OrderGoodsParam param) {
|
||||
@@ -38,6 +44,21 @@ public class OrderGoodsServiceImpl extends ServiceImpl<OrderGoodsMapper, OrderGo
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderGoods> listByOrderId(Integer orderId) {
|
||||
List<OrderGoods> list = list(
|
||||
new LambdaQueryWrapper<OrderGoods>()
|
||||
.eq(OrderGoods::getOrderId, orderId)
|
||||
);
|
||||
List<Goods> 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();
|
||||
|
||||
@@ -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<OrderMapper, Order> 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<Order> pageRel(OrderParam param) {
|
||||
PageParam<Order, OrderParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<Order> list = baseMapper.selectPageRel(page, param);
|
||||
@Override
|
||||
public PageResult<Order> pageRel(OrderParam param) {
|
||||
PageParam<Order, OrderParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<Order> list = baseMapper.selectPageRel(page, param);
|
||||
|
||||
if (param.getSceneType() != null) {
|
||||
final Set<Integer> orderIds = list.stream().map(Order::getOrderId).collect(Collectors.toSet());
|
||||
if (!CollectionUtils.isEmpty(orderIds)) {
|
||||
// 查询预定订单信息
|
||||
if (param.getSceneType().equals("showOrderInfo")) {
|
||||
final List<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().in(OrderInfo::getOrderId, orderIds));
|
||||
final Map<Integer, List<OrderInfo>> 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<OrderInfo> orderInfos = collect.get(d.getOrderId());
|
||||
if (!CollectionUtils.isEmpty(orderInfos)) {
|
||||
d.setOrderInfo(orderInfos);
|
||||
}
|
||||
if (param.getSceneType() != null) {
|
||||
final Set<Integer> orderIds = list.stream().map(Order::getOrderId).collect(Collectors.toSet());
|
||||
if (!CollectionUtils.isEmpty(orderIds)) {
|
||||
// 查询预定订单信息
|
||||
if (param.getSceneType().equals("showOrderInfo")) {
|
||||
final List<OrderInfo> orderInfoList = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().in(OrderInfo::getOrderId, orderIds));
|
||||
final Map<Integer, List<OrderInfo>> 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<OrderInfo> orderInfos = collect.get(d.getOrderId());
|
||||
if (!CollectionUtils.isEmpty(orderInfos)) {
|
||||
d.setOrderInfo(orderInfos);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// 查询商品信息
|
||||
if (param.getSceneType().equals("showOrderGoods")) {
|
||||
final List<OrderGoods> goodsList = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>().in(OrderGoods::getOrderId, orderIds));
|
||||
final Map<Integer, List<OrderGoods>> 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<OrderGoods> 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<OrderGoods> goodsList = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>().in(OrderGoods::getOrderId, orderIds));
|
||||
final Map<Integer, List<OrderGoods>> 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<OrderGoods> 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<Order> listRel(OrderParam param) {
|
||||
List<Order> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Order, OrderParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Order> listRel(OrderParam param) {
|
||||
List<Order> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Order, OrderParam> 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<OrderInfo> list = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().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<OrderInfo> list = orderInfoService.list(new LambdaQueryWrapper<OrderInfo>().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> orderGoods = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>().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<OrderGoods> orderGoodsList = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>().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<String, String> createWxOrder(Order order) {
|
||||
final String uploadPath = config.getUploadPath(); // 服务器本地路径
|
||||
final HashMap<String, String> orderInfo = new HashMap<>();
|
||||
// 微信小程序(微信支付)
|
||||
String key = "mp-weixin:".concat(order.getTenantId().toString());
|
||||
final String string = redisUtil.get(key);
|
||||
/**
|
||||
* 创建微信支付
|
||||
*
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public HashMap<String, String> 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<String, String> 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<WebsiteField> 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<OrderInfo>().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<WebsiteField> 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<OrderInfo>().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<OrderGoods> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<SplashMapper, Splash> implements SplashService {
|
||||
|
||||
@Override
|
||||
public PageResult<Splash> pageRel(SplashParam param) {
|
||||
PageParam<Splash, SplashParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<Splash> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Splash> listRel(SplashParam param) {
|
||||
List<Splash> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Splash, SplashParam> 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));
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user