店铺和用户关联
This commit is contained in:
parent
a8505167df
commit
5a40e0ad27
@ -1622,7 +1622,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
if (StrUtil.isNotBlank(currency_id)) {
|
||||
user_intl = "+" + currency_id;
|
||||
} else {
|
||||
user_intl = CommonConstant.IDD_ZH_CN;
|
||||
user_intl = CommonConstant.IDD_ZH_CN; // +86
|
||||
}
|
||||
|
||||
user_mobile = PhoneNumberUtils.convWithIDDCodePhoneNumber(user_mobile, user_intl);
|
||||
@ -1711,7 +1711,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
if (user_base_row != null) {
|
||||
throw new ApiException(_("用户已经存在,请更换用户名"));
|
||||
} else {
|
||||
// 用户尚未注册,立即新增用户基本信息和用户附加信息
|
||||
// 检测到用户尚未注册,立即新增用户基本信息和用户附加信息
|
||||
String user_nickname = Convert.toStr(userInfo.get("user_nickname"), user_account);
|
||||
Integer user_state = Convert.toInt(userInfo.get("user_state"), 2);
|
||||
String user_key = IdUtil.simpleUUID();
|
||||
@ -1725,7 +1725,6 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
user_password = SecureUtil.md5(user_salt + SecureUtil.md5(user_password));
|
||||
user_base_reg_row.setUser_password(user_password);
|
||||
// user_base_reg_row.setUser_password((BCrypt.hashpw(user_password)));
|
||||
|
||||
user_base_reg_row.setUser_nickname(user_nickname);
|
||||
user_base_reg_row.setUser_state(user_state);
|
||||
user_base_reg_row.setUser_key(user_key);
|
||||
@ -1736,6 +1735,10 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
user_base_reg_row.setUser_is_admin(userIsAdmin);// 用户类型:0-普通用户;1-管理员;2-入驻商户;默认是普通用户
|
||||
user_base_reg_row.setUser_type(userType); // 用户类型:0-普通用户;1-管理员;2-入驻商户;默认是普通用户
|
||||
|
||||
if (CommonConstant.USER_TYPE_MCH.equals(userIsAdmin)) {
|
||||
user_base_reg_row.setRights_group_id("2,24");// 店铺管理员,店铺 权限
|
||||
}
|
||||
|
||||
if (!saveOrUpdate(user_base_reg_row)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
@ -1744,7 +1747,6 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
|
||||
Integer user_id = user_base_reg_row.getUser_id();
|
||||
String ip = HttpServletUtils.getClientIpAddr();
|
||||
|
||||
user_login_reg_row.setUser_id(user_id);
|
||||
user_login_reg_row.setUser_reg_datetime(cur_date);
|
||||
user_login_reg_row.setUser_reg_date(DateUtil.parse(DateUtil.today()));
|
||||
@ -1769,15 +1771,14 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
user_info_reg_row.setUser_id(user_id);
|
||||
user_info_reg_row.setUser_gender(user_gender);
|
||||
user_info_reg_row.setUser_intl(user_intl);
|
||||
|
||||
String user_avatar = Convert.toStr(userInfo.get("user_avatar"), "");
|
||||
String user_notename = Convert.toStr(userInfo.get("user_notename"), "");
|
||||
|
||||
user_info_reg_row.setUser_email(StrUtil.isNotBlank(user_email) ? user_email : "");
|
||||
user_info_reg_row.setUser_avatar(user_avatar);
|
||||
user_info_reg_row.setUser_birthday(DateUtil.parse("2000-01-01"));
|
||||
user_info_reg_row.setUser_notename(user_notename);
|
||||
|
||||
|
||||
// todo 会员卡号
|
||||
user_info_reg_row.setUser_level_card("");
|
||||
if (!accountUserInfoService.saveOrUpdate(user_info_reg_row)) {
|
||||
@ -2746,28 +2747,23 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
// 流程:通过手机号检查是否有绑定关系?没有就直接注册,有就直接登录,返回登录后的所有信息,附加是否已经申请入驻标记?
|
||||
// 商家入驻账号,都是需要手机号绑定的。账号组成:1000000+(数字加法)自增ID,密码随机6位数
|
||||
if (StrUtil.isBlank(user_mobile) || StrUtil.isBlank(verify_code)) {
|
||||
// throw new ApiException(_("缺少必要参数!"));
|
||||
return CommonResult.failed(_("缺少必要参数!"));
|
||||
}
|
||||
|
||||
if (!PhoneNumberUtils.checkPhoneNumber(user_mobile)) {
|
||||
// throw new ApiException(_("请输入正确的手机号!"));
|
||||
return CommonResult.failed(_("请输入正确的手机号!"));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(rand_key)) {
|
||||
// throw new ApiException(_("程序非法请求, 检测验证码键值!"));
|
||||
return CommonResult.failed(_("程序非法请求, 检测验证码键值!"));
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(verify_code)) {
|
||||
// throw new ApiException(_("请输入验证码!"));
|
||||
return CommonResult.failed(_("请输入验证码!"));
|
||||
}
|
||||
|
||||
// rmk 为什么随机数和手机号一致?
|
||||
if (ObjectUtil.notEqual(user_mobile, rand_key)) {
|
||||
// throw new ApiException(_("非法数据,或者提交超时,请刷新页面重新提交!"));
|
||||
return CommonResult.failed(_("非法数据,或者提交超时,请刷新页面重新提交!"));
|
||||
}
|
||||
|
||||
@ -2775,7 +2771,6 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl<AccountUserBaseM
|
||||
// if (!checkVerifyCode(verifyMobile, verify_code)) {
|
||||
if (!"9999".equals(verify_code)) {
|
||||
// TODO 切换到正式平台
|
||||
// throw new ApiException(_("验证码错误!"));
|
||||
return CommonResult.failed(_("验证码错误!"));
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ import java.text.ParseException;
|
||||
*/
|
||||
public class UserInfoService {
|
||||
|
||||
private HttpServletRequest request;
|
||||
private final HttpServletRequest request;
|
||||
|
||||
public UserInfoService(HttpServletRequest request) {
|
||||
this.request = request;
|
||||
@ -57,7 +57,7 @@ public class UserInfoService {
|
||||
if (StrUtil.isBlank(token)) {
|
||||
token = this.request.getParameter("perm_key");
|
||||
}
|
||||
if (StrUtil.isEmpty(token)) {
|
||||
if (StrUtil.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -263,14 +263,6 @@
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
@ -284,20 +276,6 @@
|
||||
<artifactId>fluent-hc</artifactId>
|
||||
<version>4.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpcore</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.suisung.mall</groupId>-->
|
||||
<!-- <artifactId>mall-account</artifactId>-->
|
||||
<!-- <version>1.0-SNAPSHOT</version>-->
|
||||
<!-- <scope>compile</scope>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!--打票机 使用的库 结束-->
|
||||
<dependency>
|
||||
|
||||
@ -4,6 +4,8 @@ import com.suisung.mall.common.api.CommonResult;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @program: mall-suite
|
||||
@ -13,7 +15,15 @@ import java.security.NoSuchAlgorithmException;
|
||||
**/
|
||||
public interface KdApiExpressSearchService {
|
||||
|
||||
CommonResult select(String order_id, String stock_bill_id) throws UnsupportedEncodingException, NoSuchAlgorithmException;
|
||||
CommonResult select(String order_id, String stock_bill_id);
|
||||
|
||||
CommonResult returnLogistics(String return_tracking_name, String return_tracking_number, String order_id) throws UnsupportedEncodingException, NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* 根据订单号,获取快递鸟的物流轨迹(注意)
|
||||
*
|
||||
* @param order_id
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getLogisticsTraces(String order_id);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.suisung.mall.shop.api.service.impl;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.PhoneUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
@ -10,6 +11,7 @@ import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
import com.suisung.mall.common.modules.base.ShopBaseExpress;
|
||||
import com.suisung.mall.common.modules.order.ShopOrderDeliveryAddress;
|
||||
@ -31,6 +33,7 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -44,8 +47,8 @@ import java.util.Map;
|
||||
@Service
|
||||
public class KdApiExpressSearchServiceImpl implements KdApiExpressSearchService {
|
||||
|
||||
public static Map<String, String> stateMap = new HashMap<String, String>();
|
||||
private static final Logger logger = LoggerFactory.getLogger(KdApiExpressSearchServiceImpl.class);
|
||||
public static Map<String, String> stateMap = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
stateMap.put("0", "没有记录");
|
||||
@ -70,6 +73,7 @@ public class KdApiExpressSearchServiceImpl implements KdApiExpressSearchService
|
||||
stateMap.put("412", "快递柜或驿站超时未取");
|
||||
}
|
||||
|
||||
private final String request_url = "https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
|
||||
@Autowired
|
||||
private ShopOrderLogisticsService shopOrderLogisticsService;
|
||||
@Autowired
|
||||
@ -80,9 +84,8 @@ public class KdApiExpressSearchServiceImpl implements KdApiExpressSearchService
|
||||
private ShopBaseExpressService shopBaseExpressService;
|
||||
@Autowired
|
||||
private ShopOrderReturnService shopOrderReturnService;
|
||||
private final String request_url = "https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
|
||||
|
||||
public String orderOnlineByJson(String order_tracking_number, String shipperCode, String CustomerName) throws UnsupportedEncodingException, NoSuchAlgorithmException {
|
||||
public String orderOnlineByJson(String order_tracking_number, String shipperCode, String CustomerName) {
|
||||
//组装应用级参数
|
||||
String RequestData = "{" +
|
||||
"'OrderCode': ''," +
|
||||
@ -94,16 +97,21 @@ public class KdApiExpressSearchServiceImpl implements KdApiExpressSearchService
|
||||
Map params = new HashMap<>();
|
||||
String appId = accountBaseConfigService.getConfig("kuaidiniao_e_business_id");
|
||||
String appKey = accountBaseConfigService.getConfig("kuaidiniao_app_key");
|
||||
try {
|
||||
|
||||
params.put("RequestData", urlEncoder(RequestData, "UTF-8"));
|
||||
params.put("EBusinessID", appId);
|
||||
params.put("RequestType", "8002");//快递查询接口指令8002/地图版快递查询接口指令8004
|
||||
String dataSign = encrypt(RequestData, appKey, "UTF-8");
|
||||
params.put("DataSign", urlEncoder(dataSign, "UTF-8"));
|
||||
params.put("DataType", "2");
|
||||
String result = HttpUtil.post(request_url, params);
|
||||
params.put("RequestData", urlEncoder(RequestData, "UTF-8"));
|
||||
params.put("EBusinessID", appId);
|
||||
params.put("RequestType", "8002");//快递查询接口指令8002/地图版快递查询接口指令8004
|
||||
String dataSign = encrypt(RequestData, appKey, "UTF-8");
|
||||
params.put("DataSign", urlEncoder(dataSign, "UTF-8"));
|
||||
params.put("DataType", "2");
|
||||
String result = HttpUtil.post(request_url, params);
|
||||
|
||||
return result;
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,7 +173,7 @@ public class KdApiExpressSearchServiceImpl implements KdApiExpressSearchService
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult select(String order_id, String stock_bill_id) throws UnsupportedEncodingException, NoSuchAlgorithmException {
|
||||
public CommonResult select(String order_id, String stock_bill_id) {
|
||||
QueryWrapper<ShopOrderLogistics> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", order_id);
|
||||
queryWrapper.eq("stock_bill_id", stock_bill_id);
|
||||
@ -182,13 +190,13 @@ public class KdApiExpressSearchServiceImpl implements KdApiExpressSearchService
|
||||
ShopOrderDeliveryAddress orderDeliveryAddress = shopOrderDeliveryAddressService.get(order_id);
|
||||
String phone_number;
|
||||
try {
|
||||
phone_number = orderDeliveryAddress.getDa_mobile().substring(7, 11);
|
||||
phone_number = orderDeliveryAddress.getDa_mobile().substring(7, 11); // 手机号码末尾4位数
|
||||
} catch (Exception e) {
|
||||
throw new ApiException(I18nUtil._("收货信息中手机号填写错误"));
|
||||
}
|
||||
|
||||
for (ShopOrderLogistics shopOrderLogistic : shopOrderLogistics) {
|
||||
String order_tracking_number = shopOrderLogistic.getOrder_tracking_number();
|
||||
String order_tracking_number = shopOrderLogistic.getOrder_tracking_number(); // 物流运单号
|
||||
logistics_info_str = orderOnlineByJson(order_tracking_number, shopOrderLogistic.getLogistics_number(), phone_number);
|
||||
JSONObject logistics_info = JSONUtil.parseObj(logistics_info_str);
|
||||
String StateEx = (String) logistics_info.get("StateEx");
|
||||
@ -214,6 +222,64 @@ public class KdApiExpressSearchServiceImpl implements KdApiExpressSearchService
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String, Object>> getLogisticsTraces(String order_id) {
|
||||
QueryWrapper<ShopOrderLogistics> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("order_id", order_id);
|
||||
queryWrapper.eq("logistics_enable", CommonConstant.Enable);
|
||||
|
||||
List<ShopOrderLogistics> shopOrderLogistics = shopOrderLogisticsService.find(queryWrapper);
|
||||
if (CollUtil.isEmpty(shopOrderLogistics)) {
|
||||
logger.warn(I18nUtil._("未找到发货记录"));
|
||||
return null;
|
||||
}
|
||||
|
||||
ShopOrderDeliveryAddress orderDeliveryAddress = shopOrderDeliveryAddressService.get(order_id);
|
||||
String phone_number;
|
||||
try {
|
||||
phone_number = orderDeliveryAddress.getDa_mobile().substring(7, 11); // 手机号码末尾4位数
|
||||
} catch (Exception e) {
|
||||
logger.info(I18nUtil._("收货信息中手机号填写错误"));
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> retList = new ArrayList<>();
|
||||
for (ShopOrderLogistics shopOrderLogistic : shopOrderLogistics) {
|
||||
Map<String, Object> resultMap = new HashMap();
|
||||
String order_tracking_number = shopOrderLogistic.getOrder_tracking_number(); // 物流运单号
|
||||
String logistics_info_str = orderOnlineByJson(order_tracking_number, shopOrderLogistic.getLogistics_number(), phone_number);
|
||||
if (StrUtil.isBlank(logistics_info_str)) {
|
||||
logger.info(I18nUtil._("物流信息获取失败"));
|
||||
continue;
|
||||
}
|
||||
|
||||
JSONObject logistics_info = JSONUtil.parseObj(logistics_info_str);
|
||||
if (ObjectUtil.isNull(logistics_info)) {
|
||||
logger.info(I18nUtil._("转换物流信息获取失败"));
|
||||
continue;
|
||||
}
|
||||
String StateEx = (String) logistics_info.get("StateEx");
|
||||
Integer state = logistics_info.get("State", Integer.class);
|
||||
if (state == null || state.equals(0)) {
|
||||
String reason = logistics_info.get("Reason", String.class);
|
||||
logger.info(I18nUtil._("非系统错误,请联系管理员检查物流配置项,或检查发货信息是否真实有效!错误信息:{" + reason + "}"));
|
||||
continue;
|
||||
}
|
||||
|
||||
resultMap.put("shipperCode", logistics_info.get("ShipperCode"));
|
||||
resultMap.put("logisticCode", logistics_info.get("LogisticCode"));
|
||||
resultMap.put("state", logistics_info.get("State"));
|
||||
resultMap.put("stateEx", StateEx);
|
||||
resultMap.put("express_state", stateMap.get(StateEx));
|
||||
resultMap.put("traces", logistics_info.get("Traces"));
|
||||
|
||||
retList.add(resultMap);
|
||||
}
|
||||
|
||||
return retList;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult returnLogistics(String return_tracking_name, String return_tracking_number, String order_id) throws UnsupportedEncodingException, NoSuchAlgorithmException {
|
||||
QueryWrapper<ShopBaseExpress> wrapper = new QueryWrapper<>();
|
||||
|
||||
@ -24,24 +24,6 @@ public class IpUtil implements ApplicationRunner {
|
||||
|
||||
private static Searcher searcher = null;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
try {
|
||||
log.info("开始加载 ip2region 数据文件");
|
||||
|
||||
//Resource resource = new ClassPathResource("static/ip/ip2region.xdb");
|
||||
//InputStream inputStream = resource.getInputStream()
|
||||
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("static/ip/ip2region.xdb");
|
||||
byte[] bytes = new byte[inputStream.available()];
|
||||
inputStream.read(bytes);
|
||||
inputStream.close();
|
||||
searcher = Searcher.newWithBuffer(bytes);
|
||||
log.info("成功加载 ip2region 数据文件。");
|
||||
} catch (IOException e) {
|
||||
log.error("加载 ip2region 失败。{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRegion(String ip) {
|
||||
if (Objects.isNull(searcher)) {
|
||||
log.error("IP2RegionUtils 没有成功加载数据文件");
|
||||
@ -50,7 +32,7 @@ public class IpUtil implements ApplicationRunner {
|
||||
try {
|
||||
return searcher.search(ip);
|
||||
} catch (Exception e) {
|
||||
log.error("IP 格式错误:{}", e.getMessage());
|
||||
log.error("IP 格式错误:{}", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -77,4 +59,22 @@ public class IpUtil implements ApplicationRunner {
|
||||
|
||||
return districtVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
try {
|
||||
log.info("开始加载 ip2region 数据文件");
|
||||
|
||||
//Resource resource = new ClassPathResource("static/ip/ip2region.xdb");
|
||||
//InputStream inputStream = resource.getInputStream()
|
||||
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("static/ip/ip2region.xdb");
|
||||
byte[] bytes = new byte[inputStream.available()];
|
||||
inputStream.read(bytes);
|
||||
inputStream.close();
|
||||
searcher = Searcher.newWithBuffer(bytes);
|
||||
log.info("成功加载 ip2region 数据文件。");
|
||||
} catch (IOException e) {
|
||||
log.error("加载 ip2region 失败。{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7992,8 +7992,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
public BigDecimal getOrderPaymentAmount(Integer order_state_id, Integer order_is_paid, Integer store_id, Integer subsite_id, BigInteger order_time) {
|
||||
|
||||
Map orderPaymentAmount = shopOrderBaseMapper.getOrderPaymentAmount(order_state_id, order_is_paid, store_id, subsite_id, order_time);
|
||||
|
||||
if (orderPaymentAmount.get("paymentAmount") == null) {
|
||||
if (orderPaymentAmount == null || orderPaymentAmount.get("paymentAmount") == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
|
||||
@ -263,7 +263,6 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean ifSupplierMarket() {
|
||||
|
||||
@ -1470,7 +1469,6 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
return row;
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommonResult enable() {
|
||||
@ -2984,8 +2982,6 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
|
||||
// 新增 shop_store_base,shop_store_info,shop_store_company, shop_store_employee 待补充
|
||||
|
||||
String storeFacadeImage = shopMerchEntry.getFront_facade_image();
|
||||
@ -3015,7 +3011,6 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
shopStoreBase.setStore_end_time(System.currentTimeMillis() + 1000L * 60 * 60 * 24 * 365 * 5); // 5年
|
||||
if (!save(shopStoreBase)) {
|
||||
logger.error("生成店铺:新增店铺基本信息失败");
|
||||
// return Pair.of(0, "新增店铺失败");
|
||||
throw new ApiException(I18nUtil._("新增店铺失败"));
|
||||
}
|
||||
// 保存后店铺Id
|
||||
@ -3111,7 +3106,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
ShopStoreEmployee shopStoreEmployee = new ShopStoreEmployee();
|
||||
shopStoreEmployee.setStore_id(storeId);
|
||||
shopStoreEmployee.setUser_id(userId);
|
||||
shopStoreEmployee.setRights_group_id("1"); // 店铺管理员
|
||||
shopStoreEmployee.setRights_group_id("2,24"); // 店铺管理员,店铺
|
||||
shopStoreEmployee.setEmployee_is_admin(CommonConstant.Enable);
|
||||
shopStoreEmployee.setEmployee_is_kefu(CommonConstant.Enable);
|
||||
shopStoreEmployeeService.save(shopStoreEmployee);
|
||||
@ -3120,6 +3115,9 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
throw new ApiException(I18nUtil._("新增店铺员工失败"));
|
||||
}
|
||||
|
||||
// 关联店铺到用户,给用户增加店铺管理员权限
|
||||
initShopKeeperRightsGroup(userId, storeId);
|
||||
|
||||
return Pair.of(storeId, "新增成功");
|
||||
} catch (Exception e) {
|
||||
logger.error("生成店铺失败", e);
|
||||
@ -3127,6 +3125,132 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化店长(店铺管理员)的权限组
|
||||
*
|
||||
* @param userId
|
||||
* @param storeId
|
||||
*/
|
||||
private void initShopKeeperRightsGroup(Integer userId, Integer storeId) {
|
||||
if (ObjectUtil.isNull(userId) || ObjectUtil.isNull(storeId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//初始化默认权限
|
||||
Page<Serializable> page = shopStoreEmployeeRightsBaseService.listKey(new QueryWrapper<>(), 1, ConfigConstant.MAX_LIST_NUM);
|
||||
|
||||
List<Integer> rights_group_rights_ids = Convert.toList(Integer.class, page.getRecords());
|
||||
List<ShopStoreEmployeeRightsGroup> shopStoreEmployeeRightsGroups = new ArrayList<>();
|
||||
String str_rights_group_rights_ids = CollUtil.join(rights_group_rights_ids, ",");
|
||||
|
||||
ShopStoreEmployeeRightsGroup shopManager = new ShopStoreEmployeeRightsGroup();
|
||||
shopManager.setStore_id(storeId);
|
||||
shopManager.setRights_group_rights_ids(str_rights_group_rights_ids);
|
||||
shopManager.setRights_group_name(I18nUtil._("店铺管理员")); //Store Owner
|
||||
shopManager.setRights_group_rights_data(""); //Store Owner
|
||||
shopStoreEmployeeRightsGroups.add(shopManager);
|
||||
|
||||
ShopStoreEmployeeRightsGroup operationsManager = new ShopStoreEmployeeRightsGroup();
|
||||
operationsManager.setStore_id(storeId);
|
||||
operationsManager.setRights_group_rights_ids(str_rights_group_rights_ids);
|
||||
operationsManager.setRights_group_name(I18nUtil._("运营经理")); //Store Owner
|
||||
operationsManager.setRights_group_rights_data(""); //Store Owner
|
||||
shopStoreEmployeeRightsGroups.add(operationsManager);
|
||||
|
||||
ShopStoreEmployeeRightsGroup orderReviewer = new ShopStoreEmployeeRightsGroup();
|
||||
orderReviewer.setStore_id(storeId);
|
||||
orderReviewer.setRights_group_rights_ids(str_rights_group_rights_ids);
|
||||
orderReviewer.setRights_group_name(I18nUtil._("订单审核员")); //Store Owner
|
||||
orderReviewer.setRights_group_rights_data(""); //Store Owner
|
||||
shopStoreEmployeeRightsGroups.add(orderReviewer);
|
||||
|
||||
ShopStoreEmployeeRightsGroup financialAuditor = new ShopStoreEmployeeRightsGroup();
|
||||
financialAuditor.setStore_id(storeId);
|
||||
financialAuditor.setRights_group_rights_ids(str_rights_group_rights_ids);
|
||||
financialAuditor.setRights_group_name(I18nUtil._("财务审核员")); //Store Owner
|
||||
financialAuditor.setRights_group_rights_data(""); //Store Owner
|
||||
shopStoreEmployeeRightsGroups.add(financialAuditor);
|
||||
|
||||
ShopStoreEmployeeRightsGroup shippingAuditor = new ShopStoreEmployeeRightsGroup();
|
||||
shippingAuditor.setStore_id(storeId);
|
||||
shippingAuditor.setRights_group_rights_ids(str_rights_group_rights_ids);
|
||||
shippingAuditor.setRights_group_name(I18nUtil._("发货审核员")); //Store Owner
|
||||
shippingAuditor.setRights_group_rights_data(""); //Store Owner
|
||||
shopStoreEmployeeRightsGroups.add(shippingAuditor);
|
||||
|
||||
ShopStoreEmployeeRightsGroup businessManager = new ShopStoreEmployeeRightsGroup();
|
||||
businessManager.setStore_id(storeId);
|
||||
businessManager.setRights_group_rights_ids(str_rights_group_rights_ids);
|
||||
businessManager.setRights_group_name(I18nUtil._("业务经理")); //Store Owner
|
||||
businessManager.setRights_group_rights_data(""); //Store Owner
|
||||
shopStoreEmployeeRightsGroups.add(businessManager);
|
||||
|
||||
ShopStoreEmployeeRightsGroup warehouseManager = new ShopStoreEmployeeRightsGroup();
|
||||
warehouseManager.setStore_id(storeId);
|
||||
warehouseManager.setRights_group_rights_ids(str_rights_group_rights_ids);
|
||||
warehouseManager.setRights_group_name(I18nUtil._("仓库管理员")); //Store Owner
|
||||
warehouseManager.setRights_group_rights_data(""); //Store Owner
|
||||
shopStoreEmployeeRightsGroups.add(warehouseManager);
|
||||
|
||||
ShopStoreEmployeeRightsGroup dataMaintainer = new ShopStoreEmployeeRightsGroup();
|
||||
dataMaintainer.setStore_id(storeId);
|
||||
dataMaintainer.setRights_group_rights_ids(str_rights_group_rights_ids);
|
||||
dataMaintainer.setRights_group_name(I18nUtil._("资料维护员")); //Store Owner
|
||||
dataMaintainer.setRights_group_rights_data(""); //Store Owner
|
||||
shopStoreEmployeeRightsGroups.add(dataMaintainer);
|
||||
|
||||
ShopStoreEmployeeRightsGroup customerService = new ShopStoreEmployeeRightsGroup();
|
||||
customerService.setStore_id(storeId);
|
||||
customerService.setRights_group_rights_ids(str_rights_group_rights_ids);
|
||||
customerService.setRights_group_name(I18nUtil._("客服")); //Store Owner
|
||||
customerService.setRights_group_rights_data(""); //Store Owner
|
||||
shopStoreEmployeeRightsGroups.add(customerService);
|
||||
|
||||
ShopStoreEmployeeRightsGroup extension1 = new ShopStoreEmployeeRightsGroup();
|
||||
extension1.setStore_id(storeId);
|
||||
extension1.setRights_group_rights_ids(str_rights_group_rights_ids);
|
||||
extension1.setRights_group_name(I18nUtil._("扩展1")); //Store Owner
|
||||
extension1.setRights_group_rights_data(""); //Store Owner
|
||||
shopStoreEmployeeRightsGroups.add(extension1);
|
||||
|
||||
ShopStoreEmployeeRightsGroup extension2 = new ShopStoreEmployeeRightsGroup();
|
||||
extension2.setStore_id(storeId);
|
||||
extension2.setRights_group_rights_ids(str_rights_group_rights_ids);
|
||||
extension2.setRights_group_name(I18nUtil._("扩展2")); //Store Owner
|
||||
extension2.setRights_group_rights_data(""); //Store Owner
|
||||
shopStoreEmployeeRightsGroups.add(extension2);
|
||||
|
||||
if (!shopStoreEmployeeRightsGroupService.saveOrUpdate(shopStoreEmployeeRightsGroups)) {
|
||||
throw new ApiException(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
List<Integer> rights_group_id = shopStoreEmployeeRightsGroups.stream().map(s -> s.getRights_group_id()).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(rights_group_id)) {
|
||||
// 初始化雇员信息
|
||||
ShopStoreEmployee shopStoreEmployee = new ShopStoreEmployee();
|
||||
shopStoreEmployee.setUser_id(userId);
|
||||
shopStoreEmployee.setStore_id(storeId);
|
||||
shopStoreEmployee.setRights_group_id(CollUtil.join(rights_group_id, ","));
|
||||
shopStoreEmployee.setEmployee_is_admin(CommonConstant.USER_TYPE_ADMIN);
|
||||
|
||||
if (!shopStoreEmployeeService.saveOrUpdate(shopStoreEmployee)) {
|
||||
throw new ApiException(I18nUtil._("设置店铺管理员权限失败"));
|
||||
}
|
||||
|
||||
// 添加店铺到用户
|
||||
AccountUserBase accountUserBase = new AccountUserBase();
|
||||
accountUserBase.setUser_id(userId);
|
||||
accountUserBase.setStore_ids(String.valueOf(storeId));
|
||||
|
||||
// todo 初始化商家角色(默认 店铺管理员角色)
|
||||
String user_rights_group_id = Convert.toStr(rights_group_id.get(0));
|
||||
accountUserBase.setRights_group_id(StrUtil.join(",", user_rights_group_id, 2));
|
||||
if (!accountService.saveOrUpdateUserBase(accountUserBase)) {
|
||||
throw new ApiException(I18nUtil._("店铺关联到用户失败"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据店铺名称判断店铺是否存在
|
||||
*
|
||||
@ -3176,7 +3300,6 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
return tree;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归构建tree
|
||||
*
|
||||
|
||||
@ -164,4 +164,10 @@ esign:
|
||||
app_id: 7439053575
|
||||
app_secret: 8da2e1eeeaf88e09bcf432a2fdd3e4d7
|
||||
app_rsa: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiC
|
||||
debug: false
|
||||
esign_prod:
|
||||
server_url: https://openapi.esign.cn
|
||||
app_id: 5111986290
|
||||
app_secret: 4408a0395464596cf7d33dda5f9c7608
|
||||
app_rsa: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApzK8BGqUdq9eufyPieCux2bMuKnXHQXgCT2kVcHqwFW1LqZMxm/npuf94C8XLK481klD15WPTVi5YUrqnXYZpIawbuH1+2bfHnZL4aSdZ+QUvlol2WLigoxlgPU9gFYWj/ykovQKi78myWbrIzaM6VJxB6RSJKBVzxm2v8M93J73S8btT7E/RRBtX+dGP7In0PpTwugsHG/w7NQ/e3budt4FLIobGzZT26GkuQ6k8fme6M+aAWgfmQIEGi+a8HLl8hP21wHHCxLJKHxxH/OADQGnzRiK632yaXmGD9/cj2xo/6zzNKDkHK9Ud64E7Pj2LrZPBaXPoxhLqJ7j6v6MgQIDAQAB
|
||||
debug: false
|
||||
Loading…
Reference in New Issue
Block a user