添加商城管理员;添加积分减扣;添加模板创建

This commit is contained in:
DB 2023-11-10 18:35:37 +08:00
parent 0f7fedda1c
commit ca60e849b7
30 changed files with 799 additions and 135 deletions

View File

@ -18,11 +18,6 @@
<groupId>com.cpop</groupId>
<artifactId>Cpop-Core</artifactId>
</dependency>
<!-- okhttp3 -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -107,6 +107,11 @@
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</dependency>
<!-- okhttp3 -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,53 @@
package com.cpop.core.base.enums;
import lombok.Getter;
/**
* 初始化角色枚举
* @author Administrator
*/
@Getter
public enum InitRoleEnum {
/**
* OAM超级管理员角色
*/
SUPER_OAM_ROLE("1", "SuperOamAdmin", "SuperOamAdmin", -1, UserType.OAM_USER),
/**
* MALL超级管理员角色
*/
SUPER_MALL_ROLE("2", "SuperMallAdmin", "SuperMallAdmin", -1, UserType.MALL_USER),
;
/**
* 主键
*/
private final String id;
/**
* 角色名称
*/
private final String roleName;
/**
* 角色值
*/
private final String roleValue;
/**
* 排序
*/
private final Integer orderNo;
/**
* 用户类型
*/
private final UserType userType;
InitRoleEnum(String id, String roleName, String roleValue, Integer orderNo, UserType userType) {
this.id = id;
this.roleName = roleName;
this.roleValue = roleValue;
this.orderNo = orderNo;
this.userType = userType;
}
}

View File

@ -140,4 +140,15 @@ public interface CoreService {
* @Date: 2023/8/27 23:37
*/
SysUser getSysUserByPhone(String phoneNumber, UserType userType);
/**
* @descriptions 检查用户是否存在
* @author DB
* @date 2023/11/10 11:57
* @param username 用户名
* @param id 主键
* @param userType 用户类型
* @return: void
*/
void isAccountExist(String username, String id, String userType);
}

View File

@ -1,5 +1,6 @@
package com.cpop.core.service.impl;
import com.cpop.common.utils.StringUtils;
import com.cpop.core.base.entity.LoginUser;
import com.cpop.core.base.enums.OperationLogEnum;
import com.cpop.core.base.enums.UserType;
@ -12,6 +13,9 @@ import com.cpop.core.service.CoreService;
import com.cpop.core.utils.MessageUtils;
import com.cpop.core.utils.SecurityUtils;
import com.cpop.core.utils.uuid.IdUtils;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.Db;
import com.mybatisflex.core.row.DbChain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
@ -21,6 +25,8 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import static com.cpop.core.base.table.table.SysUserTableDef.SYS_USER;
/**
* @author DB
* @Description:
@ -258,4 +264,25 @@ public class CoreServiceImpl implements CoreService {
public SysUser getSysUserByPhone(String phoneNumber, UserType userType) {
return coreMapper.getSysUserByPhone(phoneNumber, userType.toString());
}
/**
* @descriptions 检查用户是否存在
* @author DB
* @date 2023/11/10 11:57
* @param username 用户名
* @param id 主键
* @param userType 用户类型
* @return: void
*/
@Override
public void isAccountExist(String username, String id, String userType) {
if (StringUtils.isBlank(username)) {
return;
}
if (DbChain.table(SYS_USER).where(SYS_USER.USER_NAME.eq(username))
.and(SYS_USER.USER_TYPE.eq(userType))
.and(SYS_USER.ID.ne(id)).count() > 0) {
throw new ServiceException(MessageUtils.message("i18n_alert_userIsExist"));
}
}
}

View File

@ -3,6 +3,7 @@ package com.cpop.core.strategy.login;
import com.cpop.common.constant.Constants;
import com.cpop.common.utils.bean.BeanUtils;
import com.cpop.core.base.entity.LoginUser;
import com.cpop.core.base.entity.Permission;
import com.cpop.core.base.entity.loginInfo.MallStaffLoginInfo;
import com.cpop.core.base.enums.SourceType;
import com.cpop.core.base.enums.UserType;
@ -10,11 +11,14 @@ import com.cpop.core.base.exception.CpopAuthenticationException;
import com.cpop.core.base.table.SysUser;
import com.mybatisflex.core.row.DbChain;
import com.mybatisflex.core.row.Row;
import com.mybatisflex.core.row.RowUtil;
import org.springframework.stereotype.Component;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author DB
@ -85,7 +89,7 @@ public class MallLoginStrategy implements LoginStrategy{
else {
permissionSet.add(Constants.ALL_PERMISSION);
//TODO:测试中所有新建用户都是超级管理员
/*//查询员工信息
//查询员工信息
List<Row> list = DbChain.table("cp_sys_menu")
.select("pom.permission")
.from("cp_sys_menu").as("pom")
@ -99,7 +103,7 @@ public class MallLoginStrategy implements LoginStrategy{
} else {
List<Permission> permissions = RowUtil.toEntityList(list, Permission.class);
permissionSet = permissions.stream().map(Permission::getPermission).collect(Collectors.toSet());
}*/
}
}
return permissionSet;
}

View File

