Ver Fonte

创建商品订单

kobe6258 há 4 meses atrás
pai
commit
498c6d0348

+ 0 - 5
api/ht_account_api.go

@@ -79,11 +79,6 @@ func (f *HTAccountApi) EnCodeData(req CustomerRiskReq) (token string, err error)
 		return
 	}
 	token = base64.StdEncoding.EncodeToString(rsa)
-	token = "ATXEfCqzhAp7hiM1fIWE7SJ6WqHqAX6oCInDi2BA+RTCZBDOJzFEL16HVhGQKGnYzw3tVSKA2XMsX+Cnw1Cbd/iR10cXYk9m0JE/WodQRxfIwYlq2mjpQS0CsNqzuiR+iSBqpqA/ZUZ8+3oeTVfK0vNXc91NgdnpqA6oqwln3Ouj8XKmXbJSFVPt9/5LP/GKL5fSIFtxIx2QcwTobV05htAE0vpn0ZQ7elHnXyhb5qlBOHXYgWaOKFy0/d73kdWsGTawxcrmQINeaXOXOssuQlzwq+2edZSUzLY3Jr0KRh9mcXm6mL+2u/31jCbELG/ouvBY8s2+7XdBl0QQEm9FEw=="
-	logger.Info("加密后数据:%v", token)
-	private, _ := auth.ParsePrivateKey(f.htConfig.GetWebhookPrivateKey())
-	aa, _ := auth.DecryptWithRSA(private, token)
-	fmt.Println(string(aa))
 	return
 }
 

+ 7 - 0
common/exception/exc_enums.go

@@ -134,6 +134,11 @@ const (
 	OrderPayTimeoutError
 )
 
