From 0f7fedda1cb868f4e1ebeecceef89a4c87c5e59a Mon Sep 17 00:00:00 2001 From: DB <2502523450@qq.com> Date: Thu, 9 Nov 2023 18:15:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=9F=8Ebug=E4=BF=AE=E5=A4=8D;?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=95=86=E5=9F=8E=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-prod.yml | 6 +- .../src/main/resources/application-test.yml | 6 +- .../com/cpop/mall/web/CpopWxPayTests.java | 4 +- .../backstage/BackstageProductController.java | 22 ++- .../service/impl/OrderServiceImpl.java | 4 +- .../service/impl/ProductServiceImpl.java | 4 +- .../service/impl/ShoppingCartServiceImpl.java | 7 + .../business/task/ShoppingCartAsyncTask.java | 69 ++++++++++ .../cpop/mall/business/vo/ProductInfoVo.java | 9 ++ .../cpop/mall/business/vo/ProductPageVo.java | 14 -- .../com/cpop/oam/business/bo/MallStaffBo.java | 116 ++++++++++++++++ .../cpop/oam/business/bo/MallStaffPageBo.java | 29 ++++ .../controller/OamMallController.java | 49 +++++++ .../business/controller/StaffController.java | 5 +- .../oam/business/service/OamMallService.java | 20 +++ .../service/impl/OamMallServiceImpl.java | 63 +++++++++ .../service/impl/StaffServiceImpl.java | 4 +- .../cpop/oam/business/vo/MallStaffPageVo.java | 126 ++++++++++++++++++ .../business/controller/BrandController.java | 17 ++- .../cpop/system/business/entity/Brand.java | 5 + .../system/business/service/BrandService.java | 9 ++ .../service/impl/BrandServiceImpl.java | 39 +++++- .../service/impl/MenuServiceImpl.java | 6 +- .../cpop/system/business/vo/BrandPageVo.java | 25 ++++ 24 files changed, 624 insertions(+), 34 deletions(-) create mode 100644 Cpop-Mall/src/main/java/com/cpop/mall/business/task/ShoppingCartAsyncTask.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/business/bo/MallStaffBo.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/business/bo/MallStaffPageBo.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/business/controller/OamMallController.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/business/service/OamMallService.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/OamMallServiceImpl.java create mode 100644 Cpop-Oam/src/main/java/com/cpop/oam/business/vo/MallStaffPageVo.java diff --git a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml index e4a58f3..e40c331 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml +++ b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-prod.yml @@ -82,6 +82,8 @@ wx: # 私钥文件 privateCertPath: /root/cpop-union/cpop-mall/script/secretKey/wxPay_cert.pem #支付通知地址 - notifyUrl: https://test.cpopsz.com/onlineShop/Cpop-Mall/wxPay/callback/notify/order + notifyUrl: https://test.cpopsz.com/onlineShop/wxPay/callback/notify/order #退款通知地址 - notifyRefund: https://test.cpopsz.com/onlineShop/Cpop-Mall/wxPay/callback/notify/refund \ No newline at end of file + notifyRefund: https://test.cpopsz.com/onlineShop/wxPay/callback/notify/refund + #分账通知地址 + notifySharing: https://test.cpopsz.com/onlineShop/wxPay/callback/notify/profitSharing \ No newline at end of file diff --git a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml index 1413eb1..8ca82f5 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml +++ b/Cpop-Mall/Cpop-Mall-Web/src/main/resources/application-test.yml @@ -112,6 +112,8 @@ wx: # 私钥文件 privateCertPath: /root/cpop-union/cpop-mall/script/secretKey/wxPay_cert.pem #支付通知地址 - notifyUrl: https://test.cpopsz.com/onlineShop/Cpop-Mall/wxPay/callback/notify/order + notifyUrl: https://test.cpopsz.com/onlineShop/wxPay/callback/notify/order #退款通知地址 - notifyRefund: https://test.cpopsz.com/onlineShop/Cpop-Mall/wxPay/callback/notify/refund \ No newline at end of file + notifyRefund: https://test.cpopsz.com/onlineShop/wxPay/callback/notify/refund + #分账通知地址 + notifySharing: https://test.cpopsz.com/onlineShop/wxPay/callback/notify/profitSharing \ No newline at end of file diff --git a/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java b/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java index 1ce3da7..2203147 100644 --- a/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java +++ b/Cpop-Mall/Cpop-Mall-Web/src/test/java/com/cpop/mall/web/CpopWxPayTests.java @@ -57,8 +57,8 @@ public class CpopWxPayTests { .setTotal(refund) .setCurrency("CNY"); request.setSubMchid(wxPayService.getConfig().getSubMchId()) - .setTransactionId("4200002027202310279036554434") - .setOutTradeNo("75505378790948864") + .setTransactionId("4200002015202311095099886928") + .setOutTradeNo("80137484138201088") //.setTransactionId(order.getOutOrderNo()) //.setOutTradeNo(order.getId()) .setNotifyUrl(wxPayProperties.getNotifyRefund()) diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageProductController.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageProductController.java index 285a338..ee4ffcf 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageProductController.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/controller/backstage/BackstageProductController.java @@ -7,7 +7,9 @@ import com.cpop.mall.business.bo.ProductPageBo; import com.cpop.mall.business.service.ProductRecordService; import com.cpop.mall.business.service.ProductService; import com.cpop.mall.business.service.ProductSpecificationService; +import com.cpop.mall.business.task.ShoppingCartAsyncTask; import com.cpop.mall.business.vo.JamboxCardTemplateListVo; +import com.cpop.mall.business.vo.ProductInfoVo; import com.cpop.mall.business.vo.ProductPageVo; import com.cpop.mall.business.vo.StoreListVo; import com.mybatisflex.core.paginate.Page; @@ -54,6 +56,20 @@ public class BackstageProductController { return R.ok(page); } + /** + * @descriptions 查询商城-商品详情 + * @author DB + * @date 2023/11/09 11:00 + * @param id 主键 + * @return: com.cpop.core.base.R + */ + @GetMapping("/getProductInfo/{id}") + @ApiOperation("查询商城-商品详情") + public R getProductInfo(@PathVariable @ApiParam("主键") String id) { + ProductInfoVo info = productService.getProductInfo(id); + return R.ok(info); + } + /** * @descriptions 选择品牌下的店铺/校区 * @author DB @@ -145,7 +161,7 @@ public class BackstageProductController { @DeleteMapping("/removeById/{id}") @ApiOperation("根据主键删除商城-商品") @Transactional(rollbackFor = Exception.class) - public R removeById(@PathVariable("id") @ApiParam("商城-商品主键") Serializable id) { + public R removeById(@PathVariable("id") @ApiParam("商城-商品主键") String id) { productService.removeById(id); //删规格 ProductSpecificationService productSpecificationService = SpringUtils.getBean(ProductSpecificationService.class); @@ -153,6 +169,8 @@ public class BackstageProductController { //删商品记录详情 ProductRecordService specificationRecordService = SpringUtils.getBean(ProductRecordService.class); specificationRecordService.updateChain().where(PRODUCT_RECORD.PRODUCT_ID.eq(id)).remove(); + //删除购物车 + SpringUtils.getBean(ShoppingCartAsyncTask.class).asyncRemoveShoppingCart(id); return R.ok(); } @@ -184,6 +202,4 @@ public class BackstageProductController { return R.ok(); } - - } diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderServiceImpl.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderServiceImpl.java index 36ec630..0d1c75c 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderServiceImpl.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/OrderServiceImpl.java @@ -443,7 +443,9 @@ public class OrderServiceImpl extends ServiceImpl implements Brand brand = SpringUtils.getBean(BrandService.class).getById(order.getBrandId()); if (StringUtils.isBlank(brand.getWxAppId()) || !StringUtils.equals(brand.getWxAppId(), wxPayService.getConfig().getAppId())) { //需要分账 - wxPayAsyncTask.asyncWxPayProfitSharing(orderId, notifyResult, wxPayService); + if (notifyResult.getTotalFee() >= 10) { + wxPayAsyncTask.asyncWxPayProfitSharing(orderId, notifyResult, wxPayService); + } } //异步更新 SpringUtils.getBean(ProductRecordSyncStockTask.class).asyncUpdateRecords(orderNumMap); diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java index c5ce852..3eed592 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ProductServiceImpl.java @@ -22,6 +22,7 @@ import com.cpop.mall.business.service.OrderEvaluateService; import com.cpop.mall.business.service.ProductRecordService; import com.cpop.mall.business.service.ProductService; import com.cpop.mall.business.service.ProductSpecificationService; +import com.cpop.mall.business.task.ShoppingCartAsyncTask; import com.cpop.mall.business.vo.*; import com.cpop.mall.framework.constant.MallRedisConstant; import com.cpop.system.business.service.StoreService; @@ -259,7 +260,8 @@ public class ProductServiceImpl extends ServiceImpl impl redisService.setCacheObject(MallRedisConstant.STOCK_RECORD_NUM + item.getId(), item.getRecordNum()); }); specificationRecordService.updateBatch(recordList); - + //异步更新购物车价格 + SpringUtils.getBean(ShoppingCartAsyncTask.class).asyncUpdateShoppingCartAmount(product); } /** diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ShoppingCartServiceImpl.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ShoppingCartServiceImpl.java index 2602b46..acf4c25 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ShoppingCartServiceImpl.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/service/impl/ShoppingCartServiceImpl.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.cpop.common.utils.StringUtils; import com.cpop.common.utils.bean.BeanUtils; import com.cpop.core.base.entity.PageDomain; +import com.cpop.core.base.exception.ServiceException; import com.cpop.core.utils.SecurityUtils; import com.cpop.core.utils.sql.SqlUtils; import com.cpop.mall.business.bo.ShoppingCartBo; @@ -75,6 +76,12 @@ public class ShoppingCartServiceImpl extends ServiceImpl 0) { + throw new ServiceException("您当前购物车已有此商品,请勿重复添加"); + } ShoppingCart shoppingCart = BeanUtils.mapToClass(bo, ShoppingCart.class); shoppingCart.setUserId(loginUserInfo.getString("userId")); this.save(shoppingCart); diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/task/ShoppingCartAsyncTask.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/task/ShoppingCartAsyncTask.java new file mode 100644 index 0000000..76a0ba6 --- /dev/null +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/task/ShoppingCartAsyncTask.java @@ -0,0 +1,69 @@ +package com.cpop.mall.business.task; + +import com.cpop.core.utils.SpringUtils; +import com.cpop.mall.business.entity.Product; +import com.cpop.mall.business.entity.ProductRecord; +import com.cpop.mall.business.service.ProductRecordService; +import com.cpop.mall.business.service.ShoppingCartService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static com.cpop.mall.business.entity.table.ProductRecordTableDef.PRODUCT_RECORD; +import static com.cpop.mall.business.entity.table.ShoppingCartTableDef.SHOPPING_CART; + +/** + * @author DB + * @createTime 2023/11/09 16:42 + * @description + */ +@Component +@Slf4j +public class ShoppingCartAsyncTask { + + /** + * @Description: 异步更新购物车价格 + * @param product 商品 + * @Author DB + * @Date: 2023/11/1 0:09 + */ + @Async("customAsyncThreadPool") + public void asyncUpdateShoppingCartAmount(Product product) { + //获取商品记录 + List recordList = SpringUtils.getBean(ProductRecordService.class).queryChain() + .where(PRODUCT_RECORD.PRODUCT_ID.eq(product.getId())) + .list(); + //批量修改购物车产品价格 + ShoppingCartService cartService = SpringUtils.getBean(ShoppingCartService.class); + recordList.forEach(item->{ + cartService.updateChain().setRaw(SHOPPING_CART.AMOUNT, item.getRecordPrice() + " * number") + .setRaw(SHOPPING_CART.POINT, item.getRecordPoints() + " * number") + .where(SHOPPING_CART.PRODUCT_RECORD_ID.eq(item.getId())).update(); + }); + } + + /** + * @Description: 异步删除购物车 + * @param productId 商品Id + * @Author DB + * @Date: 2023/11/1 0:09 + */ + @Async("customAsyncThreadPool") + public void asyncRemoveShoppingCart(String productId) { + //获取商品记录 + List recordList = SpringUtils.getBean(ProductRecordService.class).queryChain() + .where(PRODUCT_RECORD.PRODUCT_ID.eq(productId)) + .list(); + //批量修改购物车产品价格 + if (!recordList.isEmpty()){ + ShoppingCartService cartService = SpringUtils.getBean(ShoppingCartService.class); + cartService.updateChain() + .where(SHOPPING_CART.PRODUCT_RECORD_ID.in(recordList.stream().map(ProductRecord::getId).collect(Collectors.toSet()))) + .remove(); + } + } +} diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductInfoVo.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductInfoVo.java index 54eec84..60f85b5 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductInfoVo.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductInfoVo.java @@ -1,5 +1,6 @@ package com.cpop.mall.business.vo; +import com.cpop.core.annontation.StringArrayConvert; import com.fasterxml.jackson.annotation.JsonFormat; import com.mybatisflex.annotation.RelationOneToMany; import io.swagger.annotations.ApiModel; @@ -43,6 +44,7 @@ public class ProductInfoVo implements Serializable { /** * 商店(校区)集合 */ + @StringArrayConvert @ApiModelProperty("商店(校区)集合") private String storeIds; @@ -58,6 +60,13 @@ public class ProductInfoVo implements Serializable { @ApiModelProperty("商品图地址") private String picUrl; + /** + * 限购数量 + */ + @ApiModelProperty("限购数量") + private Integer limitNum; + + /** * 商品详情图地址 */ diff --git a/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductPageVo.java b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductPageVo.java index aae5b09..68898cf 100644 --- a/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductPageVo.java +++ b/Cpop-Mall/src/main/java/com/cpop/mall/business/vo/ProductPageVo.java @@ -126,20 +126,6 @@ public class ProductPageVo implements Serializable { @ApiModelProperty("商品交易成功信息") private ProductTradeInfo tradeInfo; - /** - * 产品规格 - */ - @RelationOneToMany(selfField = "id", targetField = "productId",targetTable = "cp_mall_product_specification") - @ApiModelProperty("产品规格") - private List productSpecificationVos; - - /** - * 产品规格记录 - */ - @RelationOneToMany(selfField = "id", targetField = "productId",targetTable = "cp_mall_product_record") - @ApiModelProperty("产品规格记录") - private List productRecordVos; - /** * 创建时间 */ diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/MallStaffBo.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/MallStaffBo.java new file mode 100644 index 0000000..2ebb3bf --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/MallStaffBo.java @@ -0,0 +1,116 @@ +package com.cpop.oam.business.bo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * 员工表Bo + * + * @author DB.lost + * @since 2023-05-11 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "Staff对象", description = "员工表") +public class MallStaffBo implements Serializable { + + /** + * 主键 + */ + @ApiModelProperty("主键") + private String id; + + /** + * 姓名不能为空 + */ + @NotBlank(message = "姓名不能为空") + @ApiModelProperty("姓名") + private String name; + + /** + * 品牌id不能为空 + */ + @NotBlank(message = "品牌id不能为空") + @ApiModelProperty(value = "品牌id") + private String brandId; + + /** + * 角色品牌id + */ + @ApiModelProperty("角色品牌id") + private String roleBrandId; + + /** + * 用户id + */ + @ApiModelProperty("用户id") + private String userId; + + /** + * 用户名 + */ + @NotBlank(message = "用户名不能为空") + @ApiModelProperty(value = "用户名",required = true) + private String userName; + + /** + * 密码 + */ + @NotBlank(message = "密码不能为空") + @ApiModelProperty(value = "密码",required = true) + private String password; + + /** + * 昵称 + */ + @NotBlank(message = "昵称不能为空") + @ApiModelProperty(value = "昵称",required = true) + private String nickName; + + /** + * 邮箱 + */ + @ApiModelProperty(value = "邮箱") + private String email; + + /** + * 手机号 + */ + @NotBlank(message = "手机号不能为空") + @ApiModelProperty(value = "手机号",required = true) + private String phoneNumber; + + /** + * 性别(0:男;1:女) + */ + @NotNull(message = "性别不能为空") + @ApiModelProperty(value = "性别(0:男;1:女)",required = true) + private Boolean sex; + + /** + * 头像 + */ + @ApiModelProperty(value = "头像") + private String avatar; + + /** + * 状态(0:停用;1:启用) + */ + @NotNull(message = "状态不能为空") + @ApiModelProperty(value = "状态(0:停用;1:启用)",required = true) + private Boolean status; + + /** + * 角色id + */ + @NotBlank(message = "角色id不能为空") + @ApiModelProperty(value = "角色id",required = true) + private String roleId; + +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/MallStaffPageBo.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/MallStaffPageBo.java new file mode 100644 index 0000000..fadcb60 --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/bo/MallStaffPageBo.java @@ -0,0 +1,29 @@ +package com.cpop.oam.business.bo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; + +/** + * 员工表Bo + * + * @author DB.lost + * @since 2023-05-11 + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "Staff对象", description = "员工表") +public class MallStaffPageBo implements Serializable { + + /** + * 姓名不能为空 + */ + @ApiModelProperty("姓名") + private String name; + +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/OamMallController.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/OamMallController.java new file mode 100644 index 0000000..a3d47ff --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/OamMallController.java @@ -0,0 +1,49 @@ +package com.cpop.oam.business.controller; + +import com.cpop.core.base.R; +import com.cpop.oam.business.bo.MallStaffBo; +import com.cpop.oam.business.bo.MallStaffPageBo; +import com.cpop.oam.business.bo.StaffPageBo; +import com.cpop.oam.business.service.OamMallService; +import com.cpop.oam.business.vo.MallStaffPageVo; +import com.cpop.oam.business.vo.StaffPageVo; +import com.mybatisflex.core.paginate.Page; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author DB + * @createTime 2023/11/09 14:40 + * @description + */ +@RestController +@Api(tags = "商城管理模块") +@RequestMapping("/oamMall") +public class OamMallController { + + @Autowired + private OamMallService oamMallService; + + /** + * @descriptions 查询商城管理员分页列表 + * @author DB + * @date 2023/11/09 15:33 + * @param brandIds 品牌id集合 + * @param name 姓名 + * @return: com.cpop.core.base.R> + */ + @ApiOperation("查询商城管理员分页列表") + @GetMapping("/getMallStaffPage") + public R> getMallStaffPage(String brandIds, String name) { + Page page = oamMallService.getMallStaffPage(brandIds, name); + return R.ok(page); + } +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/StaffController.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/StaffController.java index a038876..078458c 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/StaffController.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/StaffController.java @@ -21,7 +21,8 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -import static com.cpop.oam.business.entity.table.RoleTableDef.ROLE; +import static com.cpop.system.business.entity.table.RoleTableDef.ROLE; + /** * 员工表 控制层。 @@ -190,4 +191,6 @@ public class StaffController { staffService.modifyUserPassword(bo); return R.ok(); } + + } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/OamMallService.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/OamMallService.java new file mode 100644 index 0000000..c89c7d2 --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/OamMallService.java @@ -0,0 +1,20 @@ +package com.cpop.oam.business.service; + +import com.cpop.oam.business.vo.MallStaffPageVo; +import com.mybatisflex.core.paginate.Page; + +import java.util.List; + +/** + * 商城管理 + */ +public interface OamMallService { + + /** + * @descriptions 查询商城管理员分页列表 + * @author DB + * @date 2023/11/09 14:47 + * @return: com.mybatisflex.core.paginate.Page + */ + Page getMallStaffPage(String brandIds, String name); +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/OamMallServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/OamMallServiceImpl.java new file mode 100644 index 0000000..09842c9 --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/OamMallServiceImpl.java @@ -0,0 +1,63 @@ +package com.cpop.oam.business.service.impl; + +import com.cpop.common.utils.StringUtils; +import com.cpop.common.utils.bean.BeanUtils; +import com.cpop.core.base.entity.PageDomain; +import com.cpop.core.base.enums.UserType; +import com.cpop.core.utils.sql.SqlUtils; +import com.cpop.oam.business.bo.MallStaffPageBo; +import com.cpop.oam.business.service.OamMallService; +import com.cpop.oam.business.vo.MallStaffPageVo; +import com.mybatisflex.core.paginate.Page; +import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.core.row.Db; +import com.mybatisflex.core.row.Row; +import com.mybatisflex.core.row.RowUtil; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.List; + +import static com.cpop.core.base.table.table.SysUserTableDef.SYS_USER; +import static com.cpop.system.business.entity.table.RoleTableDef.ROLE; + +/** + * @author DB + * @createTime 2023/11/09 14:42 + * @description + */ +@Service("oamMallService") +public class OamMallServiceImpl implements OamMallService { + + /** + * @descriptions 查询商城管理员分页列表 + * @author DB + * @date 2023/11/09 14:47 + * @return: com.mybatisflex.core.paginate.Page + */ + @Override + public Page getMallStaffPage(String brandIds, String name) { + PageDomain pageDomain = SqlUtils.getInstance().getPageDomain(); + QueryWrapper queryWrapper = QueryWrapper.create(); + if (StringUtils.isNotBlank(name)) { + queryWrapper.and("name like ?", "%" + name + "%"); + } + if (StringUtils.isNotBlank(brandIds)) { + queryWrapper.in("cp_mall_role_brand.brand_id", Arrays.asList(brandIds.split(","))); + } + Page rowPage = Db.paginate("cp_mall_staff", pageDomain.getPageNum(), pageDomain.getPageSize(), + queryWrapper.select("cp_mall_staff.*") + .select(SYS_USER.USER_NAME, SYS_USER.AVATAR, SYS_USER.EMAIL, SYS_USER.NICK_NAME, SYS_USER.PASSWORD, SYS_USER.PHONE_NUMBER, SYS_USER.SEX, SYS_USER.STATUS) + //角色 + .select("cp_sys_role.role_name", "cp_sys_role.id as roleId") + //品牌 + .select("cp_sys_brand.id as brandId", "cp_sys_brand.brand_name") + .from("cp_mall_staff") + .leftJoin(SYS_USER).on("cp_sys_user.id = cp_mall_staff.user_id") + .leftJoin("cp_mall_role_brand").on("cp_mall_role_brand.id = cp_mall_staff.role_brand_id") + .leftJoin("cp_sys_role").on("cp_sys_role.id = cp_mall_role_brand.role_id") + .leftJoin("cp_sys_brand").on("cp_sys_brand.id = cp_mall_role_brand.brand_id") + .where(SYS_USER.USER_TYPE.eq(UserType.MALL_USER))); + return rowPage.map(item -> RowUtil.toEntity(item, MallStaffPageVo.class)); + } +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/StaffServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/StaffServiceImpl.java index 9031da8..a738e28 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/StaffServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/StaffServiceImpl.java @@ -45,9 +45,9 @@ import java.util.List; import static com.cpop.core.base.table.table.SysOperationLogTableDef.SYS_OPERATION_LOG; import static com.cpop.core.base.table.table.SysUserTableDef.SYS_USER; -import static com.cpop.oam.business.entity.table.RoleTableDef.ROLE; import static com.cpop.oam.business.entity.table.StaffMidDeptTableDef.STAFF_MID_DEPT; import static com.cpop.oam.business.entity.table.StaffTableDef.STAFF; +import static com.cpop.system.business.entity.table.RoleTableDef.ROLE; import static com.mybatisflex.core.query.QueryMethods.distinct; import static com.mybatisflex.core.query.QueryMethods.groupConcat; @@ -77,7 +77,7 @@ public class StaffServiceImpl extends ServiceImpl implements .select(SYS_USER.USER_NAME,SYS_USER.NICK_NAME, SYS_USER.EMAIL, SYS_USER.PHONE_NUMBER, SYS_USER.SEX, SYS_USER.AVATAR, SYS_USER.STATUS, SYS_USER.PASSWORD) .select(ROLE.ROLE_NAME) //将部门id分组 - .select(groupConcat(STAFF_MID_DEPT.DEPT_ID).as(StaffPageVo::getDeptId)) + .select(groupConcat(STAFF_MID_DEPT.DEPT_ID)) .from(STAFF) .leftJoin(SYS_USER).on(SYS_USER.ID.eq(STAFF.USER_ID)) .leftJoin(ROLE).on(ROLE.ID.eq(STAFF.ROLE_ID)) diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/vo/MallStaffPageVo.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/vo/MallStaffPageVo.java new file mode 100644 index 0000000..707d624 --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/vo/MallStaffPageVo.java @@ -0,0 +1,126 @@ +package com.cpop.oam.business.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * @author DB + * @createTime 2023/10/20 11:06 + * @description + */ +@Data +@Accessors(chain = true) +@ApiModel(value = "商城员工分页返回对象") +public class MallStaffPageVo implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + @ApiModelProperty("主键") + private String id; + + /** + * 姓名 + */ + @ApiModelProperty("姓名") + private String name; + + /** + * 用户id + */ + @ApiModelProperty("用户id") + private String userId; + + /** + * 角色-品牌-id + */ + @ApiModelProperty("角色-品牌-id") + private String roleBrandId; + + /** + * 品牌id + */ + @ApiModelProperty("品牌id") + private String brandId; + + /** + * 品牌 + */ + @ApiModelProperty("品牌") + private String brandName; + + /** + * 用户名 + */ + @ApiModelProperty("用户名") + private String userName; + + /** + * 昵称 + */ + @ApiModelProperty("昵称") + private String nickName; + + /** + * 邮箱 + */ + @ApiModelProperty("邮箱") + private String email; + + /** + * 手机号 + */ + @ApiModelProperty("手机号") + private String phoneNumber; + + /** + * 性别(0:男;1:女) + */ + @ApiModelProperty("性别(0:男;1:女)") + private Boolean sex; + + /** + * 头像 + */ + @ApiModelProperty("头像") + private String avatar; + + /** + * 状态(0:停用;1:启用) + */ + @ApiModelProperty("状态(0:停用;1:启用)") + private Boolean status; + + /** + * 角色id + */ + @ApiModelProperty("角色id") + private String roleId; + + /** + * 角色名 + */ + @ApiModelProperty("角色名") + private String roleName; + + /** + * 更新时间 + */ + @ApiModelProperty("更新时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8") + private LocalDateTime updateTime; + + /** + * 密码 + */ + @ApiModelProperty("密码") + private String password; +} diff --git a/Cpop-System/src/main/java/com/cpop/system/business/controller/BrandController.java b/Cpop-System/src/main/java/com/cpop/system/business/controller/BrandController.java index 4d96f94..d6266eb 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/controller/BrandController.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/controller/BrandController.java @@ -1,7 +1,9 @@ package com.cpop.system.business.controller; import com.cpop.common.utils.bean.BeanUtils; +import com.cpop.core.annontation.OperationLog; import com.cpop.core.base.R; +import com.cpop.core.base.enums.OperationLogEnum; import com.cpop.core.base.enums.SourceType; import com.cpop.system.business.bo.BrandBo; import com.cpop.system.business.bo.BrandPageBo; @@ -76,7 +78,6 @@ public class BrandController { * @param bo 请求参数 * @return com.cpop.core.base.R> */ - @PreAuthorize("@aps.hasPermission('brandAndCampus:brand:list')") @ApiOperation("查询品牌分页列表") @GetMapping("/getBrandPage") public R> getBrandPageList(BrandPageBo bo) { @@ -84,4 +85,18 @@ public class BrandController { return R.ok(pageVo); } + /** + * @descriptions 根据品牌id删除品牌 + * @author DB + * @date 2023/11/09 10:31 + * @param id 主键 + * @return: com.cpop.core.base.R + */ + @ApiOperation("根据品牌id删除品牌") + @DeleteMapping("/removeBrandById/{id}") + public R removeBrandById(@PathVariable String id) { + brandService.removeBrandById(id); + return R.ok(); + } + } diff --git a/Cpop-System/src/main/java/com/cpop/system/business/entity/Brand.java b/Cpop-System/src/main/java/com/cpop/system/business/entity/Brand.java index 4070e00..e09d229 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/entity/Brand.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/entity/Brand.java @@ -65,6 +65,11 @@ public class Brand extends BaseEntity implements Serializable { */ private String sourceType; + /** + * 背景图 + */ + private String backgroundUrl; + /** * 逻辑删除(0否1是) */ diff --git a/Cpop-System/src/main/java/com/cpop/system/business/service/BrandService.java b/Cpop-System/src/main/java/com/cpop/system/business/service/BrandService.java index 76e45d0..266cf06 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/service/BrandService.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/service/BrandService.java @@ -31,4 +31,13 @@ public interface BrandService extends IService { * @return: com.mybatisflex.core.paginate.Page */ Page getBrandPage(BrandPageBo bo); + + /** + * @descriptions 根据品牌id删除品牌 + * @author DB + * @date 2023/11/09 10:34 + * @param id 主键 + * @return: void + */ + void removeBrandById(String id); } diff --git a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/BrandServiceImpl.java b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/BrandServiceImpl.java index 9a2cec1..6ea4aed 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/BrandServiceImpl.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/BrandServiceImpl.java @@ -1,5 +1,6 @@ package com.cpop.system.business.service.impl; +import com.cpop.common.utils.StringUtils; import com.cpop.common.utils.bean.BeanUtils; import com.cpop.core.base.entity.LoginUser; import com.cpop.core.base.entity.PageDomain; @@ -80,6 +81,7 @@ public class BrandServiceImpl extends ServiceImpl implements .setWxMchId(brand.getString("wxMchId")) .setWxMchKey(brand.getString("wxMchKey")) .setWxKeyPath(brand.getString("wxKeyPath")) + .setBackgroundUrl(brand.getString("brandBg")) .setSourceType(SourceType.JAMBOX.toString()); this.save(sysBrand); //果酱拓展表信息 @@ -90,7 +92,6 @@ public class BrandServiceImpl extends ServiceImpl implements .setId(brandKey) .set("brand_id", sysBrand.getId()) .set("brand_cloud_id", brand.getString("brandId")) - .set("background_url", brand.getString("brandBg")) .set("create_time", now) .set("update_time", now) .set("create_user_id", loginUser.getUserId()) @@ -157,10 +158,42 @@ public class BrandServiceImpl extends ServiceImpl implements @Override public Page getBrandPage(BrandPageBo bo) { PageDomain pageDomain = SqlUtils.getInstance().getPageDomain(); - return this.mapper.paginateAs(pageDomain.getPageNum(),pageDomain.getPageSize(), + return this.mapper.paginateAs(pageDomain.getPageNum(), pageDomain.getPageSize(), QueryWrapper.create() - .select(BRAND.ID,BRAND.BRAND_NAME,BRAND.WX_MCH_ID,BRAND.CREATE_TIME) + .select(BRAND.ID, BRAND.BRAND_NAME, BRAND.WX_MCH_ID, BRAND.CREATE_TIME, BRAND.BACKGROUND_URL, BRAND.WX_APP_ID, BRAND.WX_MCH_KEY, BRAND.WX_KEY_PATH) .and(BRAND.BRAND_NAME.like(bo.getName())), BrandPageVo.class); } + + /** + * @descriptions 根据品牌id删除品牌 + * @author DB + * @date 2023/11/09 10:34 + * @param id 主键 + * @return: void + */ + @Override + public void removeBrandById(String id) { + Brand brand = this.getById(id); + StoreService storeService = SpringUtils.getBean(StoreService.class); + if (StringUtils.equals(brand.getSourceType(),SourceType.JAMBOX.toString())){ + //果酱处导入,先删除拓展校区 + List storeList = storeService.queryChain().where(STORE.BRAND_ID.eq(id)).list(); + if (!storeList.isEmpty()){ + DbChain.table("cp_j_store_extend") + .set("is_delete = ?", 1) + .where("store_id in ?", storeList.stream().map(Store::getId).collect(Collectors.toSet())) + .update(); + } + } + //删除校区 + storeService.updateChain().where(STORE.BRAND_ID.eq(brand.getId())).remove(); + //逻辑删除品牌拓展 + DbChain.table("cp_j_brand_extend") + .set("is_delete = ?", 1) + .where("brand_id = ?", id) + .update(); + //删除品牌 + this.removeById(id); + } } diff --git a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/MenuServiceImpl.java b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/MenuServiceImpl.java index 27f1205..7fea0d3 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/service/impl/MenuServiceImpl.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/service/impl/MenuServiceImpl.java @@ -52,7 +52,7 @@ public class MenuServiceImpl extends ServiceImpl implements Me List list = this.listAs(QueryWrapper.create() .where(MENU.TYPE.in(0, 1)) //构建公共菜单与特有菜单 - .and(MENU.USER_TYPE.in("COMMON", user.getUserType())) + .and(MENU.USER_TYPE.eq(user.getUserType())) .orderBy(MENU.ORDER_NO.asc()), MenuRouteVo.class); return buildMenuRouteTree(list); @@ -66,7 +66,7 @@ public class MenuServiceImpl extends ServiceImpl implements Me .and(MENU.NAME.notIn(Constants.HIDE_MENU.split(","))) .and(ROLE_MENU.ROLE_ID.eq(loginStaffInfo.getString("roleId"))) //构建公共菜单与特有菜单 - .and(MENU.USER_TYPE.in("COMMON", user.getUserType())) + .and(MENU.USER_TYPE.eq(user.getUserType())) .orderBy(MENU.ORDER_NO.asc()), MenuRouteVo.class)); } @@ -148,6 +148,8 @@ public class MenuServiceImpl extends ServiceImpl implements Me String[] split = bo.getPath().split("/"); String name = StringUtils.getMethodName(split[split.length - 1].replace("/", "")); entity.setName(name); + } else { + entity.setName(null); } //设置组件 if (StringUtils.isBlank(bo.getComponent())){ diff --git a/Cpop-System/src/main/java/com/cpop/system/business/vo/BrandPageVo.java b/Cpop-System/src/main/java/com/cpop/system/business/vo/BrandPageVo.java index 015c176..47d9917 100644 --- a/Cpop-System/src/main/java/com/cpop/system/business/vo/BrandPageVo.java +++ b/Cpop-System/src/main/java/com/cpop/system/business/vo/BrandPageVo.java @@ -40,6 +40,31 @@ public class BrandPageVo implements Serializable { @ApiModelProperty("微信商户号") private String wxMchId; + /** + * 微信appid + */ + @ApiModelProperty("微信appid") + private String wxAppId; + + /** + * 微信支付密钥 + */ + @ApiModelProperty("微信支付密钥") + private String wxMchKey; + + /** + * 微信支付keypath + */ + @ApiModelProperty("微信支付keyPath") + private String wxKeyPath; + + /** + * 背景图 + */ + @StringArrayConvert + @ApiModelProperty("背景图") + private String backgroundUrl; + /** * 创建时间 */