@ -7,6 +7,7 @@ import com.cpop.core.base.enums.SourceType;
import com.cpop.core.base.enums.UserType;
import com.cpop.core.base.exception.ServiceException;
import com.cpop.core.base.table.SysUser;
import com.mybatisflex.core.row.Db;
import com.mybatisflex.core.row.DbChain;
import com.mybatisflex.core.row.Row;
import com.mybatisflex.core.row.RowKey;
@ -112,10 +113,8 @@ public class MiniLoginStrategy implements LoginStrategy {
}
//保存小程序用户信息
LocalDateTime now = LocalDateTime.now();
RowKey snowFlakeId = RowKey.SNOW_FLAKE_ID;
boolean save = DbChain.table("cp_mini_user")
.setId(snowFlakeId)
.set("user_id", loginInfo.getUserId())
Row miniUser = Row.ofKey(RowKey.SNOW_FLAKE_ID);
miniUser.set("user_id", loginInfo.getUserId())
.set("open_id", credentials.get("openId"))
.set("app_id", credentials.get("appId"))
.set("brand_id", brand.getString("id"))
@ -125,16 +124,16 @@ public class MiniLoginStrategy implements LoginStrategy {
.set("create_time", now)
.set("update_time", now)
.set("create_user_id", 1)
.set("update_user_id", 1)
.save();
if (save){
.set("update_user_id", 1);
int save = Db.insert("cp_mini_user", miniUser);
if (save > 0) {
loginInfo.setOpenId((String) credentials.get("openId"))
.setAppId((String) credentials.get("appId"))
.setUserId(loginInfo.getUserId())
.setBrandId(brand.getString("id"))
.setNickName((String) credentials.get("nickName"))
.setAvatar((String) credentials.get("avatar"))
.setId(snowFlakeId.getValue())
.setId(miniUser.getString("id"))
.setSourceType(sourceType);
}
} else {

View File

@ -44,11 +44,6 @@ public class BrandExtend extends BaseEntity implements Serializable {
*/
private String brandCloudId;
/**
* 背景地址
*/
private String backgroundUrl;
/**
* 是否删除(0否1是)
*/

View File

@ -0,0 +1,99 @@
package com.cpop.jambox.business.task;
import com.alibaba.fastjson.JSONObject;
import com.cpop.common.utils.DateUtils;
import com.cpop.common.utils.StringUtils;
import com.cpop.core.base.exception.ServiceException;
import com.cpop.core.utils.SpringUtils;
import com.cpop.jambox.business.entity.CardTemplate;
import com.cpop.jambox.business.service.CardTemplateService;
import com.cpop.jambox.framework.constant.JamboxCloudUrl;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import org.springframework.scheduling.annotation.Async;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Date;
/**
* @author DB
* @createTime 2023/11/10 17:52
* @description 课卡模板异步任务
*/
@Component
public class CardTemplateAsyncTask {
/**
* 生成课卡
*/
@Async("customAsyncThreadPool")
public void cloudCreateCard(JSONObject jsonBody,String cardTemplateId) {
try {
//查询课卡信息
CardTemplate cardTemplate = SpringUtils.getBean(CardTemplateService.class).getById(cardTemplateId);
//课卡名称
jsonBody.put("periodName", cardTemplate.getName());
//时限卡
if (cardTemplate.getTemplateType().equals(1)) {
jsonBody.put("moneyCard", true);
jsonBody.put("amount", cardTemplate.getPrice());
} else if (cardTemplate.getTemplateType().equals(2)) {
jsonBody.put("timeLimit", true);
jsonBody.put("periodNumber", cardTemplate.getValidDay());
jsonBody.put("periodType", cardTemplate.getTemplateType());
} else {
// 课卡类型课时卡
jsonBody.put("periodType", cardTemplate.getTemplateType());
// 课卡计费类型 true false 课时卡
jsonBody.put("timeLimit", false);
// 课时卡课时数
jsonBody.put("periodNumber", cardTemplate.getClassNumber());
// 课卡到期时间
if (null != cardTemplate.getDayAppointment()){
// 日最大约课次数
jsonBody.put("maxFrequency", cardTemplate.getDayAppointment());
}
if (StringUtils.isNotBlank(cardTemplate.getName())){
// 课卡名称
jsonBody.put("periodName", cardTemplate.getName());
}
if (null != cardTemplate.getWeekAppointment()){
// 周最大约课次数
jsonBody.put("maxWeekFrequency", cardTemplate.getWeekAppointment());
}
// 首次上课开始计有效期
if (null != cardTemplate.getBufferDay()){
// 最大停卡次数
jsonBody.put("maxStopTime", cardTemplate.getBufferDay());
}
}
//课卡有效期
String periodExpire;
if (null != cardTemplate.getValidDay() && cardTemplate.getValidDay() > 0) {
//减一天
Date date = DateUtils.addDateDays(new Date(), cardTemplate.getValidDay() - 1);
periodExpire = DateUtils.dateTime(date);
} else {
//TODO:可能需要调整
periodExpire = DateUtils.parseDateToStr("yyyy-MM-dd", cardTemplate.getEndDate());
}
jsonBody.put("periodExpire", periodExpire);
//获取课卡信息
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, jsonBody.toJSONString());
Request request = new Request.Builder()
.url(JamboxCloudUrl.COMMON_CARD_URL)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
client.newCall(request).execute();
} catch (IOException e) {
throw new ServiceException(e.getMessage());
}
}
}

View File

@ -0,0 +1,17 @@
package com.cpop.jambox.framework.constant;
/**
* 果酱云地址
*/
public interface JamboxCloudUrl {
/**
* 基础地址
*/
String BASE_URL = "https://beibeike-qy-b33k4-1302318474.ap-shanghai.app.tcloudbase.com";
/**
* 课卡相关云函数
*/
String COMMON_CARD_URL = BASE_URL + "/merchant_cloud";
}

View File

@ -0,0 +1,27 @@
package com.cpop.mall.business.dto;
import lombok.Data;
/**
* @author DB
* @createTime 2023/11/10 16:33
* @description
*/
@Data
public class UserPointDto {
/**
* 总积分
*/
private Integer totalPoint;
/**
* 云品牌id
*/
private String brandCloudId;
/**
* 旧用户id
*/
private String oldUserId;
}

View File

@ -105,6 +105,11 @@ public class Product extends BaseEntity implements Serializable {
*/
private BigDecimal minPrice;
/**
* 课卡模板id
*/
private String cardTemplateId;
/**
* 逻辑删除0否1是
*/

View File

@ -13,11 +13,15 @@ import com.cpop.core.utils.QuartzUtils;
import com.cpop.core.utils.SecurityUtils;
import com.cpop.core.utils.SpringUtils;
import com.cpop.core.utils.sql.SqlUtils;
import com.cpop.jambox.business.entity.BrandExtend;
import com.cpop.jambox.business.service.BrandExtendService;
import com.cpop.mall.business.bo.*;
import com.cpop.mall.business.dto.UserPointDto;
import com.cpop.mall.business.dto.WxPayGoodsDetailDto;
import com.cpop.mall.business.entity.*;
import com.cpop.mall.business.mapper.OrderMapper;
import com.cpop.mall.business.service.*;
import com.cpop.mall.business.task.OrderDetailAsyncTask;
import com.cpop.mall.business.task.OrderOverTimeUnPayTask;
import com.cpop.mall.business.task.ProductRecordSyncStockTask;
import com.cpop.mall.business.task.WxPayAsyncTask;
@ -36,29 +40,34 @@ import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.datasource.DataSourceKey;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.DbChain;
import com.mybatisflex.core.row.Row;
import com.mybatisflex.core.row.RowKey;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.locks.Lock;
import java.util.stream.Collectors;
import static com.cpop.core.base.table.table.SysUserTableDef.SYS_USER;
import static com.cpop.jambox.business.entity.table.BrandExtendTableDef.BRAND_EXTEND;
import static com.cpop.mall.business.entity.table.OrderDetailTableDef.ORDER_DETAIL;
import static com.cpop.mall.business.entity.table.OrderRefundTableDef.ORDER_REFUND;
import static com.cpop.mall.business.entity.table.OrderTableDef.ORDER;
import static com.cpop.mall.business.entity.table.ProductRecordTableDef.PRODUCT_RECORD;
import static com.cpop.mall.business.entity.table.ProductTableDef.PRODUCT;
import static com.cpop.mall.business.entity.table.ShoppingCartTableDef.SHOPPING_CART;
import static com.cpop.system.business.entity.table.ProfitSharingTableDef.PROFIT_SHARING;
import static com.cpop.system.business.entity.table.StoreTableDef.STORE;
import static com.mybatisflex.core.query.QueryMethods.field;
import static com.mybatisflex.core.query.QueryMethods.select;
import static com.mybatisflex.core.query.QueryMethods.*;
/**
@ -156,6 +165,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
//检查库存
Map<String, Integer> recordNumIsEnough = null;
try {
//如果是积分商品,先检查积分
if (bo.getPayType() == 1) {
UserPointDto userPoint = getUserPoint(loginUserInfo);
if (userPoint.getTotalPoint() < bo.getTotalPoint()) {
throw new ServiceException("您的积分不足!");
}
}
Order order = BeanUtils.mapToClass(bo, Order.class);
List<OrderDetail> orderDetails = BeanUtils.mapToList(bo.getOrderDetailList(), OrderDetail.class);
//规格记录ids
@ -303,7 +319,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
} else {
//统计支付商品情况
Map<String, Integer> recordNumIsEnough = orderDetails.stream().collect(Collectors.toMap(OrderDetail::getProductRecordId, OrderDetail::getNumber));
result = pointPay(recordNumIsEnough, order.getId());
result = pointPay(recordNumIsEnough, order, loginUserInfo);
//删除定时器任务
QuartzUtils quartzUtils = SpringUtils.getBean(QuartzUtils.class);
quartzUtils.deleteJob(QuartzEnums.ORDER_OVERTIME_UN_PAY_TASK.getName() + order.getId(),
@ -315,6 +331,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
.set(ORDER.RECEIVE_NAME,bo.getReceiveName())
.where(ORDER.ID.eq(bo.getId()))
.update();
//异步处理订单详情
SpringUtils.getBean(OrderDetailAsyncTask.class).asyncProcessingOrderDetails(order, loginUserInfo, orderDetails, productList);
return result;
} catch (Exception e) {
throw new ServiceException(e.getMessage());
@ -330,22 +348,82 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
/**
* @Description: 积分支付
* @param recordNumIsEnough
* @return
* @Author DB
* @Date: 2023/10/28 9:33
*/
private Object pointPay(Map<String, Integer> recordNumIsEnough,String orderId){
private Object pointPay(Map<String, Integer> recordNumIsEnough, Order order, JSONObject loginUserInfo) {
UserPointDto userPoint = getUserPoint(loginUserInfo);
if (userPoint.getTotalPoint() < order.getTotalPoint()) {
throw new ServiceException("您的积分不足!");
}
//扣除积分
try {
LocalDateTime now = LocalDateTime.now();
DataSourceKey.use("jambox");
DbChain.table("t_point_record")
.setId(RowKey.of("record_id", KeyType.Auto))
.set("user_id", userPoint.getOldUserId())
.set("brand_id", userPoint.getBrandCloudId())
.set("point_behaviour", 9)
.set("behaviour_record", "商城购买商品")
.set("point_change", order.getTotalPoint())
.set("point_time", now)
.set("cumulative", userPoint.getTotalPoint() - order.getTotalPoint())
.set("creation_by", userPoint.getOldUserId())
.set("last_modified", userPoint.getOldUserId())
.set("creation_time", now)
.save();
} finally {
DataSourceKey.clear();
}
ProductRecordService productRecordService = SpringUtils.getBean(ProductRecordService.class);
List<ProductRecord> productRecords = productRecordService.listByIds(recordNumIsEnough.keySet());
productRecords.forEach(item -> {
item.setRecordNum(item.getRecordNum() - recordNumIsEnough.get(item.getId()));
});
productRecordService.updateBatch(productRecords);
//TODO: 通知到云
//修改订单状态
return this.updateChain().set(ORDER.ORDER_STATUS, 1).where(ORDER.ID.eq(orderId)).update();
return this.updateChain().set(ORDER.ORDER_STATUS, 1).where(ORDER.ID.eq(order.getId())).update();
}
/**
* @descriptions 获取当前用户积分
* @author DB
* @date 2023/11/10 16:10
* @param loginUserInfo 用户信息
* @return: java.lang.Integer
*/
private UserPointDto getUserPoint(JSONObject loginUserInfo){
//获取云品牌id
BrandExtend brandExtend = SpringUtils.getBean(BrandExtendService.class)
.getOne(QueryWrapper.create()
.where(BRAND_EXTEND.BRAND_ID.eq(loginUserInfo.getString("brandId"))));
//修改用户积分
try {
DataSourceKey.use("jambox");
//获取旧用户信息
List<Row> rows = DbChain.table("t_user_info")
.select("user_id")
.where("open_id = ?", loginUserInfo.getString("openId"))
.list();
List<String> userIds = rows.stream().map(item -> item.getString("userId")).collect(Collectors.toList());
Row pointChange = DbChain.table("t_point_record")
.select(sum("point_change").as("pointChange"))
.in("user_id", userIds)
.and("brand_id = ?", brandExtend.getBrandCloudId())
.one();
if (null == pointChange.getInt("pointChange")) {
throw new ServiceException("您的积分不足!");
}else {
UserPointDto userPointDto = new UserPointDto();
userPointDto.setTotalPoint(pointChange.getInt("pointChange"));
userPointDto.setBrandCloudId(brandExtend.getBrandCloudId());
userPointDto.setOldUserId(userIds.get(0));
return userPointDto;
}
} finally {
DataSourceKey.clear();
}
}
/**
@ -568,7 +646,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
return wxPayService.createOrder(orderRequest);
} else {
return pointPay(recordNumIsEnough, order.getId());
return pointPay(recordNumIsEnough, order, loginUserInfo);
}
} catch (Exception e){
//回滚库存

View File

@ -8,6 +8,7 @@ import com.cpop.core.base.entity.LoginUser;
import com.cpop.core.base.entity.PageDomain;
import com.cpop.core.base.entity.loginInfo.MallStaffLoginInfo;
import com.cpop.core.base.entity.loginInfo.OamStaffLoginInfo;
import com.cpop.core.base.enums.InitRoleEnum;
import com.cpop.core.base.enums.SourceType;
import com.cpop.core.base.enums.UserType;
import com.cpop.core.base.exception.ServiceException;
@ -70,7 +71,7 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
, QueryWrapper.create()
//去重
.select(distinct(STAFF.ALL_COLUMNS))
.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(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)
.select(ROLE_BRAND.BRAND_ID)
.select(BRAND.BRAND_NAME)
@ -83,6 +84,8 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
//姓名
.and(STAFF.NAME.like(bo.getName()))
.and(SYS_USER.USER_NAME.ne(Constants.SUPER_ADMIN).or(SYS_USER.USER_NAME.isNull()))
//不查询超级管理员
.and(ROLE.ID.ne(InitRoleEnum.SUPER_MALL_ROLE.getId()).or(ROLE.ID.isNull()))
.groupBy(STAFF.ID)
, StaffPageVo.class);
}

View File

@ -0,0 +1,71 @@
package com.cpop.mall.business.task;
import com.alibaba.fastjson.JSONObject;
import com.cpop.common.utils.DateUtils;
import com.cpop.core.utils.SpringUtils;
import com.cpop.jambox.business.entity.StoreExtend;
import com.cpop.jambox.business.service.CardTemplateService;
import com.cpop.jambox.business.service.StoreExtendService;
import com.cpop.jambox.business.task.CardTemplateAsyncTask;
import com.cpop.jambox.framework.constant.JamboxCloudUrl;
import com.cpop.mall.business.entity.Order;
import com.cpop.mall.business.entity.OrderDetail;
import com.cpop.mall.business.entity.Product;
import com.cpop.mall.business.entity.ProductRecord;
import com.cpop.mall.business.service.ProductRecordService;
import okhttp3.*;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.cpop.jambox.business.entity.table.StoreExtendTableDef.STORE_EXTEND;
/**
* @author DB
* @createTime 2023/11/10 17:11
* @description 订单详情异步任务
*/
@Component
public class OrderDetailAsyncTask {
@Async("customAsyncThreadPool")
public void asyncProcessingOrderDetails(Order order, JSONObject loginUserInfo, List<OrderDetail> orderDetails, List<Product> productList) {
Map<String, Product> productMap = productList.stream().collect(Collectors.toMap(Product::getId, item -> item));
List<ProductRecord> productRecords = SpringUtils.getBean(ProductRecordService.class).listByIds(orderDetails.stream().map(OrderDetail::getProductRecordId).collect(Collectors.toSet()));
Map<String, ProductRecord> productRecordMap = productRecords.stream().collect(Collectors.toMap(ProductRecord::getId, item -> item));
//获取云校区id
List<StoreExtend> storeExtendList = SpringUtils.getBean(StoreExtendService.class).queryChain()
.where(STORE_EXTEND.STORE_ID.in(orderDetails.stream().map(OrderDetail::getStoreId).collect(Collectors.toSet())))
.list();
Map<String, String> storeCloudMap = storeExtendList.stream().collect(Collectors.toMap(StoreExtend::getStoreId, StoreExtend::getStoreCloudId));
orderDetails.forEach(item -> {
//获取当前订单记录的商品信息
ProductRecord productRecord = productRecordMap.get(item.getProductRecordId());
Product product = productMap.get(productRecord.getId());
//课卡
if (product.getProductType() == 0) {
//课卡信息
JSONObject jsonBody = new JSONObject();
jsonBody.put("_type", "addPeriod");
//订单id
jsonBody.put("classCardId", order.getId());
//办卡实收金额
jsonBody.put("money", order.getTotalAmount());
//店铺/校区
jsonBody.put("storeId", storeCloudMap.get(item.getStoreId()));
//手机号
jsonBody.put("phone", loginUserInfo.getString("phoneNumber"));
//客户名称
jsonBody.put("customerName", loginUserInfo.getString("nickName"));
//客户性别
jsonBody.put("customerSex", loginUserInfo.getBoolean("sex") ? "" : "");
//客户地址
jsonBody.put("customerAddress", order.getReceiveAddress());
SpringUtils.getBean(CardTemplateAsyncTask.class).cloudCreateCard(jsonBody, product.getCardTemplateId());
}
});
}
}

View File

@ -41,6 +41,7 @@ public class MemberRestrictStrategy implements BuyRestrictStrategy{
.where(BRAND_EXTEND.BRAND_ID.eq(loginUserInfo.getString("brandId")))
.one();
//查询当前用户是否是会员
try {
DataSourceKey.use("jambox");
long count = Db.selectCountByQuery("j_membership", QueryWrapper.create()
.select()
@ -52,10 +53,12 @@ public class MemberRestrictStrategy implements BuyRestrictStrategy{
//会员时间未过期
.and("j_membership.end_time >= ?", LocalDate.now())
.and("j_membership.deleted = 1"));
DataSourceKey.clear();
//没有会员
if (count == 0) {
throw new ServiceException("你尚未成为会员,无法购买商品:" + product.getProductName());
}
} finally {
DataSourceKey.clear();
}
}
}

View File

@ -40,12 +40,6 @@ public class MallStaffBo implements Serializable {
@ApiModelProperty(value = "品牌id")
private String brandId;
/**
* 角色品牌id
*/
@ApiModelProperty("角色品牌id")
private String roleBrandId;
/**
* 用户id
*/
@ -106,11 +100,4 @@ public class MallStaffBo implements Serializable {
@ApiModelProperty(value = "状态(0:停用;1:启用)",required = true)
private Boolean status;
/**
* 角色id
*/
@NotBlank(message = "角色id不能为空")
@ApiModelProperty(value = "角色id",required = true)
private String roleId;
}

View File

@ -1,21 +1,21 @@
package com.cpop.oam.business.controller;
import com.cpop.core.base.R;
import com.cpop.core.service.CoreService;
import com.cpop.core.utils.SpringUtils;
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.BrandListVo;
import com.cpop.oam.business.vo.MallStaffPageVo;
import com.cpop.oam.business.vo.StaffPageVo;
import com.cpop.system.business.service.BrandService;
import com.mybatisflex.core.paginate.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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 org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -40,10 +40,70 @@ public class OamMallController {
* @param name 姓名
* @return: com.cpop.core.base.R<com.mybatisflex.core.paginate.Page<com.cpop.oam.business.vo.MallStaffPageVo>>
*/
@PreAuthorize("@aps.hasPermission('mall:admin:list')")
@ApiOperation("查询商城管理员分页列表")
@GetMapping("/getMallStaffPage")
public R<Page<MallStaffPageVo>> getMallStaffPage(String brandIds, String name) {
Page<MallStaffPageVo> page = oamMallService.getMallStaffPage(brandIds, name);
return R.ok(page);
}
/**
* @descriptions 查询品牌列表
* @author DB
* @date 2023/11/10 11:45
* @return: com.cpop.core.base.R<java.util.List<com.cpop.oam.business.vo.BrandListVo>>
*/
@ApiOperation("查询品牌列表")
@GetMapping("/getBrandList")
public R<List<BrandListVo>> getBrandList() {
List<BrandListVo> list = SpringUtils.getBean(BrandService.class).queryChain().listAs(BrandListVo.class);
return R.ok(list);
}
/**
* @descriptions 用户名是否存在
* @author DB
* @date 2023/11/10 12:03
* @param username 用户名
* @param id id
* @param userType 用户类型
* @return: com.cpop.core.base.R<java.lang.Void>
*/
@ApiOperation("用户名是否存在")
@GetMapping("/isAccountExist")
public R<Void> isAccountExist(@ApiParam("用户名") String username, @ApiParam("userId") String id, @ApiParam("用户类型") String userType) {
SpringUtils.getBean(CoreService.class).isAccountExist(username, id, userType);
return R.ok();
}
/**
* @descriptions 新增管理员
* @author DB
* @date 2023/09/08 14:04
* @param bo 请求参数
* @return com.jambox.core.base.R<java.lang.Void>
*/
@PreAuthorize("@aps.hasPermission('mall:admin:insert')")
@ApiOperation("新增管理员")
@PostMapping("/insertAdmin")
public R<Void> insertAdmin(@RequestBody @Validated MallStaffBo bo) {
oamMallService.insertAdmin(bo);
return R.ok();
}
/**
* @descriptions 删除管理员
* @author DB
* @date 2023/11/10 14:33
* @param id 主键
* @return: com.cpop.core.base.R<java.lang.Void>
*/
@PreAuthorize("@aps.hasPermission('mall:admin:remove')")
@ApiOperation("删除管理员")
@DeleteMapping("/removeAdmin/{id}")
public R<Void> removeAdmin(@PathVariable String id) {
oamMallService.removeAdmin(id);
return R.ok();
}
}

View File

@ -1,5 +1,6 @@
package com.cpop.oam.business.service;
import com.cpop.oam.business.bo.MallStaffBo;
import com.cpop.oam.business.vo.MallStaffPageVo;
import com.mybatisflex.core.paginate.Page;
@ -17,4 +18,22 @@ public interface OamMallService {
* @return: com.mybatisflex.core.paginate.Page<com.cpop.oam.business.vo.MallStaffPageVo>
*/
Page<MallStaffPageVo> getMallStaffPage(String brandIds, String name);
/**
* @descriptions 新增管理员
* @author DB
* @date 2023/11/10 12:14
* @param bo 请求参数
* @return: void
*/
void insertAdmin(MallStaffBo bo);
/**
* @descriptions 删除管理员
* @author DB
* @date 2023/11/10 14:34
* @param id 主键
* @return: void
*/
void removeAdmin(String id);
}

View File

@ -1,20 +1,34 @@
package com.cpop.oam.business.service.impl;
import com.alibaba.fastjson.JSONObject;
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;
import com.cpop.core.base.entity.loginInfo.OamStaffLoginInfo;
import com.cpop.core.base.enums.InitRoleEnum;
import com.cpop.core.base.enums.SourceType;
import com.cpop.core.base.enums.UserType;
import com.cpop.core.base.exception.ServiceException;
import com.cpop.core.base.table.SysUser;
import com.cpop.core.service.CoreService;
import com.cpop.core.service.RedisService;
import com.cpop.core.utils.*;
import com.cpop.core.utils.sql.SqlUtils;
import com.cpop.core.utils.uuid.IdUtils;
import com.cpop.oam.business.bo.MallStaffBo;
import com.cpop.oam.business.bo.MallStaffPageBo;
import com.cpop.oam.business.bo.StaffBo;
import com.cpop.oam.business.entity.Staff;
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 com.mybatisflex.core.row.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
@ -57,7 +71,116 @@ public class OamMallServiceImpl implements OamMallService {
.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)));
.where(SYS_USER.USER_TYPE.eq(UserType.MALL_USER))
.and("cp_mall_staff.is_delete = 0"));
return rowPage.map(item -> RowUtil.toEntity(item, MallStaffPageVo.class));
}
/**
* @descriptions 新增管理员
* @author DB
* @date 2023/11/10 12:14
* @param bo 请求参数
* @return: void
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void insertAdmin(MallStaffBo bo) {
//先添加用户信息
SysUser sysUser;
if (validatedUserInfo(bo)) {
throw new ServiceException(MessageUtils.message("i18n_alert_userOrPhoneOrEmailIsExist"));
} else {
//用户名-手机-邮箱都需要做唯一校验
sysUser = BeanUtils.mapToClass(bo, SysUser.class);
//解密与重设密码
decryptAndResetPasswords(sysUser);
sysUser.setId(IdUtils.fastSimpleUUID());
//获取当前创建人员信息
LoginUser loginUser = SecurityUtils.getInstance().getLoginUser();
sysUser.setCreateUserId(loginUser.getUserId());
sysUser.setUpdateUserId(loginUser.getUserId());
sysUser.setUserType(UserType.MALL_USER.toString());
SpringUtils.getBean(CoreService.class).insertSysUser(sysUser);
}
LocalDateTime now = LocalDateTime.now();
//创建中间表
Row roleBrand = Row.ofKey(RowKey.SNOW_FLAKE_ID);
roleBrand.set("brand_id", bo.getBrandId())
.set("role_id", InitRoleEnum.SUPER_MALL_ROLE.getId())
.set("source_type", SourceType.JAMBOX.toString())
.set("create_time", now)
.set("update_time", now)
.set("create_user_id", 1)
.set("update_user_id", 1);
Db.insert("cp_mall_role_brand",roleBrand);
DbChain.table("cp_mall_staff")
.setId(RowKey.SNOW_FLAKE_ID)
.set("name", bo.getName())
.set("role_brand_id", roleBrand.getString("id"))
.set("user_id", sysUser.getId())
.set("create_time", now)
.set("update_time", now)
.set("create_user_id", 1)
.set("update_user_id", 1)
.save();
}
/**
* @descriptions 删除管理员
* @author DB
* @date 2023/11/10 14:34
* @param id 主键
* @return: void
*/
@Override
public void removeAdmin(String id) {
//查询员工信息
Row staff = DbChain.table("cp_mall_staff").where("id = ?", id).one();
if (null != staff) {
DbChain.table("cp_mall_staff")
.set("is_delete", 1)
.where("id = ?", id)
.update();
DbChain.table("cp_mall_role_brand")
.where("id = ?", staff.getString("roleBrandId"))
.remove();
//删除系统用户
SpringUtils.getBean(CoreService.class).removeSysUserById(staff.getString("userId"));
}
}
/**
* @Description: 用户名-手机-邮箱都需要做唯一校验
* @param bo 请求参数
* @return Boolean 通过/未通过
* @Author DB
* @Date: 2023/5/11 11:02
**/
private Boolean validatedUserInfo(MallStaffBo bo) {
long count = DbChain.table(SYS_USER)
//用户名
.where(SYS_USER.USER_NAME.eq(bo.getUserName()))
//手机号
.or(SYS_USER.PHONE_NUMBER.eq(bo.getPhoneNumber()))
.count();
if (StringUtils.isNotBlank(bo.getUserId())) {
return count > 1;
} else {
return count > 0;
}
}
/**
* @Description: 解密与重设密码
* @param sysUser 系统用户
* @Author: DB
* @Date: 2023/5/11 11:03
**/
private void decryptAndResetPasswords(SysUser sysUser) {
//先用rsa解密
String password = SpringUtils.getBean(RsaUtils.class).decrypt(sysUser.getPassword());
//再加密
sysUser.setPassword(SpringUtils.getBean(PasswordEncoder.class).encode(password));
}
}

