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 9827ff1e..43f91244 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 @@ -3,6 +3,7 @@ package com.suisung.mall.account.controller; import cn.hutool.core.lang.Validator; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONObject; import com.suisung.mall.account.service.AccountUserBaseService; import com.suisung.mall.account.service.AccountUserInfoService; import com.suisung.mall.common.api.CommonResult; @@ -18,10 +19,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.Map; @@ -179,10 +177,8 @@ public class LoginController extends BaseControllerImpl { @ApiOperation(value = "商家版注册与登录") @RequestMapping(value = "/doMerchSmsRegisterAndLogin", method = RequestMethod.POST) - public CommonResult doMerchSmsRegisterAndLogin(@RequestParam(name = "user_mobile") String user_mobile, - @RequestParam(name = "rand_key", required = false) String rand_key, - @RequestParam(name = "verify_code") String verify_code) { - return accountUserBaseService.doMerchSmsRegisterAndLogin(user_mobile, rand_key, verify_code); + public CommonResult doMerchSmsRegisterAndLogin(@RequestBody JSONObject paramJSON) { + return accountUserBaseService.doMerchSmsRegisterAndLogin(paramJSON.getStr("user_mobile"), paramJSON.getStr("rand_key"), paramJSON.getStr("verify_code")); } @ApiOperation("退出登录") diff --git a/mall-account/src/main/java/com/suisung/mall/account/controller/mobile/UserController.java b/mall-account/src/main/java/com/suisung/mall/account/controller/mobile/UserController.java index a5259821..2d08d1e0 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/controller/mobile/UserController.java +++ b/mall-account/src/main/java/com/suisung/mall/account/controller/mobile/UserController.java @@ -55,35 +55,26 @@ import java.util.concurrent.ThreadPoolExecutor; @RequestMapping("/mobile/account/user") public class UserController extends BaseControllerImpl { + private final Logger logger = LoggerFactory.getLogger(UserController.class); @Autowired private AccountUserBaseService accountUserBaseService; - @Autowired private AccountBaseRoleLevelService accountBaseRoleLevelService; - @Autowired private AccountBaseUserLevelService accountBaseUserLevelService; - @Autowired private PayService payService; - @Autowired private ShopService shopService; - @Autowired private AccountUserSnsService accountUserSnsService; - @Autowired private AccountBaseConfigService accountBaseConfigService; - @Autowired private AccountUserInfoService accountUserInfoService; - @Autowired private ThreadPoolExecutor executor; - private Logger logger = LoggerFactory.getLogger(UserController.class); - /** * 用户基本信息管理界面 * @@ -275,17 +266,15 @@ public class UserController extends BaseControllerImpl { @RequestParam(name = "email", required = false) String email) { // 2024-12-12 update - if(StrUtil.isNotBlank(mobile)) { - if(!StrUtil.startWith(mobile, CommonConstant.IDD_ZH_CN)) { + if (StrUtil.isNotBlank(mobile)) { + if (!StrUtil.startWith(mobile, CommonConstant.IDD_ZH_CN)) { mobile = CommonConstant.IDD_ZH_CN + mobile; } - if(!PhoneNumberUtils.isValidNumber(mobile)){ + if (!PhoneNumberUtils.isValidNumber(mobile)) { throw new ApiException(I18nUtil._("请输入正确的手机号!")); } - } - - else if (StrUtil.isNotBlank(email) && !CheckUtil.isEmail(email)) { + } else if (StrUtil.isNotBlank(email) && !CheckUtil.isEmail(email)) { throw new ApiException(I18nUtil._("请输入正确邮箱格式!")); } @@ -297,7 +286,7 @@ public class UserController extends BaseControllerImpl { @ApiOperation(value = "获取邮箱验证码找回密码") @RequestMapping(value = "/emailVerifyCode", method = RequestMethod.GET) public CommonResult getEmailMobileVerifyCode(@RequestParam(name = "mobile", required = false) String mobile, - @RequestParam(name = "email", required = false) String email) { + @RequestParam(name = "email", required = false) String email) { if (StrUtil.isNotBlank(mobile) && !PhoneUtil.isMobile(mobile)) { throw new ApiException(I18nUtil._("请输入正确的手机号!")); } 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 ea06e2af..23823e7f 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 @@ -202,11 +202,15 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl params2 = new HashMap<>(); + params2.put("user_mobile", params.get("user_mobile")); + data.put("merch_approval_status", shopService.shopMerchEntryApprovalStatus(params2)); } return restResult; @@ -1792,42 +1796,48 @@ 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_mobile", user_mobile); +// 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); // 商家入驻注册 + + // 注:注册商家账号,都是需要手机号绑定的。 + accountUserBase = register(userInfo); + if (accountUserBase == null) { + throw new ApiException(_("账号注册失败!")); + } + + // TODO 发送短信通知用户,告知用户随机密码:尊敬的商家用户,你们刚注册账号的账号密码为:" + user_password + ",请妥善保管,以免丢失。 } - // 手机号码未绑定的情况,直接去注册一个账号 - Map userInfo = new HashMap<>(); - userInfo.put("user_account", com.suisung.mall.common.utils.StringUtils.genLklOrderNo(4));// 时间 yyyyMMddHHmmss + 4位随机数 - userInfo.put("user_mobile", user_mobile); - // 密码要随机数 - 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); // 商家入驻注册 - - // 注:注册商家账号,都是需要手机号绑定的。 - accountUserBase = register(userInfo); - if (accountUserBase == null) { - throw new ApiException(_("账号注册失败!")); - } - - // TODO 发送短信通知用户,告知用户随机密码:尊敬的商家用户,你们刚注册账号的账号密码为:" + user_password + ",请妥善保管,以免丢失。 - - Map params = new HashMap<>(); params.put("client_id", isMerch ? AuthConstant.MCH_CLIENT_ID : AuthConstant.MOBILE_CLIENT_ID); params.put("client_secret", AuthConstant.AUTHORITY_MOBILE_SECRET); @@ -2768,6 +2784,7 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl params); + } 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 b4eb839c..a79fa443 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 @@ -1,11 +1,13 @@ package com.suisung.mall.common.utils.phone; +import cn.hutool.core.util.StrUtil; import com.google.i18n.phonenumbers.NumberParseException; import com.google.i18n.phonenumbers.PhoneNumberToCarrierMapper; import com.google.i18n.phonenumbers.PhoneNumberUtil; import com.google.i18n.phonenumbers.Phonenumber; import com.google.i18n.phonenumbers.geocoding.PhoneNumberOfflineGeocoder; +import com.suisung.mall.common.constant.CommonConstant; import java.util.Locale; @@ -47,6 +49,16 @@ public class PhoneNumberUtils { return checkPhoneNumber(COUNTRY_CODE_CHINA, phoneNumber); } + /** + * 如果手机号码不带国家码,转换中国大陆区号86的手机号码 + * + * @param phoneNumber + * @return + */ + public static String convZhPhoneNumber(String phoneNumber) { + return StrUtil.startWith(phoneNumber, "+") ? phoneNumber : CommonConstant.IDD_ZH_CN + phoneNumber; + } + /** * 判断手机号是否有效(国际) * diff --git a/mall-pay/src/main/java/com/suisung/mall/pay/controller/admin/PayController.java b/mall-pay/src/main/java/com/suisung/mall/pay/controller/admin/PayController.java index 9c062c41..2c2ea51c 100644 --- a/mall-pay/src/main/java/com/suisung/mall/pay/controller/admin/PayController.java +++ b/mall-pay/src/main/java/com/suisung/mall/pay/controller/admin/PayController.java @@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.modules.order.ShopOrderReturn; import com.suisung.mall.common.modules.pay.*; -import com.suisung.mall.common.utils.CheckUtil; import com.suisung.mall.common.utils.MybatisPlusQueryUtil; import com.suisung.mall.pay.service.*; import io.seata.core.context.RootContext; @@ -37,35 +36,26 @@ import java.util.Map; @RequestMapping("/admin/pay/payController") public class PayController { + private final Logger logger = LoggerFactory.getLogger(PayController.class); @Autowired private PayUserResourceService payUserResourceService; - @Autowired private PayConsumeDepositService payConsumeDepositService; - @Autowired private PayPaymentChannelService payPaymentChannelService; - @Autowired private PayUserBankCardService payUserBankCardService; - @Autowired private PayConsumeWithdrawService payConsumeWithdrawService; - @Autowired private PayConsumeTradeService payConsumeTradeService; - @Autowired private PayConsumeRecordService payConsumeRecordService; - @Autowired private PayPlantformResourceService payPlantformResourceService; - @Autowired private PayUserPayService payUserPayService; - private Logger logger = LoggerFactory.getLogger(PayController.class); - @ApiOperation(value = "根据user_id 删除门店顾客关系数据", notes = "根据user_id 删除门店顾客关系数据") @RequestMapping(value = "/deleteUserChainByUid", method = RequestMethod.POST) @GlobalTransactional @@ -247,7 +237,7 @@ public class PayController { } catch (TransactionException ex) { logger.error("seata 事务异常!"); } - return CommonResult.failed(e.getMessage()); + return CommonResult.failed(e.getMessage()); } return CommonResult.success(); } @@ -266,28 +256,28 @@ public class PayController { } catch (TransactionException ex) { logger.error("seata 事务异常!"); } - return CommonResult.failed(e.getMessage()); + return CommonResult.failed(e.getMessage()); } return CommonResult.success(); } @RequestMapping(value = "/getOrderNum", method = RequestMethod.POST) public long getOrderNum(@RequestParam(name = "order_state_id", required = false) Integer order_state_id, - @RequestParam(name = "store_id", required = false) Integer store_id, - @RequestParam(name = "chain_id", required = false) Integer chain_id, - @RequestParam(name = "day_flag", required = false) Integer day_flag, - @RequestParam(name = "month_flag", required = false) Integer month_flag, - @RequestParam(name = "trade_type_id", required = false) Integer trade_type_id, - @RequestParam(name = "subsite_id", required = false) Integer subsite_id) { + @RequestParam(name = "store_id", required = false) Integer store_id, + @RequestParam(name = "chain_id", required = false) Integer chain_id, + @RequestParam(name = "day_flag", required = false) Integer day_flag, + @RequestParam(name = "month_flag", required = false) Integer month_flag, + @RequestParam(name = "trade_type_id", required = false) Integer trade_type_id, + @RequestParam(name = "subsite_id", required = false) Integer subsite_id) { return payConsumeTradeService.getOrderNum(order_state_id, store_id, chain_id, day_flag, month_flag, trade_type_id, subsite_id); } @RequestMapping(value = "/getOrderPaymentAmount", method = RequestMethod.POST) public BigDecimal getOrderPaymentAmount(@RequestParam(name = "trade_is_paid", required = false) Integer trade_is_paid, - @RequestParam(name = "store_id", required = false) Integer store_id, - @RequestParam(name = "subsite_id", required = false) Integer subsite_id, - @RequestParam(name = "day_flag", required = false) Integer day_flag, - @RequestParam(name = "month_flag", required = false) Integer month_flag) { + @RequestParam(name = "store_id", required = false) Integer store_id, + @RequestParam(name = "subsite_id", required = false) Integer subsite_id, + @RequestParam(name = "day_flag", required = false) Integer day_flag, + @RequestParam(name = "month_flag", required = false) Integer month_flag) { return payConsumeTradeService.getOrderPaymentAmount(trade_is_paid, store_id, subsite_id, day_flag, month_flag); } @@ -311,8 +301,8 @@ public class PayController { @GlobalTransactional @ApiOperation(value = "初始化用户积分表", notes = "初始化用户积分表") @RequestMapping(value = "/initUserPoints", method = RequestMethod.POST) - public boolean initUserPoints(@RequestParam(name = "user_id") Integer user_id) { - boolean flag = false; + public Boolean initUserPoints(@RequestParam(name = "user_id") Integer user_id) { + Boolean flag = false; try { flag = payUserResourceService.initUserPoints(user_id); } catch (Exception e) { @@ -320,8 +310,10 @@ public class PayController { GlobalTransactionContext.reload(RootContext.getXID()).rollback(); } catch (TransactionException ex) { logger.error("seata 事务异常!"); + return false; } } + return flag; } @@ -372,7 +364,7 @@ public class PayController { @ApiOperation(value = "微信退款", notes = "微信退款") @RequestMapping(value = "/wxPayRefund", method = RequestMethod.POST) public ShopOrderReturn wxPayRefund(@RequestBody ShopOrderReturn orderReturn) { - return payUserPayService.wxPayRefund(orderReturn); + return payUserPayService.wxPayRefund(orderReturn); } @ApiOperation(value = "支付宝退款", notes = "支付宝退款") diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/merch/controller/mobile/ShopMerchEntryController.java b/mall-shop/src/main/java/com/suisung/mall/shop/merch/controller/mobile/ShopMerchEntryController.java index 9c0c712d..f783c3b2 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/merch/controller/mobile/ShopMerchEntryController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/merch/controller/mobile/ShopMerchEntryController.java @@ -54,4 +54,11 @@ public class ShopMerchEntryController extends BaseControllerImpl { approvalStatusList.add(3); return shopMerchEntryService.shopMerchEntryDetail(null, jsonParam.getStr("mobile"), approvalStatusList); } + + @ApiOperation(value = "通过手机号mobile获取商家入驻审核状态", notes = "通过手机号获取商家入驻审核状态") + @RequestMapping(value = "/approval/status", method = RequestMethod.POST) + public Integer shopMerchEntryApprovalStatus(@RequestBody JSONObject jsonParam) { + // approvalStatus 入驻商家的审批状态:1-已通过;2-未通过;3-待审核;4-未申请; + return shopMerchEntryService.shopMerchEntryApprovalStatus(jsonParam.getStr("mobile")); + } } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/ShopMerchEntryService.java b/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/ShopMerchEntryService.java index f05b1797..24ae482c 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/ShopMerchEntryService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/ShopMerchEntryService.java @@ -69,4 +69,13 @@ public interface ShopMerchEntryService { * @return */ Boolean isApplied(String mobile, String bizLicenseNumber); + + /** + * 获取商家入驻审核状态 + * approval_status 入驻商家的审批状态:1-已通过;2-未通过;3-待审核;4-未申请; + * + * @param loginMobile + * @return + */ + Integer shopMerchEntryApprovalStatus(String loginMobile); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/impl/ShopMerchEntryServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/impl/ShopMerchEntryServiceImpl.java index fc52f4ba..0f30ebe2 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/impl/ShopMerchEntryServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/impl/ShopMerchEntryServiceImpl.java @@ -315,4 +315,28 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl 0; } + + /** + * 获取商家入驻审核状态 + * approval_status 入驻商家的审批状态:1-已通过;2-未通过;3-待审核;4-未申请; + * + * @param loginMobile + * @return + */ + @Override + public Integer shopMerchEntryApprovalStatus(String loginMobile) { + if (StrUtil.isBlank(loginMobile)) { + return 1; + } + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("login_mobile", loginMobile).orderByAsc("id"); + + List recordList = list(queryWrapper); + if (CollectionUtil.isEmpty(recordList)) { + return 4; + } + + return recordList.get(0).getApproval_status(); + } }