+const (
+	ProductErrorCode int = iota + 100000
+	ProductOffSale
+)
+
 // ErrorMap 用于存储错误码和错误信息的映射
 var ErrorMap = map[int]string{
 	SysError:              "系统异常",
@@ -225,6 +230,8 @@ var ErrorMap = map[int]string{
 	//order
 	IllegalOrderStatus:   "非法的订单状态",
 	OrderPayTimeoutError: "订单支付超时",
+	//product
+	ProductOffSale: "商品已下架",
 }
 
 func Equals(code int, message string) bool {

+ 13 - 14
common/utils/auth/rsa_utils.go

@@ -21,26 +21,25 @@ func EncryptWithRSA(publicKey *rsa.PublicKey, data []byte) ([]byte, error) {
 }
 
 // DecryptWithRSA 使用 RSA 私钥解密数据
-func DecryptWithRSA(privateKey *rsa.PrivateKey, encrypted string) ([]byte, error) {
-	encKey, _ := base64.StdEncoding.DecodeString(encrypted)
-	blockSize := privateKey.Size()
-	maxChunkSize := blockSize
-	var plaintext []byte
-	for len(encKey) > 0 {
+func DecryptWithRSA(privateKey *rsa.PrivateKey, encryptedText string) (plaintext []byte, err error) {
+	encryptBytes, _ := base64.StdEncoding.DecodeString(encryptedText)
+	maxChunkSize := privateKey.Size()
+	for len(encryptBytes) > 0 {
 		chunkSize := maxChunkSize
-		if len(encKey) < chunkSize {
-			chunkSize = len(encKey)
+		if len(encryptBytes) < chunkSize {
+			chunkSize = len(encryptBytes)
 		}
-
-		chunk := encKey[:chunkSize]
-		encKey = encKey[chunkSize:]
-		decryptedChunk, err := rsa.DecryptPKCS1v15(rand.Reader, privateKey, chunk)
+		encryptedChunk := encryptBytes[:chunkSize]
+		encryptBytes = encryptBytes[chunkSize:]
+		var decryptedChunk []byte
+		decryptedChunk, err = rsa.DecryptPKCS1v15(rand.Reader, privateKey, encryptedChunk)
 		if err != nil {
-			return nil, err
+			logger.Error("RSA解密失败", err)
+			return
 		}
 		plaintext = append(plaintext, decryptedChunk...)
 	}
-	return plaintext, nil
+	return
 }
 
 // ParsePrivateKeyFromPEM 解析RSA公钥

+ 1 - 1
controllers/order/order_controller.go → controllers/user/order_controller.go

@@ -1,4 +1,4 @@
-package order
+package user
 
 import (
 	"eta/eta_mini_ht_api/common/exception"

+ 13 - 9
controllers/web_hook/htfutures_account_controller.go

@@ -125,11 +125,11 @@ func (h *HTFuturesAccountController) SyncCustomerRiskLevel() {
 			h.FailedResult("身份证号不能为空", result)
 			return
 		}
-		//if !utils.IsValidIDCard(custInfo.IdNo) && !utils.IsValidOldIDCard(custInfo.IdNo) {
-		//	err = exception.New(exception.SyncRiskError)
-		//	h.FailedResult("身份证号不合法", result)
-		//	return
-		//}
+		if custInfo.DealMobileTel != custInfo.MobileTel {
+			err = exception.New(exception.SyncRiskError)
+			h.FailedResult(fmt.Sprintf("柜台预留手机号码不一致,测评手机:%s,柜台预留手机:%s", custInfo.DealMobileTel, custInfo.MobileTel), result)
+			return
+		}
 		if riskInfo.CorpRiskLevel == "" {
 			err = exception.New(exception.SyncRiskError)
 			h.FailedResult("风险等级不能为空", result)
@@ -176,6 +176,7 @@ func (h *HTFuturesAccountController) SyncCustomerAccountInfo() {
 		h.GetPostParams(syncCustomerRiskLevelReq)
 		custInfo := syncCustomerRiskLevelReq.CustInfo
 		riskInfo := syncCustomerRiskLevelReq.RiskInfo
+
 		if custInfo.ClientName == "" {
 			err = exception.New(exception.SyncRiskError)
 			h.FailedResult("用户名字不能为空", result)
@@ -191,6 +192,7 @@ func (h *HTFuturesAccountController) SyncCustomerAccountInfo() {
 			h.FailedResult("身份证号不能为空", result)
 			return
 		}
+
 		//if !utils.IsValidIDCard(custInfo.IdNo) && !utils.IsValidOldIDCard(custInfo.IdNo) {
 		//	err = exception.New(exception.SyncRiskError)
 		//	h.FailedResult("身份证号不合法", result)
@@ -206,6 +208,7 @@ func (h *HTFuturesAccountController) SyncCustomerAccountInfo() {
 			h.FailedResult("风险测评有效结束日期不能为空", result)
 			return
 		}
+
 		err = userService.UpdateRiskLevelInfo(userService.RiskLevelInfoDTO{
 			Name:             custInfo.ClientName,
 			PhoneNumber:      custInfo.MobileTel,
@@ -231,10 +234,11 @@ type SyncCustomerRiskLevelReq struct {
 }
 
 type CustInfo struct {
-	MobileTel  string `json:"mobile_tel"`
-	ClientName string `json:"client_name"`
-	IdKind     string `json:"id_kind"`
-	IdNo       string `json:"id_no"`
+	MobileTel     string `json:"mobile_tel"`
+	DealMobileTel string `json:"deal_mobile_tel"`
+	ClientName    string `json:"client_name"`
+	IdKind        string `json:"id_kind"`
+	IdNo          string `json:"id_no"`
 }
 
 type RiskInfo struct {

+ 4 - 3
domian/merchant/merchant_product.go

@@ -27,10 +27,11 @@ type MerchantProductDTO struct {
 	Type        string
 	IsPermanent bool
 	ValidDays   int
+	SaleStatus  string
 }
 
-func GetMerchantProductById(id int) (product MerchantProductDTO, err error) {
-	productDao, err := merchantDao.GetMerchantProductById(id)
+func GetMerchantProductById(id int) (productDTO MerchantProductDTO, err error) {
+	product, err := merchantDao.GetMerchantProductById(id)
 	if err != nil {
 		if errors.Is(err, gorm.ErrRecordNotFound) {
 			logger.Error("商品信息不存在[productId:%d]", id)
@@ -38,7 +39,7 @@ func GetMerchantProductById(id int) (product MerchantProductDTO, err error) {
 			logger.Error("获取商品信息失败[productId:%d],err:", id, err)
 		}
 	}
-	product = convertToDTO(productDao)
+	productDTO = convertToDTO(product)
 	return
 }
 func convertToDTO(product merchantDao.MerchantProduct) MerchantProductDTO {

+ 1 - 1
models/merchant/merchant_product.go

@@ -11,7 +11,7 @@ type SaleStatus string
 type MerchantProductType string
 
 const (
-	detailColumns  = "id,title,price,is_permanent,valid_days,type,risk_level"
+	detailColumns  = "id,title,price,is_permanent,valid_days,type,risk_level,stale_status"
 	sourceIdColumn = "id,risk_level,source_id"
 )
 const (

+ 1 - 2
routers/router.go

@@ -3,7 +3,6 @@ package routers
 import (
 	"eta/eta_mini_ht_api/controllers"
 	"eta/eta_mini_ht_api/controllers/media"
-	"eta/eta_mini_ht_api/controllers/order"
 	"eta/eta_mini_ht_api/controllers/product"
 	"eta/eta_mini_ht_api/controllers/report"
 	"eta/eta_mini_ht_api/controllers/sys"
@@ -73,7 +72,7 @@ func init() {
 		),
 		web.NSNamespace("/order",
 			web.NSInclude(
-				&order.OrderController{},
+				&user.OrderController{},
 			),
 		),
 		web.NSNamespace("/ws",

+ 6 - 0
service/order/order_service.go

@@ -17,6 +17,8 @@ import (
 
 const (
 	permanentlyValid = "永久有效"
+	OnSale           = "on_sale"  //上架
+	OffSale          = "off_sale" //下架
 )
 
 type ProductOrderInfo struct {
@@ -48,6 +50,10 @@ func CreateProductOrder(templateUser user.User, productId int, orderNo string) (
 		err = exception.NewWithException(exception.ProductInfoError, err.Error())
 		return
 	}
+	if productInfo.SaleStatus == OffSale {
+		err = exception.New(exception.ProductOffSale)
+		return
+	}
 	officialUser, err := userService.GetUserByTemplateUserId(templateUser.Id)
 	if err != nil {
 		if errors.Is(err, gorm.ErrRecordNotFound) {