View File

@ -0,0 +1,31 @@
package com.cpop.oam.business.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @author DB
* @createTime 2023/11/10 11:39
* @description
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "Brand列表返回对象")
public class BrandListVo implements Serializable {
/**
* 主键
*/
@ApiModelProperty("主键")
private String id;
/**
* 云函数id
*/
@ApiModelProperty("品牌名")
private String brandName;
}

View File

@ -0,0 +1,42 @@
package com.cpop.oam.framework.config;
import com.cpop.core.base.enums.InitRoleEnum;
import com.cpop.core.utils.SpringUtils;
import com.cpop.system.business.entity.Role;
import com.cpop.system.business.service.RoleService;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import static org.springframework.integration.config.xml.IntegrationNamespaceUtils.ROLE;
/**
* @author DB
* @createTime 2023/11/10 12:25
* @description 初始化配置
*/
@Component
public class InitConfig {
/**
* 初始化
*/
@PostConstruct
public void init(){
//检查角色初始化
RoleService roleService = SpringUtils.getBean(RoleService.class);
for (InitRoleEnum value : InitRoleEnum.values()) {
Role role = roleService.queryChain().where("id = ?", value.getId()).one();
if (role == null){
Role newRole = new Role();
newRole.setId(value.getId())
.setRoleName(value.getRoleName())
.setRoleValue(value.getRoleValue())
.setOrderNo(value.getOrderNo())
.setUserType(value.getUserType());
roleService.save(newRole);
}
}
}
}

