diff --git a/mall-account/src/main/java/com/suisung/mall/account/controller/LoginController.java b/mall-account/src/main/java/com/suisung/mall/account/controller/LoginController.java index 6d8ca2c7..b32e4445 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/controller/LoginController.java +++ b/mall-account/src/main/java/com/suisung/mall/account/controller/LoginController.java @@ -46,6 +46,17 @@ public class LoginController extends BaseControllerImpl { @Autowired private UserInfoService userInfoService; + /** + * 移动端登录 + */ + @RequestMapping(value = "/testcase", method = RequestMethod.GET) + public Object testcase() { + Map arg = new HashMap(); + arg.put("password", "HzMk23"); + + return accountUserBaseService.sendSmsMessage("", "SMS_481085172", arg); + } + @ApiOperation(value = "登录以后返回token") @ApiImplicitParams({ @ApiImplicitParam(name = "user_account", value = "账号", paramType = "query", required = false, dataType = "String"), @@ -115,7 +126,7 @@ public class LoginController extends BaseControllerImpl { } /** - * 注册后直接登录 + * (用户端)注册后直接登录 * * @param user_account * @param user_email diff --git a/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java b/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java index c3379867..5bd6f41d 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java +++ b/mall-account/src/main/java/com/suisung/mall/account/service/AccountUserBaseService.java @@ -188,4 +188,14 @@ public interface AccountUserBaseService extends IBaseService { * @return */ CommonResult doForgetPassword(String userAccountOrMobile, String verifyCode, String newPassword); + + /** + * 发送短信 + * + * @param mobile 发送的手机号码 + * @param templateCode 模版编号 + * @param msgArgs 模版的参数key与值 + * @return + */ + Boolean sendSmsMessage(String mobile, String templateCode, Map msgArgs); } diff --git a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java index 7acd3632..b6274fa7 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java +++ b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java @@ -1607,47 +1607,49 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl userInfo = new HashMap<>(); - userInfo.put("user_account", com.suisung.mall.common.utils.StringUtils.genLklOrderNo(4));// 时间 yyyyMMddHHmmss + 4位随机数 + userInfo.put("user_account", user_mobile);// 时间 yyyyMMddHHmmss + 4位随机数 com.suisung.mall.common.utils.StringUtils.genLklOrderNo(4) userInfo.put("user_mobile", user_mobile); userInfo.put("user_is_admin", CommonConstant.USER_TYPE_MCH); // 商家入驻注册 -// userInfo.put("verify_code", verifyCode); - // 密码要随机数 + // 随机数明文密码 String user_password = com.suisung.mall.common.utils.StringUtils.random(6, com.suisung.mall.common.utils.StringUtils.RandomType.STRING); userInfo.put("user_password", user_password); userInfo.put("is_admin", CommonConstant.USER_TYPE_MCH); // 商家入驻注册 @@ -2858,7 +2858,12 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl smsArgs = new HashMap<>(); + smsArgs.put("password", user_password); + sendSmsMessage(user_mobile, "SMS_481085172", smsArgs); } Map params = new HashMap<>(); @@ -3248,5 +3253,58 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl msgArgs) { + //读取sms配置信息 + String service_user_id = accountBaseConfigService.getConfig("service_user_id"); + String service_app_key = accountBaseConfigService.getConfig("service_app_key"); + mobile = StrUtil.removePrefix(mobile, CommonConstant.IDD_ZH_CN); + + SmsDto smsDto = new SmsDto(); + smsDto.setSmsType(accountBaseConfigService.getConfig("sms_type", 1)); //默认短信通道 + smsDto.setSmsSign(accountBaseConfigService.getConfig("sms_sign", "")); //默认短信通道 + smsDto.setServiceUserId(service_user_id); + smsDto.setServiceAppKey(service_app_key); + + //其它通道,要赋值通道信息 appid 以及 key + String aliyunSmsAccessKeyId = accountBaseConfigService.getConfig("aliyun_sms_access_key_id"); + String aliyunSmsAccessKeySecret = accountBaseConfigService.getConfig("aliyun_sms_access_key_secret"); + String aliyunSmsRegionId = accountBaseConfigService.getConfig("aliyun_sms_region_id"); + + smsDto.setAliyunSmsAccessKeyId(aliyunSmsAccessKeyId); + smsDto.setAliyunSmsAccessKeySecret(aliyunSmsAccessKeySecret); + smsDto.setAliyunSmsRegionId(aliyunSmsRegionId); + + String huaweiSmsKey = accountBaseConfigService.getConfig("huawei_sms_access_key"); + String huaweiSmsKeySecret = accountBaseConfigService.getConfig("huawei_sms_access_secret"); + smsDto.setHuaweiSmsKey(huaweiSmsKey); + smsDto.setHuaweiSmsKeySecret(huaweiSmsKeySecret); + + // 短信应用SDK AppID 1400开头 + Integer tengxunAppId = accountBaseConfigService.getConfig("tengxun_sms_app_id", 0); + // 短信应用SDK AppKey + String tengxunAppkey = accountBaseConfigService.getConfig("tengxun_sms_app_key"); + smsDto.setTengxunAppId(tengxunAppId); + smsDto.setTengxunAppkey(tengxunAppkey); + smsDto.setTengxunTemplateId(1); //短信模板ID + + smsDto.setMobile(mobile); + String aliyunSmsSign = accountBaseConfigService.getConfig("aliyun_sms_sign"); + smsDto.setSmsSign(aliyunSmsSign); + smsDto.setTemplateCode(templateCode); + // smsDto.setContent("您的验证码为:${code},请勿泄露于他人!"); + smsDto.setParamMap(msgArgs); //传入模板对应参数 + + try { + ThirdUtil.send(smsDto); + return true; + } catch (Exception e) { + logger.error("发送短信失败:", e); + return false; + } + + + } + } diff --git a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBindConnectServiceImpl.java b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBindConnectServiceImpl.java index 1832da2f..bc08fccb 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBindConnectServiceImpl.java +++ b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBindConnectServiceImpl.java @@ -78,7 +78,14 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq("bind_id", bind_id) .eq("bind_type", bind_type) @@ -89,6 +96,8 @@ public class AccountUserBindConnectServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("bind_id", bindId).eq("bind_type", bindType); - if (userType != null) { + queryWrapper.eq("bind_id", bindId).eq("bind_type", bindType).eq("bind_active", CommonConstant.Enable); + if (ObjectUtil.isNotEmpty(userType)) { queryWrapper.eq("user_type", userType); } diff --git a/mall-common/src/main/java/com/suisung/mall/common/modules/account/AccountUserBase.java b/mall-common/src/main/java/com/suisung/mall/common/modules/account/AccountUserBase.java index 32f5e936..cc3eb67e 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/modules/account/AccountUserBase.java +++ b/mall-common/src/main/java/com/suisung/mall/common/modules/account/AccountUserBase.java @@ -72,7 +72,7 @@ public class AccountUserBase implements Serializable { private String user_quickcode; @ApiModelProperty(value = "用户身份:0-个人身份;1-企业身份;") - private String user_type; + private Integer user_type; @ApiModelProperty(value = "公司id") private String user_company_id; diff --git a/mall-common/src/main/java/com/suisung/mall/common/utils/phone/PhoneNumberUtils.java b/mall-common/src/main/java/com/suisung/mall/common/utils/phone/PhoneNumberUtils.java index 9ba1504d..96e093cf 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/utils/phone/PhoneNumberUtils.java +++ b/mall-common/src/main/java/com/suisung/mall/common/utils/phone/PhoneNumberUtils.java @@ -10,6 +10,7 @@ import com.google.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder; import com.suisung.mall.common.constant.CommonConstant; import java.util.Locale; +import java.util.regex.Pattern; public class PhoneNumberUtils { /** @@ -66,6 +67,40 @@ public class PhoneNumberUtils { return StrUtil.startWith(phoneNumber, "+") ? phoneNumber : CommonConstant.IDD_ZH_CN + phoneNumber; } + /** + * 如果手机号码不带国家码,转换指定国家区号 + * + * @param phoneNumber 不带国际码的手机号 + * @param IDDCode + * @return + */ + public static String convWithIDDCodePhoneNumber(String phoneNumber, String IDDCode) { + if (StrUtil.isBlank(phoneNumber) + || phoneNumber.equalsIgnoreCase("null") + || phoneNumber.equalsIgnoreCase("none") + || phoneNumber.equalsIgnoreCase("nil") + || phoneNumber.equalsIgnoreCase("undefined")) { + return ""; + } + + if (isValidNumber(phoneNumber)) { + return phoneNumber; + } + + if (StrUtil.isBlank(IDDCode)) { + IDDCode = CommonConstant.IDD_ZH_CN; + } else { + if (!StrUtil.startWith(IDDCode, "+")) { + IDDCode = "+" + IDDCode; + } + + if (!isValidCountryCode(IDDCode)) { + IDDCode = CommonConstant.IDD_ZH_CN; + } + } + return IDDCode + phoneNumber; + } + /** * 去掉手机的国家码,方法不严谨 * @@ -217,4 +252,23 @@ public class PhoneNumberUtils { return phoneNumberUtil.isValidNumber(pn); } + /** + * 判断字符串是不是国际电话区号 + * + * @param code + * @return + */ + public static boolean isValidCountryCode(String code) { + // 定义正则表达式,用于匹配国际电话区号的格式 + String regex = "^\\+\\d{1,3}$"; + // 编译正则表达式 + Pattern pattern = Pattern.compile(regex); + // 检查字符串是否匹配正则表达式 + return pattern.matcher(code).matches(); + } + + public static void main(String[] args) { + System.out.println(isValidNumber("13111111111")); + } + } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractFillingFileService.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractFillingFileService.java index ac46cd45..fafe710d 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractFillingFileService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractFillingFileService.java @@ -66,4 +66,13 @@ public interface EsignContractFillingFileService { * @return */ EsignContractFillingFile getEsignContractFillingFile(String mchMobile, String templateId); + + /** + * 更改商家入驻合同关联的店铺ID + * + * @param mchMobile + * @param storeId + * @return + */ + Boolean updateContractFillingStoreId(String mchMobile, Integer storeId); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractService.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractService.java index aebeea3d..488f40f7 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignContractService.java @@ -114,4 +114,13 @@ public interface EsignContractService { * @return */ Pair checkSignFlowStatus(String mchMobile); + + /** + * 更改商家入驻合同关联的店铺ID + * + * @param mchMobile + * @param storeId + * @return + */ + Boolean updateContractStoreId(String mchMobile, Integer storeId); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractFillingFileServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractFillingFileServiceImpl.java index 6485a0c9..85865d9a 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractFillingFileServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractFillingFileServiceImpl.java @@ -10,6 +10,7 @@ package com.suisung.mall.shop.esign.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; @@ -613,4 +614,29 @@ public class EsignContractFillingFileServiceImpl extends BaseServiceImpl updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("mobile", mchMobile); + updateWrapper.set("store_id", storeId); + return update(updateWrapper); + } catch (Exception e) { + log.error("更改合同关联的店铺ID发生错误:", e); + return false; + } + } } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractServiceImpl.java index 196d7109..0b1d3b23 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractServiceImpl.java @@ -291,18 +291,14 @@ public class EsignContractServiceImpl extends BaseServiceImpl { - try { - Pair retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(esignContract.getMch_mobile()); - if (retPair.getFirst() > 0) { - // 更改合同记录表的店铺id - UpdateWrapper updateWrapper = new UpdateWrapper<>(); - updateWrapper.eq("sign_flow_id", signFlowId); - updateWrapper.set("store_id", retPair.getSecond()); - update(updateWrapper); - } - } catch (Exception e) { - log.error("店铺创建失败:", e); + + Pair retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(esignContract.getMch_mobile()); + if (retPair.getFirst() > 0) { + // 更改合同记录表的店铺id + updateContractStoreId(esignContract.getMch_mobile(), retPair.getFirst()); + esignContractFillingFileService.updateContractFillingStoreId(esignContract.getMch_mobile(), retPair.getFirst()); } + }); return new ResponseEntity<>(new JSONObject().put("code", 200).put("msg", "success").toString(), HttpStatus.OK); @@ -682,6 +678,31 @@ public class EsignContractServiceImpl extends BaseServiceImpl updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("mch_mobile", mchMobile); + updateWrapper.set("store_id", storeId); + return update(updateWrapper); + } catch (Exception e) { + log.error("更改合同关联的店铺ID发生错误:", e); + return false; + } + } + // e签宝签名相关方法 diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java index d22b22cb..f3db330f 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java @@ -2958,7 +2958,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl merchEntryInfo2StoreInfo(String mchMobile) { - Integer storeId = 0; + if (StrUtil.isBlank(mchMobile)) { logger.error("生成店铺:商家手机号不能为空"); return Pair.of(0, "商家手机号不能为空"); @@ -2982,142 +2982,148 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl districtList = shopBaseDistrictService.getFullDistrictByDistrictCode(shopMerchEntry.getCounty_id()); - shopStoreBase.setStore_district_id(shopBaseDistrictService.joinDistrict(districtList, 1, true, "/")); - shopStoreBase.setStore_area(shopBaseDistrictService.joinDistrict(districtList, 2, true, "/")); - shopStoreBase.setStore_address(shopMerchEntry.getStore_address()); - shopStoreBase.setStore_longitude(shopMerchEntry.getStore_longitude()); - shopStoreBase.setStore_latitude(shopMerchEntry.getStore_latitude()); - shopStoreBase.setStore_grade_id(1001); // 店铺等级,默认为普通店铺 - shopStoreBase.setStore_type(1);//店铺类型(ENUM): 1-卖家店铺; 2-供应商店铺 - shopStoreBase.setStore_is_open(1); - shopStoreBase.setStore_is_selfsupport(0); - shopStoreBase.setStore_o2o_flag(0); - shopStoreBase.setSubsite_id(0); - shopStoreBase.setStore_state_id(StateCode.STORE_STATE_YES);//店铺资料信息状态(ENUM):3210-待完善资料; 3220-等待审核 ; 3230-资料审核没有通过;3240-资料审核通过,待付款 - shopStoreBase.setStore_time(DateUtil.date()); - shopStoreBase.setStore_end_time(System.currentTimeMillis() + 1000L * 60 * 60 * 24 * 365 * 5); // 5年 - if (!save(shopStoreBase)) { - logger.error("生成店铺:新增店铺基本信息失败"); + String storeFacadeImage = shopMerchEntry.getFront_facade_image(); + + // shop_store_base + ShopStoreBase shopStoreBase = new ShopStoreBase(); + shopStoreBase.setUser_id(userId); // 店铺管理员用户Id + shopStoreBase.setStore_name(shopMerchEntry.getStore_name()); + shopStoreBase.setStore_category_id(shopMerchEntry.getBiz_category()); + shopStoreBase.setStore_logo(storeFacadeImage); // 临时使用门面照片做logo + + // 省市区记录有序列表 + List districtList = shopBaseDistrictService.getFullDistrictByDistrictCode(shopMerchEntry.getCounty_id()); + shopStoreBase.setStore_district_id(shopBaseDistrictService.joinDistrict(districtList, 1, true, "/")); + shopStoreBase.setStore_area(shopBaseDistrictService.joinDistrict(districtList, 2, true, "/")); + shopStoreBase.setStore_address(shopMerchEntry.getStore_address()); + shopStoreBase.setStore_longitude(shopMerchEntry.getStore_longitude()); + shopStoreBase.setStore_latitude(shopMerchEntry.getStore_latitude()); + shopStoreBase.setStore_grade_id(1001); // 店铺等级,默认为普通店铺 + shopStoreBase.setStore_type(1);//店铺类型(ENUM): 1-卖家店铺; 2-供应商店铺 + shopStoreBase.setStore_is_open(1); + shopStoreBase.setStore_is_selfsupport(0); + shopStoreBase.setStore_o2o_flag(0); + shopStoreBase.setSubsite_id(0); + shopStoreBase.setStore_state_id(StateCode.STORE_STATE_YES);//店铺资料信息状态(ENUM):3210-待完善资料; 3220-等待审核 ; 3230-资料审核没有通过;3240-资料审核通过,待付款 + shopStoreBase.setStore_time(DateUtil.date()); + 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 - storeId = shopStoreBase.getStore_id(); - - // shop_store_info - ShopStoreInfo shopStoreInfo = new ShopStoreInfo(); - shopStoreInfo.setStore_id(storeId); - shopStoreInfo.setStore_start_time(DateUtil.date()); - shopStoreInfo.setStore_end_time(DateUtil.offsetDay(DateUtil.date(), 365 * 5)); - shopStoreInfo.setStore_opening_hours("08:00"); - shopStoreInfo.setStore_close_hours("22:00"); - shopStoreInfo.setStore_discount(BigDecimal.valueOf(10));// 原价 - shopStoreInfo.setStore_tel(shopMerchEntry.getLogin_mobile()); - shopStoreInfo.setStore_banner(storeFacadeImage); - - JSONArray list = new JSONArray(); - if (StrUtil.isNotBlank(storeFacadeImage)) { - JSONObject slide = new JSONObject(); - slide.put("img", storeFacadeImage); - slide.put("name", "店铺门面照片"); - slide.put("check", true); - slide.put("url", "https://www.gpsxcs.cn"); - list.put(slide); - } - if (StrUtil.isNotBlank(shopMerchEntry.getEnvironment_image())) { - JSONObject slide = new JSONObject(); - slide.put("img", shopMerchEntry.getEnvironment_image()); - slide.put("name", "店铺环境照片"); - slide.put("check", true); - slide.put("url", "https://www.gpsxcs.cn"); - list.put(slide); - } - shopStoreInfo.setStore_slide(list.toString()); - - shopStoreInfo.setStore_address(shopMerchEntry.getStore_address()); // 包含省市区的详细地址 - shopStoreInfo.setStore_state_id(StateCode.STORE_STATE_YES); - if (!shopStoreInfoService.save(shopStoreInfo)) { - logger.error("生成店铺:新增店铺info失败"); - throw new ApiException(I18nUtil._("新增店铺失败")); - } - - // 如果商家是企业,则保存商家公司信息 - if (CommonConstant.MCH_ENTITY_TYPE_QY.equals(shopMerchEntry.getEntity_type())) { - // shop_store_company - ShopStoreCompany shopStoreCompany = new ShopStoreCompany(); - shopStoreCompany.setUser_id(userId); - shopStoreCompany.setStore_id(storeId); - - // 公司名 - shopStoreCompany.setCompany_name(shopMerchEntry.getBiz_license_company()); - shopStoreCompany.setCompany_area(shopStoreBase.getStore_area()); - shopStoreCompany.setCompany_address(shopMerchEntry.getStore_address()); - - // 营业执照 - shopStoreCompany.setBusiness_id(shopMerchEntry.getBiz_license_number()); - shopStoreCompany.setBusiness_license_electronic(shopMerchEntry.getBiz_license_image()); - - // 企业法人 - shopStoreCompany.setLegal_person(shopMerchEntry.getLegal_person_name()); - shopStoreCompany.setLegal_person_number(shopMerchEntry.getLegal_person_id_number()); - shopStoreCompany.setLegal_person_electronic(shopMerchEntry.getLegal_person_id_images()); - - // 联系人 - shopStoreCompany.setContacts_name(shopMerchEntry.getContact_name()); - shopStoreCompany.setContacts_phone(shopMerchEntry.getLogin_mobile()); - - // 银行对公账号 - shopStoreCompany.setBank_account_name(shopMerchEntry.getAccount_holder_name()); - shopStoreCompany.setBank_account_number(shopMerchEntry.getAccount_number()); - shopStoreCompany.setBank_name(shopMerchEntry.getBank_name()); - - Date today = new Date(); - - shopStoreCompany.setOrganization_code_start(today); - shopStoreCompany.setOrganization_code_end(DateUtil.offsetDay(today, 365 * 5)); - shopStoreCompany.setEstablish_date(today); - shopStoreCompany.setBusiness_licence_start(today); - shopStoreCompany.setBusiness_licence_end(DateUtil.offsetDay(today, 365 * 5)); - - shopStoreCompany.setCompany_description(""); - shopStoreCompany.setStore_class_ids(""); - shopStoreCompany.setStore_class_names(""); - shopStoreCompany.setStore_class_commission(""); - - // 待补充 - if (!shopStoreCompanyService.save(shopStoreCompany)) { - logger.error("生成店铺:新增店铺公司失败"); - throw new ApiException(I18nUtil._("新增店铺公司失败")); + throw new ApiException(I18nUtil._("新增店铺失败")); } - } + // 保存后店铺Id + Integer storeId = shopStoreBase.getStore_id(); - // shop_store_employee 店铺员工,添加管理员 - ShopStoreEmployee shopStoreEmployee = new ShopStoreEmployee(); - shopStoreEmployee.setStore_id(storeId); - shopStoreEmployee.setUser_id(userId); - shopStoreEmployee.setRights_group_id("1"); // 店铺管理员 - shopStoreEmployee.setEmployee_is_admin(CommonConstant.Enable); - shopStoreEmployee.setEmployee_is_kefu(CommonConstant.Enable); - shopStoreEmployeeService.save(shopStoreEmployee); - if (!shopStoreEmployeeService.save(shopStoreEmployee)) { - logger.error("生成店铺:新增店铺员工失败"); - throw new ApiException(I18nUtil._("新增店铺员工失败")); - } + // shop_store_info + ShopStoreInfo shopStoreInfo = new ShopStoreInfo(); + shopStoreInfo.setStore_id(storeId); + shopStoreInfo.setStore_start_time(DateUtil.date()); + shopStoreInfo.setStore_end_time(DateUtil.offsetDay(DateUtil.date(), 365 * 5)); + shopStoreInfo.setStore_opening_hours("08:00"); + shopStoreInfo.setStore_close_hours("22:00"); + shopStoreInfo.setStore_discount(BigDecimal.valueOf(10));// 原价 + shopStoreInfo.setStore_tel(shopMerchEntry.getLogin_mobile()); + shopStoreInfo.setStore_banner(storeFacadeImage); - return Pair.of(storeId, "新增成功"); + JSONArray list = new JSONArray(); + if (StrUtil.isNotBlank(storeFacadeImage)) { + JSONObject slide = new JSONObject(); + slide.put("img", storeFacadeImage); + slide.put("name", "店铺门面照片"); + slide.put("check", true); + slide.put("url", "https://www.gpsxcs.cn"); + list.put(slide); + } + if (StrUtil.isNotBlank(shopMerchEntry.getEnvironment_image())) { + JSONObject slide = new JSONObject(); + slide.put("img", shopMerchEntry.getEnvironment_image()); + slide.put("name", "店铺环境照片"); + slide.put("check", true); + slide.put("url", "https://www.gpsxcs.cn"); + list.put(slide); + } + shopStoreInfo.setStore_slide(list.toString()); + + shopStoreInfo.setStore_address(shopMerchEntry.getStore_address()); // 包含省市区的详细地址 + shopStoreInfo.setStore_state_id(StateCode.STORE_STATE_YES); + if (!shopStoreInfoService.save(shopStoreInfo)) { + logger.error("生成店铺:新增店铺info失败"); + throw new ApiException(I18nUtil._("新增店铺失败")); + } + + // 如果商家是企业,则保存商家公司信息 + if (CommonConstant.MCH_ENTITY_TYPE_QY.equals(shopMerchEntry.getEntity_type())) { + // shop_store_company + ShopStoreCompany shopStoreCompany = new ShopStoreCompany(); + shopStoreCompany.setUser_id(userId); + shopStoreCompany.setStore_id(storeId); + + // 公司名 + shopStoreCompany.setCompany_name(shopMerchEntry.getBiz_license_company()); + shopStoreCompany.setCompany_area(shopStoreBase.getStore_area()); + shopStoreCompany.setCompany_address(shopMerchEntry.getStore_address()); + + // 营业执照 + shopStoreCompany.setBusiness_id(shopMerchEntry.getBiz_license_number()); + shopStoreCompany.setBusiness_license_electronic(shopMerchEntry.getBiz_license_image()); + + // 企业法人 + shopStoreCompany.setLegal_person(shopMerchEntry.getLegal_person_name()); + shopStoreCompany.setLegal_person_number(shopMerchEntry.getLegal_person_id_number()); + shopStoreCompany.setLegal_person_electronic(shopMerchEntry.getLegal_person_id_images()); + + // 联系人 + shopStoreCompany.setContacts_name(shopMerchEntry.getContact_name()); + shopStoreCompany.setContacts_phone(shopMerchEntry.getLogin_mobile()); + + // 银行对公账号 + shopStoreCompany.setBank_account_name(shopMerchEntry.getAccount_holder_name()); + shopStoreCompany.setBank_account_number(shopMerchEntry.getAccount_number()); + shopStoreCompany.setBank_name(shopMerchEntry.getBank_name()); + + Date today = new Date(); + shopStoreCompany.setOrganization_code_start(today); + shopStoreCompany.setOrganization_code_end(DateUtil.offsetDay(today, 365 * 5)); + shopStoreCompany.setEstablish_date(today); + shopStoreCompany.setBusiness_licence_start(today); + shopStoreCompany.setBusiness_licence_end(DateUtil.offsetDay(today, 365 * 5)); + + shopStoreCompany.setCompany_description(""); + shopStoreCompany.setStore_class_ids(""); + shopStoreCompany.setStore_class_names(""); + shopStoreCompany.setStore_class_commission(""); + + // 待补充 + if (!shopStoreCompanyService.save(shopStoreCompany)) { + logger.error("生成店铺:新增店铺公司失败"); + throw new ApiException(I18nUtil._("新增店铺公司失败")); + } + } + + // shop_store_employee 店铺员工,添加管理员 + ShopStoreEmployee shopStoreEmployee = new ShopStoreEmployee(); + shopStoreEmployee.setStore_id(storeId); + shopStoreEmployee.setUser_id(userId); + shopStoreEmployee.setRights_group_id("1"); // 店铺管理员 + shopStoreEmployee.setEmployee_is_admin(CommonConstant.Enable); + shopStoreEmployee.setEmployee_is_kefu(CommonConstant.Enable); + shopStoreEmployeeService.save(shopStoreEmployee); + if (!shopStoreEmployeeService.save(shopStoreEmployee)) { + logger.error("生成店铺:新增店铺员工失败"); + throw new ApiException(I18nUtil._("新增店铺员工失败")); + } + + return Pair.of(storeId, "新增成功"); + } catch (Exception e) { + logger.error("生成店铺失败", e); + return Pair.of(0, I18nUtil._("新增店铺失败")); + } } /** diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncThirdDataServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncThirdDataServiceImpl.java index a07efc42..d9f3fded 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncThirdDataServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sync/service/impl/SyncThirdDataServiceImpl.java @@ -436,7 +436,7 @@ public class SyncThirdDataServiceImpl implements SyncThirdDataService { accountUserBase.setUser_is_admin(CommonConstant.USER_TYPE_NORMAL); accountUserBase.setStore_ids(storeId); accountUserBase.setRights_group_id("0");// 普通用户,不是商家 - accountUserBase.setUser_type("0"); + accountUserBase.setUser_type(CommonConstant.USER_TYPE_NORMAL); // 默认给了随机密码和盐,token String user_key = IdUtil.simpleUUID();