拆分think模块包
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.BrandService;
|
||||
import com.gxwebsoft.shop.entity.Brand;
|
||||
import com.gxwebsoft.shop.param.BrandParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 品牌控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-04 11:38:21
|
||||
*/
|
||||
@Api(tags = "品牌管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/brand")
|
||||
public class BrandController extends BaseController {
|
||||
@Resource
|
||||
private BrandService brandService;
|
||||
|
||||
@ApiOperation("分页查询品牌")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Brand>> page(BrandParam param) {
|
||||
// 使用关联查询
|
||||
return success(brandService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:brand:list')")
|
||||
@ApiOperation("查询全部品牌")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Brand>> list(BrandParam param) {
|
||||
// 使用关联查询
|
||||
return success(brandService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询品牌")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Brand> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(brandService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:brand:save')")
|
||||
@ApiOperation("添加品牌")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Brand brand) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// brand.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (brandService.save(brand)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:brand:update')")
|
||||
@ApiOperation("修改品牌")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Brand brand) {
|
||||
if (brandService.updateById(brand)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:brand:remove')")
|
||||
@ApiOperation("删除品牌")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (brandService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:brand:save')")
|
||||
@ApiOperation("批量添加品牌")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Brand> list) {
|
||||
if (brandService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:brand:update')")
|
||||
@ApiOperation("批量修改品牌")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Brand> batchParam) {
|
||||
if (batchParam.update(brandService, "brand_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:brand:remove')")
|
||||
@ApiOperation("批量删除品牌")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (brandService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
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.shop.entity.Cart;
|
||||
import com.gxwebsoft.shop.entity.Merchant;
|
||||
import com.gxwebsoft.shop.param.CartParam;
|
||||
import com.gxwebsoft.shop.service.CartService;
|
||||
import com.gxwebsoft.shop.service.MerchantService;
|
||||
import com.gxwebsoft.shop.vo.CartVo;
|
||||
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.*;
|
||||
|
||||
/**
|
||||
* 购物车控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-29 21:02:39
|
||||
*/
|
||||
@Api(tags = "购物车管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/cart")
|
||||
public class CartController extends BaseController {
|
||||
@Resource
|
||||
private CartService cartService;
|
||||
@Resource
|
||||
private MerchantService merchantService;
|
||||
|
||||
@ApiOperation("分页查询购物车")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Cart>> page(CartParam param) {
|
||||
// 使用关联查询
|
||||
return success(cartService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部购物车")
|
||||
@GetMapping()
|
||||
public ApiResult<CartVo> list(CartParam param) {
|
||||
if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
return success("请先登录",null);
|
||||
}
|
||||
// 附加用户ID
|
||||
param.setUserId(getLoginUserId());
|
||||
return success(cartService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:list')")
|
||||
@ApiOperation("根据id查询购物车")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Cart> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(cartService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加购物车")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Cart cart) {
|
||||
if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
return success("请先登录",null);
|
||||
}
|
||||
// 修正用户ID
|
||||
cart.setUserId(getLoginUserId());
|
||||
// 修正购买数量
|
||||
if (ObjectUtil.isEmpty(cart.getCartNum())) {
|
||||
cart.setCartNum(1);
|
||||
}
|
||||
// 超出最大限制
|
||||
if (cartService.count(new LambdaUpdateWrapper<Cart>().eq(Cart::getUserId,getLoginUserId())) > 50) {
|
||||
return fail("购物车宝贝数量已满,建议您先去结算或清理~");
|
||||
}
|
||||
// 重复商品叠加数量
|
||||
final Cart one = cartService.getOne(new LambdaQueryWrapper<Cart>()
|
||||
.eq(Cart::getUserId, getLoginUserId())
|
||||
.eq(Cart::getGoodsId,cart.getGoodsId())
|
||||
.eq(Cart::getSpec,cart.getSpec())
|
||||
.last("limit 1"));
|
||||
if(ObjectUtil.isNotEmpty(one)){
|
||||
one.setCartNum(cart.getCartNum()+1);
|
||||
cartService.updateById(one);
|
||||
return success("更新成功",one.getId());
|
||||
}
|
||||
if (cartService.save(cart)) {
|
||||
return success("添加成功",cart.getId());
|
||||
}
|
||||
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改购物车")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Cart cart) {
|
||||
if (cartService.updateById(cart)) {
|
||||
final CartParam param = new CartParam();
|
||||
param.setType(cart.getType());
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:remove')")
|
||||
@ApiOperation("删除购物车")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (cartService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:save')")
|
||||
@ApiOperation("批量添加购物车")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Cart> list) {
|
||||
if (cartService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:update')")
|
||||
@ApiOperation("批量修改购物车")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Cart> batchParam) {
|
||||
if (batchParam.update(cartService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:remove')")
|
||||
@ApiOperation("批量删除购物车")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (cartService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("全选操作")
|
||||
@PutMapping("/onSelectAll/{yes}")
|
||||
public ApiResult<?> onSelectAll(@PathVariable("yes") Boolean yes) {
|
||||
if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
return success("请先登录",null);
|
||||
}
|
||||
final List<Cart> carts = cartService.list(new LambdaUpdateWrapper<Cart>()
|
||||
.eq(Cart::getSelected,!yes)
|
||||
.eq(Cart::getUserId, getLoginUserId()));
|
||||
carts.forEach(d -> {
|
||||
d.setSelected(yes);
|
||||
});
|
||||
return success("修改成功", cartService.updateBatchById(carts));
|
||||
}
|
||||
|
||||
@ApiOperation("增加数量")
|
||||
@PutMapping("/addCartNum")
|
||||
public ApiResult<?> addCartNum(@RequestBody Cart cart) {
|
||||
if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
return success("请先登录",null);
|
||||
}
|
||||
cart.setCartNum(cart.getCartNum()+1);
|
||||
cartService.updateById(cart);
|
||||
return success("操作成功");
|
||||
}
|
||||
|
||||
@ApiOperation("减少数量")
|
||||
@PutMapping("/subCartNum")
|
||||
public ApiResult<?> subCartNum(@RequestBody Cart cart) {
|
||||
if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
return success("请先登录",null);
|
||||
}
|
||||
cart.setCartNum(cart.getCartNum()-1);
|
||||
cartService.updateById(cart);
|
||||
return success("操作成功");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.entity.Cart;
|
||||
import com.gxwebsoft.shop.service.CashierService;
|
||||
import com.gxwebsoft.shop.entity.Cashier;
|
||||
import com.gxwebsoft.shop.param.CashierParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.shop.vo.CashierVo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收银控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-08-04 11:51:43
|
||||
*/
|
||||
@Api(tags = "收银管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/cashier")
|
||||
public class CashierController extends BaseController {
|
||||
@Resource
|
||||
private CashierService cashierService;
|
||||
|
||||
@ApiOperation("分页查询收银")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Cashier>> page(CashierParam param) {
|
||||
// 使用关联查询
|
||||
return success(cashierService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部收银")
|
||||
@GetMapping()
|
||||
public ApiResult<CashierVo> list(CashierParam param) {
|
||||
if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
return success("请先登录",null);
|
||||
}
|
||||
// 附加收银员ID
|
||||
param.setCashierId(getLoginUserId());
|
||||
// 收银员ID
|
||||
// final Set<String> collect = getLoginUser().getRoles().stream().map(Role::getRoleCode).collect(Collectors.toSet());
|
||||
// if (!collect.contains("merchantClerk")) {
|
||||
// return fail("这个账户没有收银权限",null);
|
||||
// }
|
||||
return success(cashierService.listRel(param));
|
||||
}
|
||||
|
||||
// @ApiOperation("按groupId分组查询全部收银")
|
||||
// @GetMapping("/listByGroupId")
|
||||
// public ApiResult<List<CashierVo>> listByGroupId(CashierParam param) {
|
||||
// if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
// return success("请先登录",null);
|
||||
// }
|
||||
// // 附加收银员ID
|
||||
// param.setCashierId(getLoginUserId());
|
||||
// // 收银员ID
|
||||
// return success(cashierService.listRelByGroupId(param));
|
||||
// }
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cashier:list')")
|
||||
@ApiOperation("根据id查询收银")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Cashier> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(cashierService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加收银")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Cashier cashier) {
|
||||
if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
return success("请先登录",null);
|
||||
}
|
||||
cashier.setCashierId(getLoginUserId());
|
||||
// 修正购买数量
|
||||
if (ObjectUtil.isEmpty(cashier.getCartNum())) {
|
||||
cashier.setCartNum(1);
|
||||
}
|
||||
// 超出最大限制
|
||||
if (cashierService.count(new LambdaUpdateWrapper<Cashier>().eq(Cashier::getCashierId,getLoginUserId())) > 50) {
|
||||
return fail("购物车宝贝数量已满,建议您先去结算或清理~");
|
||||
}
|
||||
// 重复商品叠加数量
|
||||
final Cashier one = cashierService.getOne(new LambdaQueryWrapper<Cashier>()
|
||||
.eq(Cashier::getCashierId,getLoginUserId())
|
||||
.eq(Cashier::getGoodsId,cashier.getGoodsId())
|
||||
.eq(Cashier::getSpec,cashier.getSpec())
|
||||
.eq(Cashier::getGroupId,0)
|
||||
.last("limit 1"));
|
||||
|
||||
if(ObjectUtil.isNotEmpty(one)){
|
||||
return fail("请勿重复添加");
|
||||
}
|
||||
if (cashierService.save(cashier)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改收银")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Cashier cashier) {
|
||||
if (cashierService.updateById(cashier)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除收银")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (cashierService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加收银")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Cashier> list) {
|
||||
if (cashierService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改收银")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Cashier> batchParam) {
|
||||
if (batchParam.update(cashierService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除收银")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (cashierService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("增加数量")
|
||||
@PutMapping("/addCartNum")
|
||||
public ApiResult<?> addCartNum(@RequestBody Cashier cashier) {
|
||||
if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
return success("请先登录",null);
|
||||
}
|
||||
cashier.setCartNum(cashier.getCartNum()+1);
|
||||
cashierService.updateById(cashier);
|
||||
return success("操作成功");
|
||||
}
|
||||
|
||||
@ApiOperation("减少数量")
|
||||
@PutMapping("/subCartNum")
|
||||
public ApiResult<?> subCartNum(@RequestBody Cashier cashier) {
|
||||
if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
return success("请先登录",null);
|
||||
}
|
||||
cashier.setCartNum(cashier.getCartNum()-1);
|
||||
cashierService.updateById(cashier);
|
||||
return success("操作成功");
|
||||
}
|
||||
|
||||
@ApiOperation("清空")
|
||||
@PutMapping("/cearCartNum")
|
||||
public ApiResult<?> removeCartNum(@RequestBody Cashier cashier) {
|
||||
if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
return success("请先登录",null);
|
||||
}
|
||||
cashier.setCartNum(cashier.getCartNum()-1);
|
||||
cashierService.updateById(cashier);
|
||||
return success("操作成功");
|
||||
}
|
||||
|
||||
@ApiOperation("挂单")
|
||||
@PutMapping("/packCashier")
|
||||
public ApiResult<?> packCashier() {
|
||||
if (ObjectUtil.isEmpty(getLoginUser())) {
|
||||
return success("请先登录",null);
|
||||
}
|
||||
final long timeMillis = System.currentTimeMillis();
|
||||
final boolean update = cashierService.update(new LambdaUpdateWrapper<Cashier>().eq(Cashier::getGroupId, 0).eq(Cashier::getCashierId, getLoginUserId()).set(Cashier::getGroupId, timeMillis/1000));
|
||||
|
||||
return success("操作成功",update);
|
||||
}
|
||||
|
||||
@ApiOperation("取单")
|
||||
@PutMapping("/getByGroup/{id}")
|
||||
public ApiResult<?> getByGroup(@PathVariable("id") Integer id) {
|
||||
if (cashierService.update(new LambdaUpdateWrapper<Cashier>().eq(Cashier::getGroupId,id).set(Cashier::getGroupId,0))) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除整单")
|
||||
@DeleteMapping("/removeByGroup/{id}")
|
||||
public ApiResult<?> removeByGroup(@PathVariable("id") Integer id) {
|
||||
if (cashierService.remove(new LambdaQueryWrapper<Cashier>().eq(Cashier::getGroupId,id))) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.ChatConversationService;
|
||||
import com.gxwebsoft.shop.entity.ChatConversation;
|
||||
import com.gxwebsoft.shop.param.ChatConversationParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 聊天消息表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-27 16:08:04
|
||||
*/
|
||||
@Api(tags = "聊天消息表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/chat-conversation")
|
||||
public class ChatConversationController extends BaseController {
|
||||
@Resource
|
||||
private ChatConversationService chatConversationService;
|
||||
|
||||
@ApiOperation("分页查询聊天消息表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ChatConversation>> page(ChatConversationParam param) {
|
||||
// 使用关联查询
|
||||
return success(chatConversationService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部聊天消息表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ChatConversation>> list(ChatConversationParam param) {
|
||||
// 使用关联查询
|
||||
return success(chatConversationService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:chatConversation:list')")
|
||||
@ApiOperation("根据id查询聊天消息表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ChatConversation> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(chatConversationService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加聊天消息表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ChatConversation chatConversation) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// chatConversation.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (chatConversationService.save(chatConversation)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改聊天消息表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ChatConversation chatConversation) {
|
||||
if (chatConversationService.updateById(chatConversation)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除聊天消息表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (chatConversationService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加聊天消息表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ChatConversation> list) {
|
||||
if (chatConversationService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改聊天消息表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ChatConversation> batchParam) {
|
||||
if (batchParam.update(chatConversationService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除聊天消息表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (chatConversationService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.ChatMessageService;
|
||||
import com.gxwebsoft.shop.entity.ChatMessage;
|
||||
import com.gxwebsoft.shop.param.ChatMessageParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 聊天消息表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-27 16:08:04
|
||||
*/
|
||||
@Api(tags = "聊天消息表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/chat-message")
|
||||
public class ChatMessageController extends BaseController {
|
||||
@Resource
|
||||
private ChatMessageService chatMessageService;
|
||||
|
||||
@ApiOperation("分页查询聊天消息表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ChatMessage>> page(ChatMessageParam param) {
|
||||
// 使用关联查询
|
||||
return success(chatMessageService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部聊天消息表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ChatMessage>> list(ChatMessageParam param) {
|
||||
// 使用关联查询
|
||||
return success(chatMessageService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:chatMessage:list')")
|
||||
@ApiOperation("根据id查询聊天消息表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ChatMessage> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(chatMessageService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加聊天消息表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ChatMessage chatMessage) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// chatMessage.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (chatMessageService.save(chatMessage)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改聊天消息表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ChatMessage chatMessage) {
|
||||
if (chatMessageService.updateById(chatMessage)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除聊天消息表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (chatMessageService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加聊天消息表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ChatMessage> list) {
|
||||
if (chatMessageService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改聊天消息表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ChatMessage> batchParam) {
|
||||
if (batchParam.update(chatMessageService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除聊天消息表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (chatMessageService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.CountService;
|
||||
import com.gxwebsoft.shop.entity.Count;
|
||||
import com.gxwebsoft.shop.param.CountParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商城销售统计表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-31 22:25:10
|
||||
*/
|
||||
@Api(tags = "商城销售统计表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/count")
|
||||
public class CountController extends BaseController {
|
||||
@Resource
|
||||
private CountService countService;
|
||||
|
||||
@ApiOperation("分页查询商城销售统计表")
|
||||
@GetMapping("/data")
|
||||
public ApiResult<?> data(CountParam param) {
|
||||
final DateTime dateTime = DateUtil.offsetDay(DateUtil.date(), 1);
|
||||
System.out.println("dateTime = " + dateTime);
|
||||
|
||||
final DateTime dateTime2 = DateUtil.offsetDay(DateUtil.date(), -1);
|
||||
System.out.println("dateTime2 = " + dateTime2);
|
||||
final DateTime dateTime3 = DateUtil.offsetDay(DateUtil.date(), -2);
|
||||
System.out.println("dateTime3 = " + dateTime3);
|
||||
return success(countService.list(new LambdaQueryWrapper<Count>().ge(Count::getDateTime, dateTime3).last("limit 2")));
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询商城销售统计表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Count>> page(CountParam param) {
|
||||
// 使用关联查询
|
||||
return success(countService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商城销售统计表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Count>> list(CountParam param) {
|
||||
// 使用关联查询
|
||||
return success(countService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:count:list')")
|
||||
@ApiOperation("根据id查询商城销售统计表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Count> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(countService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加商城销售统计表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Count count) {
|
||||
if (countService.save(count)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改商城销售统计表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Count count) {
|
||||
if (countService.updateById(count)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除商城销售统计表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (countService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加商城销售统计表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Count> list) {
|
||||
if (countService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商城销售统计表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Count> batchParam) {
|
||||
if (batchParam.update(countService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商城销售统计表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (countService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.entity.DealerReferee;
|
||||
import com.gxwebsoft.shop.entity.DealerUser;
|
||||
import com.gxwebsoft.shop.service.DealerApplyService;
|
||||
import com.gxwebsoft.shop.entity.DealerApply;
|
||||
import com.gxwebsoft.shop.param.DealerApplyParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.DealerRefereeService;
|
||||
import com.gxwebsoft.shop.service.DealerUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分销商申请记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-28 11:57:41
|
||||
*/
|
||||
@Api(tags = "分销商申请记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/dealer-apply")
|
||||
public class DealerApplyController extends BaseController {
|
||||
@Resource
|
||||
private DealerApplyService dealerApplyService;
|
||||
@Resource
|
||||
private DealerUserService dealerUserService;
|
||||
@Resource
|
||||
private DealerRefereeService dealerRefereeService;
|
||||
|
||||
@ApiOperation("分页查询分销商申请记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DealerApply>> page(DealerApplyParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerApplyService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部分销商申请记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DealerApply>> list(DealerApplyParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerApplyService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询分销商申请记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DealerApply> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(dealerApplyService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@ApiOperation("添加分销商申请记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DealerApply dealerApply) {
|
||||
final Integer refereeId = dealerApply.getRefereeId();
|
||||
final DealerUser dealerUser = new DealerUser();
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
dealerApply.setUserId(loginUser.getUserId());
|
||||
dealerUser.setUserId(loginUser.getUserId());
|
||||
dealerUser.setMobile(loginUser.getPhone());
|
||||
dealerUser.setTenantId(loginUser.getTenantId());
|
||||
}
|
||||
final int count = dealerUserService.count(new LambdaQueryWrapper<DealerUser>().eq(DealerUser::getUserId, refereeId));
|
||||
System.out.println("count = " + count);
|
||||
if (dealerUserService.count(new LambdaQueryWrapper<DealerUser>().eq(DealerUser::getUserId,refereeId)) == 0) {
|
||||
return fail("邀请人ID不存在");
|
||||
}
|
||||
if (dealerApplyService.save(dealerApply)) {
|
||||
// 加入正式分销商
|
||||
dealerUser.setRealName(dealerApply.getRealName());
|
||||
dealerUser.setRefereeId(dealerApply.getRefereeId());
|
||||
dealerUserService.save(dealerUser);
|
||||
// 添加关系
|
||||
final DealerReferee referee = new DealerReferee();
|
||||
referee.setDealerId(refereeId);
|
||||
referee.setUserId(dealerUser.getUserId());
|
||||
referee.setLevel(1);
|
||||
referee.setTenantId(dealerApply.getTenantId());
|
||||
dealerRefereeService.save(referee);
|
||||
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改分销商申请记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DealerApply dealerApply) {
|
||||
if (dealerApplyService.updateById(dealerApply)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除分销商申请记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (dealerApplyService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加分销商申请记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DealerApply> list) {
|
||||
if (dealerApplyService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改分销商申请记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DealerApply> batchParam) {
|
||||
if (batchParam.update(dealerApplyService, "apply_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除分销商申请记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (dealerApplyService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.DealerCapitalService;
|
||||
import com.gxwebsoft.shop.entity.DealerCapital;
|
||||
import com.gxwebsoft.shop.param.DealerCapitalParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分销商资金明细表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-28 11:57:41
|
||||
*/
|
||||
@Api(tags = "分销商资金明细表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/dealer-capital")
|
||||
public class DealerCapitalController extends BaseController {
|
||||
@Resource
|
||||
private DealerCapitalService dealerCapitalService;
|
||||
|
||||
@ApiOperation("分页查询分销商资金明细表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DealerCapital>> page(DealerCapitalParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerCapitalService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部分销商资金明细表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DealerCapital>> list(DealerCapitalParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerCapitalService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:dealerCapital:list')")
|
||||
@ApiOperation("根据id查询分销商资金明细表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DealerCapital> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(dealerCapitalService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加分销商资金明细表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DealerCapital dealerCapital) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
dealerCapital.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (dealerCapitalService.save(dealerCapital)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改分销商资金明细表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DealerCapital dealerCapital) {
|
||||
if (dealerCapitalService.updateById(dealerCapital)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除分销商资金明细表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (dealerCapitalService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加分销商资金明细表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DealerCapital> list) {
|
||||
if (dealerCapitalService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改分销商资金明细表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DealerCapital> batchParam) {
|
||||
if (batchParam.update(dealerCapitalService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除分销商资金明细表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (dealerCapitalService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.DealerOrderService;
|
||||
import com.gxwebsoft.shop.entity.DealerOrder;
|
||||
import com.gxwebsoft.shop.param.DealerOrderParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分销商订单记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-28 11:57:41
|
||||
*/
|
||||
@Api(tags = "分销商订单记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/dealer-order")
|
||||
public class DealerOrderController extends BaseController {
|
||||
@Resource
|
||||
private DealerOrderService dealerOrderService;
|
||||
|
||||
@ApiOperation("分页查询分销商订单记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DealerOrder>> page(DealerOrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerOrderService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部分销商订单记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DealerOrder>> list(DealerOrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerOrderService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:dealerOrder:list')")
|
||||
@ApiOperation("根据id查询分销商订单记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DealerOrder> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(dealerOrderService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加分销商订单记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DealerOrder dealerOrder) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
dealerOrder.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (dealerOrderService.save(dealerOrder)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改分销商订单记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DealerOrder dealerOrder) {
|
||||
if (dealerOrderService.updateById(dealerOrder)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除分销商订单记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (dealerOrderService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加分销商订单记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DealerOrder> list) {
|
||||
if (dealerOrderService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改分销商订单记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DealerOrder> batchParam) {
|
||||
if (batchParam.update(dealerOrderService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除分销商订单记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (dealerOrderService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.DealerRefereeService;
|
||||
import com.gxwebsoft.shop.entity.DealerReferee;
|
||||
import com.gxwebsoft.shop.param.DealerRefereeParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分销商推荐关系表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-28 11:57:41
|
||||
*/
|
||||
@Api(tags = "分销商推荐关系表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/dealer-referee")
|
||||
public class DealerRefereeController extends BaseController {
|
||||
@Resource
|
||||
private DealerRefereeService dealerRefereeService;
|
||||
|
||||
@ApiOperation("分页查询分销商推荐关系表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DealerReferee>> page(DealerRefereeParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerRefereeService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部分销商推荐关系表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DealerReferee>> list(DealerRefereeParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerRefereeService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:dealerReferee:list')")
|
||||
@ApiOperation("根据id查询分销商推荐关系表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DealerReferee> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(dealerRefereeService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加分销商推荐关系表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DealerReferee dealerReferee) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
dealerReferee.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (dealerRefereeService.save(dealerReferee)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改分销商推荐关系表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DealerReferee dealerReferee) {
|
||||
if (dealerRefereeService.updateById(dealerReferee)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除分销商推荐关系表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (dealerRefereeService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加分销商推荐关系表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DealerReferee> list) {
|
||||
if (dealerRefereeService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改分销商推荐关系表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DealerReferee> batchParam) {
|
||||
if (batchParam.update(dealerRefereeService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除分销商推荐关系表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (dealerRefereeService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.DealerSettingService;
|
||||
import com.gxwebsoft.shop.entity.DealerSetting;
|
||||
import com.gxwebsoft.shop.param.DealerSettingParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分销商设置表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-28 11:57:41
|
||||
*/
|
||||
@Api(tags = "分销商设置表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/dealer-setting")
|
||||
public class DealerSettingController extends BaseController {
|
||||
@Resource
|
||||
private DealerSettingService dealerSettingService;
|
||||
|
||||
@ApiOperation("分页查询分销商设置表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DealerSetting>> page(DealerSettingParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerSettingService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部分销商设置表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DealerSetting>> list(DealerSettingParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerSettingService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:dealerSetting:list')")
|
||||
@ApiOperation("根据id查询分销商设置表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DealerSetting> get(@PathVariable("id") String id) {
|
||||
// 使用关联查询
|
||||
return success(dealerSettingService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加分销商设置表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DealerSetting dealerSetting) {
|
||||
if (dealerSettingService.save(dealerSetting)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改分销商设置表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DealerSetting dealerSetting) {
|
||||
if (dealerSettingService.updateById(dealerSetting)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除分销商设置表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (dealerSettingService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加分销商设置表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DealerSetting> list) {
|
||||
if (dealerSettingService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改分销商设置表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DealerSetting> batchParam) {
|
||||
if (batchParam.update(dealerSettingService, "key")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除分销商设置表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (dealerSettingService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||
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.DealerUser;
|
||||
import com.gxwebsoft.shop.param.DealerUserParam;
|
||||
import com.gxwebsoft.shop.service.DealerUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static com.gxwebsoft.common.core.constants.RedisConstants.ACCESS_TOKEN_KEY;
|
||||
|
||||
/**
|
||||
* 分销商用户记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-28 19:21:15
|
||||
*/
|
||||
@Api(tags = "分销商用户记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/dealer-user")
|
||||
public class DealerUserController extends BaseController {
|
||||
@Resource
|
||||
private DealerUserService dealerUserService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private ConfigProperties config;
|
||||
|
||||
|
||||
@ApiOperation("生成专属二维码")
|
||||
@GetMapping("/getDealerUserQrcode")
|
||||
public ApiResult<?> getDealerUserQrcode() {
|
||||
final Integer loginUserId = getLoginUserId();
|
||||
if(loginUserId == null){
|
||||
return fail("请先登录");
|
||||
}
|
||||
|
||||
final DealerUser dealerUser = dealerUserService.getOne(new LambdaQueryWrapper<DealerUser>().eq(DealerUser::getUserId, loginUserId).last("limit 1"));
|
||||
|
||||
// 生成小程序码
|
||||
String apiUrl = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + getAccessToken();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("path", "package/dealer/invite?id=" + loginUserId);
|
||||
map.put("env_version", "trial"); // 正式版为"release",体验版为"trial",开发版为"develop"
|
||||
|
||||
// 获取图片 Buffer
|
||||
byte[] qrCode = HttpRequest.post(apiUrl)
|
||||
.body(JSON.toJSONString(map))
|
||||
.execute().bodyBytes();
|
||||
|
||||
// 保存的文件名称
|
||||
final String fileName = loginUserId.toString().concat(".png");
|
||||
// 保存路径
|
||||
String filePath = getUploadDir().concat("user-code/") + fileName;
|
||||
File file = FileUtil.writeBytes(qrCode, filePath);
|
||||
|
||||
if (file != null) {
|
||||
final String qrcode = config.getFileServer().concat("/user-code/").concat(fileName);
|
||||
dealerUser.setQrcode(qrcode);
|
||||
dealerUserService.updateById(dealerUser);
|
||||
return success("操作成功",qrcode);
|
||||
}
|
||||
return success(dealerUser);
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询分销商用户记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DealerUser>> page(DealerUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerUserService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部分销商用户记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DealerUser>> list(DealerUserParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerUserService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询分销商用户记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DealerUser> get(@PathVariable("id") Integer id) {
|
||||
// 分销商信息
|
||||
final DealerUser dealerUser = dealerUserService.getOne(new LambdaQueryWrapper<DealerUser>()
|
||||
.eq(DealerUser::getUserId, id)
|
||||
.eq(DealerUser::getIsDelete, 0)
|
||||
.last("limit 1")
|
||||
);
|
||||
// 上级分销商
|
||||
final DealerUser dealerUser1 = dealerUserService.getOne(new LambdaQueryWrapper<DealerUser>()
|
||||
.eq(DealerUser::getUserId, dealerUser.getRefereeId())
|
||||
.eq(DealerUser::getIsDelete, 0));
|
||||
dealerUser.setDealerName(dealerUser1.getRealName());
|
||||
dealerUser.setDealerUser(dealerUser1);
|
||||
return success(dealerUser);
|
||||
}
|
||||
|
||||
@ApiOperation("添加分销商用户记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DealerUser dealerUser) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
dealerUser.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (dealerUserService.save(dealerUser)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改分销商用户记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DealerUser dealerUser) {
|
||||
if (dealerUserService.updateById(dealerUser)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除分销商用户记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (dealerUserService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加分销商用户记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DealerUser> list) {
|
||||
if (dealerUserService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改分销商用户记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DealerUser> batchParam) {
|
||||
if (batchParam.update(dealerUserService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除分销商用户记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (dealerUserService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
|
||||
private String getAccessToken() {
|
||||
String key = ACCESS_TOKEN_KEY.concat(":").concat(getTenantId().toString());
|
||||
// 从缓存获取access_token
|
||||
final String value = redisUtil.get(key);
|
||||
if (value != null) {
|
||||
// 解析access_token
|
||||
JSONObject response = JSON.parseObject(value);
|
||||
return response.getString("access_token");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private String getUploadDir() {
|
||||
return config.getUploadPath() + "file/";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.DealerWithdrawService;
|
||||
import com.gxwebsoft.shop.entity.DealerWithdraw;
|
||||
import com.gxwebsoft.shop.param.DealerWithdrawParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分销商提现明细表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-28 11:57:41
|
||||
*/
|
||||
@Api(tags = "分销商提现明细表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/dealer-withdraw")
|
||||
public class DealerWithdrawController extends BaseController {
|
||||
@Resource
|
||||
private DealerWithdrawService dealerWithdrawService;
|
||||
|
||||
@ApiOperation("分页查询分销商提现明细表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<DealerWithdraw>> page(DealerWithdrawParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerWithdrawService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部分销商提现明细表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<DealerWithdraw>> list(DealerWithdrawParam param) {
|
||||
// 使用关联查询
|
||||
return success(dealerWithdrawService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:dealerWithdraw:list')")
|
||||
@ApiOperation("根据id查询分销商提现明细表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<DealerWithdraw> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(dealerWithdrawService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加分销商提现明细表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody DealerWithdraw dealerWithdraw) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
dealerWithdraw.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (dealerWithdrawService.save(dealerWithdraw)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改分销商提现明细表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody DealerWithdraw dealerWithdraw) {
|
||||
if (dealerWithdrawService.updateById(dealerWithdraw)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除分销商提现明细表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (dealerWithdrawService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加分销商提现明细表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<DealerWithdraw> list) {
|
||||
if (dealerWithdrawService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改分销商提现明细表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<DealerWithdraw> batchParam) {
|
||||
if (batchParam.update(dealerWithdrawService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除分销商提现明细表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (dealerWithdrawService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.utils.JSONUtil;
|
||||
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.entity.GoodsCategory;
|
||||
import com.gxwebsoft.shop.entity.GoodsSpec;
|
||||
import com.gxwebsoft.shop.param.GoodsCategoryParam;
|
||||
import com.gxwebsoft.shop.service.GoodsCategoryService;
|
||||
import com.gxwebsoft.shop.service.GoodsService;
|
||||
import com.gxwebsoft.shop.service.GoodsSpecService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gxwebsoft.common.core.utils.CommonUtil.toTreeData;
|
||||
|
||||
/**
|
||||
* 商品分类控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-03-30 19:34:16
|
||||
*/
|
||||
@Api(tags = "商品分类管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/goods-category")
|
||||
public class GoodsCategoryController extends BaseController {
|
||||
@Resource
|
||||
private GoodsCategoryService goodsCategoryService;
|
||||
@Resource
|
||||
private GoodsSpecService goodsSpecService;
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
|
||||
@ApiOperation("查询商城菜单分类级商品数据(不联动)")
|
||||
@GetMapping("/listCategoryTree")
|
||||
public ApiResult<List<GoodsCategory>> listCategoryTree(GoodsCategoryParam param) {
|
||||
// 查询非店铺分类
|
||||
param.setMerchantId(0);
|
||||
final List<GoodsCategory> goodsCategoryList = goodsCategoryService.listRel(param);
|
||||
// 收集分类ID
|
||||
final Set<Integer> categoryIds = goodsCategoryList.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet());
|
||||
if (categoryIds.isEmpty()) {
|
||||
return success(goodsCategoryList);
|
||||
}
|
||||
// List转为树形结构
|
||||
final List<GoodsCategory> list = toTreeData(goodsCategoryList, 0, GoodsCategory::getParentId, GoodsCategory::getCategoryId, GoodsCategory::setChildren);
|
||||
// 查询所有商品
|
||||
final List<Goods> goods = goodsService.list(new LambdaQueryWrapper<Goods>()
|
||||
.in(Goods::getCategoryId, categoryIds)
|
||||
.eq(Goods::getIsShow, 1)
|
||||
.eq(Goods::getDeleted, 0));
|
||||
|
||||
final Map<Integer, List<Goods>> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
|
||||
final Set<Integer> goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet());
|
||||
|
||||
final List<GoodsSpec> specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||
|
||||
final Map<Integer, List<GoodsSpec>> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||
|
||||
list.forEach(d -> {
|
||||
d.setName(d.getTitle());
|
||||
final List<Goods> goodsList = collectGoods.get(d.getCategoryId());
|
||||
if (!CollectionUtils.isEmpty(goodsList)) {
|
||||
goodsList.forEach(v -> {
|
||||
final List<GoodsSpec> goodsSpecs = collectGoodsSpec.get(v.getGoodsId());
|
||||
if (!CollectionUtils.isEmpty(goodsSpecs)) {
|
||||
final GoodsSpec spec = goodsSpecs.get(0);
|
||||
v.setSpecValue(spec.getSpecValue());
|
||||
v.setGoodsSpecValue(JSONUtil.parseObject(spec.getSpecValue(), Object.class));
|
||||
}
|
||||
});
|
||||
d.setGoods(collectGoods.get(d.getCategoryId()));
|
||||
}
|
||||
});
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@ApiOperation("查询商城菜单分类级商品数据(不联动)")
|
||||
@GetMapping("/listCategoryParentIdTree/{parentId}")
|
||||
public ApiResult<List<GoodsCategory>> listCategoryParentIdTree(@PathVariable("parentId") Integer parentId) {
|
||||
// 查询非店铺分类
|
||||
final List<GoodsCategory> list = goodsCategoryService.list(new LambdaQueryWrapper<GoodsCategory>()
|
||||
.eq(GoodsCategory::getParentId,parentId)
|
||||
.eq(GoodsCategory::getType,0)
|
||||
.eq(GoodsCategory::getMerchantId,0));
|
||||
|
||||
final Set<Integer> categoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet());
|
||||
final List<Goods> goods = goodsService.list(new LambdaQueryWrapper<Goods>().in(Goods::getCategoryId, categoryIds));
|
||||
final Map<Integer, List<Goods>> collect = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
|
||||
final Map<Integer, List<Goods>> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
|
||||
final Set<Integer> goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet());
|
||||
|
||||
final List<GoodsSpec> specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||
|
||||
final Map<Integer, List<GoodsSpec>> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||
|
||||
list.forEach(d -> {
|
||||
d.setName(d.getTitle());
|
||||
final List<Goods> goodsList = collectGoods.get(d.getCategoryId());
|
||||
if (!CollectionUtils.isEmpty(goodsList)) {
|
||||
goodsList.forEach(v -> {
|
||||
final List<GoodsSpec> goodsSpecs = collectGoodsSpec.get(v.getGoodsId());
|
||||
if (!CollectionUtils.isEmpty(goodsSpecs)) {
|
||||
final GoodsSpec spec = goodsSpecs.get(0);
|
||||
v.setSpecValue(spec.getSpecValue());
|
||||
v.setGoodsSpecValue(JSONUtil.parseObject(spec.getSpecValue(), Object.class));
|
||||
}
|
||||
});
|
||||
d.setGoods(collectGoods.get(d.getCategoryId()));
|
||||
}
|
||||
});
|
||||
return success("请求成功",list);
|
||||
}
|
||||
|
||||
@ApiOperation("查询门店菜单分类及菜品数据(联动)")
|
||||
@GetMapping("/listShopCategoryTree")
|
||||
public ApiResult<List<GoodsCategory>> listShopCategoryTree(GoodsCategoryParam param) {
|
||||
final List<GoodsCategory> list = goodsCategoryService.listRel(param);
|
||||
final Set<Integer> categoryIds = list.stream().map(GoodsCategory::getCategoryId).collect(Collectors.toSet());
|
||||
if (categoryIds.isEmpty()) {
|
||||
return success(list);
|
||||
}
|
||||
|
||||
final List<Goods> goods = goodsService.list(new LambdaQueryWrapper<Goods>().in(Goods::getCategoryId, categoryIds).eq(Goods::getIsShow, 1).eq(Goods::getDeleted, 0));
|
||||
final Map<Integer, List<Goods>> collectGoods = goods.stream().collect(Collectors.groupingBy(Goods::getCategoryId));
|
||||
|
||||
final Set<Integer> goodsIds = goods.stream().map(Goods::getGoodsId).collect(Collectors.toSet());
|
||||
|
||||
final List<GoodsSpec> specs = goodsSpecService.list(new LambdaQueryWrapper<GoodsSpec>().in(GoodsSpec::getGoodsId, goodsIds));
|
||||
|
||||
final Map<Integer, List<GoodsSpec>> collectGoodsSpec = specs.stream().collect(Collectors.groupingBy(GoodsSpec::getGoodsId));
|
||||
|
||||
list.forEach(d -> {
|
||||
d.setName(d.getTitle());
|
||||
final List<Goods> goodsList = collectGoods.get(d.getCategoryId());
|
||||
if (!CollectionUtils.isEmpty(goodsList)) {
|
||||
goodsList.forEach(v -> {
|
||||
final List<GoodsSpec> goodsSpecs = collectGoodsSpec.get(v.getGoodsId());
|
||||
if (!CollectionUtils.isEmpty(goodsSpecs)) {
|
||||
final GoodsSpec spec = goodsSpecs.get(0);
|
||||
v.setSpecValue(spec.getSpecValue());
|
||||
v.setGoodsSpecValue(JSONUtil.parseObject(spec.getSpecValue(), Object.class));
|
||||
}
|
||||
});
|
||||
d.setGoods(collectGoods.get(d.getCategoryId()));
|
||||
}
|
||||
});
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("分页查询商品分类")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<GoodsCategory>> page(GoodsCategoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsCategoryService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商品分类")
|
||||
@GetMapping()
|
||||
public ApiResult<List<GoodsCategory>> list(GoodsCategoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsCategoryService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询商品分类")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<GoodsCategory> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(goodsCategoryService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加商品分类")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody GoodsCategory goodsCategory) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
goodsCategory.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (goodsCategoryService.save(goodsCategory)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改商品分类")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody GoodsCategory goodsCategory) {
|
||||
if (goodsCategoryService.updateById(goodsCategory)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除商品分类")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (goodsCategoryService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加商品分类")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<GoodsCategory> list) {
|
||||
if (goodsCategoryService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商品分类")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<GoodsCategory> batchParam) {
|
||||
if (batchParam.update(goodsCategoryService, "category_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商品分类")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsCategoryService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.gxwebsoft.common.core.utils.JSONUtil;
|
||||
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.entity.GoodsSku;
|
||||
import com.gxwebsoft.shop.entity.GoodsSpec;
|
||||
import com.gxwebsoft.shop.param.GoodsParam;
|
||||
import com.gxwebsoft.shop.service.GoodsService;
|
||||
import com.gxwebsoft.shop.service.GoodsSkuService;
|
||||
import com.gxwebsoft.shop.service.GoodsSpecService;
|
||||
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.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-25 19:22:01
|
||||
*/
|
||||
@Api(tags = "商品记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/goods")
|
||||
public class GoodsController extends BaseController {
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
@Resource
|
||||
private GoodsSpecService goodsSpecService;
|
||||
@Resource
|
||||
private GoodsSkuService goodsSkuService;
|
||||
|
||||
@ApiOperation("统计信息")
|
||||
@GetMapping("/data")
|
||||
public ApiResult<Map<String, Integer>> data(GoodsParam param) {
|
||||
Map<String, Integer> data = new HashMap<>();
|
||||
final LambdaQueryWrapper<Goods> wrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if (param.getMerchantId() != null) {
|
||||
wrapper.eq(Goods::getMerchantId,param.getMerchantId());
|
||||
}
|
||||
|
||||
Integer totalNum = goodsService.count(
|
||||
wrapper.eq(Goods::getIsShow,1).gt(Goods::getStock,0)
|
||||
);
|
||||
data.put("totalNum", totalNum);
|
||||
|
||||
Integer totalNum2 = goodsService.count(
|
||||
wrapper.eq(Goods::getIsShow,0)
|
||||
);
|
||||
data.put("totalNum2", totalNum2);
|
||||
|
||||
Integer totalNum3 = goodsService.count(
|
||||
wrapper.eq(Goods::getStock,0)
|
||||
);
|
||||
data.put("totalNum3", totalNum3);
|
||||
|
||||
// 下架已售罄的商品
|
||||
goodsService.update(new LambdaUpdateWrapper<Goods>().eq(Goods::getStock,0).eq(Goods::getIsShow,1).set(Goods::getIsShow,0));
|
||||
|
||||
return success(data);
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询商品记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Goods>> page(GoodsParam param) {
|
||||
// 使用关联查询
|
||||
System.out.println("param = " + param);
|
||||
return success(goodsService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商品记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Goods>> list(GoodsParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询商品记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Goods> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
final Goods goods = goodsService.getByIdRel(id);
|
||||
|
||||
// 提取specValue
|
||||
final GoodsSpec spec = goodsSpecService.getOne(new LambdaQueryWrapper<GoodsSpec>().eq(GoodsSpec::getGoodsId, id).last("limit 1"));
|
||||
if (spec != null) {
|
||||
final String specValue = spec.getSpecValue();
|
||||
final Object object = JSONUtil.parseObject(specValue, Object.class);
|
||||
goods.setGoodsSpecValue(object);
|
||||
}
|
||||
|
||||
return success(goods);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:save')")
|
||||
@ApiOperation("添加商品记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Goods goods) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
goods.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (goodsService.save(goods)) {
|
||||
// 保存商品规格及sku信息
|
||||
goodsService.saveBatchByAsync(goods);
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:update')")
|
||||
@ApiOperation("修改商品记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Goods goods) {
|
||||
if (goodsService.updateById(goods)) {
|
||||
// 删除旧信息
|
||||
goodsSpecService.remove(new LambdaQueryWrapper<GoodsSpec>().eq(GoodsSpec::getGoodsId, goods.getGoodsId()));
|
||||
goodsSkuService.remove(new LambdaQueryWrapper<GoodsSku>().eq(GoodsSku::getGoodsId, goods.getGoodsId()));
|
||||
// 保存商品规格及sku信息
|
||||
goodsService.saveBatchByAsync(goods);
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:remove')")
|
||||
@ApiOperation("删除商品记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (goodsService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:save')")
|
||||
@ApiOperation("批量添加商品记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Goods> list) {
|
||||
if (goodsService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goods:update')")
|
||||
@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')")
|
||||
@ApiOperation("批量删除商品记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
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.shop.entity.GoodsSku;
|
||||
import com.gxwebsoft.shop.entity.GoodsSkuVO;
|
||||
import com.gxwebsoft.shop.param.GoodsSkuParam;
|
||||
import com.gxwebsoft.shop.service.GoodsSkuService;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 商品sku列表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-26 10:49:02
|
||||
*/
|
||||
@Api(tags = "商品sku列表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/goods-sku")
|
||||
public class GoodsSkuController extends BaseController {
|
||||
@Resource
|
||||
private GoodsSkuService goodsSkuService;
|
||||
|
||||
@ApiOperation("根据商品spec生成SKU列表")
|
||||
@PostMapping("/generateGoodsSku")
|
||||
public ApiResult<List<GoodsSku>> generateGoodsSku(@RequestBody List<GoodsSkuVO> voList) {
|
||||
List<List<String>> resultList = new ArrayList<>();
|
||||
voList.forEach(d -> {
|
||||
resultList.add(d.getDetail());
|
||||
});
|
||||
System.out.println("resultList = " + resultList);
|
||||
List<String> combine = generateSku(resultList,0,"",new ArrayList<>());
|
||||
|
||||
List<GoodsSku> goodsSkuList = new ArrayList<>();
|
||||
for (String sku : combine) {
|
||||
System.out.println(sku);
|
||||
GoodsSku goodsSku = new GoodsSku();
|
||||
goodsSku.setSku(sku);
|
||||
goodsSku.setUuid(UUID.randomUUID().toString());
|
||||
goodsSku.setImages(new ArrayList<>());
|
||||
goodsSkuList.add(goodsSku);
|
||||
}
|
||||
|
||||
return success(goodsSkuList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据属性值生成sku
|
||||
*
|
||||
* @param list 属性值列表
|
||||
* @param index 下标
|
||||
* @param str 初始化数据
|
||||
* @param newObjs 新obj
|
||||
*/
|
||||
public static List<String> generateSku(List<List<String>> list, int index, String str, List<String> newObjs) {
|
||||
if (index == list.size()) {
|
||||
newObjs.add(str);
|
||||
return newObjs;
|
||||
}
|
||||
for (String dataStr : list.get(index)) {
|
||||
if (StringUtils.isBlank(str)) {
|
||||
generateSku(list, index + 1, str + dataStr, newObjs);
|
||||
} else {
|
||||
generateSku(list, index + 1, str + "," + dataStr, newObjs);
|
||||
}
|
||||
}
|
||||
return newObjs;
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询商品sku列表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<GoodsSku>> page(GoodsSkuParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsSkuService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商品sku列表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<GoodsSku>> list(GoodsSkuParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsSkuService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:goodsSku:list')")
|
||||
@ApiOperation("根据id查询商品sku列表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<GoodsSku> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(goodsSkuService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加商品sku列表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody GoodsSku goodsSku) {
|
||||
if (goodsSkuService.save(goodsSku)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改商品sku列表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody GoodsSku goodsSku) {
|
||||
if (goodsSkuService.updateById(goodsSku)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除商品sku列表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (goodsSkuService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加商品sku列表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<GoodsSku> list) {
|
||||
if (goodsSkuService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商品sku列表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<GoodsSku> batchParam) {
|
||||
if (batchParam.update(goodsSkuService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商品sku列表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsSkuService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.GoodsSpecService;
|
||||
import com.gxwebsoft.shop.entity.GoodsSpec;
|
||||
import com.gxwebsoft.shop.param.GoodsSpecParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品多规格控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-03 16:06:23
|
||||
*/
|
||||
@Api(tags = "商品多规格管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/goods-spec")
|
||||
public class GoodsSpecController extends BaseController {
|
||||
@Resource
|
||||
private GoodsSpecService goodsSpecService;
|
||||
|
||||
@ApiOperation("分页查询商品多规格")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<GoodsSpec>> page(GoodsSpecParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsSpecService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商品多规格")
|
||||
@GetMapping()
|
||||
public ApiResult<List<GoodsSpec>> list(GoodsSpecParam param) {
|
||||
// 使用关联查询
|
||||
return success(goodsSpecService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询商品多规格")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<GoodsSpec> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(goodsSpecService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加商品多规格")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody GoodsSpec goodsSpec) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// goodsSpec.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (goodsSpecService.save(goodsSpec)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改商品多规格")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody GoodsSpec goodsSpec) {
|
||||
if (goodsSpecService.updateById(goodsSpec)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除商品多规格")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (goodsSpecService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加商品多规格")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<GoodsSpec> list) {
|
||||
if (goodsSpecService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商品多规格")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<GoodsSpec> batchParam) {
|
||||
if (batchParam.update(goodsSpecService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商品多规格")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (goodsSpecService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.RequestUtil;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.mapper.MerchantAccountMapper;
|
||||
import com.gxwebsoft.shop.service.MerchantAccountService;
|
||||
import com.gxwebsoft.shop.entity.MerchantAccount;
|
||||
import com.gxwebsoft.shop.param.MerchantAccountParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商户账号控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-19 12:02:24
|
||||
*/
|
||||
@Api(tags = "商户账号管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/merchant-account")
|
||||
public class MerchantAccountController extends BaseController {
|
||||
@Resource
|
||||
private MerchantAccountService merchantAccountService;
|
||||
@Resource
|
||||
private MerchantAccountMapper merchantAccountMapper;
|
||||
|
||||
@ApiOperation("分页查询商户账号")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<MerchantAccount>> page(MerchantAccountParam param) {
|
||||
// 使用关联查询
|
||||
return success(merchantAccountService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商户账号")
|
||||
@GetMapping()
|
||||
public ApiResult<List<MerchantAccount>> list(MerchantAccountParam param) {
|
||||
// 使用关联查询
|
||||
return success(merchantAccountService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询商户账号")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<MerchantAccount> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(merchantAccountService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加商户账号")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody MerchantAccount merchantAccount, HttpServletRequest request) {
|
||||
if (merchantAccountService.count(new LambdaQueryWrapper<MerchantAccount>().eq(MerchantAccount::getPhone,merchantAccount.getPhone())) > 0) {
|
||||
return fail("手机号码已存在");
|
||||
}
|
||||
// 获取远程用户信息
|
||||
final RequestUtil requestUtil = new RequestUtil();
|
||||
String access_token = JwtUtil.getAccessToken(request);
|
||||
requestUtil.setAccessToken(access_token);
|
||||
requestUtil.setTenantId(getTenantId().toString());
|
||||
User userByPhone = requestUtil.getUserByPhone(merchantAccount.getPhone());
|
||||
// 新增注册
|
||||
if (userByPhone == null) {
|
||||
if (requestUtil.saveUserByPhone(merchantAccount)) {
|
||||
userByPhone = requestUtil.getUserByPhone(merchantAccount.getPhone());
|
||||
}
|
||||
}
|
||||
merchantAccount.setUserId(userByPhone.getUserId());
|
||||
if (merchantAccountService.save(merchantAccount)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改商户账号")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody MerchantAccount merchantAccount) {
|
||||
if (merchantAccountService.updateById(merchantAccount)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除商户账号")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (merchantAccountService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加商户账号")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<MerchantAccount> list) {
|
||||
if (merchantAccountService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商户账号")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<MerchantAccount> batchParam) {
|
||||
if (batchParam.update(merchantAccountService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商户账号")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (merchantAccountService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("根据手机号码查询商户账号信息")
|
||||
@GetMapping("/getMerchantAccountByPhone")
|
||||
public ApiResult<MerchantAccount> getMerchantAccountByPhone(MerchantAccountParam param){
|
||||
param.setTenantId(getTenantId());
|
||||
final MerchantAccount merchantAccount = merchantAccountMapper.getMerchantAccountByPhone(param);
|
||||
if(merchantAccount == null){
|
||||
return fail("账号不存在",null);
|
||||
}
|
||||
return success(merchantAccount);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.MerchantApplyService;
|
||||
import com.gxwebsoft.shop.entity.MerchantApply;
|
||||
import com.gxwebsoft.shop.param.MerchantApplyParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商户入驻申请控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-05 01:24:36
|
||||
*/
|
||||
@Api(tags = "商户入驻申请管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/merchant-apply")
|
||||
public class MerchantApplyController extends BaseController {
|
||||
@Resource
|
||||
private MerchantApplyService merchantApplyService;
|
||||
|
||||
@ApiOperation("分页查询商户入驻申请")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<MerchantApply>> page(MerchantApplyParam param) {
|
||||
// 使用关联查询
|
||||
return success(merchantApplyService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商户入驻申请")
|
||||
@GetMapping()
|
||||
public ApiResult<List<MerchantApply>> list(MerchantApplyParam param) {
|
||||
// 使用关联查询
|
||||
return success(merchantApplyService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询商户入驻申请")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<MerchantApply> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(merchantApplyService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加商户入驻申请")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody MerchantApply merchantApply) {
|
||||
if (merchantApplyService.save(merchantApply)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改商户入驻申请")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody MerchantApply merchantApply) {
|
||||
if (merchantApplyService.updateById(merchantApply)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除商户入驻申请")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (merchantApplyService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加商户入驻申请")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<MerchantApply> list) {
|
||||
if (merchantApplyService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商户入驻申请")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<MerchantApply> batchParam) {
|
||||
if (batchParam.update(merchantApplyService, "apply_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商户入驻申请")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (merchantApplyService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
import com.gxwebsoft.common.core.utils.RequestUtil;
|
||||
import com.gxwebsoft.common.core.web.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.shop.entity.Merchant;
|
||||
import com.gxwebsoft.shop.entity.MerchantAccount;
|
||||
import com.gxwebsoft.shop.param.MerchantParam;
|
||||
import com.gxwebsoft.shop.service.MerchantAccountService;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商户控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-05 00:03:54
|
||||
*/
|
||||
@Api(tags = "商户管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/merchant")
|
||||
public class MerchantController extends BaseController {
|
||||
@Resource
|
||||
private MerchantService merchantService;
|
||||
@Resource
|
||||
private MerchantAccountService merchantAccountService;
|
||||
|
||||
@ApiOperation("分页查询商户")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Merchant>> page(MerchantParam param) {
|
||||
// 使用关联查询
|
||||
System.out.println("param = " + param);
|
||||
return success(merchantService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商户")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Merchant>> list(MerchantParam param) {
|
||||
// 使用关联查询
|
||||
return success(merchantService.listRel(param));
|
||||
}
|
||||
|
||||
@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, HttpServletRequest request) {
|
||||
if (merchantService.count(new LambdaQueryWrapper<Merchant>().eq(Merchant::getPhone,merchant.getPhone())) > 0) {
|
||||
return fail("商户手机号码" + merchant.getPhone() + "已存在");
|
||||
}
|
||||
if (merchantService.save(merchant)) {
|
||||
// 设置商家后台入口
|
||||
merchant.setAdminUrl(merchant.getTenantId() + ".m.wsdns.cn");
|
||||
merchantService.updateById(merchant);
|
||||
// 获取用户信息
|
||||
final RequestUtil requestUtil = new RequestUtil();
|
||||
String access_token = JwtUtil.getAccessToken(request);
|
||||
requestUtil.setAccessToken(access_token);
|
||||
requestUtil.setTenantId(getTenantId().toString());
|
||||
final MerchantAccount merchantAccount = new MerchantAccount();
|
||||
merchantAccount.setMerchantId(merchant.getMerchantId());
|
||||
merchantAccount.setPhone(merchant.getPhone());
|
||||
merchantAccount.setPassword(merchant.getPhone().substring(merchant.getPhone().length() - 6));
|
||||
merchantAccount.setRealName(merchant.getRealName());
|
||||
merchantAccount.setRoleId(merchant.getRoleId());
|
||||
merchantAccount.setRoleName(merchant.getRoleName());
|
||||
requestUtil.saveUserByPhone(merchantAccount);
|
||||
merchantAccountService.save(merchantAccount);
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:merchant:update')")
|
||||
@ApiOperation("修改商户")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Merchant merchant) {
|
||||
if (merchantService.updateById(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)) {
|
||||
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)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.MerchantTypeService;
|
||||
import com.gxwebsoft.shop.entity.MerchantType;
|
||||
import com.gxwebsoft.shop.param.MerchantTypeParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商户类型控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-05 00:08:51
|
||||
*/
|
||||
@Api(tags = "商户类型管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/merchant-type")
|
||||
public class MerchantTypeController extends BaseController {
|
||||
@Resource
|
||||
private MerchantTypeService merchantTypeService;
|
||||
|
||||
@ApiOperation("分页查询商户类型")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<MerchantType>> page(MerchantTypeParam param) {
|
||||
// 使用关联查询
|
||||
return success(merchantTypeService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商户类型")
|
||||
@GetMapping()
|
||||
public ApiResult<List<MerchantType>> list(MerchantTypeParam param) {
|
||||
// 使用关联查询
|
||||
return success(merchantTypeService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询商户类型")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<MerchantType> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(merchantTypeService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加商户类型")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody MerchantType merchantType) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// merchantType.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (merchantTypeService.save(merchantType)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改商户类型")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody MerchantType merchantType) {
|
||||
if (merchantTypeService.updateById(merchantType)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除商户类型")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (merchantTypeService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加商户类型")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<MerchantType> list) {
|
||||
if (merchantTypeService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商户类型")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<MerchantType> batchParam) {
|
||||
if (batchParam.update(merchantTypeService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商户类型")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (merchantTypeService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-08-09 16:33:41
|
||||
*/
|
||||
@Api(tags = "管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order")
|
||||
public class OrderController extends BaseController {
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Order>> page(OrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Order>> list(OrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:order:list')")
|
||||
@ApiOperation("根据id查询")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Order> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(orderService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Order order) {
|
||||
if (orderService.save(order)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Order order) {
|
||||
if (orderService.updateById(order)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (orderService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Order> list) {
|
||||
if (orderService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Order> batchParam) {
|
||||
if (batchParam.update(orderService, "order_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
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.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品信息控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-05-26 15:42:03
|
||||
*/
|
||||
@Api(tags = "商品信息管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order-goods")
|
||||
public class OrderGoodsController extends BaseController {
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
|
||||
@ApiOperation("分页查询商品信息")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<OrderGoods>> page(OrderGoodsParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderGoodsService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部商品信息")
|
||||
@GetMapping()
|
||||
public ApiResult<List<OrderGoods>> list(OrderGoodsParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderGoodsService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderGoods:list')")
|
||||
@ApiOperation("根据id查询商品信息")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<OrderGoods> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(orderGoodsService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加商品信息")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody OrderGoods orderGoods) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
orderGoods.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (orderGoodsService.save(orderGoods)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改商品信息")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody OrderGoods orderGoods) {
|
||||
if (orderGoodsService.updateById(orderGoods)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除商品信息")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (orderGoodsService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加商品信息")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<OrderGoods> list) {
|
||||
if (orderGoodsService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改商品信息")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<OrderGoods> batchParam) {
|
||||
if (batchParam.update(orderGoodsService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除商品信息")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderGoodsService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.OrderInfoService;
|
||||
import com.gxwebsoft.shop.entity.OrderInfo;
|
||||
import com.gxwebsoft.shop.param.OrderInfoParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-08-10 13:44:39
|
||||
*/
|
||||
@Api(tags = "管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order-info")
|
||||
public class OrderInfoController extends BaseController {
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<OrderInfo>> page(OrderInfoParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderInfoService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部")
|
||||
@GetMapping()
|
||||
public ApiResult<List<OrderInfo>> list(OrderInfoParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderInfoService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderInfo:list')")
|
||||
@ApiOperation("根据id查询")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<OrderInfo> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(orderInfoService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody OrderInfo orderInfo) {
|
||||
if (orderInfoService.save(orderInfo)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody OrderInfo orderInfo) {
|
||||
if (orderInfoService.updateById(orderInfo)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (orderInfoService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<OrderInfo> list) {
|
||||
if (orderInfoService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<OrderInfo> batchParam) {
|
||||
if (batchParam.update(orderInfoService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderInfoService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.OrderInfoLogService;
|
||||
import com.gxwebsoft.shop.entity.OrderInfoLog;
|
||||
import com.gxwebsoft.shop.param.OrderInfoLogParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单核销控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-05-14 13:20:04
|
||||
*/
|
||||
@Api(tags = "订单核销管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order-info-log")
|
||||
public class OrderInfoLogController extends BaseController {
|
||||
@Resource
|
||||
private OrderInfoLogService orderInfoLogService;
|
||||
|
||||
@ApiOperation("分页查询订单核销")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<OrderInfoLog>> page(OrderInfoLogParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderInfoLogService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部订单核销")
|
||||
@GetMapping()
|
||||
public ApiResult<List<OrderInfoLog>> list(OrderInfoLogParam param) {
|
||||
// 使用关联查询
|
||||
return success(orderInfoLogService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:orderInfoLog:list')")
|
||||
@ApiOperation("根据id查询订单核销")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<OrderInfoLog> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(orderInfoLogService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加订单核销")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody OrderInfoLog orderInfoLog) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// orderInfoLog.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (orderInfoLogService.save(orderInfoLog)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改订单核销")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody OrderInfoLog orderInfoLog) {
|
||||
if (orderInfoLogService.updateById(orderInfoLog)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除订单核销")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (orderInfoLogService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加订单核销")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<OrderInfoLog> list) {
|
||||
if (orderInfoLogService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改订单核销")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<OrderInfoLog> batchParam) {
|
||||
if (batchParam.update(orderInfoLogService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除订单核销")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (orderInfoLogService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import com.gxwebsoft.shop.entity.UserBalanceLog;
|
||||
import com.gxwebsoft.shop.service.RechargeOrderService;
|
||||
import com.gxwebsoft.shop.entity.RechargeOrder;
|
||||
import com.gxwebsoft.shop.param.RechargeOrderParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
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 2024-07-26 23:18:48
|
||||
*/
|
||||
@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')")
|
||||
@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(Long.toString(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')")
|
||||
@ApiOperation("分页查询会员充值订单表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<RechargeOrder>> page(RechargeOrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(rechargeOrderService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:list')")
|
||||
@ApiOperation("查询全部会员充值订单表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<RechargeOrder>> list(RechargeOrderParam param) {
|
||||
// 使用关联查询
|
||||
return success(rechargeOrderService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:list')")
|
||||
@ApiOperation("根据id查询会员充值订单表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<RechargeOrder> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(rechargeOrderService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加会员充值订单表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody RechargeOrder rechargeOrder) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
rechargeOrder.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (rechargeOrderService.save(rechargeOrder)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改会员充值订单表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody RechargeOrder rechargeOrder) {
|
||||
if (rechargeOrderService.updateById(rechargeOrder)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除会员充值订单表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (rechargeOrderService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:rechargeOrder:save')")
|
||||
@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')")
|
||||
@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')")
|
||||
@ApiOperation("批量删除会员充值订单表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (rechargeOrderService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.SpecService;
|
||||
import com.gxwebsoft.shop.entity.Spec;
|
||||
import com.gxwebsoft.shop.param.SpecParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-07-25 03:00:41
|
||||
*/
|
||||
@Api(tags = "规格管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/spec")
|
||||
public class SpecController extends BaseController {
|
||||
@Resource
|
||||
private SpecService specService;
|
||||
|
||||
@ApiOperation("分页查询规格")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Spec>> page(SpecParam param) {
|
||||
// 使用关联查询
|
||||
return success(specService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部规格")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Spec>> list(SpecParam param) {
|
||||
// 使用关联查询
|
||||
return success(specService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:spec:list')")
|
||||
@ApiOperation("根据id查询规格")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Spec> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(specService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:spec:save')")
|
||||
@ApiOperation("添加规格")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Spec spec) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
spec.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (specService.save(spec)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:spec:update')")
|
||||
@ApiOperation("修改规格")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Spec spec) {
|
||||
if (specService.updateById(spec)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:spec:remove')")
|
||||
@ApiOperation("删除规格")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (specService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:spec:save')")
|
||||
@ApiOperation("批量添加规格")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Spec> list) {
|
||||
if (specService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:spec:update')")
|
||||
@ApiOperation("批量修改规格")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Spec> batchParam) {
|
||||
if (batchParam.update(specService, "spec_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
@PreAuthorize("hasAuthority('shop:spec:remove')")
|
||||
@ApiOperation("批量删除规格")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (specService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.shop.entity.SpecValue;
|
||||
import com.gxwebsoft.shop.param.SpecValueParam;
|
||||
import com.gxwebsoft.shop.service.SpecValueService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格值控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-01 09:49:15
|
||||
*/
|
||||
@Api(tags = "规格值管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/spec-value")
|
||||
public class SpecValueController extends BaseController {
|
||||
@Resource
|
||||
private SpecValueService specValueService;
|
||||
|
||||
@ApiOperation("分页查询规格值")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<SpecValue>> page(SpecValueParam param) {
|
||||
// 使用关联查询
|
||||
return success(specValueService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部规格值")
|
||||
@GetMapping()
|
||||
public ApiResult<List<SpecValue>> list(SpecValueParam param) {
|
||||
// 使用关联查询
|
||||
return success(specValueService.listRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询规格值")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<SpecValue> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(specValueService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加规格值")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody SpecValue specValue) {
|
||||
if (specValueService.count(new LambdaQueryWrapper<SpecValue>().eq(SpecValue::getSpecId,specValue.getSpecId()).eq(SpecValue::getSpecValue,specValue.getSpecValue())) > 0) {
|
||||
return fail("规格值已存在");
|
||||
}
|
||||
if (specValueService.save(specValue)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改规格值")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody SpecValue specValue) {
|
||||
if (specValueService.updateById(specValue)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除规格值")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (specValueService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加规格值")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<SpecValue> list) {
|
||||
if (specValueService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改规格值")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<SpecValue> batchParam) {
|
||||
if (batchParam.update(specValueService, "spec_value_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除规格值")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (specValueService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
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.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收货地址控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-05-26 10:58:37
|
||||
*/
|
||||
@Api(tags = "收货地址管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/user-address")
|
||||
public class UserAddressController extends BaseController {
|
||||
@Resource
|
||||
private UserAddressService userAddressService;
|
||||
|
||||
@ApiOperation("分页查询收货地址")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserAddress>> page(UserAddressParam param) {
|
||||
// 使用关联查询
|
||||
return success(userAddressService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部收货地址")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserAddress>> list(UserAddressParam param) {
|
||||
// 使用关联查询
|
||||
return success(userAddressService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userAddress:list')")
|
||||
@ApiOperation("根据id查询收货地址")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserAddress> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(userAddressService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加收货地址")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserAddress userAddress) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userAddress.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (userAddressService.save(userAddress)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改收货地址")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserAddress userAddress) {
|
||||
if (userAddress.getIsDefault() != null && userAddress.getIsDefault().equals(true)) {
|
||||
final boolean update = userAddressService.update(new LambdaUpdateWrapper<UserAddress>().eq(UserAddress::getUserId, getLoginUserId()).set(UserAddress::getIsDefault, 0));
|
||||
}
|
||||
if (userAddressService.updateById(userAddress)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除收货地址")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userAddressService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加收货地址")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserAddress> list) {
|
||||
if (userAddressService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改收货地址")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserAddress> batchParam) {
|
||||
if (batchParam.update(userAddressService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除收货地址")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userAddressService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
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.BatchParam;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户余额变动明细表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-05-29 15:57:44
|
||||
*/
|
||||
@Api(tags = "用户余额变动明细表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/user-balance-log")
|
||||
public class UserBalanceLogController extends BaseController {
|
||||
@Resource
|
||||
private UserBalanceLogService userBalanceLogService;
|
||||
|
||||
@ApiOperation("分页查询用户余额变动明细表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserBalanceLog>> page(UserBalanceLogParam param) {
|
||||
// 使用关联查询
|
||||
return success(userBalanceLogService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部用户余额变动明细表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserBalanceLog>> list(UserBalanceLogParam param) {
|
||||
// 使用关联查询
|
||||
return success(userBalanceLogService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userBalanceLog:list')")
|
||||
@ApiOperation("根据id查询用户余额变动明细表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserBalanceLog> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(userBalanceLogService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加用户余额变动明细表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserBalanceLog userBalanceLog) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
userBalanceLog.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (userBalanceLogService.save(userBalanceLog)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改用户余额变动明细表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserBalanceLog userBalanceLog) {
|
||||
if (userBalanceLogService.updateById(userBalanceLog)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除用户余额变动明细表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userBalanceLogService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加用户余额变动明细表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserBalanceLog> list) {
|
||||
if (userBalanceLogService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改用户余额变动明细表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserBalanceLog> batchParam) {
|
||||
if (batchParam.update(userBalanceLogService, "log_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除用户余额变动明细表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userBalanceLogService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.UserCollectionService;
|
||||
import com.gxwebsoft.shop.entity.UserCollection;
|
||||
import com.gxwebsoft.shop.param.UserCollectionParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 我的收藏控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-04-28 18:17:37
|
||||
*/
|
||||
@Api(tags = "我的收藏管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/user-collection")
|
||||
public class UserCollectionController extends BaseController {
|
||||
@Resource
|
||||
private UserCollectionService userCollectionService;
|
||||
|
||||
@ApiOperation("分页查询我的收藏")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<UserCollection>> page(UserCollectionParam param) {
|
||||
// 使用关联查询
|
||||
return success(userCollectionService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部我的收藏")
|
||||
@GetMapping()
|
||||
public ApiResult<List<UserCollection>> list(UserCollectionParam param) {
|
||||
// 使用关联查询
|
||||
return success(userCollectionService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:userCollection:list')")
|
||||
@ApiOperation("根据id查询我的收藏")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<UserCollection> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(userCollectionService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加我的收藏")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody UserCollection userCollection) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// userCollection.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (userCollectionService.save(userCollection)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改我的收藏")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody UserCollection userCollection) {
|
||||
if (userCollectionService.updateById(userCollection)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除我的收藏")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (userCollectionService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加我的收藏")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<UserCollection> list) {
|
||||
if (userCollectionService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改我的收藏")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<UserCollection> batchParam) {
|
||||
if (batchParam.update(userCollectionService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除我的收藏")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (userCollectionService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.UsersService;
|
||||
import com.gxwebsoft.shop.entity.Users;
|
||||
import com.gxwebsoft.shop.param.UsersParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-08-09 15:20:25
|
||||
*/
|
||||
@Api(tags = "管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/users")
|
||||
public class UsersController extends BaseController {
|
||||
@Resource
|
||||
private UsersService usersService;
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Users>> page(UsersParam param) {
|
||||
// 使用关联查询
|
||||
return success(usersService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Users>> list(UsersParam param) {
|
||||
// 使用关联查询
|
||||
return success(usersService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:users:list')")
|
||||
@ApiOperation("根据id查询")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Users> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(usersService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Users users) {
|
||||
if (usersService.save(users)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Users users) {
|
||||
if (usersService.updateById(users)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (usersService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Users> list) {
|
||||
if (usersService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Users> batchParam) {
|
||||
if (batchParam.update(usersService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (usersService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.WechatDepositService;
|
||||
import com.gxwebsoft.shop.entity.WechatDeposit;
|
||||
import com.gxwebsoft.shop.param.WechatDepositParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 押金控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2024-05-03 15:50:28
|
||||
*/
|
||||
@Api(tags = "押金管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/wechat-deposit")
|
||||
public class WechatDepositController extends BaseController {
|
||||
@Resource
|
||||
private WechatDepositService wechatDepositService;
|
||||
|
||||
@ApiOperation("分页查询押金")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<WechatDeposit>> page(WechatDepositParam param) {
|
||||
// 使用关联查询
|
||||
return success(wechatDepositService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部押金")
|
||||
@GetMapping()
|
||||
public ApiResult<List<WechatDeposit>> list(WechatDepositParam param) {
|
||||
// 使用关联查询
|
||||
return success(wechatDepositService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:wechatDeposit:list')")
|
||||
@ApiOperation("根据id查询押金")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<WechatDeposit> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(wechatDepositService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:wechatDeposit:list')")
|
||||
@ApiOperation("添加押金")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody WechatDeposit wechatDeposit) {
|
||||
// 记录当前登录用户id
|
||||
// User loginUser = getLoginUser();
|
||||
// if (loginUser != null) {
|
||||
// wechatDeposit.setUserId(loginUser.getUserId());
|
||||
// }
|
||||
if (wechatDepositService.save(wechatDeposit)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:wechatDeposit:update')")
|
||||
@ApiOperation("修改押金")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody WechatDeposit wechatDeposit) {
|
||||
if (wechatDepositService.updateById(wechatDeposit)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:wechatDeposit:remove')")
|
||||
@ApiOperation("删除押金")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (wechatDepositService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:wechatDeposit:save')")
|
||||
@ApiOperation("批量添加押金")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<WechatDeposit> list) {
|
||||
if (wechatDepositService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:wechatDeposit:update')")
|
||||
@ApiOperation("批量修改押金")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<WechatDeposit> batchParam) {
|
||||
if (batchParam.update(wechatDepositService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:wechatDeposit:remove')")
|
||||
@ApiOperation("批量删除押金")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (wechatDepositService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||
import com.gxwebsoft.common.core.utils.WxNativeUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.common.system.entity.Payment;
|
||||
import com.gxwebsoft.common.system.param.SettingParam;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.common.system.service.SettingService;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
import com.wechat.pay.java.service.payments.nativepay.NativePayService;
|
||||
import com.wechat.pay.java.service.payments.nativepay.model.Amount;
|
||||
import com.wechat.pay.java.service.payments.nativepay.model.PrepayRequest;
|
||||
import com.wechat.pay.java.service.payments.nativepay.model.PrepayResponse;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Api(tags = "微信Native支付接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/wx-native-pay")
|
||||
public class WxNativePayController extends BaseController {
|
||||
@Value("${spring.profiles.active}")
|
||||
String active;
|
||||
public static String merchantId = "1246610101";
|
||||
public static String privateKeyPath = "/Users/gxwebsoft/JAVA/com.gxwebsoft.core/src/main/resources/cert/apiclient_key.pem";
|
||||
public static String merchantSerialNumber = "48749613B40AA8F1D768583FC352358E13EB5AF0";
|
||||
public static String apiV3Key = "zGufUcqa7ovgxRL0kF5OlPr482EZwtn9";
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
private Config wxPayConfig;
|
||||
@Resource
|
||||
private ConfigProperties config;
|
||||
@Resource
|
||||
private SettingService settingService;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
|
||||
|
||||
@ApiOperation("生成付款码")
|
||||
@PostMapping("/codeUrl")
|
||||
public ApiResult<?> getCodeUrl(@RequestBody Order order) {
|
||||
final User loginUser = getLoginUser();
|
||||
if(loginUser == null){
|
||||
return fail("请先登录");
|
||||
}
|
||||
String key = "Payment:wxPay:".concat(getTenantId().toString());
|
||||
final Payment payment = redisUtil.get(key, Payment.class);
|
||||
if (payment == null) {
|
||||
return fail("微信支付未配置");
|
||||
}
|
||||
// 获取微信小程序配置信息
|
||||
final String string = redisUtil.get("mp-weixin:".concat(getTenantId().toString()));
|
||||
if(string == null){
|
||||
return fail("微信小程序未配置");
|
||||
}
|
||||
final JSONObject jsonObject = JSONObject.parseObject(string);
|
||||
final String appId = jsonObject.getString("appId");
|
||||
|
||||
// 处理订单数据
|
||||
order.setTenantId(loginUser.getTenantId());
|
||||
order.setUid(loginUser.getUserId());
|
||||
// order.setRealName(loginUser.getRealName());
|
||||
order.setPhone(loginUser.getPhone());
|
||||
// order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.MONTH, order.getTotalNum()));
|
||||
|
||||
// 使用自动更新平台证书的RSA配置
|
||||
// 一个商户号只能初始化一个配置,否则会因为重复的下载任务报错
|
||||
|
||||
// 构建service
|
||||
NativePayService service = new NativePayService.Builder().config(this.getWxPayConfig()).build();
|
||||
// request.setXxx(val)设置所需参数,具体参数可见Request定义
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
// 计算金额
|
||||
order.setMoney(new BigDecimal("0.01")); // order.getPayPrice().toString()
|
||||
long orderNo = IdUtil.getSnowflakeNextId();
|
||||
order.setOrderNo(Long.toString(orderNo));
|
||||
BigDecimal decimal = order.getMoney();
|
||||
final BigDecimal multiply = decimal.multiply(new BigDecimal(100));
|
||||
// 将 BigDecimal 转换为 Integer
|
||||
Integer money = multiply.intValue();
|
||||
Amount amount = new Amount();
|
||||
amount.setTotal(money);
|
||||
request.setAmount(amount);
|
||||
request.setAppid(appId);
|
||||
request.setMchid(payment.getMchId());
|
||||
request.setDescription(order.getComments());
|
||||
request.setNotifyUrl("https://modules.gxwebsoft.com/api/shop/wx-native-pay/notify/" + getTenantId());
|
||||
request.setOutTradeNo(order.getOrderNo());
|
||||
// 调用下单方法,得到应答
|
||||
PrepayResponse response = service.prepay(request);
|
||||
// 使用微信扫描 code_url 对应的二维码,即可体验Native支付
|
||||
// System.out.println(response.getCodeUrl());
|
||||
// 生成指定url对应的二维码到文件,宽和高都是300像素
|
||||
// QrCodeUtil.generate(response.getCodeUrl(), 300, 300, FileUtil.file("/Users/gxwebsoft/Documents/uploads/wx-native-qrcode.jpg"));
|
||||
orderService.save(order);
|
||||
|
||||
return success("生成付款码", response.getCodeUrl());
|
||||
}
|
||||
|
||||
|
||||
private Config getWxPayConfig() {
|
||||
// 获取租户ID
|
||||
final Integer tenantId = getTenantId();
|
||||
Config build = WxNativeUtil.getConfig(tenantId);
|
||||
if (build != null) {
|
||||
return build;
|
||||
}
|
||||
String key = "Payment:wxPay:".concat(tenantId.toString());
|
||||
final Payment payment = redisUtil.get(key, Payment.class);
|
||||
System.out.println("payment = " + payment);
|
||||
String apiclientKey = config.getUploadPath().concat("/file").concat(payment.getApiclientKey());
|
||||
// 开发环境配置
|
||||
if(active.equals("dev")){
|
||||
apiclientKey = privateKeyPath;
|
||||
}
|
||||
Config config = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId(payment.getMchId())
|
||||
.privateKeyFromPath(apiclientKey)
|
||||
.merchantSerialNumber(payment.getMerchantSerialNumber())
|
||||
.apiV3Key(payment.getApiKey())
|
||||
.build();
|
||||
System.out.println("config = " + config);
|
||||
WxNativeUtil.addConfig(tenantId, config);
|
||||
return config;
|
||||
}
|
||||
|
||||
@ApiModelProperty("异步通知")
|
||||
@PostMapping("/notify/{tenantId}")
|
||||
public String wxNotify(@RequestHeader Map<String, String> header, @RequestBody String body, @PathVariable("tenantId") Integer tenantId) {
|
||||
System.out.println("异步通知*************** = ");
|
||||
System.out.println("request header = " + header);
|
||||
System.out.println("request body = " + body);
|
||||
System.out.println("tenantId = " + tenantId);
|
||||
|
||||
// 获取支付配置信息用于解密
|
||||
final SettingParam param = new SettingParam();
|
||||
param.setSettingKey("payment");
|
||||
param.setTenantId(tenantId);
|
||||
final String uploadPath = config.getUploadPath(); // 服务器本地路径
|
||||
|
||||
return "fail";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.booking.service.UserCardService;
|
||||
import com.gxwebsoft.common.core.config.ConfigProperties;
|
||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.entity.OrderInfo;
|
||||
import com.gxwebsoft.shop.entity.Payment;
|
||||
import com.gxwebsoft.shop.service.OrderInfoService;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.service.UsersService;
|
||||
import com.wechat.pay.java.core.notification.NotificationConfig;
|
||||
import com.wechat.pay.java.core.notification.NotificationParser;
|
||||
import com.wechat.pay.java.core.notification.RSANotificationConfig;
|
||||
import com.wechat.pay.java.service.partnerpayments.jsapi.model.Transaction;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 会员特权购买记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-06-20 18:07:50
|
||||
*/
|
||||
@Api(tags = "微信支付结果通知")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/wx-pay")
|
||||
public class WxPayNotifyController extends BaseController {
|
||||
@Value("${spring.profiles.active}")
|
||||
String active;
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
@Resource
|
||||
private UsersService usersService;
|
||||
@Resource
|
||||
private UserCardService userCardService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private ConfigProperties conf;
|
||||
// 本地证书
|
||||
public static String wechatpayCertPath = "/Users/gxwebsoft/JAVA/com.gxwebsoft.core/src/main/resources/cert/wechatpay_4A3231584E93B6AE77820074D07EADEACCB7E223.pem"; // 平台证书
|
||||
|
||||
@ApiModelProperty("异步通知")
|
||||
@PostMapping("/notify/{tenantId}")
|
||||
public String wxNotify(@RequestHeader Map<String, String> header, @RequestBody String body, @PathVariable("tenantId") Integer tenantId) {
|
||||
System.out.println("异步通知*************** = ");
|
||||
System.out.println("request header = " + header);
|
||||
System.out.println("request body = " + body);
|
||||
System.out.println("tenantId = " + tenantId);
|
||||
|
||||
// 获取支付配置信息用于解密
|
||||
String key = "Payment:1:".concat(tenantId.toString());
|
||||
final Payment payment = redisUtil.get(key, Payment.class);
|
||||
String privateKey = payment.getApiKey();
|
||||
String apiclientCert = conf.getUploadPath().concat("/file").concat(payment.getApiclientCert());
|
||||
// 开发环境配置
|
||||
if(active.equals("dev")){
|
||||
apiclientCert = wechatpayCertPath;
|
||||
}
|
||||
|
||||
com.wechat.pay.java.core.notification.RequestParam requestParam = new com.wechat.pay.java.core.notification.RequestParam.Builder()
|
||||
.serialNumber(header.get("wechatpay-serial"))
|
||||
.nonce(header.get("wechatpay-nonce"))
|
||||
.signature(header.get("wechatpay-signature"))
|
||||
.timestamp(header.get("wechatpay-timestamp"))
|
||||
.body(body)
|
||||
.build();
|
||||
|
||||
System.out.println("payment = " + payment);
|
||||
System.out.println("requestParam = " + requestParam);
|
||||
|
||||
// 如果已经初始化了 RSAAutoCertificateConfig,可直接使用
|
||||
// 没有的话,则构造一个
|
||||
NotificationConfig config = new RSANotificationConfig.Builder()
|
||||
.apiV3Key(privateKey)
|
||||
.certificatesFromPath(apiclientCert)
|
||||
.build();
|
||||
|
||||
|
||||
// 初始化 NotificationParser
|
||||
NotificationParser parser = new NotificationParser(config);
|
||||
|
||||
// 以支付通知回调为例,验签、解密并转换成 Transaction
|
||||
try {
|
||||
Transaction transaction = parser.parse(requestParam, Transaction.class);
|
||||
final String outTradeNo = transaction.getOutTradeNo();
|
||||
final String transactionId = transaction.getTransactionId();
|
||||
final Integer total = transaction.getAmount().getTotal();
|
||||
final String tradeStateDesc = transaction.getTradeStateDesc();
|
||||
final Transaction.TradeStateEnum tradeState = transaction.getTradeState();
|
||||
final Transaction.TradeTypeEnum tradeType = transaction.getTradeType();
|
||||
System.out.println("transaction = " + transaction);
|
||||
System.out.println("tradeStateDesc = " + tradeStateDesc);
|
||||
System.out.println("tradeType = " + tradeType);
|
||||
System.out.println("tradeState = " + tradeState);
|
||||
System.out.println("outTradeNo = " + outTradeNo);
|
||||
System.out.println("amount = " + total);
|
||||
|
||||
// if (StrUtil.equals("支付成功", tradeStateDesc)) {
|
||||
// 1. 查询要处理的订单
|
||||
// Order order = orderService.getByOutTradeNo(outTradeNo);
|
||||
// 2. 已支付则跳过
|
||||
// if (order.getPayStatus().equals(1)) {
|
||||
// return "SUCCESS";
|
||||
// }
|
||||
// 2. 未支付则处理更新订单状态
|
||||
// if (order.getPayStatus().equals(0)) {
|
||||
// 5. TODO 处理订单状态
|
||||
// order.setPayTime(DateUtil.date());
|
||||
// order.setPayStatus(1);
|
||||
// order.setTransactionId(transactionId);
|
||||
// order.setPayPrice(new BigDecimal(NumberUtil.decimalFormat("0.00", total * 0.01)));
|
||||
// order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.YEAR, 10));
|
||||
// System.out.println("实际付款金额 = " + order.getPayPrice());
|
||||
// orderService.updateByOutTradeNo(order);
|
||||
// 6. TODO 同步更新订单明细的支付状态
|
||||
// orderInfoService.update(new LambdaUpdateWrapper<OrderInfo>().eq(OrderInfo::getOrderId,order.getOrderId()).set(OrderInfo::getPayStatus,1));
|
||||
// orderInfoService.updateByOutTradeNo(order);
|
||||
// 7.同步会员卡状态
|
||||
// if(order.getType().equals(2)){
|
||||
// final UserCard userCard = userCardService.getById(order.getVid());
|
||||
// userCard.setStatus(1);
|
||||
// userCardService.updateById(userCard);
|
||||
// }
|
||||
// 8.发放积分
|
||||
// usersService.addIntegral(order);
|
||||
|
||||
// return "SUCCESS";
|
||||
// }
|
||||
// }
|
||||
} catch (Exception $e) {
|
||||
System.out.println($e.getMessage());
|
||||
}
|
||||
|
||||
return "fail";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.entity.Cart;
|
||||
import com.gxwebsoft.shop.service.*;
|
||||
import com.wechat.pay.java.service.partnerpayments.jsapi.model.Transaction;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 会员特权购买记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2023-06-20 18:07:50
|
||||
*/
|
||||
@Api(tags = "微信支付结果通知")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/wx-pay/notify/nbg")
|
||||
public class WxPayNotifyNbgController extends BaseController {
|
||||
@Resource
|
||||
private OrderService orderService;
|
||||
@Resource
|
||||
private OrderInfoService orderInfoService;
|
||||
@Resource
|
||||
private OrderGoodsService orderGoodsService;
|
||||
@Resource
|
||||
private GoodsService goodsService;
|
||||
@Resource
|
||||
private UsersService usersService;
|
||||
@Resource
|
||||
private CartService cartService;
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@ApiModelProperty("微信支付通知")
|
||||
@PostMapping()
|
||||
public String demo(@RequestBody Transaction transaction){
|
||||
|
||||
System.out.println("支付通知 >>>>> ");
|
||||
System.out.println("transaction = " + transaction);
|
||||
|
||||
// TODO 1.查询订单信息
|
||||
// final Order order = orderService.getByOutTradeNo(transaction.getOutTradeNo());
|
||||
// TODO 2.更新订单支付状态
|
||||
// order.setPayStatus(1);
|
||||
// order.setTransactionId(transaction.getTransactionId());
|
||||
// order.setPayPrice(new BigDecimal(NumberUtil.decimalFormat("0.00", transaction.getAmount().getTotal() * 0.01)));
|
||||
// order.setPayTime(DateUtil.date());
|
||||
// order.setExpirationTime(DateUtil.offset(DateUtil.date(), DateField.YEAR, 10));
|
||||
// orderService.updateById(order);
|
||||
// TODO 3.更新订单商品的支付状态
|
||||
// if (order.getType().equals(0)) {
|
||||
// final boolean update = orderGoodsService.update(new LambdaUpdateWrapper<OrderGoods>().eq(OrderGoods::getOrderId, order.getOrderId()).set(OrderGoods::getPayStatus, 1));
|
||||
// System.out.println("update1 = " + update);
|
||||
// // TODO 3.1 更新商品销量、库存数量
|
||||
// final List<OrderGoods> orderGoods = orderGoodsService.list(new LambdaQueryWrapper<OrderGoods>().eq(OrderGoods::getOrderId, order.getOrderId()));
|
||||
// final Set<Integer> goodsIds = orderGoods.stream().map(OrderGoods::getGoodsId).collect(Collectors.toSet());
|
||||
// final Map<Integer, List<OrderGoods>> collectGoods = orderGoods.stream().collect(Collectors.groupingBy(OrderGoods::getGoodsId));
|
||||
// final List<Goods> goods = goodsService.list(new LambdaQueryWrapper<Goods>().in(Goods::getGoodsId, goodsIds));
|
||||
// for (Goods g : goods) {
|
||||
// final List<OrderGoods> goods1 = collectGoods.get(g.getGoodsId());
|
||||
// final OrderGoods goods2 = goods1.get(0);
|
||||
// g.setSales(g.getSales() + goods2.getTotalNum());
|
||||
// if (g.getStock().compareTo(0) >= 0) {
|
||||
// g.setStock(g.getStock() - goods2.getTotalNum());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// final boolean batchById = goodsService.updateBatchById(goods);
|
||||
// System.out.println("batchById = " + batchById);
|
||||
// }
|
||||
// if (order.getType().equals(1)) {
|
||||
// final boolean update = orderInfoService.update(new LambdaUpdateWrapper<OrderInfo>().eq(OrderInfo::getOrderId, order.getOrderId()).set(OrderInfo::getPayStatus, 1));
|
||||
// System.out.println("update2 = " + update);
|
||||
// // TODO 3.2 更新订单类型为预定的关联订单信息
|
||||
// }
|
||||
|
||||
// TODO 4. 清除购物车
|
||||
// final boolean remove = cartService.remove(new LambdaQueryWrapper<Cart>().eq(Cart::getUserId, order.getUid()).eq(Cart::getIsNew, true));
|
||||
// System.out.println("remove = " + remove);
|
||||
|
||||
|
||||
// TODO 5.累计会员积分
|
||||
|
||||
return "订单已支付";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user