View File

@ -1,10 +1,13 @@
package com.cpop.system.business.bo;
import com.cpop.core.annontation.StringArrayConvert;
import com.mybatisflex.annotation.Id;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* @author DB
* @createTime 2023/10/25 16:43
@ -23,13 +26,15 @@ public class BrandBo {
/**
* 品牌名
*/
@NotBlank(message = "品牌不能为空")
@ApiModelProperty(value = "品牌名", required = true)
private String brandName;
/**
* 微信商户号
*/
@ApiModelProperty("微信商户号")
@NotBlank(message = "商户号不能为空")
@ApiModelProperty(value = "微信商户号",required = true)
private String wxMchId;
/**
@ -49,4 +54,11 @@ public class BrandBo {
*/
@ApiModelProperty("微信支付keypath")
private String wxKeyPath;
/**
* 背景图
*/
@StringArrayConvert
@ApiModelProperty("背景图")
private String backgroundUrl;
}

View File

@ -1,28 +0,0 @@
package com.cpop.system.business.bo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* Description:
* date: 2023/6/1 18:07
* @Author DB
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "Brand分页对象", description = "Brand分页对象")
public class BrandPageBo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 品牌名
*/
@ApiModelProperty("品牌名")
private String name;
}

View File

@ -1,15 +1,13 @@
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;
import com.cpop.system.business.vo.BrandPageVo;
import com.mybatisflex.core.paginate.Page;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@ -24,8 +22,6 @@ import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.io.Serializable;
import java.util.List;
/**
* 系统-品牌表 控制层
@ -45,18 +41,35 @@ public class BrandController {
* @descriptions 新增系统品牌
* @author DB
* @date 2023/10/25 16:53
* @param brand 品牌参数
* @param bo 品牌参数
* @return: com.cpop.core.base.R<java.lang.Void>
*/
@PreAuthorize("@aps.hasPermission('brandStore:brand:insert')")
@PostMapping("/insertSysBrand")
@ApiOperation("新增系统品牌")
public R<Void> insertSysBrand(@RequestBody @ApiParam("系统-品牌") BrandBo brand) {
Brand entity = BeanUtils.mapToClass(brand, Brand.class);
public R<Void> insertSysBrand(@RequestBody @ApiParam("系统-品牌") @Validated BrandBo bo) {
Brand entity = BeanUtils.mapToClass(bo, Brand.class);
entity.setSourceType(SourceType.COMMON.toString());
brandService.save(entity);
return R.ok();
}
/**
* @descriptions 修改系统品牌
* @author DB
* @date 2023/11/10 9:21
* @param bo 品牌参数
* @return: com.cpop.core.base.R<java.lang.Void>
*/
@PreAuthorize("@aps.hasPermission('brandStore:brand:update')")
@ApiOperation("修改系统品牌")
@PutMapping("/updateSysBrand")
public R<Void> updateSysBrand(@RequestBody @ApiParam("系统-品牌") @Validated BrandBo bo) {
Brand entity = BeanUtils.mapToClass(bo, Brand.class);
brandService.updateById(entity);
return R.ok();
}
/**
* @descriptions 导入果酱品牌
* @author DB
@ -64,6 +77,7 @@ public class BrandController {
* @param brandId 果酱品牌信息
* @return: boolean
*/
@PreAuthorize("@aps.hasPermission('brandStore:brand:insert')")
@PostMapping("/importJamboxBrand/{brandId}")
@ApiOperation("导入果酱品牌")
public R<Void> importJamboxBrand(@PathVariable String brandId) {
@ -75,13 +89,14 @@ public class BrandController {
* @descriptions 查询品牌分页列表
* @author DB
* @date 2023/09/13 17:55
* @param bo 请求参数
* @param brandName 请求参数
* @return com.cpop.core.base.R<com.mybatisflex.core.paginate.Page<com.cpop.system.business.vo.BrandPageVo>>
*/
@ApiOperation("查询品牌分页列表")
@GetMapping("/getBrandPage")
public R<Page<BrandPageVo>> getBrandPageList(BrandPageBo bo) {
Page<BrandPageVo> pageVo = brandService.getBrandPage(bo);
@PreAuthorize("@aps.hasPermission('brandStore:brand:list')")
public R<Page<BrandPageVo>> getBrandPageList(String brandName) {
Page<BrandPageVo> pageVo = brandService.getBrandPage(brandName);
return R.ok(pageVo);
}
@ -92,6 +107,7 @@ public class BrandController {
* @param id 主键
* @return: com.cpop.core.base.R<java.lang.Void>
*/
@PreAuthorize("@aps.hasPermission('brandStore:brand:remove')")
@ApiOperation("根据品牌id删除品牌")
@DeleteMapping("/removeBrandById/{id}")
public R<Void> removeBrandById(@PathVariable String id) {

View File

@ -66,7 +66,6 @@ public class MenuController {
* @return com.jambox.core.base.R<java.lang.Void>
*/
@PreAuthorize("@aps.hasPermission('system:menu:insert')")
@OperationLog(operationLogEnumType = OperationLogEnum.INSERT_OAM_MENU)
@ApiOperation("新增系统菜单")
@PostMapping("/insertSysMenu")
public R<Void> insertSysMenu(@RequestBody @Validated MenuBo bo) {
@ -81,7 +80,6 @@ public class MenuController {
* @Date: 2023/5/10 16:01
**/
@PreAuthorize("@aps.hasPermission('system:menu:update')")
@OperationLog(operationLogEnumType = OperationLogEnum.UPDATE_OAM_MENU)
@ApiOperation("修改系统菜单")
@PutMapping("/updateSysMenu")
public R<Void> updateSysMenu(@RequestBody @Validated MenuBo bo) {
@ -96,7 +94,6 @@ public class MenuController {
* @Date: 2023/5/10 16:01
**/
@PreAuthorize("@aps.hasPermission('system:menu:remove')")
@OperationLog(operationLogEnumType = OperationLogEnum.REMOVE_OAM_MENU)
@ApiOperation("删除系统菜单")
@DeleteMapping("/removeSysMenu/{id}")
public R<Void> removeSysMenu(@PathVariable String id) {

View File

@ -49,8 +49,9 @@ public class SysCommonController {
// 上传并返回新文件名称
String fileName = FileUploadUtils.getInstance().upload(filePath, file);
//强制将http变成https
String https = serverConfig.getUrl().replace("http:", "https:");
String url = https + fileName;
//String https = serverConfig.getUrl().replace("http:", "https:");
//String url = https + fileName;
String url = serverConfig.getUrl() + fileName;
SysFileVo sysFileVo = new SysFileVo();
sysFileVo.setUrl(url)
.setFileName(fileName)

View File

@ -1,6 +1,5 @@
package com.cpop.system.business.service;
import com.cpop.system.business.bo.BrandPageBo;
import com.cpop.system.business.vo.BrandPageVo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
@ -30,7 +29,7 @@ public interface BrandService extends IService<Brand> {
* @param bo 请求参数
* @return: com.mybatisflex.core.paginate.Page<com.cpop.system.business.vo.BrandPageVo>
*/
Page<BrandPageVo> getBrandPage(BrandPageBo bo);
Page<BrandPageVo> getBrandPage(String brandName);
/**
* @descriptions 根据品牌id删除品牌

View File

@ -9,7 +9,6 @@ import com.cpop.core.base.exception.ServiceException;
import com.cpop.core.utils.SecurityUtils;
import com.cpop.core.utils.SpringUtils;
import com.cpop.core.utils.sql.SqlUtils;
import com.cpop.system.business.bo.BrandPageBo;
import com.cpop.system.business.entity.Store;
import com.cpop.system.business.service.StoreService;
import com.cpop.system.business.vo.BrandPageVo;
@ -152,16 +151,16 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
* @descriptions 查询品牌分页列表
* @author DB
* @date 2023/10/25 17:32
* @param bo 请求参数
* @param brandName 品牌名
* @return: com.mybatisflex.core.paginate.Page<com.cpop.system.business.vo.BrandPageVo>
*/
@Override
public Page<BrandPageVo> getBrandPage(BrandPageBo bo) {
public Page<BrandPageVo> getBrandPage(String brandName) {
PageDomain pageDomain = SqlUtils.getInstance().getPageDomain();
return this.mapper.paginateAs(pageDomain.getPageNum(), pageDomain.getPageSize(),
QueryWrapper.create()
.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())),
.and(BRAND.BRAND_NAME.like(brandName)),
BrandPageVo.class);
}
@ -173,6 +172,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
* @return: void
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void removeBrandById(String id) {
Brand brand = this.getById(id);
StoreService storeService = SpringUtils.getBean(StoreService.class);
@ -181,7 +181,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
List<Store> storeList = storeService.queryChain().where(STORE.BRAND_ID.eq(id)).list();
if (!storeList.isEmpty()){
DbChain.table("cp_j_store_extend")
.set("is_delete = ?", 1)
.set("is_delete", 1)
.where("store_id in ?", storeList.stream().map(Store::getId).collect(Collectors.toSet()))
.update();
}
@ -190,7 +190,7 @@ public class BrandServiceImpl extends ServiceImpl<BrandMapper, Brand> implements
storeService.updateChain().where(STORE.BRAND_ID.eq(brand.getId())).remove();
//逻辑删除品牌拓展
DbChain.table("cp_j_brand_extend")
.set("is_delete = ?", 1)
.set("is_delete", 1)
.where("brand_id = ?", id)
.update();
//删除品牌

View File

@ -5,6 +5,7 @@ import com.cpop.common.constant.Constants;
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.enums.InitRoleEnum;
import com.cpop.core.utils.SecurityUtils;
import com.cpop.system.business.bo.MenuBo;
import com.cpop.system.business.bo.MenuListBo;
@ -57,6 +58,17 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
MenuRouteVo.class);
return buildMenuRouteTree(list);
} else {
//一般管理员
if (StringUtils.equals(loginStaffInfo.getString("roleId"), InitRoleEnum.SUPER_MALL_ROLE.getId())) {
return buildMenuRouteTree(this.listAs(QueryWrapper.create()
.where(MENU.TYPE.in(0, 1))
//构建公共菜单与特有菜单
.and(MENU.USER_TYPE.eq(user.getUserType()))
.where(MENU.STATUS.eq(1))
.and(MENU.NAME.notIn(Constants.HIDE_MENU.split(",")))
.orderBy(MENU.ORDER_NO.asc()),
MenuRouteVo.class));
}else {
return buildMenuRouteTree(this.listAs(QueryWrapper.create()
.select(MENU.ALL_COLUMNS)
.leftJoin(ROLE_MENU).on(ROLE_MENU.MENU_ID.eq(MENU.ID))
@ -71,6 +83,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
MenuRouteVo.class));
}
}
}
@Override
public List<MenuVo> getSysMenuTreeList(MenuListBo bo) {