Initial commit
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.entity.Cart;
|
||||
import com.gxwebsoft.shop.param.CartParam;
|
||||
import com.gxwebsoft.shop.service.CartService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 购物车记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-25 19:04:43
|
||||
*/
|
||||
@Api(tags = "购物车记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/cart")
|
||||
public class CartController extends BaseController {
|
||||
@Resource
|
||||
private CartService cartService;
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询购物车记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Cart>> page(CartParam param) {
|
||||
PageParam<Cart, CartParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(cartService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(cartService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部购物车记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Cart>> list(CartParam param) {
|
||||
// PageParam<Cart, CartParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
// return success(cartService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
|
||||
return success(cartService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询购物车记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Cart> get(@PathVariable("id") Integer id) {
|
||||
return success(cartService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(cartService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加购物车记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Cart cart) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
// 存入redis
|
||||
Map<String,Object> userMap = BeanUtil.beanToMap(loginUser);
|
||||
String userMapKey = "oa:cart:".concat(loginUser.getUserId().toString());
|
||||
stringRedisTemplate.opsForHash().putAll(userMapKey,userMap);
|
||||
stringRedisTemplate.expire(userMapKey,30, TimeUnit.MINUTES);
|
||||
|
||||
if (loginUser != null) {
|
||||
cart.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (cartService.save(cart)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改购物车记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Cart cart) {
|
||||
if (cartService.updateById(cart)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除购物车记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (cartService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加购物车记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Cart> list) {
|
||||
if (cartService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改购物车记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Cart> batchParam) {
|
||||
if (batchParam.update(cartService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除购物车记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (cartService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.CategoryService;
|
||||
import com.gxwebsoft.shop.entity.Category;
|
||||
import com.gxwebsoft.shop.param.CategoryParam;
|
||||
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 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 2022-11-22 17:45:37
|
||||
*/
|
||||
@Api(tags = "商品分类表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/category")
|
||||
public class CategoryController extends BaseController {
|
||||
@Resource
|
||||
private CategoryService categoryService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:category:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商品分类表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Category>> page(CategoryParam param) {
|
||||
PageParam<Category, CategoryParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
page.setDefaultOrder("sort_number");
|
||||
return success(categoryService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(categoryService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:category:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商品分类表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Category>> list(CategoryParam param) {
|
||||
PageParam<Category, CategoryParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
page.setDefaultOrder("sort_number");
|
||||
return success(categoryService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(categoryService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:category:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商品分类表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Category> get(@PathVariable("id") Integer id) {
|
||||
return success(categoryService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(categoryService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:category:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商品分类表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Category category) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
category.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (categoryService.save(category)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:category:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商品分类表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Category category) {
|
||||
if (categoryService.updateById(category)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:category:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商品分类表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (categoryService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:category:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商品分类表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Category> list) {
|
||||
if (categoryService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:category:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商品分类表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Category> batchParam) {
|
||||
if (batchParam.update(categoryService, "category_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:category:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商品分类表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (categoryService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.CommentService;
|
||||
import com.gxwebsoft.shop.entity.Comment;
|
||||
import com.gxwebsoft.shop.param.CommentParam;
|
||||
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 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 2022-11-23 21:18:56
|
||||
*/
|
||||
@Api(tags = "商品评价记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/comment")
|
||||
public class CommentController extends BaseController {
|
||||
@Resource
|
||||
private CommentService commentService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:comment:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商品评价记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Comment>> page(CommentParam param) {
|
||||
PageParam<Comment, CommentParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(commentService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(commentService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:comment:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商品评价记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Comment>> list(CommentParam param) {
|
||||
PageParam<Comment, CommentParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(commentService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(commentService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:comment:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商品评价记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Comment> get(@PathVariable("id") Integer id) {
|
||||
return success(commentService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(commentService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:comment:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商品评价记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Comment comment) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
comment.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (commentService.save(comment)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:comment:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商品评价记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Comment comment) {
|
||||
if (commentService.updateById(comment)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:comment:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商品评价记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (commentService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:comment:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商品评价记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Comment> list) {
|
||||
if (commentService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:comment:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商品评价记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Comment> batchParam) {
|
||||
if (batchParam.update(commentService, "comment_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:comment:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商品评价记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (commentService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.CouponService;
|
||||
import com.gxwebsoft.shop.entity.Coupon;
|
||||
import com.gxwebsoft.shop.param.CouponParam;
|
||||
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 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 2022-11-28 18:26:05
|
||||
*/
|
||||
@Api(tags = "优惠券记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/coupon")
|
||||
public class CouponController extends BaseController {
|
||||
@Resource
|
||||
private CouponService couponService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:coupon:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询优惠券记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Coupon>> page(CouponParam param) {
|
||||
PageParam<Coupon, CouponParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(couponService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(couponService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:coupon:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部优惠券记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Coupon>> list(CouponParam param) {
|
||||
PageParam<Coupon, CouponParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(couponService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(couponService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:coupon:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询优惠券记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Coupon> get(@PathVariable("id") Integer id) {
|
||||
return success(couponService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(couponService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:coupon:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加优惠券记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Coupon coupon) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
coupon.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (couponService.save(coupon)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:coupon:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改优惠券记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Coupon coupon) {
|
||||
if (couponService.updateById(coupon)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:coupon:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除优惠券记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (couponService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:coupon:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加优惠券记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Coupon> list) {
|
||||
if (couponService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:coupon:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改优惠券记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Coupon> batchParam) {
|
||||
if (batchParam.update(couponService, "coupon_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:coupon:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除优惠券记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (couponService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.ExpressService;
|
||||
import com.gxwebsoft.shop.entity.Express;
|
||||
import com.gxwebsoft.shop.param.ExpressParam;
|
||||
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 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 2022-11-22 00:21:07
|
||||
*/
|
||||
@Api(tags = "物流公司记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/express")
|
||||
public class ExpressController extends BaseController {
|
||||
@Resource
|
||||
private ExpressService expressService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:express:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询物流公司记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Express>> page(ExpressParam param) {
|
||||
PageParam<Express, ExpressParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(expressService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(expressService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:express:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部物流公司记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Express>> list(ExpressParam param) {
|
||||
PageParam<Express, ExpressParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(expressService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(expressService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:express:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询物流公司记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Express> get(@PathVariable("id") Integer id) {
|
||||
return success(expressService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(expressService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:express:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加物流公司记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Express express) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
express.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (expressService.save(express)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:express:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改物流公司记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Express express) {
|
||||
if (expressService.updateById(express)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:express:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除物流公司记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (expressService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:express:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加物流公司记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Express> list) {
|
||||
if (expressService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:express:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改物流公司记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Express> batchParam) {
|
||||
if (batchParam.update(expressService, "express_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:express:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除物流公司记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (expressService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.entity.Goods;
|
||||
import com.gxwebsoft.shop.param.GoodsParam;
|
||||
import com.gxwebsoft.shop.service.GoodsService;
|
||||
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 2022-11-23 12:47:16
|
||||
*/
|
||||
@Api(tags = "商品记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/goods")
|
||||
public class GoodsController extends BaseController {
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商品记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Goods>> page(GoodsParam param) {
|
||||
// PageParam<Goods, GoodsParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
// return success(goodsService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
return success(goodsService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商品记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Goods>> list(GoodsParam param) {
|
||||
// PageParam<Goods, GoodsParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
// return success(goodsService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
return success(goodsService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商品记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Goods> get(@PathVariable("id") Integer id) {
|
||||
return success(goodsService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(goodsService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商品记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Goods goods) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
goods.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (goodsService.save(goods)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商品记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Goods goods) {
|
||||
if (goodsService.updateById(goods)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商品记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (goodsService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商品记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Goods> list) {
|
||||
if (goodsService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商品记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Goods> batchParam) {
|
||||
if (batchParam.update(goodsService, "goods_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商品记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.GoodsServiceService;
|
||||
import com.gxwebsoft.shop.entity.GoodsService;
|
||||
import com.gxwebsoft.shop.param.GoodsServiceParam;
|
||||
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 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 2022-11-23 21:57:50
|
||||
*/
|
||||
@Api(tags = "商品服务与承诺记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/goods-service")
|
||||
public class GoodsServiceController extends BaseController {
|
||||
@Resource
|
||||
private GoodsServiceService goodsServiceService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsService:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商品服务与承诺记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<GoodsService>> page(GoodsServiceParam param) {
|
||||
PageParam<GoodsService, GoodsServiceParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time asc");
|
||||
return success(goodsServiceService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(goodsServiceService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsService:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商品服务与承诺记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<GoodsService>> list(GoodsServiceParam param) {
|
||||
PageParam<GoodsService, GoodsServiceParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(goodsServiceService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(goodsServiceService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsService:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商品服务与承诺记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<GoodsService> get(@PathVariable("id") Integer id) {
|
||||
return success(goodsServiceService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(goodsServiceService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsService:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商品服务与承诺记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody GoodsService goodsService) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
goodsService.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (goodsServiceService.save(goodsService)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsService:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商品服务与承诺记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody GoodsService goodsService) {
|
||||
if (goodsServiceService.updateById(goodsService)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsService:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商品服务与承诺记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (goodsServiceService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsService:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商品服务与承诺记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<GoodsService> list) {
|
||||
if (goodsServiceService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsService:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商品服务与承诺记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<GoodsService> batchParam) {
|
||||
if (batchParam.update(goodsServiceService, "service_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsService:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商品服务与承诺记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsServiceService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.MemberService;
|
||||
import com.gxwebsoft.shop.entity.Member;
|
||||
import com.gxwebsoft.shop.param.MemberParam;
|
||||
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 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 2022-11-25 14:02:24
|
||||
*/
|
||||
@Api(tags = "商城会员管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/member")
|
||||
public class MemberController extends BaseController {
|
||||
@Resource
|
||||
private MemberService memberService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:member:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商城会员")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Member>> page(MemberParam param) {
|
||||
PageParam<Member, MemberParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
// return success(memberService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
return success(memberService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:member:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商城会员")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Member>> list(MemberParam param) {
|
||||
PageParam<Member, MemberParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
// return success(memberService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
return success(memberService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:member:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商城会员")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Member> get(@PathVariable("id") Integer id) {
|
||||
return success(memberService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(memberService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:member:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商城会员")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Member member) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
member.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (memberService.save(member)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:member:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商城会员")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Member member) {
|
||||
if (memberService.updateById(member)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:member:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商城会员")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (memberService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:member:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商城会员")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Member> list) {
|
||||
if (memberService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:member:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商城会员")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Member> batchParam) {
|
||||
if (batchParam.update(memberService, "member_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:member:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商城会员")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (memberService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.service.MerchantClerkService;
|
||||
import com.gxwebsoft.shop.entity.MerchantClerk;
|
||||
import com.gxwebsoft.shop.param.MerchantClerkParam;
|
||||
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 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 2022-11-30 16:32:25
|
||||
*/
|
||||
@Api(tags = "商家门店店员表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/merchant-clerk")
|
||||
public class MerchantClerkController extends BaseController {
|
||||
@Resource
|
||||
private MerchantClerkService merchantClerkService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantClerk:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商家门店店员表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<MerchantClerk>> page(MerchantClerkParam param) {
|
||||
PageParam<MerchantClerk, MerchantClerkParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
// return success(merchantClerkService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
return success(merchantClerkService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantClerk:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商家门店店员表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<MerchantClerk>> list(MerchantClerkParam param) {
|
||||
PageParam<MerchantClerk, MerchantClerkParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
// return success(merchantClerkService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
return success(merchantClerkService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantClerk:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商家门店店员表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<MerchantClerk> get(@PathVariable("id") Integer id) {
|
||||
return success(merchantClerkService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(merchantClerkService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantClerk:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商家门店店员表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody MerchantClerk merchantClerk) {
|
||||
// 判断用户ID是否存在
|
||||
User user = userService.getById(merchantClerk.getUserId());
|
||||
if(user != null){
|
||||
// 防止重复
|
||||
if (merchantClerkService.count(new LambdaQueryWrapper<MerchantClerk>()
|
||||
.eq(MerchantClerk::getUserId, merchantClerk.getUserId())) > 0) {
|
||||
return fail("该用户已被绑定");
|
||||
}
|
||||
if (merchantClerkService.save(merchantClerk)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantClerk:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商家门店店员表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody MerchantClerk merchantClerk) {
|
||||
if (merchantClerkService.updateById(merchantClerk)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantClerk:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商家门店店员表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (merchantClerkService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantClerk:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商家门店店员表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<MerchantClerk> list) {
|
||||
if (merchantClerkService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantClerk:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商家门店店员表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<MerchantClerk> batchParam) {
|
||||
if (batchParam.update(merchantClerkService, "clerk_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantClerk:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商家门店店员表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (merchantClerkService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.utils.CacheClient;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.shop.entity.Merchant;
|
||||
import com.gxwebsoft.shop.param.MerchantParam;
|
||||
import com.gxwebsoft.shop.service.MerchantService;
|
||||
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;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.RedisConstants.MERCHANT_GEO_KEY;
|
||||
import static com.gxwebsoft.common.core.constants.RedisConstants.MERCHANT_KEY;
|
||||
|
||||
/**
|
||||
* 商户管理控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-30 15:10:54
|
||||
*/
|
||||
@Api(tags = "商户管理管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/merchant")
|
||||
public class MerchantController extends BaseController {
|
||||
@Resource
|
||||
private MerchantService merchantService;
|
||||
@Resource
|
||||
private CacheClient cacheClient;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchant:list')")
|
||||
@ApiOperation("分页查询商户管理")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Merchant>> page(MerchantParam param) {
|
||||
// 搜索条件
|
||||
if (getMerchantCode() != null) {
|
||||
param.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
// 使用关联查询
|
||||
return success(merchantService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchant:list')")
|
||||
@ApiOperation("查询全部商户管理")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Merchant>> list(MerchantParam param) {
|
||||
PageParam<Merchant, MerchantParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
// 使用关联查询
|
||||
return success(merchantService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchant:list')")
|
||||
@ApiOperation("根据id查询商户管理")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Merchant> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(merchantService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchant:save')")
|
||||
@ApiOperation("添加商户管理")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Merchant merchant) {
|
||||
if (merchantService.count(new LambdaQueryWrapper<Merchant>()
|
||||
.eq(Merchant::getMerchantCode, merchant.getMerchantCode())) > 0) {
|
||||
return fail("商户编号已存在");
|
||||
}
|
||||
if (merchantService.save(merchant)) {
|
||||
// 添加缓存
|
||||
String lngAndLat = merchant.getLngAndLat();
|
||||
String[] split = lngAndLat.split(",");
|
||||
Double x = Double.parseDouble(split[0]);
|
||||
Double y = Double.parseDouble(split[1]);
|
||||
String id = merchant.getMerchantId().toString();
|
||||
cacheClient.geoAdd(MERCHANT_GEO_KEY,x,y,id);
|
||||
cacheClient.set(MERCHANT_KEY.concat(":").concat(merchant.getMerchantId().toString()),merchant);
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchant:update')")
|
||||
@ApiOperation("修改商户管理")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Merchant merchant) {
|
||||
// 超级管理员不能设为店主
|
||||
if(getLoginUser().getUserId().equals(merchant.getMerchantOwner())){
|
||||
return fail("超级管理员不能绑定为负责人!");
|
||||
}
|
||||
if (merchantService.updateById(merchant)) {
|
||||
// 添加缓存
|
||||
String lngAndLat = merchant.getLngAndLat();
|
||||
String[] split = lngAndLat.split(",");
|
||||
Double x = Double.parseDouble(split[0]);
|
||||
Double y = Double.parseDouble(split[1]);
|
||||
String id = merchant.getMerchantId().toString();
|
||||
cacheClient.geoAdd(MERCHANT_GEO_KEY,x,y,id);
|
||||
cacheClient.geoAdd(MERCHANT_GEO_KEY,x,y,id);
|
||||
cacheClient.set(MERCHANT_KEY.concat(":").concat(merchant.getMerchantId().toString()),merchant);
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchant:remove')")
|
||||
@ApiOperation("删除商户管理")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (merchantService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchant:save')")
|
||||
@ApiOperation("批量添加商户管理")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Merchant> list) {
|
||||
if (merchantService.saveBatch(list)) {
|
||||
list.forEach(d -> {
|
||||
// 添加缓存
|
||||
String lngAndLat = d.getLngAndLat();
|
||||
String[] split = lngAndLat.split(",");
|
||||
Double x = Double.parseDouble(split[0]);
|
||||
Double y = Double.parseDouble(split[1]);
|
||||
String id = d.getMerchantId().toString();
|
||||
cacheClient.geoAdd(MERCHANT_GEO_KEY,x,y,id);
|
||||
cacheClient.geoAdd(MERCHANT_GEO_KEY,x,y,id);
|
||||
cacheClient.set(MERCHANT_KEY.concat(":").concat(d.getMerchantId().toString()),d);
|
||||
});
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchant:update')")
|
||||
@ApiOperation("批量修改商户管理")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Merchant> batchParam) {
|
||||
if (batchParam.update(merchantService, "merchant_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchant:remove')")
|
||||
@ApiOperation("批量删除商户管理")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (merchantService.removeByIds(ids)) {
|
||||
// 删除缓存
|
||||
ids.forEach(id -> {
|
||||
cacheClient.geoRemove(MERCHANT_GEO_KEY,id);
|
||||
});
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchant:list')")
|
||||
@ApiOperation("根据定位查询附近的商户列表")
|
||||
@PostMapping("/getListByGeo")
|
||||
public ApiResult<List<Merchant>> getListByGeo(@RequestBody MerchantParam param) {
|
||||
return success(merchantService.listByGeo(param));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.MerchantWithdrawService;
|
||||
import com.gxwebsoft.shop.entity.MerchantWithdraw;
|
||||
import com.gxwebsoft.shop.param.MerchantWithdrawParam;
|
||||
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 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 2022-12-02 00:41:09
|
||||
*/
|
||||
@Api(tags = "商户提现记录管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/merchant-withdraw")
|
||||
public class MerchantWithdrawController extends BaseController {
|
||||
@Resource
|
||||
private MerchantWithdrawService merchantWithdrawService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantWithdraw:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商户提现记录")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<MerchantWithdraw>> page(MerchantWithdrawParam param) {
|
||||
PageParam<MerchantWithdraw, MerchantWithdrawParam> page = new PageParam<>(param);
|
||||
// 搜索条件
|
||||
if (getMerchantCode() != null) {
|
||||
param.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
// return success(merchantWithdrawService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
return success(merchantWithdrawService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantWithdraw:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商户提现记录")
|
||||
@GetMapping()
|
||||
public ApiResult<List<MerchantWithdraw>> list(MerchantWithdrawParam param) {
|
||||
PageParam<MerchantWithdraw, MerchantWithdrawParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(merchantWithdrawService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(merchantWithdrawService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantWithdraw:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商户提现记录")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<MerchantWithdraw> get(@PathVariable("id") Integer id) {
|
||||
return success(merchantWithdrawService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(merchantWithdrawService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantWithdraw:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商户提现记录")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody MerchantWithdraw merchantWithdraw) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
merchantWithdraw.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (merchantWithdrawService.save(merchantWithdraw)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantWithdraw:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商户提现记录")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody MerchantWithdraw merchantWithdraw) {
|
||||
if (merchantWithdrawService.updateById(merchantWithdraw)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantWithdraw:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商户提现记录")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (merchantWithdrawService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantWithdraw:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商户提现记录")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<MerchantWithdraw> list) {
|
||||
if (merchantWithdrawService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantWithdraw:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商户提现记录")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<MerchantWithdraw> batchParam) {
|
||||
if (batchParam.update(merchantWithdrawService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchantWithdraw:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商户提现记录")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (merchantWithdrawService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.OrderAddressService;
|
||||
import com.gxwebsoft.shop.entity.OrderAddress;
|
||||
import com.gxwebsoft.shop.param.OrderAddressParam;
|
||||
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 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 2022-12-02 21:21:10
|
||||
*/
|
||||
@Api(tags = "订单收货地址记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order-address")
|
||||
public class OrderAddressController extends BaseController {
|
||||
@Resource
|
||||
private OrderAddressService orderAddressService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderAddress:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询订单收货地址记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<OrderAddress>> page(OrderAddressParam param) {
|
||||
PageParam<OrderAddress, OrderAddressParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(orderAddressService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(orderAddressService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderAddress:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部订单收货地址记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<OrderAddress>> list(OrderAddressParam param) {
|
||||
PageParam<OrderAddress, OrderAddressParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(orderAddressService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(orderAddressService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderAddress:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询订单收货地址记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<OrderAddress> get(@PathVariable("id") Integer id) {
|
||||
return success(orderAddressService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(orderAddressService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderAddress:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加订单收货地址记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody OrderAddress orderAddress) {
|
||||
// 记录当前登录用户id、租户id、商户编号
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
orderAddress.setUserId(loginUser.getUserId());
|
||||
orderAddress.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
if (orderAddressService.save(orderAddress)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderAddress:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改订单收货地址记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody OrderAddress orderAddress) {
|
||||
if (orderAddressService.updateById(orderAddress)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderAddress:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除订单收货地址记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (orderAddressService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderAddress:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加订单收货地址记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<OrderAddress> list) {
|
||||
if (orderAddressService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderAddress:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改订单收货地址记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<OrderAddress> batchParam) {
|
||||
if (batchParam.update(orderAddressService, "order_address_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderAddress:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除订单收货地址记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderAddressService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||
import cn.hutool.extra.qrcode.QrConfig;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.apps.entity.BcAgent;
|
||||
import com.gxwebsoft.apps.entity.EquipmentGoods;
|
||||
import com.gxwebsoft.apps.entity.EquipmentOrderGoods;
|
||||
import com.gxwebsoft.apps.param.BcAgentParam;
|
||||
import com.gxwebsoft.apps.service.BcAgentService;
|
||||
import com.gxwebsoft.apps.service.EquipmentGoodsService;
|
||||
import com.gxwebsoft.apps.service.EquipmentOrderGoodsService;
|
||||
import com.gxwebsoft.apps.service.EquipmentService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.entity.UserReferee;
|
||||
import com.gxwebsoft.shop.param.OrderGoodsParam;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
import com.gxwebsoft.shop.service.OrderGoodsService;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.service.UserRefereeService;
|
||||
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 javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.OrderConstants.*;
|
||||
|
||||
/**
|
||||
* 订单记录表控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2022-11-16 11:25:58
|
||||
*/
|
||||
@Api(tags = "订单记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order")
|
||||
public class OrderController extends BaseController {
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private EquipmentGoodsService equipmentGoodsService;
|
||||
@Resource
|
||||
private EquipmentService equipmentService;
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
@Resource
|
||||
private EquipmentOrderGoodsService equipmentOrderGoodsService;
|
||||
@Resource
|
||||
private UserRefereeService userRefereeService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private BcAgentService bcAgentService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询订单记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Order>> page(OrderParam param) {
|
||||
// 搜索条件
|
||||
if (getMerchantCode() != null) {
|
||||
param.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
// 云芯威项目查询关联设备
|
||||
if(getTenantId().equals(6)){
|
||||
// 查询订单的关联商品
|
||||
List<Order> list = orderService.listRel(param);
|
||||
// 查询订单的设备
|
||||
for (Order order : list) {
|
||||
final OrderGoodsParam orderGoodsParam = new OrderGoodsParam();
|
||||
orderGoodsParam.setOrderId(order.getOrderId());
|
||||
order.setGoodsList(orderGoodsService.listRel(orderGoodsParam));
|
||||
order.setEquipmentGoods(equipmentOrderGoodsService.getOne(new LambdaQueryWrapper<EquipmentOrderGoods>().eq(EquipmentOrderGoods::getOrderId,order.getOrderId())));
|
||||
order.setEquipment(equipmentService.getById(order.getEquipmentId()));
|
||||
}
|
||||
PageParam<Order, OrderParam> page = new PageParam<>(param);
|
||||
return success(new PageResult<>(list, page.getTotal()));
|
||||
}
|
||||
// 贵港自然资源报餐
|
||||
if(getTenantId().equals(10048) && getAppId() != null){
|
||||
final BcAgentParam bcAgentParam = new BcAgentParam();
|
||||
bcAgentParam.setParentId(getLoginUserId());
|
||||
bcAgentParam.setLimit(100L);
|
||||
final PageResult<BcAgent> result = bcAgentService.pageRel(bcAgentParam);
|
||||
final Set<Integer> collect = result.getList().stream().map(BcAgent::getUserId).collect(Collectors.toSet());
|
||||
collect.add(getLoginUserId());
|
||||
param.setUserId(null);
|
||||
param.setUserIds(collect);
|
||||
return success(orderService.pageRel(param));
|
||||
}
|
||||
|
||||
// 使用关联查询
|
||||
return success(orderService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部订单记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Order>> list(OrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("按订单集查询")
|
||||
@PostMapping("/listByIds")
|
||||
public ApiResult<List<Order>> listByIds(@RequestBody List<Integer> orderIds) {
|
||||
System.out.println("按订单集查询 = " + orderIds);
|
||||
Integer userId = getLoginUserId();
|
||||
// 代报餐情况(未完成)
|
||||
final Order order = orderService.getById(orderIds.get(0));
|
||||
if (!order.getUserId().equals(getLoginUserId())) {
|
||||
userId = order.getUserId();
|
||||
final List<Order> list1 = orderService.list(new LambdaQueryWrapper<Order>().in(Order::getOrderId,orderIds).eq(Order::getUserId, userId).eq(Order::getPayStatus,PAY_STATUS_NO_PAY));
|
||||
final Set<Integer> collect = list1.stream().map(Order::getOrderId).collect(Collectors.toSet());
|
||||
return success(orderService.listByIds(collect));
|
||||
}
|
||||
|
||||
final List<Order> list1 = orderService.list(new LambdaQueryWrapper<Order>().eq(Order::getUserId, getLoginUserId()).eq(Order::getPayStatus,PAY_STATUS_NO_PAY));
|
||||
final List<Integer> collect = list1.stream().map(Order::getOrderId).collect(Collectors.toList());
|
||||
// 使用关联查询
|
||||
return success(orderService.listByIds(collect));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询订单记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Order> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
Order order = orderService.getByIdRel(id);
|
||||
// 云芯威关联设备查询
|
||||
if (!order.getGoodsId().equals(0) || !order.getEquipmentId().equals(0)) {
|
||||
order.setEquipmentGoods(equipmentOrderGoodsService.getOne(new LambdaQueryWrapper<EquipmentOrderGoods>().eq(EquipmentOrderGoods::getOrderId,order.getOrderId())));
|
||||
order.setEquipment(equipmentService.getById(order.getEquipmentId()));
|
||||
}
|
||||
return success(order);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加订单记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Order order) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
order.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (orderService.save(order)) {
|
||||
// 云芯威BMS
|
||||
if (order.getTenantId().equals(6)) {
|
||||
final EquipmentGoods eg = equipmentGoodsService.getById(order.getOrderSourceId());
|
||||
eg.setOrderId(order.getOrderId());
|
||||
// 添加订单商品
|
||||
final EquipmentOrderGoods oeg = new EquipmentOrderGoods();
|
||||
oeg.setOrderId(order.getOrderId());
|
||||
oeg.setGoodsName(eg.getGoodsName());
|
||||
oeg.setEquipmentCategory(eg.getEquipmentCategory());
|
||||
oeg.setImage(eg.getImage());
|
||||
oeg.setCategoryId(eg.getCategoryId());
|
||||
oeg.setBatteryModel(eg.getBatteryModel());
|
||||
oeg.setSellingPoint(eg.getSellingPoint());
|
||||
oeg.setStockTotal(eg.getStockTotal());
|
||||
oeg.setContent(eg.getContent());
|
||||
oeg.setBatteryPrice(eg.getBatteryPrice());
|
||||
oeg.setBatteryRent(eg.getBatteryRent());
|
||||
oeg.setBatteryInsurance(eg.getBatteryInsurance());
|
||||
oeg.setBatteryDeposit(eg.getBatteryDeposit());
|
||||
oeg.setDownPayment(eg.getDownPayment());
|
||||
oeg.setPeriods(eg.getPeriods());
|
||||
oeg.setRepayment(eg.getRepayment());
|
||||
oeg.setServiceCharges(eg.getServiceCharges());
|
||||
oeg.setPeriodsType(eg.getPeriodsType());
|
||||
oeg.setUserId(eg.getUserId());
|
||||
oeg.setComments(eg.getComments());
|
||||
oeg.setStatus(eg.getStatus());
|
||||
oeg.setMerchantCode(eg.getMerchantCode());
|
||||
oeg.setTenantId(eg.getTenantId());
|
||||
|
||||
equipmentOrderGoodsService.saveOrUpdate(oeg);
|
||||
|
||||
// 添加推荐人关系
|
||||
if (order.getDealerId() != null) {
|
||||
final User dealer = userService.getById(order.getDealerId());
|
||||
if(dealer == null){
|
||||
return fail("推荐人的用户ID不存在");
|
||||
}
|
||||
final UserReferee referee = new UserReferee();
|
||||
referee.setDealerId(order.getDealerId());
|
||||
referee.setUserId(getLoginUserId());
|
||||
userRefereeService.save(referee);
|
||||
}
|
||||
}
|
||||
// 是否存入星期值
|
||||
if(order.getDeliveryTime() != null){
|
||||
order.setWeek(DateUtil.dayOfWeek(order.getDeliveryTime()) - 1);
|
||||
}
|
||||
return success("添加成功",order);
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改订单记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Order order) {
|
||||
if (orderService.updateById(order)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除订单记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (orderService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加订单记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Order> list) {
|
||||
if (orderService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改订单记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Order> batchParam) {
|
||||
if (batchParam.update(orderService, "order_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除订单记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("支付成功")
|
||||
@PostMapping("/setPayStatus")
|
||||
public ApiResult<?> setPayStatus(@RequestBody Order order){
|
||||
if (orderService.updateById(order)) {
|
||||
return success("设置成功");
|
||||
}
|
||||
return fail("设置失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("生成核销付款码(二维码)")
|
||||
@GetMapping("/generateQrCode")
|
||||
public ApiResult<?> generateQrCode(OrderParam param) throws IOException {
|
||||
// 查询当天的报餐信息
|
||||
param.setUserId(getLoginUserId());
|
||||
param.setDeliveryTime(DateUtil.beginOfDay(DateUtil.date()).toString());
|
||||
param.setOrderStatus(ORDER_STATUS_DOING);
|
||||
param.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
param.setDeleted(0);
|
||||
final List<Order> list = orderService.listRel(param);
|
||||
if(list.size() == 0){
|
||||
return fail("今日无报餐记录");
|
||||
}
|
||||
final Order order = list.get(0);
|
||||
// LOGO URL地址
|
||||
String logoUrl = "https://file.wsdns.cn/20230430/6fa31aca3b0d47af98a149cf2dd26a4f.jpeg";
|
||||
// 二维码生成图片保存路径
|
||||
String filePath = "/www/wwwroot/file.ws/file/qrcode/" + getLoginUserId() + "/payQrCode.jpg";
|
||||
// 二维码访问路径
|
||||
String qrcodeUrl = "https://file.gxwebsoft.com/qrcode/" + getLoginUserId() + "/payQrCode.jpg" + "?v=" + DateUtil.current();
|
||||
// 二维码内容
|
||||
final String orderNo = order.getOrderNo().toString();
|
||||
// 将URL转为BufferedImage
|
||||
BufferedImage bufferedImage = ImageIO.read(new URL(logoUrl));
|
||||
// 生成二维码
|
||||
QrConfig config = new QrConfig(300, 300);
|
||||
// 设置边距,既二维码和背景之间的边距
|
||||
config.setMargin(1);
|
||||
// 附带小logo
|
||||
config.setImg(bufferedImage);
|
||||
QrCodeUtil.generate(orderNo, config, FileUtil.file(filePath));
|
||||
return success("请求成功",qrcodeUrl);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.OrderGoodsService;
|
||||
import com.gxwebsoft.shop.entity.OrderGoods;
|
||||
import com.gxwebsoft.shop.param.OrderGoodsParam;
|
||||
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 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 2022-12-09 17:15:31
|
||||
*/
|
||||
@Api(tags = "订单商品记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order-goods")
|
||||
public class OrderGoodsController extends BaseController {
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderGoods:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询订单商品记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<OrderGoods>> page(OrderGoodsParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderGoodsService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderGoods:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部订单商品记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<OrderGoods>> list(OrderGoodsParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderGoodsService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderGoods:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询订单商品记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<OrderGoods> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(orderGoodsService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderGoods:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加订单商品记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody OrderGoods orderGoods) {
|
||||
// 记录当前登录用户id、租户id、商户编号
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
orderGoods.setUserId(loginUser.getUserId());
|
||||
orderGoods.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
if (orderGoodsService.save(orderGoods)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderGoods:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改订单商品记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody OrderGoods orderGoods) {
|
||||
if (orderGoodsService.updateById(orderGoods)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderGoods:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除订单商品记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (orderGoodsService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderGoods:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加订单商品记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<OrderGoods> list) {
|
||||
if (orderGoodsService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderGoods:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改订单商品记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<OrderGoods> batchParam) {
|
||||
if (batchParam.update(orderGoodsService, "order_goods_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderGoods:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除订单商品记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderGoodsService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.OrderRefundAddressService;
|
||||
import com.gxwebsoft.shop.entity.OrderRefundAddress;
|
||||
import com.gxwebsoft.shop.param.OrderRefundAddressParam;
|
||||
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 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 2023-05-18 13:09:51
|
||||
*/
|
||||
@Api(tags = "售后单退货地址记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order-refund-address")
|
||||
public class OrderRefundAddressController extends BaseController {
|
||||
@Resource
|
||||
private OrderRefundAddressService orderRefundAddressService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefundAddress:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询售后单退货地址记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<OrderRefundAddress>> page(OrderRefundAddressParam param) {
|
||||
PageParam<OrderRefundAddress, OrderRefundAddressParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(orderRefundAddressService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(orderRefundAddressService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefundAddress:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部售后单退货地址记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<OrderRefundAddress>> list(OrderRefundAddressParam param) {
|
||||
PageParam<OrderRefundAddress, OrderRefundAddressParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(orderRefundAddressService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(orderRefundAddressService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefundAddress:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询售后单退货地址记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<OrderRefundAddress> get(@PathVariable("id") Integer id) {
|
||||
return success(orderRefundAddressService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(orderRefundAddressService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefundAddress:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加售后单退货地址记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody OrderRefundAddress orderRefundAddress) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
orderRefundAddress.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (orderRefundAddressService.save(orderRefundAddress)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefundAddress:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改售后单退货地址记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody OrderRefundAddress orderRefundAddress) {
|
||||
if (orderRefundAddressService.updateById(orderRefundAddress)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefundAddress:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除售后单退货地址记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (orderRefundAddressService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefundAddress:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加售后单退货地址记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<OrderRefundAddress> list) {
|
||||
if (orderRefundAddressService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefundAddress:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改售后单退货地址记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<OrderRefundAddress> batchParam) {
|
||||
if (batchParam.update(orderRefundAddressService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefundAddress:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除售后单退货地址记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderRefundAddressService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.apps.entity.Equipment;
|
||||
import com.gxwebsoft.apps.service.EquipmentService;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.service.OrderRefundService;
|
||||
import com.gxwebsoft.shop.entity.OrderRefund;
|
||||
import com.gxwebsoft.shop.param.OrderRefundParam;
|
||||
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.shop.service.OrderService;
|
||||
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;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.OrderConstants.RECEIPT_STATUS_RETURN;
|
||||
|
||||
/**
|
||||
* 售后单记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-05-18 13:09:51
|
||||
*/
|
||||
@Api(tags = "售后单记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order-refund")
|
||||
public class OrderRefundController extends BaseController {
|
||||
@Resource
|
||||
private OrderRefundService orderRefundService;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private EquipmentService equipmentService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefund:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询售后单记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<OrderRefund>> page(OrderRefundParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderRefundService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefund:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部售后单记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<OrderRefund>> list(OrderRefundParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderRefundService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefund:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询售后单记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<OrderRefund> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(orderRefundService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefund:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加售后单记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody OrderRefund orderRefund) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
orderRefund.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (orderRefundService.save(orderRefund)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefund:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改售后单记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody OrderRefund orderRefund) {
|
||||
if (orderRefundService.updateById(orderRefund)) {
|
||||
if(orderRefund.getTenantId().equals(6)){
|
||||
final Integer orderId = orderRefund.getOrderId();
|
||||
final Order order = orderService.getById(orderId);
|
||||
System.out.println("order = " + order);
|
||||
order.setReceiptStatus(RECEIPT_STATUS_RETURN);
|
||||
final Equipment equipment = equipmentService.getById(order.getEquipmentId());
|
||||
equipment.setUserId(0);
|
||||
equipmentService.updateById(equipment);
|
||||
}
|
||||
return success("操作成功");
|
||||
}
|
||||
return fail("退租失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefund:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除售后单记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (orderRefundService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefund:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加售后单记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<OrderRefund> list) {
|
||||
if (orderRefundService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefund:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改售后单记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<OrderRefund> batchParam) {
|
||||
if (batchParam.update(orderRefundService, "order_refund_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRefund:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除售后单记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderRefundService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.OrderRenewService;
|
||||
import com.gxwebsoft.shop.entity.OrderRenew;
|
||||
import com.gxwebsoft.shop.param.OrderRenewParam;
|
||||
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 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 2023-04-13 10:34:35
|
||||
*/
|
||||
@Api(tags = "续费订单记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order-renew")
|
||||
public class OrderRenewController extends BaseController {
|
||||
@Resource
|
||||
private OrderRenewService orderRenewService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRenew:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询续费订单记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<OrderRenew>> page(OrderRenewParam param) {
|
||||
PageParam<OrderRenew, OrderRenewParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(orderRenewService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(orderRenewService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRenew:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部续费订单记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<OrderRenew>> list(OrderRenewParam param) {
|
||||
PageParam<OrderRenew, OrderRenewParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(orderRenewService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(orderRenewService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRenew:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询续费订单记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<OrderRenew> get(@PathVariable("id") Integer id) {
|
||||
return success(orderRenewService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(orderRenewService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRenew:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加续费订单记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody OrderRenew orderRenew) {
|
||||
// 记录当前登录用户id、租户id、商户编号
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
orderRenew.setUserId(loginUser.getUserId());
|
||||
orderRenew.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
if (orderRenewService.save(orderRenew)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRenew:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改续费订单记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody OrderRenew orderRenew) {
|
||||
if (orderRenewService.updateById(orderRenew)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRenew:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除续费订单记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (orderRenewService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRenew:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加续费订单记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<OrderRenew> list) {
|
||||
if (orderRenewService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRenew:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改续费订单记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<OrderRenew> batchParam) {
|
||||
if (batchParam.update(orderRenewService, "order_renew_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderRenew:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除续费订单记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderRenewService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,539 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayConstants;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.internal.util.AlipayEncrypt;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.alipay.api.request.AlipayTradeCreateRequest;
|
||||
import com.alipay.api.request.AlipayTradeQueryRequest;
|
||||
import com.alipay.api.response.AlipayTradeCreateResponse;
|
||||
import com.alipay.api.response.AlipayTradeQueryResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.apps.entity.BcTemporary;
|
||||
import com.gxwebsoft.apps.param.BcTemporaryParam;
|
||||
import com.gxwebsoft.apps.service.BcTemporaryService;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
import com.gxwebsoft.common.core.utils.AlipayConfigUtil;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.OperationRecordService;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.entity.Payment;
|
||||
import com.gxwebsoft.shop.entity.UserBalanceLog;
|
||||
import com.gxwebsoft.shop.param.PaymentParam;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.service.PaymentService;
|
||||
import com.gxwebsoft.shop.service.UserBalanceLogService;
|
||||
import com.gxwebsoft.shop.service.UserOauthService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.BalanceConstants.BALANCE_USE;
|
||||
import static com.gxwebsoft.common.core.constants.OrderConstants.*;
|
||||
|
||||
/**
|
||||
* 商城支付方式记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-12-15 19:11:07
|
||||
*/
|
||||
@Api(tags = "商城支付方式记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/payment")
|
||||
public class PaymentController extends BaseController {
|
||||
@Resource
|
||||
private PaymentService paymentService;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private Environment config;
|
||||
@Resource
|
||||
private ConfigProperties pathConfig;
|
||||
@Resource
|
||||
private OperationRecordService operationRecordService;
|
||||
@Resource
|
||||
private UserOauthService userOauthService;
|
||||
@Resource
|
||||
private AlipayConfigUtil alipayConfig;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UserBalanceLogService userBalanceLogService;
|
||||
@Resource
|
||||
private BcTemporaryService bcTemporaryService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:payment:list')")
|
||||
@ApiOperation("分页查询商城支付方式记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Payment>> page(PaymentParam param) {
|
||||
PageParam<Payment, PaymentParam> page = new PageParam<>(param);
|
||||
return success(paymentService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(paymentService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:payment:list')")
|
||||
@ApiOperation("查询全部商城支付方式记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Payment>> list(PaymentParam param) {
|
||||
PageParam<Payment, PaymentParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(paymentService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(paymentService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:payment:list')")
|
||||
@ApiOperation("根据id查询商城支付方式记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Payment> get(@PathVariable("id") Integer id) {
|
||||
return success(paymentService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(paymentService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:payment:save')")
|
||||
@ApiOperation("添加商城支付方式记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Payment payment) {
|
||||
if (paymentService.count(new LambdaQueryWrapper<Payment>()
|
||||
.eq(Payment::getMethod, payment.getMethod())) > 0) {
|
||||
return fail("该支付方式已存在");
|
||||
}
|
||||
if (paymentService.save(payment)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:payment:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商城支付方式记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Payment payment) {
|
||||
if (paymentService.updateById(payment)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:payment:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商城支付方式记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (paymentService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:payment:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商城支付方式记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Payment> list) {
|
||||
if (paymentService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:payment:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商城支付方式记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Payment> batchParam) {
|
||||
if (batchParam.update(paymentService, "payment_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:payment:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商城支付方式记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (paymentService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("支付宝手机号码")
|
||||
@PostMapping("/getPhoneNumber")
|
||||
public ApiResult<?> getPhoneNumber(@RequestBody Map<String, String> params) {
|
||||
final String encryptedData = params.get("encryptedData");
|
||||
final String tenantId = params.get("tenantId");
|
||||
// 支付宝配置信息
|
||||
JSONObject config = alipayConfig.payment(Integer.valueOf(tenantId));
|
||||
|
||||
//1. 获取验签和解密所需要的参数
|
||||
JSONObject jsonObject =JSONObject.parseObject(encryptedData);
|
||||
String content = jsonObject.getString("response");
|
||||
String sign = jsonObject.getString("sign");
|
||||
String signType = "RSA2";
|
||||
String charset = "UTF-8";
|
||||
String encryptType = "AES";
|
||||
String alipayCertPublicKey = pathConfig.getUploadPath() + "file" + config.getString("alipayCertPublicKey");
|
||||
boolean isDataEncrypted = !content.startsWith("{");
|
||||
boolean signVerified = false;
|
||||
//2. 验签
|
||||
String signContent = content;
|
||||
String signVeriKey = ""; // 支付宝公钥
|
||||
String decryptKey = config.getString("decryptKey"); // 加解密密钥
|
||||
// System.out.println("decryptKey = " + decryptKey);
|
||||
// System.out.println(content);
|
||||
// System.out.println(sign);
|
||||
// System.out.println(alipayCertPublicKey);
|
||||
// System.out.println(charset);
|
||||
// System.out.println(signType);
|
||||
// System.out.println(isDataEncrypted);
|
||||
if (isDataEncrypted) {
|
||||
signContent = "\"" + signContent + "\"";
|
||||
} try {
|
||||
//验签方法
|
||||
signVerified = AlipaySignature.rsaCertCheck(signContent, sign, alipayCertPublicKey, charset, signType);
|
||||
} catch (AlipayApiException e) {
|
||||
// 验签异常, 日志
|
||||
} if (!signVerified) {
|
||||
//验签不通过(异常或者报文被篡改),终止流程(不需要做解密)
|
||||
return fail("验签失败");
|
||||
}
|
||||
//3. 解密
|
||||
String plainData = null;
|
||||
if (isDataEncrypted) {
|
||||
try {
|
||||
plainData = AlipayEncrypt.decryptContent(content, encryptType, decryptKey, charset);
|
||||
} catch (AlipayApiException e) {
|
||||
//解密异常, 记录日志
|
||||
return fail("解密异常");
|
||||
}} else {
|
||||
plainData = content;
|
||||
}
|
||||
return success("获取成功",plainData);
|
||||
}
|
||||
|
||||
@ApiModelProperty("支付宝小程序支付")
|
||||
@GetMapping("/mp-alipay/{id}")
|
||||
public ApiResult<?> mpAlipay(@PathVariable("id") Integer id) throws AlipayApiException {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 订单数据
|
||||
Order order = orderService.getByIdRel(id);
|
||||
// 实例化客户端
|
||||
DefaultAlipayClient alipayClient = alipayConfig.alipayClient(order.getTenantId());
|
||||
try {
|
||||
AlipayTradeCreateRequest request = new AlipayTradeCreateRequest();
|
||||
// 配置公共请求参数
|
||||
request.setNotifyUrl(pathConfig.getServerUrl() + "/shop/payment/mp-alipay/notify");
|
||||
// request.setNotifyUrl("https://454k72r798.goho.co/api/shop/payment/mp-alipay/notify");
|
||||
request.setReturnUrl(null);
|
||||
// 配置业务参数
|
||||
JSONObject bizContent = new JSONObject();
|
||||
System.out.println("bizContent = " + order);
|
||||
bizContent.put("out_trade_no", order.getOrderNo());
|
||||
bizContent.put("total_amount", order.getPayPrice());
|
||||
bizContent.put("subject", order.getMerchantName());
|
||||
// 拿不到手机号码??
|
||||
bizContent.put("buyer_id", userOauthService.getOauthIdByUserId(order.getUserId(), "MP-ALIPAY"));
|
||||
request.setBizContent(bizContent.toString());
|
||||
//SDK 已经封装掉了公共参数,这里只需要传入业务参数。
|
||||
AlipayTradeCreateResponse response = alipayClient.certificateExecute(request);
|
||||
String trade_no = response.getTradeNo();// 获取返回的tradeNO。
|
||||
return success("支付成功", trade_no);
|
||||
} catch (AlipayApiException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiModelProperty("异步通知")
|
||||
@OperationLog
|
||||
@PostMapping("/mp-alipay/notify")
|
||||
public String alipayNotify(@RequestParam Map<String, String> params) throws AlipayApiException {
|
||||
System.out.println("异步处理>>>>");
|
||||
System.out.println("params = " + params);
|
||||
String outTradeNo = params.get("out_trade_no");
|
||||
Order order = orderService.getByOutTradeNo(outTradeNo);
|
||||
if(order == null){
|
||||
throw new BusinessException("订单不存在");
|
||||
}
|
||||
final JSONObject config = alipayConfig.payment(order.getTenantId());
|
||||
// 生成环境证书路径
|
||||
String alipayCertPublicKey = pathConfig.getUploadPath() + "file" + config.getString("alipayCertPublicKey");
|
||||
// TODO 验签成功后,按照支付结果异步通知中的描述,对支付结果中的业务内容进行二次校验,校验成功后在response中返回success并继续商户自身业务处理,校验失败返回failure
|
||||
boolean flag = AlipaySignature.rsaCertCheckV1(params, alipayCertPublicKey, AlipayConstants.CHARSET_UTF8, AlipayConstants.SIGN_TYPE_RSA2);
|
||||
System.out.println("flag>>>>>>>>>>>>>>>>>>>>>>>");
|
||||
System.out.println(flag);
|
||||
// 处理订单业务
|
||||
if (flag) {
|
||||
final String tradeStatus = params.get("trade_status");
|
||||
final String receipt_amount = params.get("receipt_amount");
|
||||
final String payPrice = order.getPayPrice().toString();
|
||||
final String trade_no = params.get("trade_no");
|
||||
final String subject = params.get("subject");
|
||||
|
||||
// 1. 验证appId是否一致
|
||||
final String app_id = params.get("app_id");
|
||||
if(!config.getString("alipayAppId").equals(app_id)){
|
||||
System.out.println("支付宝appId不一致 = " + app_id);
|
||||
throw new BusinessException("支付宝appId不一致");
|
||||
}
|
||||
// 2. 订单金额
|
||||
if(!payPrice.equals(receipt_amount)){
|
||||
System.out.println("订单金额是不一致 = " + receipt_amount);
|
||||
throw new BusinessException("订单金额是不一致");
|
||||
}
|
||||
// 3. 判断交易状态
|
||||
if(!"TRADE_SUCCESS".equals(tradeStatus)){
|
||||
System.out.println("支付失败 = " + tradeStatus);
|
||||
throw new BusinessException("支付失败");
|
||||
}
|
||||
// 4. 修改支付状态
|
||||
order.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
order.setPayMethod(PAY_METHOD_ALIPAY);
|
||||
order.setReceiptAmount(new BigDecimal(receipt_amount));
|
||||
order.setPayTime(DateUtil.date());
|
||||
order.setTradeId(trade_no);
|
||||
order.setSubject(subject);
|
||||
System.out.println("order2 = " + order);
|
||||
final boolean b = orderService.updateByIdRel(order);
|
||||
System.out.println("bsss = " + b);
|
||||
return "success";
|
||||
}
|
||||
// TODO 验签失败则记录异常日志,并在response中返回failure.
|
||||
return "failure";
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiModelProperty("余额支付")
|
||||
@GetMapping("/balance/{id}")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public ApiResult<?> balance(@PathVariable("id") Integer id) throws AlipayApiException {
|
||||
// 1. 验证签名
|
||||
isCheckSign();
|
||||
// 订单数据
|
||||
Order order = orderService.getByIdRel(id);
|
||||
// 当前登录用户id
|
||||
User user = new User();
|
||||
// 代付款情况
|
||||
if(!order.getUserId().equals(getLoginUserId())){
|
||||
user = userService.getById(order.getUserId());
|
||||
}else{
|
||||
user = getLoginUser();
|
||||
}
|
||||
final Integer userId = user.getUserId();
|
||||
final BigDecimal balance = user.getBalance();
|
||||
final BigDecimal payPrice = order.getPayPrice();
|
||||
if(balance.compareTo(payPrice) < 0){
|
||||
return fail("余额不足 = " + balance.compareTo(payPrice));
|
||||
}
|
||||
// 2. 扣除余额操作
|
||||
BigDecimal subtract = balance.subtract(payPrice);
|
||||
user.setBalance(subtract);
|
||||
userService.updateById(user);
|
||||
// 3. 记录余额明细
|
||||
UserBalanceLog userBalanceLog = new UserBalanceLog();
|
||||
userBalanceLog.setUserId(userId);
|
||||
userBalanceLog.setScene(BALANCE_USE);
|
||||
userBalanceLog.setMoney(payPrice);
|
||||
userBalanceLog.setBalance(subtract);
|
||||
userBalanceLog.setComments(order.getOrderNo().toString());
|
||||
userBalanceLog.setMerchantCode(order.getMerchantCode());
|
||||
userBalanceLogService.save(userBalanceLog);
|
||||
// 4. 修改支付状态
|
||||
order.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
order.setPayMethod(PAY_METHOD_BALANCE);
|
||||
order.setReceiptAmount(payPrice);
|
||||
order.setPayTime(DateUtil.date());
|
||||
order.setSubject(order.getMerchantName());
|
||||
orderService.updateByIdRel(order);
|
||||
// 5. 续租订单
|
||||
if(order.getRentOrderId() > 0){
|
||||
// 主订单
|
||||
Order parentOrder = orderService.getById(order.getRentOrderId());
|
||||
// 更新过期时间延长一个月
|
||||
Date expirationTime = parentOrder.getExpirationTime();
|
||||
DateTime nextMonthTime = DateUtil.offsetMonth(expirationTime, 1);
|
||||
parentOrder.setExpirationTime(nextMonthTime);
|
||||
orderService.updateById(parentOrder);
|
||||
// 保存续费订单状态
|
||||
order.setDeliveryStatus(DELIVERY_STATUS_YES);
|
||||
order.setReceiptStatus(RECEIPT_STATUS_YES);
|
||||
order.setOrderStatus(ORDER_STATUS_COMPLETED);
|
||||
order.setStartTime(expirationTime);
|
||||
order.setExpirationTime(nextMonthTime);
|
||||
orderService.updateById(order);
|
||||
}
|
||||
// 6. 是否是临时报餐
|
||||
final BcTemporaryParam bcTemporaryParam = new BcTemporaryParam();
|
||||
bcTemporaryParam.setUserId(getLoginUserId());
|
||||
bcTemporaryParam.setApplyStatus(1);
|
||||
final List<BcTemporary> bcTemporaries = bcTemporaryService.listRel(bcTemporaryParam);
|
||||
bcTemporaries.forEach(b -> {
|
||||
b.setStatus(1);
|
||||
bcTemporaryService.updateById(b);
|
||||
});
|
||||
return success("支付成功",user);
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@ApiModelProperty("余额支付批量")
|
||||
@PostMapping("/balanceBatch")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public ApiResult<?> balanceBatch(@RequestBody List<Integer> orderIds) throws AlipayApiException {
|
||||
// 1. 验证签名
|
||||
isCheckSign();
|
||||
// 订单数据
|
||||
final List<Order> list = orderService.listByIds(orderIds);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
list.forEach(d -> {
|
||||
// 当前登录用户id
|
||||
User user = new User();
|
||||
// 代付款情况
|
||||
if(!d.getUserId().equals(getLoginUserId())){
|
||||
user = userService.getById(d.getUserId());
|
||||
}else{
|
||||
user = getLoginUser();
|
||||
}
|
||||
final Integer userId = user.getUserId();
|
||||
final BigDecimal balance = user.getBalance();
|
||||
final BigDecimal payPrice = d.getPayPrice();
|
||||
if(balance.compareTo(payPrice) < 0){
|
||||
sb.append("下单失败:").append(user.getNickname()).append("余额不足");
|
||||
throw new BusinessException("余额不足");
|
||||
}
|
||||
// 2. 扣除余额操作
|
||||
BigDecimal subtract = balance.subtract(payPrice);
|
||||
user.setBalance(subtract);
|
||||
userService.updateById(user);
|
||||
// 3. 记录余额明细
|
||||
UserBalanceLog userBalanceLog = new UserBalanceLog();
|
||||
userBalanceLog.setUserId(userId);
|
||||
userBalanceLog.setScene(BALANCE_USE);
|
||||
userBalanceLog.setMoney(payPrice);
|
||||
userBalanceLog.setBalance(subtract);
|
||||
userBalanceLog.setComments(d.getOrderNo().toString());
|
||||
userBalanceLog.setMerchantCode(d.getMerchantCode());
|
||||
userBalanceLogService.save(userBalanceLog);
|
||||
// 4. 修改支付状态
|
||||
d.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
d.setPayMethod(PAY_METHOD_BALANCE);
|
||||
d.setReceiptAmount(payPrice);
|
||||
d.setPayTime(DateUtil.date());
|
||||
d.setSubject(d.getMerchantName());
|
||||
orderService.updateByIdRel(d);
|
||||
// 5. 续租订单
|
||||
if(d.getRentOrderId() > 0){
|
||||
// 主订单
|
||||
Order parentOrder = orderService.getById(d.getRentOrderId());
|
||||
// 更新过期时间延长一个月
|
||||
Date expirationTime = parentOrder.getExpirationTime();
|
||||
DateTime nextMonthTime = DateUtil.offsetMonth(expirationTime, 1);
|
||||
parentOrder.setExpirationTime(nextMonthTime);
|
||||
orderService.updateById(parentOrder);
|
||||
// 保存续费订单状态
|
||||
d.setDeliveryStatus(DELIVERY_STATUS_YES);
|
||||
d.setReceiptStatus(RECEIPT_STATUS_YES);
|
||||
d.setOrderStatus(ORDER_STATUS_COMPLETED);
|
||||
d.setStartTime(expirationTime);
|
||||
d.setExpirationTime(nextMonthTime);
|
||||
orderService.updateById(d);
|
||||
}
|
||||
// 6. 是否是临时报餐
|
||||
final BcTemporaryParam bcTemporaryParam = new BcTemporaryParam();
|
||||
bcTemporaryParam.setUserId(getLoginUserId());
|
||||
bcTemporaryParam.setApplyStatus(1);
|
||||
final List<BcTemporary> bcTemporaries = bcTemporaryService.listRel(bcTemporaryParam);
|
||||
bcTemporaries.forEach(b -> {
|
||||
b.setStatus(1);
|
||||
bcTemporaryService.updateById(b);
|
||||
});
|
||||
});
|
||||
return success("支付成功",sb);
|
||||
}
|
||||
|
||||
@ApiModelProperty("统一收单交易查询")
|
||||
@GetMapping("/mp-alipay/query/{id}")
|
||||
public ApiResult<?> query(@PathVariable("id") Integer id) throws AlipayApiException {
|
||||
// 验证签名
|
||||
isCheckSign();
|
||||
// 订单数据
|
||||
Order order = orderService.getByIdRel(id);
|
||||
// 实例化客户端
|
||||
DefaultAlipayClient alipayClient = alipayConfig.alipayClient(order.getTenantId());
|
||||
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
|
||||
JSONObject bizContent = new JSONObject();
|
||||
bizContent.put("out_trade_no", order.getOrderNo());
|
||||
request.setBizContent(bizContent.toString());
|
||||
AlipayTradeQueryResponse response = alipayClient.certificateExecute(request);
|
||||
if(response.isSuccess()){
|
||||
System.out.println("调用成功");
|
||||
orderService.paySuccess(response);
|
||||
} else {
|
||||
System.out.println("调用失败");
|
||||
}
|
||||
return success("调用成功",response);
|
||||
}
|
||||
|
||||
@ApiModelProperty("测试")
|
||||
@GetMapping("/mp-alipay/test")
|
||||
public String test() {
|
||||
System.out.println("开始>>>>>");
|
||||
Order order = orderService.getByOutTradeNo("2023213225911618");
|
||||
System.out.println("order = " + order);
|
||||
order.setPayPrice(new BigDecimal("0.11"));
|
||||
order.setTotalPrice(new BigDecimal("0.11"));
|
||||
order.setPayStatus(PAY_STATUS_SUCCESS);
|
||||
final boolean b = orderService.updateByIdRel(order);
|
||||
System.out.println("b = " + b);
|
||||
|
||||
// params.put("gmt_create", "2022-12-16 21:32:33");
|
||||
// params.put("charset", "UTF-8");
|
||||
// params.put("seller_email", "zhu115289@163.com");
|
||||
// params.put("subject", "测试商品");
|
||||
// params.put("buyer_id", "2088202959044205");
|
||||
// params.put("invoice_amount", "0.01");
|
||||
// params.put("notify_id", "2022121601222213308044201435873270");
|
||||
// params.put("fund_bill_list", "");
|
||||
// params.put("notify_type", "trade_status_sync");
|
||||
// params.put("trade_status", "TRADE_SUCCESS");
|
||||
// params.put("receipt_amount", "0.01");
|
||||
// params.put("buyer_pay_amount", "0.01");
|
||||
// params.put("app_id", "2021003156628508");
|
||||
// params.put("seller_id", "2088431805524422");
|
||||
// params.put("gmt_payment", "2022-12-16 21:33:07");
|
||||
// params.put("notify_time", "2022-12-16 21:33:09");
|
||||
// params.put("version", "1.0");
|
||||
// params.put("out_trade_no", "20221116205303366");
|
||||
// params.put("total_amount", "0.01");
|
||||
// params.put("trade_no", "2022121622001444201411215463");
|
||||
// params.put("auth_app_id", "2021003156628508");
|
||||
// params.put("buyer_logon_id", "ip1***@163.com");
|
||||
// params.put("point_amount", "0.00");
|
||||
// // 处理订单业务
|
||||
// orderService.paySuccess(params);
|
||||
return "success";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.PaymentTemplateService;
|
||||
import com.gxwebsoft.shop.entity.PaymentTemplate;
|
||||
import com.gxwebsoft.shop.param.PaymentTemplateParam;
|
||||
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 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 2022-12-09 13:59:38
|
||||
*/
|
||||
@Api(tags = "商城支付模板记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/payment-template")
|
||||
public class PaymentTemplateController extends BaseController {
|
||||
@Resource
|
||||
private PaymentTemplateService paymentTemplateService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTemplate:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商城支付模板记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<PaymentTemplate>> page(PaymentTemplateParam param) {
|
||||
PageParam<PaymentTemplate, PaymentTemplateParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(paymentTemplateService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(paymentTemplateService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTemplate:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商城支付模板记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<PaymentTemplate>> list(PaymentTemplateParam param) {
|
||||
PageParam<PaymentTemplate, PaymentTemplateParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(paymentTemplateService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(paymentTemplateService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTemplate:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商城支付模板记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<PaymentTemplate> get(@PathVariable("id") Integer id) {
|
||||
return success(paymentTemplateService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(paymentTemplateService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTemplate:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商城支付模板记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody PaymentTemplate paymentTemplate) {
|
||||
if (paymentTemplateService.save(paymentTemplate)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTemplate:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商城支付模板记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody PaymentTemplate paymentTemplate) {
|
||||
if (paymentTemplateService.updateById(paymentTemplate)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTemplate:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商城支付模板记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (paymentTemplateService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTemplate:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商城支付模板记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<PaymentTemplate> list) {
|
||||
if (paymentTemplateService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTemplate:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商城支付模板记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<PaymentTemplate> batchParam) {
|
||||
if (batchParam.update(paymentTemplateService, "template_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTemplate:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商城支付模板记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (paymentTemplateService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.PaymentTradeService;
|
||||
import com.gxwebsoft.shop.entity.PaymentTrade;
|
||||
import com.gxwebsoft.shop.param.PaymentTradeParam;
|
||||
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 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 2022-12-09 13:59:38
|
||||
*/
|
||||
@Api(tags = "第三方支付交易记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/payment-trade")
|
||||
public class PaymentTradeController extends BaseController {
|
||||
@Resource
|
||||
private PaymentTradeService paymentTradeService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTrade:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询第三方支付交易记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<PaymentTrade>> page(PaymentTradeParam param) {
|
||||
PageParam<PaymentTrade, PaymentTradeParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(paymentTradeService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(paymentTradeService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTrade:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部第三方支付交易记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<PaymentTrade>> list(PaymentTradeParam param) {
|
||||
PageParam<PaymentTrade, PaymentTradeParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(paymentTradeService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(paymentTradeService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTrade:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询第三方支付交易记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<PaymentTrade> get(@PathVariable("id") Integer id) {
|
||||
return success(paymentTradeService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(paymentTradeService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTrade:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加第三方支付交易记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody PaymentTrade paymentTrade) {
|
||||
// 记录当前登录用户id、租户id、商户编号
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
paymentTrade.setUserId(loginUser.getUserId());
|
||||
paymentTrade.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
if (paymentTradeService.save(paymentTrade)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTrade:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改第三方支付交易记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody PaymentTrade paymentTrade) {
|
||||
if (paymentTradeService.updateById(paymentTrade)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTrade:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除第三方支付交易记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (paymentTradeService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTrade:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加第三方支付交易记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<PaymentTrade> list) {
|
||||
if (paymentTradeService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTrade:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改第三方支付交易记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<PaymentTrade> batchParam) {
|
||||
if (batchParam.update(paymentTradeService, "trade_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:paymentTrade:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除第三方支付交易记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (paymentTradeService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.entity.RechargeOrder;
|
||||
import com.gxwebsoft.shop.entity.UserBalanceLog;
|
||||
import com.gxwebsoft.shop.param.RechargeOrderParam;
|
||||
import com.gxwebsoft.shop.service.RechargeOrderService;
|
||||
import com.gxwebsoft.shop.service.UserBalanceLogService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.BalanceConstants.BALANCE_ADMIN;
|
||||
|
||||
/**
|
||||
* 会员充值订单表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-04-20 20:36:24
|
||||
*/
|
||||
@Api(tags = "会员充值订单表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/recharge-order")
|
||||
public class RechargeOrderController extends BaseController {
|
||||
@Resource
|
||||
private RechargeOrderService rechargeOrderService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private UserBalanceLogService userBalanceLogService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("会员充值")
|
||||
@PostMapping("/recharge")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public ApiResult<?> recharge(@RequestBody RechargeOrder rechargeOrder) {
|
||||
// 充值
|
||||
User user = userService.getById(rechargeOrder.getUserId());
|
||||
BigDecimal balance = user.getBalance().add(rechargeOrder.getPayPrice());
|
||||
user.setBalance(balance);
|
||||
userService.updateById(user);
|
||||
// 保存充值记录
|
||||
rechargeOrder.setOrderNo(IdUtil.getSnowflakeNextId());
|
||||
rechargeOrder.setBalance(balance);
|
||||
if (rechargeOrderService.save(rechargeOrder)) {
|
||||
// 记录余额明细
|
||||
UserBalanceLog userBalanceLog = new UserBalanceLog();
|
||||
userBalanceLog.setUserId(rechargeOrder.getUserId());
|
||||
userBalanceLog.setScene(BALANCE_ADMIN);
|
||||
userBalanceLog.setMoney(rechargeOrder.getPayPrice());
|
||||
userBalanceLog.setBalance(balance);
|
||||
userBalanceLog.setComments("操作人:" + getLoginUser().getNickname());
|
||||
userBalanceLog.setRemark(rechargeOrder.getComments());
|
||||
userBalanceLog.setMerchantCode(rechargeOrder.getMerchantCode());
|
||||
userBalanceLogService.save(userBalanceLog);
|
||||
return success("充值成功", user);
|
||||
}
|
||||
return fail("充值失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询会员充值订单表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<RechargeOrder>> page(RechargeOrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(rechargeOrderService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部会员充值订单表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<RechargeOrder>> list(RechargeOrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(rechargeOrderService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询会员充值订单表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<RechargeOrder> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(rechargeOrderService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加会员充值订单表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody RechargeOrder rechargeOrder) {
|
||||
// 记录当前登录用户id、租户id、商户编号
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
rechargeOrder.setUserId(loginUser.getUserId());
|
||||
rechargeOrder.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
if (rechargeOrderService.save(rechargeOrder)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改会员充值订单表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody RechargeOrder rechargeOrder) {
|
||||
if (rechargeOrderService.updateById(rechargeOrder)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除会员充值订单表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (rechargeOrderService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量充值")
|
||||
@PostMapping("/batchRecharge")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public ApiResult<?> batchRecharge(@RequestBody List<RechargeOrder> list) {
|
||||
if (rechargeOrderService.saveBatch(list)) {
|
||||
String nickname = getLoginUser().getNickname();
|
||||
ArrayList<User> users = new ArrayList<>(list.size());
|
||||
ArrayList<UserBalanceLog> logs = new ArrayList<>(list.size());
|
||||
|
||||
list.forEach(d -> {
|
||||
User user = userService.getByIdRel(d.getUserId());
|
||||
BigDecimal balance = user.getBalance().add(d.getPayPrice());
|
||||
user.setBalance(balance);
|
||||
users.add(user);
|
||||
UserBalanceLog userBalanceLog = new UserBalanceLog();
|
||||
userBalanceLog.setUserId(d.getUserId());
|
||||
userBalanceLog.setScene(BALANCE_ADMIN);
|
||||
userBalanceLog.setMoney(d.getPayPrice());
|
||||
userBalanceLog.setBalance(balance);
|
||||
userBalanceLog.setComments("操作人:" + nickname);
|
||||
userBalanceLog.setRemark(d.getComments());
|
||||
userBalanceLog.setMerchantCode(d.getMerchantCode());
|
||||
logs.add(userBalanceLog);
|
||||
});
|
||||
|
||||
// 批量充值
|
||||
userService.updateBatchById(users);
|
||||
// 记录余额明细
|
||||
userBalanceLogService.saveBatch(logs);
|
||||
return success("充值成功");
|
||||
}
|
||||
return fail("充值失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改会员充值订单表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<RechargeOrder> batchParam) {
|
||||
if (batchParam.update(rechargeOrderService, "order_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除会员充值订单表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (rechargeOrderService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.RechargeOrderPlanService;
|
||||
import com.gxwebsoft.shop.entity.RechargeOrderPlan;
|
||||
import com.gxwebsoft.shop.param.RechargeOrderPlanParam;
|
||||
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 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 2023-04-20 20:36:24
|
||||
*/
|
||||
@Api(tags = "会员充值订单套餐快照表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/recharge-order-plan")
|
||||
public class RechargeOrderPlanController extends BaseController {
|
||||
@Resource
|
||||
private RechargeOrderPlanService rechargeOrderPlanService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrderPlan:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询会员充值订单套餐快照表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<RechargeOrderPlan>> page(RechargeOrderPlanParam param) {
|
||||
PageParam<RechargeOrderPlan, RechargeOrderPlanParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(rechargeOrderPlanService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(rechargeOrderPlanService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrderPlan:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部会员充值订单套餐快照表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<RechargeOrderPlan>> list(RechargeOrderPlanParam param) {
|
||||
PageParam<RechargeOrderPlan, RechargeOrderPlanParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(rechargeOrderPlanService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(rechargeOrderPlanService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrderPlan:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询会员充值订单套餐快照表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<RechargeOrderPlan> get(@PathVariable("id") Integer id) {
|
||||
return success(rechargeOrderPlanService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(rechargeOrderPlanService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrderPlan:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加会员充值订单套餐快照表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody RechargeOrderPlan rechargeOrderPlan) {
|
||||
// 记录当前登录用户id、租户id、商户编号
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
rechargeOrderPlan.setUserId(loginUser.getUserId());
|
||||
rechargeOrderPlan.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
if (rechargeOrderPlanService.save(rechargeOrderPlan)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrderPlan:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改会员充值订单套餐快照表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody RechargeOrderPlan rechargeOrderPlan) {
|
||||
if (rechargeOrderPlanService.updateById(rechargeOrderPlan)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrderPlan:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除会员充值订单套餐快照表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (rechargeOrderPlanService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrderPlan:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加会员充值订单套餐快照表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<RechargeOrderPlan> list) {
|
||||
if (rechargeOrderPlanService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrderPlan:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改会员充值订单套餐快照表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<RechargeOrderPlan> batchParam) {
|
||||
if (batchParam.update(rechargeOrderPlanService, "order_plan_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrderPlan:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除会员充值订单套餐快照表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (rechargeOrderPlanService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.RechargePlanService;
|
||||
import com.gxwebsoft.shop.entity.RechargePlan;
|
||||
import com.gxwebsoft.shop.param.RechargePlanParam;
|
||||
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 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 2023-04-20 20:36:24
|
||||
*/
|
||||
@Api(tags = "会员充值套餐表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/recharge-plan")
|
||||
public class RechargePlanController extends BaseController {
|
||||
@Resource
|
||||
private RechargePlanService rechargePlanService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargePlan:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询会员充值套餐表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<RechargePlan>> page(RechargePlanParam param) {
|
||||
PageParam<RechargePlan, RechargePlanParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(rechargePlanService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(rechargePlanService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargePlan:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部会员充值套餐表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<RechargePlan>> list(RechargePlanParam param) {
|
||||
PageParam<RechargePlan, RechargePlanParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(rechargePlanService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(rechargePlanService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargePlan:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询会员充值套餐表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<RechargePlan> get(@PathVariable("id") Integer id) {
|
||||
return success(rechargePlanService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(rechargePlanService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargePlan:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加会员充值套餐表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody RechargePlan rechargePlan) {
|
||||
// 记录当前登录用户id、租户id、商户编号
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
rechargePlan.setUserId(loginUser.getUserId());
|
||||
rechargePlan.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
if (rechargePlanService.save(rechargePlan)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargePlan:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改会员充值套餐表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody RechargePlan rechargePlan) {
|
||||
if (rechargePlanService.updateById(rechargePlan)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargePlan:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除会员充值套餐表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (rechargePlanService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargePlan:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加会员充值套餐表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<RechargePlan> list) {
|
||||
if (rechargePlanService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargePlan:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改会员充值套餐表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<RechargePlan> batchParam) {
|
||||
if (batchParam.update(rechargePlanService, "plan_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargePlan:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除会员充值套餐表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (rechargePlanService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayConstants;
|
||||
import com.alipay.api.CertAlipayRequest;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.alipay.api.internal.util.AlipayEncrypt;
|
||||
import com.alipay.api.internal.util.AlipaySignature;
|
||||
import com.alipay.api.request.AlipayTradeCreateRequest;
|
||||
import com.alipay.api.response.AlipayTradeCreateResponse;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.web.*;
|
||||
import com.gxwebsoft.common.system.service.OperationRecordService;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.entity.Payment;
|
||||
import com.gxwebsoft.shop.param.PaymentParam;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.service.PaymentService;
|
||||
import com.gxwebsoft.shop.service.UserOauthService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 定时任务
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-12-15 19:11:07
|
||||
*/
|
||||
@Api(tags = "定时任务")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/payment")
|
||||
public class SchedulingController extends BaseController {
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
|
||||
// /**
|
||||
// * 删除失效订单
|
||||
// */
|
||||
// @Scheduled(cron="0 0 */1 * * ?")
|
||||
// public void reportCurrentTime() {
|
||||
// System.out.println("定时任务开始 = " + new Date());
|
||||
// boolean remove = orderService.remove(new LambdaQueryWrapper<Order>()
|
||||
// .lt(Order::getExpirationTime, new Date())
|
||||
// .eq(Order::getPayStatus, 10)
|
||||
// .eq(Order::getOrderStatus, 10));
|
||||
// System.out.println("remove = " + remove);
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.config.ExpressConfig;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
public class SfExpressController extends BaseController {
|
||||
|
||||
@Resource
|
||||
ExpressConfig expressConfig;
|
||||
|
||||
public ApiResult<?> createOrder(){
|
||||
String sign = "";
|
||||
String serverHost = expressConfig.getServerHost().concat("/open/api/external/createorder?sign=").concat(sign);
|
||||
return success("成功",serverHost);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.constants.RedisConstants;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@Api(tags = "测试控制器")
|
||||
@RequestMapping("/api/shop/test")
|
||||
public class TestController extends BaseController {
|
||||
|
||||
@GetMapping()
|
||||
@OperationLog
|
||||
@ApiOperation("测试方法")
|
||||
public ApiResult<?> test(){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.UserAddressService;
|
||||
import com.gxwebsoft.shop.entity.UserAddress;
|
||||
import com.gxwebsoft.shop.param.UserAddressParam;
|
||||
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 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 2022-11-25 19:04:43
|
||||
*/
|
||||
@Api(tags = "用户收货地址表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/user-address")
|
||||
public class UserAddressController extends BaseController {
|
||||
@Resource
|
||||
private UserAddressService userAddressService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userAddress:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询用户收货地址表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserAddress>> page(UserAddressParam param) {
|
||||
PageParam<UserAddress, UserAddressParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(userAddressService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(userAddressService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userAddress:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部用户收货地址表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserAddress>> list(UserAddressParam param) {
|
||||
PageParam<UserAddress, UserAddressParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(userAddressService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(userAddressService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userAddress:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询用户收货地址表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserAddress> get(@PathVariable("id") Integer id) {
|
||||
return success(userAddressService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(userAddressService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userAddress:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加用户收货地址表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserAddress userAddress) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userAddress.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (userAddressService.save(userAddress)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userAddress:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改用户收货地址表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserAddress userAddress) {
|
||||
if (userAddressService.updateById(userAddress)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userAddress:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除用户收货地址表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userAddressService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userAddress:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加用户收货地址表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserAddress> list) {
|
||||
if (userAddressService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userAddress:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改用户收货地址表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserAddress> batchParam) {
|
||||
if (batchParam.update(userAddressService, "address_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userAddress:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除用户收货地址表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userAddressService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.UserBalanceLogService;
|
||||
import com.gxwebsoft.shop.entity.UserBalanceLog;
|
||||
import com.gxwebsoft.shop.param.UserBalanceLogParam;
|
||||
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 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 2023-04-21 15:59:09
|
||||
*/
|
||||
@Api(tags = "用户余额变动明细表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/user-balance-log")
|
||||
public class UserBalanceLogController extends BaseController {
|
||||
@Resource
|
||||
private UserBalanceLogService userBalanceLogService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询用户余额变动明细表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserBalanceLog>> page(UserBalanceLogParam param) {
|
||||
// 使用关联查询
|
||||
return success(userBalanceLogService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部用户余额变动明细表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserBalanceLog>> list(UserBalanceLogParam param) {
|
||||
PageParam<UserBalanceLog, UserBalanceLogParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(userBalanceLogService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(userBalanceLogService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询用户余额变动明细表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserBalanceLog> get(@PathVariable("id") Integer id) {
|
||||
return success(userBalanceLogService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(userBalanceLogService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加用户余额变动明细表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserBalanceLog userBalanceLog) {
|
||||
// 记录当前登录用户id、租户id、商户编号
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userBalanceLog.setUserId(loginUser.getUserId());
|
||||
userBalanceLog.setMerchantCode(getMerchantCode());
|
||||
}
|
||||
if (userBalanceLogService.save(userBalanceLog)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改用户余额变动明细表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserBalanceLog userBalanceLog) {
|
||||
if (userBalanceLogService.updateById(userBalanceLog)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除用户余额变动明细表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userBalanceLogService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加用户余额变动明细表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserBalanceLog> list) {
|
||||
if (userBalanceLogService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改用户余额变动明细表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserBalanceLog> batchParam) {
|
||||
if (batchParam.update(userBalanceLogService, "log_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除用户余额变动明细表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userBalanceLogService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.UserCouponService;
|
||||
import com.gxwebsoft.shop.entity.UserCoupon;
|
||||
import com.gxwebsoft.shop.param.UserCouponParam;
|
||||
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 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 2022-11-25 19:04:43
|
||||
*/
|
||||
@Api(tags = "用户优惠券记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/user-coupon")
|
||||
public class UserCouponController extends BaseController {
|
||||
@Resource
|
||||
private UserCouponService userCouponService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userCoupon:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询用户优惠券记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserCoupon>> page(UserCouponParam param) {
|
||||
PageParam<UserCoupon, UserCouponParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(userCouponService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(userCouponService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userCoupon:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部用户优惠券记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserCoupon>> list(UserCouponParam param) {
|
||||
PageParam<UserCoupon, UserCouponParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(userCouponService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(userCouponService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userCoupon:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询用户优惠券记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserCoupon> get(@PathVariable("id") Integer id) {
|
||||
return success(userCouponService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(userCouponService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userCoupon:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加用户优惠券记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserCoupon userCoupon) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userCoupon.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (userCouponService.save(userCoupon)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userCoupon:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改用户优惠券记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserCoupon userCoupon) {
|
||||
if (userCouponService.updateById(userCoupon)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userCoupon:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除用户优惠券记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userCouponService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userCoupon:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加用户优惠券记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserCoupon> list) {
|
||||
if (userCouponService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userCoupon:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改用户优惠券记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserCoupon> batchParam) {
|
||||
if (batchParam.update(userCouponService, "user_coupon_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userCoupon:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除用户优惠券记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userCouponService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.UserFollowService;
|
||||
import com.gxwebsoft.shop.entity.UserFollow;
|
||||
import com.gxwebsoft.shop.param.UserFollowParam;
|
||||
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 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 2022-11-25 19:04:43
|
||||
*/
|
||||
@Api(tags = "关注记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/user-follow")
|
||||
public class UserFollowController extends BaseController {
|
||||
@Resource
|
||||
private UserFollowService userFollowService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userFollow:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询关注记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserFollow>> page(UserFollowParam param) {
|
||||
PageParam<UserFollow, UserFollowParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(userFollowService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(userFollowService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userFollow:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部关注记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserFollow>> list(UserFollowParam param) {
|
||||
PageParam<UserFollow, UserFollowParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(userFollowService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(userFollowService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userFollow:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询关注记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserFollow> get(@PathVariable("id") Integer id) {
|
||||
return success(userFollowService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(userFollowService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userFollow:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加关注记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserFollow userFollow) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userFollow.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (userFollowService.save(userFollow)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userFollow:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改关注记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserFollow userFollow) {
|
||||
if (userFollowService.updateById(userFollow)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userFollow:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除关注记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userFollowService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userFollow:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加关注记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserFollow> list) {
|
||||
if (userFollowService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userFollow:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改关注记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserFollow> batchParam) {
|
||||
if (batchParam.update(userFollowService, "log_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userFollow:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除关注记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userFollowService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.UserOauthService;
|
||||
import com.gxwebsoft.shop.entity.UserOauth;
|
||||
import com.gxwebsoft.shop.param.UserOauthParam;
|
||||
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 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 2022-12-15 08:33:13
|
||||
*/
|
||||
@Api(tags = "第三方用户信息表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/user-oauth")
|
||||
public class UserOauthController extends BaseController {
|
||||
@Resource
|
||||
private UserOauthService userOauthService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userOauth:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询第三方用户信息表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserOauth>> page(UserOauthParam param) {
|
||||
// 使用关联查询
|
||||
return success(userOauthService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userOauth:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部第三方用户信息表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserOauth>> list(UserOauthParam param) {
|
||||
// 使用关联查询
|
||||
return success(userOauthService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userOauth:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询第三方用户信息表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserOauth> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(userOauthService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userOauth:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加第三方用户信息表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserOauth userOauth) {
|
||||
if (userOauthService.save(userOauth)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userOauth:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改第三方用户信息表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserOauth userOauth) {
|
||||
if (userOauthService.updateById(userOauth)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userOauth:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除第三方用户信息表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userOauthService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userOauth:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加第三方用户信息表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserOauth> list) {
|
||||
if (userOauthService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userOauth:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改第三方用户信息表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserOauth> batchParam) {
|
||||
if (batchParam.update(userOauthService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userOauth:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除第三方用户信息表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userOauthService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.UserPointsLogService;
|
||||
import com.gxwebsoft.shop.entity.UserPointsLog;
|
||||
import com.gxwebsoft.shop.param.UserPointsLogParam;
|
||||
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 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 2022-11-25 19:04:43
|
||||
*/
|
||||
@Api(tags = "用户积分变动明细表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/user-points-log")
|
||||
public class UserPointsLogController extends BaseController {
|
||||
@Resource
|
||||
private UserPointsLogService userPointsLogService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userPointsLog:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询用户积分变动明细表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserPointsLog>> page(UserPointsLogParam param) {
|
||||
PageParam<UserPointsLog, UserPointsLogParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(userPointsLogService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(userPointsLogService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userPointsLog:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部用户积分变动明细表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserPointsLog>> list(UserPointsLogParam param) {
|
||||
PageParam<UserPointsLog, UserPointsLogParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(userPointsLogService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(userPointsLogService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userPointsLog:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询用户积分变动明细表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserPointsLog> get(@PathVariable("id") Integer id) {
|
||||
return success(userPointsLogService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(userPointsLogService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userPointsLog:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加用户积分变动明细表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserPointsLog userPointsLog) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userPointsLog.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (userPointsLogService.save(userPointsLog)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userPointsLog:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改用户积分变动明细表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserPointsLog userPointsLog) {
|
||||
if (userPointsLogService.updateById(userPointsLog)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userPointsLog:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除用户积分变动明细表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userPointsLogService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userPointsLog:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加用户积分变动明细表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserPointsLog> list) {
|
||||
if (userPointsLogService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userPointsLog:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改用户积分变动明细表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserPointsLog> batchParam) {
|
||||
if (batchParam.update(userPointsLogService, "log_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userPointsLog:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除用户积分变动明细表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userPointsLogService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.UserRefereeService;
|
||||
import com.gxwebsoft.shop.entity.UserReferee;
|
||||
import com.gxwebsoft.shop.param.UserRefereeParam;
|
||||
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 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 2023-04-28 14:07:29
|
||||
*/
|
||||
@Api(tags = "用户推荐关系表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/user-referee")
|
||||
public class UserRefereeController extends BaseController {
|
||||
@Resource
|
||||
private UserRefereeService userRefereeService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userReferee:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询用户推荐关系表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserReferee>> page(UserRefereeParam param) {
|
||||
PageParam<UserReferee, UserRefereeParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(userRefereeService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(userRefereeService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userReferee:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部用户推荐关系表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserReferee>> list(UserRefereeParam param) {
|
||||
// 贵港自然资源局定制
|
||||
if(getTenantId().equals(10048)){
|
||||
final List<UserReferee> userRefereeList = userRefereeService.listRel(param);
|
||||
final User user = getLoginUser();
|
||||
final UserReferee userReferee = new UserReferee();
|
||||
userReferee.setNickname(user.getNickname());
|
||||
userRefereeList.add(userReferee);
|
||||
return success(userRefereeList);
|
||||
}
|
||||
// 使用关联查询
|
||||
return success(userRefereeService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userReferee:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询用户推荐关系表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserReferee> get(@PathVariable("id") Integer id) {
|
||||
return success(userRefereeService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(userRefereeService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userReferee:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加用户推荐关系表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserReferee userReferee) {
|
||||
// if(userReferee.getDealerId().equals(userReferee.getUserId())){
|
||||
// return fail("不能邀请自己");
|
||||
// }
|
||||
final int count = userRefereeService.count(new LambdaQueryWrapper<UserReferee>()
|
||||
.eq(UserReferee::getUserId, userReferee.getUserId())
|
||||
.eq(UserReferee::getDealerId,userReferee.getDealerId())
|
||||
);
|
||||
if(count > 0){
|
||||
return fail("关系已存在");
|
||||
}
|
||||
if (userRefereeService.save(userReferee)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userReferee:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改用户推荐关系表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserReferee userReferee) {
|
||||
if (userRefereeService.updateById(userReferee)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userReferee:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除用户推荐关系表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userRefereeService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userReferee:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加用户推荐关系表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserReferee> list) {
|
||||
if (userRefereeService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userReferee:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改用户推荐关系表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserReferee> batchParam) {
|
||||
if (batchParam.update(userRefereeService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userReferee:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除用户推荐关系表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userRefereeService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.security.JwtSubject;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.LoginRecord;
|
||||
import com.gxwebsoft.common.system.entity.Role;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.entity.UserRole;
|
||||
import com.gxwebsoft.common.system.param.UserParam;
|
||||
import com.gxwebsoft.common.system.result.LoginResult;
|
||||
import com.gxwebsoft.common.system.service.*;
|
||||
import com.gxwebsoft.shop.entity.UserOauth;
|
||||
import com.gxwebsoft.shop.service.UserOauthService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.RedisConstants.ACCESS_TOKEN_KEY;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/wx-login")
|
||||
@Api(tags = "微信小程序登录API")
|
||||
public class WxLoginController extends BaseController {
|
||||
@Resource
|
||||
private SettingService settingService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private ConfigProperties configProperties;
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
@Resource
|
||||
private UserOauthService userOauthService;
|
||||
@Resource
|
||||
private LoginRecordService loginRecordService;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@ApiOperation("获取微信openId")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@PostMapping("/getOpenId")
|
||||
public ApiResult<LoginResult> getOpenId(@RequestBody UserParam userParam, HttpServletRequest request) {
|
||||
// 1.获取openid
|
||||
JSONObject result = getOpenIdByCode(userParam);
|
||||
String openid = result.getString("openid");
|
||||
String unionid = result.getString("unionid");
|
||||
if (openid == null) {
|
||||
return fail("获取openid失败", null);
|
||||
}
|
||||
// 2.通过openid查询用户是否已存在
|
||||
User user = userOauthService.getByOauthId(openid);
|
||||
// 3.存在则签发token并返回登录成功,不存在则注册新用户
|
||||
if (user == null) {
|
||||
user = addUser(userParam);
|
||||
// 添加第三方用户信息
|
||||
UserOauth uo = new UserOauth();
|
||||
uo.setUserId(user.getUserId());
|
||||
uo.setTenantId(user.getTenantId());
|
||||
uo.setOauthType("MP-WEIXIN");
|
||||
uo.setOauthId(openid);
|
||||
uo.setUnionid(unionid);
|
||||
userOauthService.save(uo);
|
||||
}
|
||||
// 4.签发token
|
||||
loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_LOGIN, null, user.getTenantId(), request);
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
return success("登录成功", new LoginResult(access_token, user));
|
||||
}
|
||||
|
||||
@ApiOperation("微信授权手机号码并登录")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@PostMapping("/loginByMpWxPhone")
|
||||
public ApiResult<LoginResult> loginByMpWxPhone(@RequestBody UserParam userParam, HttpServletRequest request) {
|
||||
// 获取手机号码
|
||||
String phone = getPhoneByCode(userParam);
|
||||
// 查询是否存在
|
||||
User user = userService.getByPhone(phone);
|
||||
// 不存在则注册
|
||||
if (user == null) {
|
||||
userParam.setPhone(phone);
|
||||
user = addUser(userParam);
|
||||
}
|
||||
// 签发token
|
||||
String access_token = JwtUtil.buildToken(new JwtSubject(user.getUsername(), user.getTenantId()),
|
||||
configProperties.getTokenExpireTime(), configProperties.getTokenKey());
|
||||
loginRecordService.saveAsync(user.getUsername(), LoginRecord.TYPE_REGISTER, null, user.getTenantId(), request);
|
||||
return success("登录成功", new LoginResult(access_token, user));
|
||||
}
|
||||
|
||||
@ApiOperation("微信授权手机号码并更新")
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@PostMapping("/updatePhoneByMpWx")
|
||||
public ApiResult<?> updatePhoneByMpWx(@RequestBody UserParam userParam) {
|
||||
// 获取微信授权手机号
|
||||
String phone = getPhoneByCode(userParam);
|
||||
// 查询当前用户
|
||||
User user = userService.getById(userParam.getUserId());
|
||||
if (user != null && phone != null) {
|
||||
user.setPhone(phone);
|
||||
userService.updateUser(user);
|
||||
return success("更新成功",phone);
|
||||
}
|
||||
return fail("更新失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新用户注册
|
||||
*/
|
||||
private User addUser(UserParam userParam) {
|
||||
User addUser = new User();
|
||||
// 注册用户
|
||||
addUser.setStatus(0);
|
||||
addUser.setUsername(createUsername("wx_"));
|
||||
addUser.setNickname("微信用户");
|
||||
addUser.setPassword(userService.encodePassword(CommonUtil.randomUUID16()));
|
||||
addUser.setTenantId(getTenantId());
|
||||
Role role = roleService.getOne(new QueryWrapper<Role>().eq("role_code", "user"), false);
|
||||
addUser.setRoleId(role.getRoleId());
|
||||
if (userService.saveUser(addUser)) {
|
||||
// 添加用户角色
|
||||
final UserRole userRole = new UserRole();
|
||||
userRole.setUserId(addUser.getUserId());
|
||||
userRole.setTenantId(addUser.getTenantId());
|
||||
userRole.setRoleId(addUser.getRoleId());
|
||||
userRoleService.save(userRole);
|
||||
}
|
||||
return addUser;
|
||||
}
|
||||
|
||||
// 获取openid
|
||||
private JSONObject getOpenIdByCode(UserParam userParam) {
|
||||
// 获取微信小程序配置信息
|
||||
JSONObject setting = settingService.getBySettingKey("mp-weixin");
|
||||
// 获取openId
|
||||
String apiUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=" + setting.getString("appId") + "&secret=" + setting.getString("appSecret") + "&js_code=" + userParam.getCode() + "&grant_type=authorization_code";
|
||||
// 执行get请求
|
||||
String result = HttpUtil.get(apiUrl);
|
||||
System.out.println("result = " + result);
|
||||
// 解析access_token
|
||||
return JSON.parseObject(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取微信手机号码
|
||||
*
|
||||
* @param userParam 需要传微信凭证code
|
||||
*/
|
||||
private String getPhoneByCode(UserParam userParam) {
|
||||
// 获取手机号码
|
||||
String apiUrl = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + getAccessToken();
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("code", userParam.getCode());
|
||||
// 执行post请求
|
||||
String post = HttpUtil.post(apiUrl, JSON.toJSONString(paramMap));
|
||||
JSONObject json = JSON.parseObject(post);
|
||||
if (json.get("errcode").equals(0)) {
|
||||
JSONObject phoneInfo = JSON.parseObject(json.getString("phone_info"));
|
||||
// 微信用户的手机号码
|
||||
return phoneInfo.getString("phoneNumber");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成随机账号
|
||||
*
|
||||
* @return username
|
||||
*/
|
||||
private String createUsername(String type) {
|
||||
return type.concat(RandomUtil.randomString(12));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接口调用凭据AccessToken
|
||||
* https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/mp-access-token/getAccessToken.html
|
||||
*/
|
||||
private String getAccessToken() {
|
||||
// 获取微信小程序配置信息
|
||||
JSONObject setting = settingService.getBySettingKey("mp-weixin");
|
||||
// 从缓存获取access_token
|
||||
String value = redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY.concat(getTenantId().toString()));
|
||||
if (value != null) {
|
||||
// 解析access_token
|
||||
JSONObject response = JSON.parseObject(value);
|
||||
return response.getString("access_token");
|
||||
}
|
||||
// 微信获取凭证接口
|
||||
String apiUrl = "https://api.weixin.qq.com/cgi-bin/token";
|
||||
// 组装url参数
|
||||
String url = apiUrl.concat("?grant_type=client_credential").concat("&appid=").concat(setting.getString("appId")).concat("&secret=").concat(setting.getString("appSecret"));
|
||||
// 执行get请求
|
||||
String result = HttpUtil.get(url);
|
||||
// 解析access_token
|
||||
JSONObject response = JSON.parseObject(result);
|
||||
if (response.getString("access_token") != null) {
|
||||
// 存入缓存
|
||||
redisTemplate.opsForValue().set(ACCESS_TOKEN_KEY.concat(getTenantId().toString()), result);
|
||||
return response.getString("access_token");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/wx-pay")
|
||||
@Api(tags = "微信支付API")
|
||||
public class WxPayController extends BaseController
|
||||
{
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
|
||||
public ApiResult<?> nativePay(@PathVariable String orderId){
|
||||
return success("支付成功");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user