cc
This commit is contained in:
@@ -278,3 +278,21 @@ func (l *LawsuitQueryService) CheckPayment(userid uint) (payment bool, err error
|
||||
|
||||
return true, nil
|
||||
}
|
||||
func (a *LawsuitQueryService) LawsuitDataAnalysis(respString string) (data []map[string]interface{}, err error) {
|
||||
var resp model.YuShanResponse[[]map[string]interface{}]
|
||||
err = json.Unmarshal([]byte(respString), &resp)
|
||||
if err != nil {
|
||||
log.Printf("Lawsuit Unmarshal error:%v", err)
|
||||
return nil, utils.ErrSystemError
|
||||
}
|
||||
if resp.Retcode == RetCodeSuccess {
|
||||
data = resp.Retdata
|
||||
return data, nil
|
||||
} else if resp.Retcode == RetCodeEmpty {
|
||||
log.Printf("Lawsuit resp empty:%s", resp.Retmsg)
|
||||
return data, utils.ErrNoRecord
|
||||
} else {
|
||||
log.Printf("Lawsuit resp error:%s", resp.Retmsg)
|
||||
return data, utils.ErrSystemError
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,35 @@ func (a *OrderService) GetList(pageSize int, pageNum int, userId uint) (list []m
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
func (a *OrderService) GetListByPromotion(pageSize int, pageNum int, promotion string) (list []model.PayOrder, err error) {
|
||||
offset := (pageNum - 1) * pageSize
|
||||
result := db.DB.Preload("Product").Where("promotion = ? AND pay_status IN ?", promotion, []string{model.PayStatusSuccess}).Order("id desc").Limit(pageSize).Offset(offset).Find(&list)
|
||||
if result.Error != nil {
|
||||
return list, result.Error
|
||||
}
|
||||
return list, nil
|
||||
}
|
||||
func (a *OrderService) GetSummaryByPromotion(promotion string) (totalCount int64, totalAmount float64, err error) {
|
||||
var count int64
|
||||
var amount float64
|
||||
|
||||
// 查询总单数
|
||||
if err := db.DB.Model(&model.PayOrder{}).
|
||||
Where("promotion = ? AND pay_status IN ?", promotion, []string{model.PayStatusSuccess}).
|
||||
Count(&count).Error; err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
// 查询总金额,使用 COALESCE 防止 NULL
|
||||
if err := db.DB.Model(&model.PayOrder{}).
|
||||
Where("promotion = ? AND pay_status IN ?", promotion, []string{model.PayStatusSuccess}).
|
||||
Select("COALESCE(SUM(amount), 0)").Scan(&amount).Error; err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return count, amount, nil
|
||||
}
|
||||
|
||||
func (a *OrderService) GetOrderByid(id uint) (order *model.PayOrder, err error) {
|
||||
order = &model.PayOrder{}
|
||||
err = db.DB.Preload("Product").Where("id = ?", id).First(order).Error
|
||||
@@ -120,7 +149,7 @@ func (a *OrderService) WeChatRefund(order model.PayOrder) (err error) {
|
||||
switch order.Platform {
|
||||
case model.PlatformMPWEIXIN:
|
||||
client = global.GlobalData.PayClient
|
||||
case model.PlatformMPH5:
|
||||
case model.PlatformMPH5, model.PlatformTYDATA:
|
||||
client = global.GlobalData.PayH5Client
|
||||
}
|
||||
outRefundNo := utils.GenerateOrderRefundNumber()
|
||||
|
||||
@@ -202,14 +202,14 @@ func (r *RequestService) WestDexRequest(code string, reqData map[string]interfac
|
||||
return "", err
|
||||
}
|
||||
key := "121a1e41fc1690dd6b90afbcacd80cf4" // 你的AES密钥
|
||||
|
||||
log.Printf("【西部数据请求】响应数据:%+v", westDexResp)
|
||||
if westDexResp.Code != "00000" {
|
||||
//decryptedData, err := utils.WestDexDecrypt(westDexResp.Data, key)
|
||||
if err != nil {
|
||||
log.Printf("【西部数据请求】响应数据解密错误: %v", err)
|
||||
return "", err
|
||||
}
|
||||
log.Printf("【西部数据请求】响应数据业务失败:%v", westDexResp.Message)
|
||||
log.Printf("【西部数据请求】响应数据业务失败:%+v", westDexResp)
|
||||
return "", errors.New("业务失败")
|
||||
}
|
||||
// 解密响应数据
|
||||
@@ -218,8 +218,7 @@ func (r *RequestService) WestDexRequest(code string, reqData map[string]interfac
|
||||
log.Printf("【西部数据请求】响应数据解密错误: %v", err)
|
||||
return "", err
|
||||
}
|
||||
// 输出解密后的数据
|
||||
log.Printf("【西部数据请求】解密后的响应数据: %s", decryptedData)
|
||||
log.Printf("【西部数据请求】响应解密后数据:%v", decryptedData)
|
||||
return decryptedData, nil
|
||||
}
|
||||
log.Printf("【西部数据请求】请求失败,状态码: %s", resp.Status)
|
||||
|
||||
@@ -4,8 +4,6 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"qnc-server/config"
|
||||
"qnc-server/db"
|
||||
@@ -114,18 +112,10 @@ func (a *SingleQueryService) MarryDataAnalysis(respString string) (data []map[st
|
||||
func (a *SingleQueryService) MarryAnalysis(jsonStr string) (resp *model.MerryResponse, err error) {
|
||||
err = json.Unmarshal([]byte(jsonStr), &resp)
|
||||
if err != nil {
|
||||
fmt.Printf("【婚姻结果解析错误】JSON解析错误: %v\n", err)
|
||||
log.Printf("【婚姻结果解析错误】JSON解析错误: %v\n", err)
|
||||
return
|
||||
}
|
||||
// 根据状态码分类处理
|
||||
switch resp.Code {
|
||||
case 201, 202, 203:
|
||||
return resp, nil
|
||||
case 300:
|
||||
return nil, utils.ErrNoRecord
|
||||
default:
|
||||
return nil, errors.New(resp.Msg)
|
||||
}
|
||||
return
|
||||
}
|
||||
func (a *SingleQueryService) QueryEvaluateMarriageOrder(orderID uint) (m model.EvaluateMarriage, err error) {
|
||||
err = db.DB.Where("order_id = ?", orderID).First(&m).Error
|
||||
|
||||
@@ -63,6 +63,44 @@ func (UserService *UserService) RequestWx(code string) (wxResponse response.WxLo
|
||||
}
|
||||
return
|
||||
}
|
||||
func (UserService *UserService) RequestWxTyData(code string) (wxResponse response.WxLoginResp, err error) {
|
||||
|
||||
// 向微信发出登录请求
|
||||
baseURL := config.ConfigData.System.WxTyDataLoginUrl
|
||||
// 创建查询参数
|
||||
params := url.Values{}
|
||||
params.Add("appid", config.ConfigData.System.WxTyDataAppId)
|
||||
params.Add("secret", config.ConfigData.System.WxTyDataSecret)
|
||||
params.Add("js_code", code)
|
||||
params.Add("grant_type", "authorization_code")
|
||||
|
||||
// 构建完整的请求 URL
|
||||
requestURL := fmt.Sprintf("%s?%s", baseURL, params.Encode())
|
||||
|
||||
// 发送 GET 请求
|
||||
resp, err := http.Get(requestURL)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
// 读取响应体
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// 将响应体解析为结构体
|
||||
err = json.Unmarshal(body, &wxResponse)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if wxResponse.ErrCode != 0 {
|
||||
err = errors.New(wxResponse.ErrMsg)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Login 全能查 公众号 获取access_token
|
||||
func (UserService *UserService) RequestWxH5(code string) (wxH5Response response.WxH5LoginResp, err error) {
|
||||
|
||||
@@ -47,6 +47,7 @@ func (c *VerifyService) VerifReqYuShan(prodID string, data *map[string]interface
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
log.Printf("【羽山接口响应返回】 %s error: %s", prodID, err.Error())
|
||||
//解密
|
||||
sDec, err := base64.StdEncoding.DecodeString(respStr)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user