diff --git a/pom.xml b/pom.xml
index 393b82c..1c9c3e3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,6 +44,11 @@
+
+ com.tencentcloudapi
+ tencentcloud-sdk-java
+ 3.1.950
+
org.springframework.boot
spring-boot-dependencies
@@ -133,6 +138,11 @@
+
+ com.tencentcloudapi
+ tencentcloud-sdk-java
+ 3.1.950
+
org.projectlombok
lombok
@@ -181,7 +191,7 @@
aliyun
aliyun
- https://maven.aliyun.com/repository/public
+ https://mirrors.tencent.com/nexus/repository/maven-public/
true
diff --git a/yami-shop-admin/src/main/resources/application-prod.yml b/yami-shop-admin/src/main/resources/application-prod.yml
index 6c08820..cb9cd8c 100644
--- a/yami-shop-admin/src/main/resources/application-prod.yml
+++ b/yami-shop-admin/src/main/resources/application-prod.yml
@@ -4,7 +4,7 @@ spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/yami_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
username: root
- password: root
+ password: 660100
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
hikari:
diff --git a/yami-shop-admin/src/main/resources/banner.txt b/yami-shop-admin/src/main/resources/banner.txt
deleted file mode 100644
index 9fdec0d..0000000
--- a/yami-shop-admin/src/main/resources/banner.txt
+++ /dev/null
@@ -1,11 +0,0 @@
- .----------------. .----------------. .----------------. .----------------. .----------------. .----------------.
-| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
-| | ____ ____ | || | __ | || | _____ | || | _____ | || | _ _ | || | _____ | |
-| ||_ \ / _|| || | / \ | || | |_ _| | || | |_ _| | || | | | | | | || | |_ _| | |
-| | | \/ | | || | / /\ \ | || | | | | || | | | | || | | |__| |_ | || | | | | |
-| | | |\ /| | | || | / ____ \ | || | | | _ | || | | | _ | || | |____ _| | || | _ | | | |
-| | _| |_\/_| |_ | || | _/ / \ \_ | || | _| |__/ | | || | _| |__/ | | || | _| |_ | || | | |_' | | |
-| ||_____||_____|| || ||____| |____|| || | |________| | || | |________| | || | |_____| | || | `.___.' | |
-| | | || | | || | | || | | || | | || | | |
-| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |
- '----------------' '----------------' '----------------' '----------------' '----------------' '----------------'
diff --git a/yami-shop-api/src/main/java/com/yami/shop/api/controller/SmsController.java b/yami-shop-api/src/main/java/com/yami/shop/api/controller/SmsController.java
index 9c04760..e78b3c9 100644
--- a/yami-shop-api/src/main/java/com/yami/shop/api/controller/SmsController.java
+++ b/yami-shop-api/src/main/java/com/yami/shop/api/controller/SmsController.java
@@ -10,39 +10,77 @@
package com.yami.shop.api.controller;
-import com.google.common.collect.Maps;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
+import com.tencentcloudapi.sms.v20210111.models.SendStatus;
import com.yami.shop.bean.app.param.SendSmsParam;
-import com.yami.shop.bean.enums.SmsType;
-import com.yami.shop.security.api.util.SecurityUtils;
+import com.yami.shop.common.response.ServerResponseEntity;
+import com.yami.shop.common.util.RedisUtil;
+import com.yami.shop.service.SendSmsService;
import com.yami.shop.service.SmsLogService;
-import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
-import com.yami.shop.common.response.ServerResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import java.security.SecureRandom;
+
/**
* @author lanhai
*/
@RestController
-@RequestMapping("/p/sms")
+@RequestMapping("/sms")
@Tag(name = "发送验证码接口")
+@AllArgsConstructor
public class SmsController {
- @Autowired
- private SmsLogService smsLogService;
+ // 数字字符集合
+ private static final String NUMERIC_CHARACTERS = "0123456789";
+ // 随机数生成器
+ private static final SecureRandom RANDOM = new SecureRandom();
+ @Autowired
+ private SmsLogService smsLogService;
+ @Autowired
+ private SendSmsService sendSmsService;
+
+ /**
+ * 生成指定长度的随机数字验证码
+ *
+ * @param length 验证码长度
+ * @return 随机数字验证码
+ */
+ public static String generateRandomNumericCode(int length) {
+ StringBuilder code = new StringBuilder();
+
+ for (int i = 0; i < length; i++) {
+ int randomIndex = RANDOM.nextInt(NUMERIC_CHARACTERS.length());
+ char randomChar = NUMERIC_CHARACTERS.charAt(randomIndex);
+ code.append(randomChar);
+ }
+
+ return code.toString();
+ }
+
/**
* 发送验证码接口
*/
@PostMapping("/send")
- @Operation(summary = "发送验证码" , description = "用户的发送验证码")
- public ServerResponseEntity audit(@RequestBody SendSmsParam sendSmsParam) {
- String userId = SecurityUtils.getUser().getUserId();
- smsLogService.sendSms(SmsType.VALID, userId, sendSmsParam.getMobile(),Maps.newHashMap());
-
- return ServerResponseEntity.success();
+ @Operation(summary = "发送验证码", description = "用户的发送验证码")
+ public ServerResponseEntity audit(@RequestBody SendSmsParam sendSmsParam) {
+// String userId = SecurityUtils.getUser().getUserId();
+// smsLogService.sendSms(SmsType.VALID, userId, sendSmsParam.getMobile(),Maps.newHashMap());
+ String code = generateRandomNumericCode(6);
+ RedisUtil.set("verification:code:" + sendSmsParam.getMobile(), code);
+ SendSmsResponse sendSmsResponse = sendSmsService.sendSms(sendSmsParam.getMobile(), code);
+ SendStatus[] sendStatusSet = sendSmsResponse.getSendStatusSet();
+ System.out.println(sendSmsResponse);
+ if (sendStatusSet[0].getCode().equals("Ok")) {
+ return ServerResponseEntity.success( "验证码发送成功");
+ }
+ return ServerResponseEntity.success("验证码发送失败");
}
+
}
diff --git a/yami-shop-api/src/main/java/com/yami/shop/api/controller/UserPortfolioController.java b/yami-shop-api/src/main/java/com/yami/shop/api/controller/UserPortfolioController.java
new file mode 100644
index 0000000..14a9fee
--- /dev/null
+++ b/yami-shop-api/src/main/java/com/yami/shop/api/controller/UserPortfolioController.java
@@ -0,0 +1,53 @@
+package com.yami.shop.api.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.yami.shop.bean.model.UserPortfolio;
+import com.yami.shop.common.response.ServerResponseEntity;
+import com.yami.shop.security.api.model.YamiUser;
+import com.yami.shop.security.api.util.SecurityUtils;
+import com.yami.shop.service.UserPortfolioService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import lombok.AllArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/p/user/portfolio")
+@Tag(name = "会员建档")
+@AllArgsConstructor
+public class UserPortfolioController {
+
+ @Autowired
+ private UserPortfolioService userPortfolioService;
+
+
+ @PostMapping("/save")
+ @Operation(summary = "会员建档", description = "保存档案信息")
+ public ServerResponseEntity save(@RequestBody UserPortfolio portfolio) {
+ YamiUser user = SecurityUtils.getUser();
+ String userId = user.getUserId();
+ portfolio.setUserId(userId);
+ userPortfolioService.save(portfolio);
+ return ServerResponseEntity.success("建档成功");
+ }
+
+ @PostMapping("/page")
+ @Operation(summary = "会员列表", description = "会员列表")
+ public ServerResponseEntity> page() {
+ YamiUser user = SecurityUtils.getUser();
+ String userId = user.getUserId();
+ List list = userPortfolioService.list(new LambdaQueryWrapper().eq(UserPortfolio::getUserId, userId));
+ return ServerResponseEntity.success(list);
+ }
+
+ @PostMapping("/detail")
+ @Operation(summary = "会员列表", description = "会员列表")
+ public ServerResponseEntity detail(@RequestParam String profileId) {
+
+ UserPortfolio userPortfolio = userPortfolioService.getOne(new LambdaQueryWrapper().eq(UserPortfolio::getPortfolioId, profileId));
+ return ServerResponseEntity.success(userPortfolio);
+ }
+}
diff --git a/yami-shop-api/src/main/java/com/yami/shop/api/controller/UserRegisterController.java b/yami-shop-api/src/main/java/com/yami/shop/api/controller/UserRegisterController.java
index 0241868..d22eb97 100644
--- a/yami-shop-api/src/main/java/com/yami/shop/api/controller/UserRegisterController.java
+++ b/yami-shop-api/src/main/java/com/yami/shop/api/controller/UserRegisterController.java
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yami.shop.bean.model.User;
import com.yami.shop.bean.param.UserRegisterParam;
import com.yami.shop.common.exception.YamiShopBindException;
+import com.yami.shop.common.util.RedisUtil;
import com.yami.shop.security.common.bo.UserInfoInTokenBO;
import com.yami.shop.security.common.enums.SysTypeEnum;
import com.yami.shop.security.common.manager.PasswordManager;
@@ -48,11 +49,25 @@ public class UserRegisterController {
if (StrUtil.isBlank(userRegisterParam.getNickName())) {
userRegisterParam.setNickName(userRegisterParam.getUserName());
}
+ if (userRegisterParam.getNickName().length() < 4) {
+ throw new YamiShopBindException("用户名长度小于4");
+ }
+ if (userRegisterParam.getPassWord().length() < 6) {
+ throw new YamiShopBindException("密码长度小于6");
+ }
// 正在进行申请注册
if (userService.count(new LambdaQueryWrapper().eq(User::getNickName, userRegisterParam.getNickName())) > 0) {
// 该用户名已注册,无法重新注册
throw new YamiShopBindException("该用户名已注册,无法重新注册");
}
+ if (userService.count(new LambdaQueryWrapper().eq(User::getPhone, userRegisterParam.getPhone())) > 0) {
+ // 该用户名已注册,无法重新注册
+ throw new YamiShopBindException("该手机号已注册,无法重新注册");
+ }
+ String code = RedisUtil.get("verification:code:" + userRegisterParam.getPhone());
+ if (!code.equals(userRegisterParam.getVerificationCode())) {
+ throw new YamiShopBindException("验证码不匹配");
+ }
Date now = new Date();
User user = new User();
user.setModifyTime(now);
@@ -64,6 +79,7 @@ public class UserRegisterController {
user.setLoginPassword(passwordEncoder.encode(decryptPassword));
String userId = IdUtil.simpleUUID();
user.setUserId(userId);
+ user.setPhone(userRegisterParam.getPhone());
userService.save(user);
// 2. 登录
UserInfoInTokenBO userInfoInTokenBO = new UserInfoInTokenBO();
diff --git a/yami-shop-api/src/main/resources/application-prod.yml b/yami-shop-api/src/main/resources/application-prod.yml
index d25012f..546e9c8 100644
--- a/yami-shop-api/src/main/resources/application-prod.yml
+++ b/yami-shop-api/src/main/resources/application-prod.yml
@@ -5,7 +5,7 @@ spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/yami_shops?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
username: root
- password: root
+ password: 660100
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.zaxxer.hikari.HikariDataSource
hikari:
diff --git a/yami-shop-api/src/main/resources/banner.txt b/yami-shop-api/src/main/resources/banner.txt
deleted file mode 100644
index 9fdec0d..0000000
--- a/yami-shop-api/src/main/resources/banner.txt
+++ /dev/null
@@ -1,11 +0,0 @@
- .----------------. .----------------. .----------------. .----------------. .----------------. .----------------.
-| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
-| | ____ ____ | || | __ | || | _____ | || | _____ | || | _ _ | || | _____ | |
-| ||_ \ / _|| || | / \ | || | |_ _| | || | |_ _| | || | | | | | | || | |_ _| | |
-| | | \/ | | || | / /\ \ | || | | | | || | | | | || | | |__| |_ | || | | | | |
-| | | |\ /| | | || | / ____ \ | || | | | _ | || | | | _ | || | |____ _| | || | _ | | | |
-| | _| |_\/_| |_ | || | _/ / \ \_ | || | _| |__/ | | || | _| |__/ | | || | _| |_ | || | | |_' | | |
-| ||_____||_____|| || ||____| |____|| || | |________| | || | |________| | || | |_____| | || | `.___.' | |
-| | | || | | || | | || | | || | | || | | |
-| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |
- '----------------' '----------------' '----------------' '----------------' '----------------' '----------------'
diff --git a/yami-shop-bean/src/main/java/com/yami/shop/bean/model/User.java b/yami-shop-bean/src/main/java/com/yami/shop/bean/model/User.java
index e72f09c..4335013 100644
--- a/yami-shop-bean/src/main/java/com/yami/shop/bean/model/User.java
+++ b/yami-shop-bean/src/main/java/com/yami/shop/bean/model/User.java
@@ -131,5 +131,9 @@ public class User implements Serializable {
* 积分
*/
private Integer score;
+ /**
+ * 积分
+ */
+ private String phone;
}
diff --git a/yami-shop-bean/src/main/java/com/yami/shop/bean/model/UserPortfolio.java b/yami-shop-bean/src/main/java/com/yami/shop/bean/model/UserPortfolio.java
index c62c6ea..163d04d 100644
--- a/yami-shop-bean/src/main/java/com/yami/shop/bean/model/UserPortfolio.java
+++ b/yami-shop-bean/src/main/java/com/yami/shop/bean/model/UserPortfolio.java
@@ -2,6 +2,7 @@ package com.yami.shop.bean.model;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@@ -12,8 +13,9 @@ public class UserPortfolio {
// 基本信息
@TableId
private Integer portfolioId; //档案id
- private Integer userId; // 会员ID
+ private String userId; // 会员ID
private String name; // 姓名
+ @JsonFormat(pattern = "yyyy-MM-dd")
private Date birthDate; // 出生日期
private String gender; // 性别
private String ethnicity; // 民族
@@ -56,4 +58,41 @@ public class UserPortfolio {
// 拒绝理由
private String rejectionReason;
+ @Override
+ public String toString() {
+ return "UserPortfolio{" +
+ "portfolioId=" + portfolioId +
+ ", userId=" + userId +
+ ", name='" + name + '\'' +
+ ", birthDate=" + birthDate +
+ ", gender='" + gender + '\'' +
+ ", ethnicity='" + ethnicity + '\'' +
+ ", nativePlace='" + nativePlace + '\'' +
+ ", idCardNumber='" + idCardNumber + '\'' +
+ ", address='" + address + '\'' +
+ ", phoneNumber='" + phoneNumber + '\'' +
+ ", emailAddress='" + emailAddress + '\'' +
+ ", emergencyContactName='" + emergencyContactName + '\'' +
+ ", emergencyContactPhone='" + emergencyContactPhone + '\'' +
+ ", healthStatus='" + healthStatus + '\'' +
+ ", medicalInsuranceInfo='" + medicalInsuranceInfo + '\'' +
+ ", primaryDoctorContact='" + primaryDoctorContact + '\'' +
+ ", longTermMedicationInfo='" + longTermMedicationInfo + '\'' +
+ ", funeralMethod='" + funeralMethod + '\'' +
+ ", ceremonyType='" + ceremonyType + '\'' +
+ ", cemeteryInfo='" + cemeteryInfo + '\'' +
+ ", prePurchasedGrave=" + prePurchasedGrave +
+ ", preReservedFuneralLocation='" + preReservedFuneralLocation + '\'' +
+ ", hasWillOrLivingDirective=" + hasWillOrLivingDirective +
+ ", paymentMethod='" + paymentMethod + '\'' +
+ ", bankAccountInfo='" + bankAccountInfo + '\'' +
+ ", prePaidFuneralCost=" + prePaidFuneralCost +
+ ", willCopy='" + willCopy + '\'' +
+ ", preDeathAgentDesignation='" + preDeathAgentDesignation + '\'' +
+ ", medicalAgentDesignation='" + medicalAgentDesignation + '\'' +
+ ", lifeSupportDecision='" + lifeSupportDecision + '\'' +
+ ", portfolioStatus=" + portfolioStatus +
+ ", rejectionReason='" + rejectionReason + '\'' +
+ '}';
+ }
}
diff --git a/yami-shop-bean/src/main/java/com/yami/shop/bean/param/UserRegisterParam.java b/yami-shop-bean/src/main/java/com/yami/shop/bean/param/UserRegisterParam.java
index 5e7f310..0ef7e91 100644
--- a/yami-shop-bean/src/main/java/com/yami/shop/bean/param/UserRegisterParam.java
+++ b/yami-shop-bean/src/main/java/com/yami/shop/bean/param/UserRegisterParam.java
@@ -46,4 +46,10 @@ public class UserRegisterParam {
@Schema(description = "用户id" )
private Long userId;
+
+
+ @Schema(description = "手机号" )
+ private String phone;
+ @Schema(description = "验证码" )
+ private String verificationCode;
}
diff --git a/yami-shop-common/src/main/resources/shop.properties b/yami-shop-common/src/main/resources/shop.properties
index 63b0068..f4168d1 100644
--- a/yami-shop-common/src/main/resources/shop.properties
+++ b/yami-shop-common/src/main/resources/shop.properties
@@ -1,5 +1,6 @@
# \u4E03\u725B\u4E91\u914D\u7F6E
-shop.qiniu.resourcesUrl=https://img.jintongapp.com/
+shop.qiniu.resourcesUrl=https://img.mall4j.com/
+; shop.qiniu.resourcesUrl=https://img.mall4j.com/
shop.qiniu.accessKey=gfzcyBDr9cd5FTForpe7HJGzELLJxztTtHhUmh6o
shop.qiniu.secretKey=zs4K9rT4Hxa3jo5OL_V2Aq5oM8yXw_O1F2jlvlJJ
shop.qiniu.bucket=****
diff --git a/yami-shop-service/src/main/java/com/yami/shop/dao/ProductMapper.java b/yami-shop-service/src/main/java/com/yami/shop/dao/ProductMapper.java
index 4e3686e..3793e6e 100644
--- a/yami-shop-service/src/main/java/com/yami/shop/dao/ProductMapper.java
+++ b/yami-shop-service/src/main/java/com/yami/shop/dao/ProductMapper.java
@@ -27,6 +27,8 @@ import java.util.Map;
* @author lanhai
*/
public interface ProductMapper extends BaseMapper {
+
+ Product getById( @Param("portId") String portId);
/**
* 更新商品库存
* @param product
diff --git a/yami-shop-service/src/main/java/com/yami/shop/service/SendSmsService.java b/yami-shop-service/src/main/java/com/yami/shop/service/SendSmsService.java
new file mode 100644
index 0000000..d46049c
--- /dev/null
+++ b/yami-shop-service/src/main/java/com/yami/shop/service/SendSmsService.java
@@ -0,0 +1,20 @@
+package com.yami.shop.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import com.tencentcloudapi.sms.v20210111.SmsClient;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
+import com.yami.shop.bean.model.SmsLog;
+
+
+/**
+ * Tencent Cloud Sms Sendsms
+ */
+
+public interface SendSmsService {
+ public SendSmsResponse sendSms(String phone, String code) ;
+}
diff --git a/yami-shop-service/src/main/java/com/yami/shop/service/impl/BasketServiceImpl.java b/yami-shop-service/src/main/java/com/yami/shop/service/impl/BasketServiceImpl.java
index 2182a39..d079bca 100644
--- a/yami-shop-service/src/main/java/com/yami/shop/service/impl/BasketServiceImpl.java
+++ b/yami-shop-service/src/main/java/com/yami/shop/service/impl/BasketServiceImpl.java
@@ -195,6 +195,7 @@ public class BasketServiceImpl extends ServiceImpl impleme
ShopDetail shopDetail = shopDetailService.getShopDetailByShopId(orderItem.getShopId());
shopCartItemDto.setShopId(shopDetail.getShopId());
shopCartItemDto.setShopName(shopDetail.getShopName());
+ shopCartItemDto.setProductType(prod.getProductType());
return Collections.singletonList(shopCartItemDto);
}
List dbShopCartItems = getShopCartItems(userId);
diff --git a/yami-shop-service/src/main/java/com/yami/shop/service/impl/ProductServiceImpl.java b/yami-shop-service/src/main/java/com/yami/shop/service/impl/ProductServiceImpl.java
index c7687a2..38d31c5 100644
--- a/yami-shop-service/src/main/java/com/yami/shop/service/impl/ProductServiceImpl.java
+++ b/yami-shop-service/src/main/java/com/yami/shop/service/impl/ProductServiceImpl.java
@@ -116,9 +116,8 @@ public class ProductServiceImpl extends ServiceImpl impl
@Override
@Cacheable(cacheNames = "product", key = "#prodId")
public Product getProductByProdId(Long prodId) {
- return productMapper.selectById(prodId);
+ return productMapper.getById(prodId.toString());
}
-
@Override
@Transactional(rollbackFor = Exception.class)
@Caching(evict = {
diff --git a/yami-shop-service/src/main/java/com/yami/shop/service/impl/SendSmsServiceImpl.java b/yami-shop-service/src/main/java/com/yami/shop/service/impl/SendSmsServiceImpl.java
new file mode 100644
index 0000000..a12ff9b
--- /dev/null
+++ b/yami-shop-service/src/main/java/com/yami/shop/service/impl/SendSmsServiceImpl.java
@@ -0,0 +1,138 @@
+package com.yami.shop.service.impl;
+
+import com.tencentcloudapi.common.Credential;
+import com.tencentcloudapi.common.exception.TencentCloudSDKException;
+import com.tencentcloudapi.common.profile.ClientProfile;
+import com.tencentcloudapi.common.profile.HttpProfile;
+import com.tencentcloudapi.sms.v20210111.SmsClient;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
+import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
+import com.yami.shop.service.SendSmsService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SendSmsServiceImpl implements SendSmsService {
+ @Override
+ public SendSmsResponse sendSms(String phone, String code) {
+ try {
+ /* 必要步骤:
+ * 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。
+ * 这里采用的是从环境变量读取的方式,需要在环境变量中先设置这两个值。
+ * 您也可以直接在代码中写死密钥对,但是小心不要将代码复制、上传或者分享给他人,
+ * 以免泄露密钥对危及您的财产安全。
+ * SecretId、SecretKey 查询: https://console.cloud.tencent.com/cam/capi */
+ Credential cred = new Credential("AKID1EXk8c8b0U5lPh2TrEa1QnCeBphR9wka", "sjbOE4sidUlx5EIORRRL6jGkAZDmGb1T");
+
+
+ // 实例化一个http选项,可选,没有特殊需求可以跳过
+ HttpProfile httpProfile = new HttpProfile();
+ // 设置代理(无需要直接忽略)
+ // httpProfile.setProxyHost("真实代理ip");
+ // httpProfile.setProxyPort(真实代理端口);
+ /* SDK默认使用POST方法。
+ * 如果您一定要使用GET方法,可以在这里设置。GET方法无法处理一些较大的请求 */
+ httpProfile.setReqMethod("POST");
+ /* SDK有默认的超时时间,非必要请不要进行调整
+ * 如有需要请在代码中查阅以获取最新的默认值 */
+ httpProfile.setConnTimeout(60);
+ /* 指定接入地域域名,默认就近地域接入域名为 sms.tencentcloudapi.com ,也支持指定地域域名访问,例如广州地域的域名为 sms.ap-guangzhou.tencentcloudapi.com */
+ httpProfile.setEndpoint("sms.tencentcloudapi.com");
+
+
+ /* 非必要步骤:
+ * 实例化一个客户端配置对象,可以指定超时时间等配置 */
+ ClientProfile clientProfile = new ClientProfile();
+ /* SDK默认用TC3-HMAC-SHA256进行签名
+ * 非必要请不要修改这个字段 */
+ clientProfile.setSignMethod("HmacSHA256");
+ clientProfile.setHttpProfile(httpProfile);
+ /* 实例化要请求产品(以sms为例)的client对象
+ * 第二个参数是地域信息,可以直接填写字符串ap-guangzhou,支持的地域列表参考 https://cloud.tencent.com/document/api/382/52071#.E5.9C.B0.E5.9F.9F.E5.88.97.E8.A1.A8 */
+ SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
+ /* 实例化一个请求对象,根据调用的接口和实际情况,可以进一步设置请求参数
+ * 您可以直接查询SDK源码确定接口有哪些属性可以设置
+ * 属性可能是基本类型,也可能引用了另一个数据结构
+ * 推荐使用IDE进行开发,可以方便的跳转查阅各个接口和数据结构的文档说明 */
+ SendSmsRequest req = new SendSmsRequest();
+
+
+ /* 填充请求参数,这里request对象的成员变量即对应接口的入参
+ * 您可以通过官网接口文档或跳转到request对象的定义处查看请求参数的定义
+ * 基本类型的设置:
+ * 帮助链接:
+ * 短信控制台: https://console.cloud.tencent.com/smsv2
+ * 腾讯云短信小助手: https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81 */
+
+
+ /* 短信应用ID: 短信SdkAppId在 [短信控制台] 添加应用后生成的实际SdkAppId,示例如1400006666 */
+ // 应用 ID 可前往 [短信控制台](https://console.cloud.tencent.com/smsv2/app-manage) 查看
+ String sdkAppId = "1400878793";
+ req.setSmsSdkAppId(sdkAppId);
+
+
+ /* 短信签名内容: 使用 UTF-8 编码,必须填写已审核通过的签名 */
+ // 签名信息可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-sign) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-sign) 的签名管理查看
+ String signName = "蕊鑫信息科技";
+ req.setSignName(signName);
+
+
+ /* 模板 ID: 必须填写已审核通过的模板 ID */
+ // 模板 ID 可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-template) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-template) 的正文模板管理查看
+ String templateId = "2030693";
+ req.setTemplateId(templateId);
+
+
+ /* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */
+ String[] templateParamSet = {code};
+ req.setTemplateParamSet(templateParamSet);
+
+
+ /* 下发手机号码,采用 E.164 标准,+[国家或地区码][手机号]
+ * 示例如:+8613711112222, 其中前面有一个+号 ,86为国家码,13711112222为手机号,最多不要超过200个手机号 */
+ String[] phoneNumberSet = {"+86" + phone};
+ req.setPhoneNumberSet(phoneNumberSet);
+
+
+ /* 用户的 session 内容(无需要可忽略): 可以携带用户侧 ID 等上下文信息,server 会原样返回 */
+ String sessionContext = "";
+ req.setSessionContext(sessionContext);
+
+
+ /* 短信码号扩展号(无需要可忽略): 默认未开通,如需开通请联系 [腾讯云短信小助手] */
+ String extendCode = "";
+ req.setExtendCode(extendCode);
+
+
+ /* 国内短信无需填写该项;国际/港澳台短信已申请独立 SenderId 需要填写该字段,默认使用公共 SenderId,无需填写该字段。注:月度使用量达到指定量级可申请独立 SenderId 使用,详情请联系 [腾讯云短信小助手](https://cloud.tencent.com/document/product/382/3773#.E6.8A.80.E6.9C.AF.E4.BA.A4.E6.B5.81)。*/
+ String senderid = "";
+ req.setSenderId(senderid);
+
+
+ /* 通过 client 对象调用 SendSms 方法发起请求。注意请求方法名与请求对象是对应的
+ * 返回的 res 是一个 SendSmsResponse 类的实例,与请求对象对应 */
+ SendSmsResponse res = client.SendSms(req);
+
+ return res;
+ // 输出json格式的字符串回包
+
+
+ // 也可以取出单个值,您可以通过官网接口文档或跳转到response对象的定义处查看返回字段的定义
+ // System.out.println(res.getRequestId());
+
+
+ /* 当出现以下错误码时,快速解决方案参考
+ * [FailedOperation.SignatureIncorrectOrUnapproved](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Afailedoperation.signatureincorrectorunapproved-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F)
+ * [FailedOperation.TemplateIncorrectOrUnapproved](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Afailedoperation.templateincorrectorunapproved-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F)
+ * [UnauthorizedOperation.SmsSdkAppIdVerifyFail](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Aunauthorizedoperation.smssdkappidverifyfail-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F)
+ * [UnsupportedOperation.ContainDomesticAndInternationalPhoneNumber](https://cloud.tencent.com/document/product/382/9558#.E7.9F.AD.E4.BF.A1.E5.8F.91.E9.80.81.E6.8F.90.E7.A4.BA.EF.BC.9Aunsupportedoperation.containdomesticandinternationalphonenumber-.E5.A6.82.E4.BD.95.E5.A4.84.E7.90.86.EF.BC.9F)
+ * 更多错误,可咨询[腾讯云助手](https://tccc.qcloud.com/web/im/index.html#/chat?webAppId=8fa15978f85cb41f7e2ea36920cb3ae1&title=Sms)
+ */
+
+
+ } catch (TencentCloudSDKException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+}
diff --git a/yami-shop-service/src/main/resources/mapper/ProductMapper.xml b/yami-shop-service/src/main/resources/mapper/ProductMapper.xml
index 891f505..3ec4721 100644
--- a/yami-shop-service/src/main/resources/mapper/ProductMapper.xml
+++ b/yami-shop-service/src/main/resources/mapper/ProductMapper.xml
@@ -254,5 +254,10 @@
where tp.product_type = 2 and tp.status = 1
+
+
diff --git a/yami-shop-service/src/main/resources/mapper/UserMapper.xml b/yami-shop-service/src/main/resources/mapper/UserMapper.xml
index 2b07e33..82265f6 100644
--- a/yami-shop-service/src/main/resources/mapper/UserMapper.xml
+++ b/yami-shop-service/src/main/resources/mapper/UserMapper.xml
@@ -22,6 +22,7 @@
+