Compare commits
50 Commits
7b47f4512f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9906e97328 | |||
| 6c540c4216 | |||
| fc9d7983b7 | |||
| 93886e2e90 | |||
| 7aa4fb60f6 | |||
| 81cd477c62 | |||
| 323f14e1f5 | |||
| cff19bb80d | |||
| 347306426f | |||
| f5f0e0d8b2 | |||
| 4908048b5b | |||
| 0b87a39c41 | |||
| d209270630 | |||
| 96a02f73d4 | |||
| 021349c60e | |||
| a63e4a9dbb | |||
| f6d3b80659 | |||
| d630d84718 | |||
| b3429bad76 | |||
| 60a0770917 | |||
| ed5ebc5648 | |||
| d63338aea4 | |||
| 578911c6ae | |||
| 5b5a708c84 | |||
| c4c3423de0 | |||
| 250dd83506 | |||
| fdc6c24c79 | |||
| b3105417ec | |||
| 54e3edfea7 | |||
| ef6ca3b9da | |||
| 07ad436fd5 | |||
| ad28fc2301 | |||
| ad809f6f8b | |||
| e96adc9f98 | |||
| a14f1dcf2a | |||
| 5942de22ad | |||
| e30e69f8b8 | |||
| c9b83926a5 | |||
| fbaab6a45c | |||
| 3a8f31a3c2 | |||
| 586330cfa6 | |||
| 04df8460a4 | |||
| 0206710e29 | |||
| d1c59b6803 | |||
| 668b3f65e3 | |||
| adb678435e | |||
| 3c6e2683f5 | |||
| dc747139c9 | |||
| 21194c60a8 | |||
| e6485c034f |
Binary file not shown.
Binary file not shown.
@@ -82,6 +82,14 @@ service main {
|
||||
// 邀请码列表查询
|
||||
@handler AdminGetInviteCodeList
|
||||
get /invite_code/list (AdminGetInviteCodeListReq) returns (AdminGetInviteCodeListResp)
|
||||
|
||||
// 代理手机号修改
|
||||
@handler AdminUpdateAgentMobile
|
||||
post /mobile/update (AdminUpdateAgentMobileReq) returns (AdminUpdateAgentMobileResp)
|
||||
|
||||
// 代理等级降级(管理端)
|
||||
@handler AdminDowngradeAgent
|
||||
post /level/downgrade (AdminDowngradeAgentReq) returns (AdminDowngradeAgentResp)
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -109,6 +117,8 @@ type (
|
||||
FrozenBalance float64 `json:"frozen_balance"` // 冻结余额
|
||||
WithdrawnAmount float64 `json:"withdrawn_amount"` // 提现总额
|
||||
IsRealName bool `json:"is_real_name"` // 是否已实名
|
||||
RealName string `json:"real_name"` // 姓名(实名认证的姓名)
|
||||
IdCardPlain string `json:"id_card_plain"` // 身份证号(解密后的明文)
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
AdminGetAgentListResp {
|
||||
@@ -153,6 +163,7 @@ type (
|
||||
AgentId *string `form:"agent_id,optional"` // 代理ID(可选)
|
||||
OrderId *string `form:"order_id,optional"` // 订单ID(可选)
|
||||
ProcessStatus *int64 `form:"process_status,optional"` // 处理状态(可选)
|
||||
OrderStatus *string `form:"order_status,optional"` // 订单状态(可选):pending-待支付,paid-已支付,refunded-已退款,closed-已关闭,failed-支付失败
|
||||
}
|
||||
AgentOrderListItem {
|
||||
Id string `json:"id"` // 主键
|
||||
@@ -165,7 +176,8 @@ type (
|
||||
ActualBasePrice float64 `json:"actual_base_price"` // 实际底价
|
||||
PriceCost float64 `json:"price_cost"` // 提价成本
|
||||
AgentProfit float64 `json:"agent_profit"` // 代理收益
|
||||
ProcessStatus int64 `json:"process_status"` // 处理状态
|
||||
ProcessStatus int64 `json:"process_status"` // 处理状态(保留用于筛选,前端不显示)
|
||||
OrderStatus string `json:"order_status"` // 订单状态:pending-待支付,paid-已支付,refunded-已退款,closed-已关闭,failed-支付失败
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
AdminGetAgentOrderListResp {
|
||||
@@ -200,6 +212,7 @@ type (
|
||||
AgentId *string `form:"agent_id,optional"` // 代理ID(可选)
|
||||
SourceAgentId *string `form:"source_agent_id,optional"` // 来源代理ID(可选)
|
||||
RebateType *int64 `form:"rebate_type,optional"` // 返佣类型(可选)
|
||||
Status *int64 `form:"status,optional"` // 状态(可选):1=已发放,2=已冻结,3=已取消(已退款)
|
||||
}
|
||||
AgentRebateListItem {
|
||||
Id string `json:"id"` // 主键
|
||||
@@ -208,6 +221,7 @@ type (
|
||||
OrderId string `json:"order_id"` // 订单ID
|
||||
RebateType int64 `json:"rebate_type"` // 返佣类型
|
||||
Amount float64 `json:"amount"` // 金额
|
||||
Status int64 `json:"status"` // 状态:1=已发放,2=已冻结,3=已取消(已退款)
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
AdminGetAgentRebateListResp {
|
||||
@@ -253,8 +267,11 @@ type (
|
||||
TaxAmount float64 `json:"tax_amount"` // 税费金额
|
||||
ActualAmount float64 `json:"actual_amount"` // 实际到账金额
|
||||
Status int64 `json:"status"` // 状态
|
||||
PayeeAccount string `json:"payee_account"` // 收款账户
|
||||
WithdrawalType int64 `json:"withdrawal_type"` // 提现方式:1=支付宝,2=银行卡
|
||||
PayeeAccount string `json:"payee_account"` // 收款账户(支付宝账号或银行卡号)
|
||||
PayeeName string `json:"payee_name"` // 收款人姓名
|
||||
BankCardNo string `json:"bank_card_no"` // 银行卡号(银行卡提现时使用)
|
||||
BankName string `json:"bank_name"` // 开户行名称(银行卡提现时使用)
|
||||
Remark string `json:"remark"` // 备注
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
@@ -422,5 +439,22 @@ type (
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []InviteCodeListItem `json:"items"` // 列表数据
|
||||
}
|
||||
// 代理手机号修改
|
||||
AdminUpdateAgentMobileReq {
|
||||
AgentId string `json:"agent_id"` // 代理ID
|
||||
Mobile string `json:"mobile"` // 新手机号
|
||||
}
|
||||
AdminUpdateAgentMobileResp {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
// 代理等级降级
|
||||
AdminDowngradeAgentReq {
|
||||
AgentId string `json:"agent_id"` // 代理ID
|
||||
ToLevel int64 `json:"to_level"` // 目标等级:1=普通,2=黄金,3=钻石(须低于当前等级)
|
||||
Remark string `json:"remark,optional"` // 备注(可选)
|
||||
}
|
||||
AdminDowngradeAgentResp {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
178
app/main/api/desc/admin/admin_complaint.api
Normal file
178
app/main/api/desc/admin/admin_complaint.api
Normal file
@@ -0,0 +1,178 @@
|
||||
syntax = "v1"
|
||||
|
||||
info (
|
||||
title: "投诉管理服务"
|
||||
desc: "投诉管理相关接口"
|
||||
version: "v1"
|
||||
)
|
||||
|
||||
@server (
|
||||
prefix: api/v1/admin/complaint
|
||||
group: admin_complaint
|
||||
middleware: AdminAuthInterceptor
|
||||
)
|
||||
service main {
|
||||
@doc "获取投诉列表"
|
||||
@handler AdminGetComplaintList
|
||||
get /list (AdminGetComplaintListReq) returns (AdminGetComplaintListResp)
|
||||
|
||||
@doc "获取投诉详情"
|
||||
@handler AdminGetComplaintDetail
|
||||
get /detail/:id (AdminGetComplaintDetailReq) returns (AdminGetComplaintDetailResp)
|
||||
|
||||
@doc "更新投诉状态"
|
||||
@handler AdminUpdateComplaintStatus
|
||||
put /update-status/:id (AdminUpdateComplaintStatusReq) returns (AdminUpdateComplaintStatusResp)
|
||||
|
||||
@doc "更新投诉备注"
|
||||
@handler AdminUpdateComplaintRemark
|
||||
put /update-remark/:id (AdminUpdateComplaintRemarkReq) returns (AdminUpdateComplaintRemarkResp)
|
||||
}
|
||||
|
||||
type (
|
||||
// 列表请求
|
||||
AdminGetComplaintListReq {
|
||||
Page int64 `form:"page,default=1"` // 页码
|
||||
PageSize int64 `form:"pageSize,default=20"` // 每页数量
|
||||
Type string `form:"type,optional"` // 投诉类型:alipay-支付宝投诉,manual-主动投诉
|
||||
Status string `form:"status,optional"` // 投诉状态:pending-待处理,processing-处理中,resolved-已解决,closed-已关闭
|
||||
Name string `form:"name,optional"` // 投诉人姓名
|
||||
Contact string `form:"contact,optional"` // 联系方式
|
||||
OrderId string `form:"order_id,optional"` // 关联订单ID
|
||||
CreateTimeStart string `form:"create_time_start,optional"` // 创建时间开始
|
||||
CreateTimeEnd string `form:"create_time_end,optional"` // 创建时间结束
|
||||
HandleTimeStart string `form:"handle_time_start,optional"` // 处理时间开始
|
||||
HandleTimeEnd string `form:"handle_time_end,optional"` // 处理时间结束
|
||||
}
|
||||
|
||||
// 列表响应
|
||||
AdminGetComplaintListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []ComplaintListItem `json:"items"` // 列表
|
||||
}
|
||||
|
||||
// 列表项
|
||||
ComplaintListItem {
|
||||
Id string `json:"id"` // 投诉ID
|
||||
Type string `json:"type"` // 投诉类型:alipay-支付宝投诉,manual-主动投诉
|
||||
OrderId string `json:"order_id"` // 关联订单ID
|
||||
Name string `json:"name"` // 投诉人姓名
|
||||
Contact string `json:"contact"` // 联系方式
|
||||
Content string `json:"content"` // 投诉内容
|
||||
Status string `json:"status"` // 投诉状态
|
||||
StatusDescription string `json:"status_description"` // 状态描述
|
||||
Remark string `json:"remark"` // 处理备注
|
||||
HandlerId string `json:"handler_id"` // 处理人ID
|
||||
HandleTime string `json:"handle_time"` // 处理时间
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
UpdateTime string `json:"update_time"` // 更新时间
|
||||
// 支付宝投诉特有字段
|
||||
TaskId string `json:"task_id"` // 支付宝投诉单号
|
||||
TradeNo string `json:"trade_no"` // 支付宝交易单号
|
||||
ComplainAmount string `json:"complain_amount"` // 投诉金额
|
||||
GmtComplain string `json:"gmt_complain"` // 投诉时间
|
||||
// 主动投诉特有字段
|
||||
Subject string `json:"subject"` // 投诉主题
|
||||
Priority string `json:"priority"` // 优先级
|
||||
Source string `json:"source"` // 投诉来源
|
||||
}
|
||||
|
||||
// 详情请求
|
||||
AdminGetComplaintDetailReq {
|
||||
Id string `path:"id"` // 投诉ID
|
||||
}
|
||||
|
||||
// 详情响应
|
||||
AdminGetComplaintDetailResp {
|
||||
Id string `json:"id"` // 投诉ID
|
||||
Type string `json:"type"` // 投诉类型:alipay-支付宝投诉,manual-主动投诉
|
||||
OrderId string `json:"order_id"` // 关联订单ID
|
||||
Name string `json:"name"` // 投诉人姓名
|
||||
Contact string `json:"contact"` // 联系方式
|
||||
Content string `json:"content"` // 投诉内容
|
||||
Status string `json:"status"` // 投诉状态
|
||||
StatusDescription string `json:"status_description"` // 状态描述
|
||||
Remark string `json:"remark"` // 处理备注
|
||||
HandlerId string `json:"handler_id"` // 处理人ID
|
||||
HandleTime string `json:"handle_time"` // 处理时间
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
UpdateTime string `json:"update_time"` // 更新时间
|
||||
// 支付宝投诉详情
|
||||
AlipayComplaint *AlipayComplaintDetail `json:"alipay_complaint,optional"` // 支付宝投诉详情
|
||||
// 主动投诉详情
|
||||
ManualComplaint *ManualComplaintDetail `json:"manual_complaint,optional"` // 主动投诉详情
|
||||
}
|
||||
|
||||
// 支付宝投诉详情
|
||||
AlipayComplaintDetail {
|
||||
Id string `json:"id"` // 支付宝投诉表ID
|
||||
AlipayId int64 `json:"alipay_id"` // 支付宝投诉主表的主键id
|
||||
TaskId string `json:"task_id"` // 投诉单号id
|
||||
OppositePid string `json:"opposite_pid"` // 被投诉人pid
|
||||
OppositeName string `json:"opposite_name"` // 被投诉方名称
|
||||
ComplainAmount string `json:"complain_amount"` // 投诉单涉及交易总金额
|
||||
GmtComplain string `json:"gmt_complain"` // 投诉时间
|
||||
GmtProcess string `json:"gmt_process"` // 处理时间
|
||||
ComplainContent string `json:"complain_content"` // 用户投诉内容
|
||||
TradeNo string `json:"trade_no"` // 投诉交易单号
|
||||
Status string `json:"status"` // 投诉状态
|
||||
StatusDescription string `json:"status_description"` // 投诉单状态枚举值描述
|
||||
ProcessCode string `json:"process_code"` // 商家处理结果码
|
||||
ProcessMessage string `json:"process_message"` // 商家处理结果码对应描述
|
||||
ProcessRemark string `json:"process_remark"` // 商家处理备注
|
||||
ProcessImgUrlList []string `json:"process_img_url_list"` // 商家处理备注图片url列表
|
||||
GmtRiskFinishTime string `json:"gmt_risk_finish_time"` // 推送时间
|
||||
ComplainUrl string `json:"complain_url"` // 投诉网址
|
||||
CertifyInfo []string `json:"certify_info"` // 投诉凭证图片信息
|
||||
TradeInfoList []AlipayComplaintTradeInfo `json:"trade_info_list"` // 交易信息列表
|
||||
}
|
||||
|
||||
// 支付宝投诉交易信息
|
||||
AlipayComplaintTradeInfo {
|
||||
Id string `json:"id"` // 交易信息表ID
|
||||
AlipayTradeId string `json:"alipay_trade_id"` // 交易信息表主键id
|
||||
AlipayComplaintRecordId string `json:"alipay_complaint_record_id"` // 投诉主表id
|
||||
TradeNo string `json:"trade_no"` // 支付宝交易单号
|
||||
OutNo string `json:"out_no"` // 商家订单号
|
||||
GmtTrade string `json:"gmt_trade"` // 交易时间
|
||||
GmtRefund string `json:"gmt_refund"` // 退款时间
|
||||
Status string `json:"status"` // 交易投诉状态
|
||||
StatusDescription string `json:"status_description"` // 交易投诉状态描述
|
||||
Amount string `json:"amount"` // 交易单金额
|
||||
}
|
||||
|
||||
// 主动投诉详情
|
||||
ManualComplaintDetail {
|
||||
Id string `json:"id"` // 主动投诉表ID
|
||||
UserId string `json:"user_id"` // 关联用户ID
|
||||
Subject string `json:"subject"` // 投诉主题
|
||||
Priority string `json:"priority"` // 优先级:low-低,medium-中,high-高,urgent-紧急
|
||||
Source string `json:"source"` // 投诉来源:web-网站,phone-电话,email-邮件,other-其他
|
||||
AttachmentUrls []string `json:"attachment_urls"` // 附件URL列表
|
||||
}
|
||||
|
||||
// 更新投诉状态请求
|
||||
AdminUpdateComplaintStatusReq {
|
||||
Id string `path:"id"` // 投诉ID
|
||||
Status string `json:"status"` // 投诉状态:pending-待处理,processing-处理中,resolved-已解决,closed-已关闭
|
||||
StatusDescription string `json:"status_description,optional"` // 状态描述
|
||||
HandlerId string `json:"handler_id,optional"` // 处理人ID
|
||||
}
|
||||
|
||||
// 更新投诉状态响应
|
||||
AdminUpdateComplaintStatusResp {
|
||||
Success bool `json:"success"` // 是否成功
|
||||
}
|
||||
|
||||
// 更新投诉备注请求
|
||||
AdminUpdateComplaintRemarkReq {
|
||||
Id string `path:"id"` // 投诉ID
|
||||
Remark string `json:"remark"` // 处理备注
|
||||
}
|
||||
|
||||
// 更新投诉备注响应
|
||||
AdminUpdateComplaintRemarkResp {
|
||||
Success bool `json:"success"` // 是否成功
|
||||
}
|
||||
)
|
||||
|
||||
@@ -47,6 +47,8 @@ type (
|
||||
AdminCreateFeatureReq {
|
||||
ApiId string `json:"api_id"` // API标识
|
||||
Name string `json:"name"` // 描述
|
||||
WhitelistPrice *float64 `json:"whitelist_price,optional"` // 白名单屏蔽价格(单位:元)
|
||||
CostPrice *float64 `json:"cost_price,optional"` // 天远API调用成本价(单位:元)
|
||||
}
|
||||
// 创建功能响应
|
||||
AdminCreateFeatureResp {
|
||||
@@ -57,6 +59,8 @@ type (
|
||||
Id string `path:"id"` // 功能ID
|
||||
ApiId *string `json:"api_id,optional"` // API标识
|
||||
Name *string `json:"name,optional"` // 描述
|
||||
WhitelistPrice *float64 `json:"whitelist_price,optional"` // 白名单屏蔽价格(单位:元)
|
||||
CostPrice *float64 `json:"cost_price,optional"` // 天远API调用成本价(单位:元)
|
||||
}
|
||||
// 更新功能响应
|
||||
AdminUpdateFeatureResp {
|
||||
@@ -82,6 +86,8 @@ type (
|
||||
Id string `json:"id"` // 功能ID
|
||||
ApiId string `json:"api_id"` // API标识
|
||||
Name string `json:"name"` // 描述
|
||||
WhitelistPrice float64 `json:"whitelist_price"` // 白名单屏蔽价格(单位:元)
|
||||
CostPrice float64 `json:"cost_price"` // 天远API调用成本价(单位:元)
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
UpdateTime string `json:"update_time"` // 更新时间
|
||||
}
|
||||
@@ -99,6 +105,8 @@ type (
|
||||
Id string `json:"id"` // 功能ID
|
||||
ApiId string `json:"api_id"` // API标识
|
||||
Name string `json:"name"` // 描述
|
||||
WhitelistPrice float64 `json:"whitelist_price"` // 白名单屏蔽价格(单位:元)
|
||||
CostPrice float64 `json:"cost_price"` // 天远API调用成本价(单位:元)
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
UpdateTime string `json:"update_time"` // 更新时间
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ type (
|
||||
ProductEn string `json:"product_en"` // 英文名
|
||||
Description string `json:"description"` // 描述
|
||||
Notes string `json:"notes,optional"` // 备注
|
||||
CostPrice float64 `json:"cost_price"` // 成本
|
||||
SellPrice float64 `json:"sell_price"` // 售价
|
||||
}
|
||||
|
||||
@@ -65,7 +64,6 @@ type (
|
||||
ProductEn *string `json:"product_en,optional"` // 英文名
|
||||
Description *string `json:"description,optional"` // 描述
|
||||
Notes *string `json:"notes,optional"` // 备注
|
||||
CostPrice *float64 `json:"cost_price,optional"` // 成本
|
||||
SellPrice *float64 `json:"sell_price,optional"` // 售价
|
||||
}
|
||||
|
||||
@@ -99,8 +97,8 @@ type (
|
||||
ProductEn string `json:"product_en"` // 英文名
|
||||
Description string `json:"description"` // 描述
|
||||
Notes string `json:"notes"` // 备注
|
||||
CostPrice float64 `json:"cost_price"` // 成本
|
||||
SellPrice float64 `json:"sell_price"` // 售价
|
||||
CostPrice float64 `json:"cost_price"` // 成本价(由功能成本累加得出)
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
UpdateTime string `json:"update_time"` // 更新时间
|
||||
}
|
||||
@@ -123,7 +121,6 @@ type (
|
||||
ProductEn string `json:"product_en"` // 英文名
|
||||
Description string `json:"description"` // 描述
|
||||
Notes string `json:"notes"` // 备注
|
||||
CostPrice float64 `json:"cost_price"` // 成本
|
||||
SellPrice float64 `json:"sell_price"` // 售价
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
UpdateTime string `json:"update_time"` // 更新时间
|
||||
|
||||
@@ -28,6 +28,10 @@ service main {
|
||||
@handler AdminGetQueryCleanupConfigList
|
||||
get /cleanup/configs (AdminGetQueryCleanupConfigListReq) returns (AdminGetQueryCleanupConfigListResp)
|
||||
|
||||
@doc "按 QueryId+FeatureApiId 补删单条查询的某个模块数据(仅内部运维使用)"
|
||||
@handler AdminDeleteQueryFeatureData
|
||||
post /cleanup/delete/feature (AdminDeleteQueryFeatureDataReq) returns (AdminDeleteQueryFeatureDataResp)
|
||||
|
||||
@doc "更新清理配置"
|
||||
@handler AdminUpdateQueryCleanupConfig
|
||||
put /cleanup/config (AdminUpdateQueryCleanupConfigReq) returns (AdminUpdateQueryCleanupConfigResp)
|
||||
@@ -41,12 +45,14 @@ service main {
|
||||
Id string `json:"id"` // 主键ID
|
||||
OrderId string `json:"order_id"` // 订单ID
|
||||
UserId string `json:"user_id"` // 用户ID
|
||||
ProductName string `json:"product_name"` // 产品ID
|
||||
ProductName string `json:"product_name"` // 产品名称
|
||||
QueryParams map[string]interface{} `json:"query_params"`
|
||||
QueryData []AdminQueryItem `json:"query_data"`
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
UpdateTime string `json:"update_time"` // 更新时间
|
||||
QueryState string `json:"query_state"` // 查询状态
|
||||
AgentUserName string `json:"agent_user_name"` // 代理用户姓名(非代理单时为空)
|
||||
AgentUserMobile string `json:"agent_user_mobile"` // 代理用户手机号(非代理单时为空)
|
||||
}
|
||||
|
||||
type AdminQueryItem {
|
||||
@@ -131,3 +137,14 @@ type AdminGetQueryCleanupConfigListResp {
|
||||
type AdminUpdateQueryCleanupConfigResp {
|
||||
Success bool `json:"success"` // 是否成功
|
||||
}
|
||||
|
||||
// 运维补删接口:按 QueryId+FeatureApiId 删除单条查询中的指定模块数据
|
||||
type AdminDeleteQueryFeatureDataReq {
|
||||
QueryId string `json:"query_id"` // 查询ID(Query表ID)
|
||||
FeatureApiId string `json:"feature_api_id"` // 模块API标识(与前台 OfflineFeature 一致)
|
||||
}
|
||||
|
||||
type AdminDeleteQueryFeatureDataResp {
|
||||
Success bool `json:"success"` // 是否删除成功(或数据本就不存在)
|
||||
Message string `json:"message"` // 结果说明
|
||||
}
|
||||
|
||||
94
app/main/api/desc/admin/dashboard.api
Normal file
94
app/main/api/desc/admin/dashboard.api
Normal file
@@ -0,0 +1,94 @@
|
||||
syntax = "v1"
|
||||
|
||||
info (
|
||||
title: "后台统计面板服务"
|
||||
desc: "后台统计面板相关接口"
|
||||
author: "team"
|
||||
version: "v1"
|
||||
)
|
||||
|
||||
// ============================================
|
||||
// 统计面板接口
|
||||
// ============================================
|
||||
@server (
|
||||
prefix: /api/v1/admin/dashboard
|
||||
group: admin_dashboard
|
||||
middleware: AdminAuthInterceptor
|
||||
)
|
||||
service main {
|
||||
// 获取统计面板数据
|
||||
@handler AdminGetDashboardStatistics
|
||||
get /statistics returns (AdminGetDashboardStatisticsResp)
|
||||
}
|
||||
|
||||
type (
|
||||
// 统计面板响应
|
||||
AdminGetDashboardStatisticsResp {
|
||||
// 订单统计
|
||||
OrderStats AdminOrderStatistics `json:"order_stats"`
|
||||
// 营收统计
|
||||
RevenueStats AdminRevenueStatistics `json:"revenue_stats"`
|
||||
// 代理统计
|
||||
AgentStats AdminAgentStatistics `json:"agent_stats"`
|
||||
// 利润统计
|
||||
ProfitStats AdminProfitStatistics `json:"profit_stats"`
|
||||
// 订单趋势(最近7天)
|
||||
OrderTrend []AdminTrendData `json:"order_trend"`
|
||||
// 营收趋势(最近7天)
|
||||
RevenueTrend []AdminTrendData `json:"revenue_trend"`
|
||||
}
|
||||
// 订单统计
|
||||
AdminOrderStatistics {
|
||||
TodayCount int64 `json:"today_count"` // 今日订单数
|
||||
MonthCount int64 `json:"month_count"` // 当月订单数
|
||||
TotalCount int64 `json:"total_count"` // 总订单数
|
||||
YesterdayCount int64 `json:"yesterday_count"` // 昨日订单数
|
||||
ChangeRate float64 `json:"change_rate"` // 变化率(百分比)
|
||||
}
|
||||
// 营收统计
|
||||
AdminRevenueStatistics {
|
||||
TodayAmount float64 `json:"today_amount"` // 今日营收
|
||||
MonthAmount float64 `json:"month_amount"` // 当月营收
|
||||
TotalAmount float64 `json:"total_amount"` // 总营收
|
||||
YesterdayAmount float64 `json:"yesterday_amount"` // 昨日营收
|
||||
ChangeRate float64 `json:"change_rate"` // 变化率(百分比)
|
||||
}
|
||||
// 代理统计
|
||||
AdminAgentStatistics {
|
||||
TotalCount int64 `json:"total_count"` // 代理总数
|
||||
TodayNew int64 `json:"today_new"` // 今日新增
|
||||
MonthNew int64 `json:"month_new"` // 当月新增
|
||||
}
|
||||
// 利润统计
|
||||
AdminProfitStatistics {
|
||||
TodayProfit float64 `json:"today_profit"` // 今日利润
|
||||
MonthProfit float64 `json:"month_profit"` // 当月利润
|
||||
TotalProfit float64 `json:"total_profit"` // 总利润
|
||||
TodayProfitRate float64 `json:"today_profit_rate"` // 今日利润率
|
||||
MonthProfitRate float64 `json:"month_profit_rate"` // 当月利润率
|
||||
TotalProfitRate float64 `json:"total_profit_rate"` // 总利润率
|
||||
// 今日明细
|
||||
TodayDetail AdminProfitDetail `json:"today_detail"`
|
||||
// 当月明细
|
||||
MonthDetail AdminProfitDetail `json:"month_detail"`
|
||||
// 总计明细
|
||||
TotalDetail AdminProfitDetail `json:"total_detail"`
|
||||
}
|
||||
// 利润明细
|
||||
AdminProfitDetail {
|
||||
Revenue float64 `json:"revenue"` // 营收
|
||||
Commission float64 `json:"commission"` // 佣金
|
||||
Rebate float64 `json:"rebate"` // 返利
|
||||
CompanyTax float64 `json:"company_tax"` // 税务成本
|
||||
ApiCost float64 `json:"api_cost"` // API调用成本
|
||||
TaxIncome float64 `json:"tax_income"` // 提现收税
|
||||
Profit float64 `json:"profit"` // 利润
|
||||
ProfitRate float64 `json:"profit_rate"` // 利润率
|
||||
}
|
||||
// 趋势数据
|
||||
AdminTrendData {
|
||||
Date string `json:"date"` // 日期(格式:MM-DD)
|
||||
Value float64 `json:"value"` // 数值
|
||||
}
|
||||
)
|
||||
|
||||
@@ -59,6 +59,10 @@ type (
|
||||
PayTimeEnd string `form:"pay_time_end,optional"` // 支付时间结束
|
||||
RefundTimeStart string `form:"refund_time_start,optional"` // 退款时间开始
|
||||
RefundTimeEnd string `form:"refund_time_end,optional"` // 退款时间结束
|
||||
// 被查询人(与 query_subject_index 密文一致,多条件为 AND)
|
||||
QuerySubjectName string `form:"query_subject_name,optional"` // 姓名(明文,服务端转密文查询)
|
||||
QuerySubjectMobile string `form:"query_subject_mobile,optional"` // 手机号
|
||||
QuerySubjectIdCard string `form:"query_subject_id_card,optional"` // 身份证
|
||||
}
|
||||
// 列表响应
|
||||
AdminGetOrderListResp {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
syntax = "v1"
|
||||
|
||||
import "product.api"
|
||||
|
||||
info (
|
||||
title: "代理服务"
|
||||
desc: "新代理系统接口"
|
||||
@@ -121,6 +123,14 @@ type (
|
||||
GetInviteLinkResp {
|
||||
InviteLink string `json:"invite_link"` // 邀请链接
|
||||
}
|
||||
// 生成邀请海报(后端 imageService 合成背景+二维码)
|
||||
GetInvitePosterReq {
|
||||
InviteLink string `form:"invite_link"` // 邀请链接
|
||||
Format string `form:"format,optional"` // base64 时返回 JSON,否则返回 image/png
|
||||
}
|
||||
GetInvitePosterResp {
|
||||
PosterBase64 string `json:"poster_base64"` // PNG base64,前端用 data:image/png;base64,{poster_base64}
|
||||
}
|
||||
// 获取代理等级特权信息
|
||||
GetLevelPrivilegeResp {
|
||||
Levels []LevelPrivilegeItem `json:"levels"`
|
||||
@@ -224,6 +234,10 @@ service main {
|
||||
@handler ApplyWithdrawal
|
||||
post /withdrawal/apply (ApplyWithdrawalReq) returns (ApplyWithdrawalResp)
|
||||
|
||||
// 获取上次提现信息(用于前端预填)
|
||||
@handler GetLastWithdrawalInfo
|
||||
get /withdrawal/last_info (GetLastWithdrawalInfoReq) returns (GetLastWithdrawalInfoResp)
|
||||
|
||||
// 实名认证
|
||||
@handler RealNameAuth
|
||||
post /real_name (RealNameAuthReq) returns (RealNameAuthResp)
|
||||
@@ -244,6 +258,10 @@ service main {
|
||||
@handler GetInviteLink
|
||||
get /invite_link (GetInviteLinkReq) returns (GetInviteLinkResp)
|
||||
|
||||
// 生成邀请海报(后端 imageService 合成背景+二维码,format=base64 返回 JSON)
|
||||
@handler GetInvitePoster
|
||||
get /invite/poster (GetInvitePosterReq) returns (GetInvitePosterResp)
|
||||
|
||||
// 获取代理等级特权信息
|
||||
@handler GetLevelPrivilege
|
||||
get /level/privilege returns (GetLevelPrivilegeResp)
|
||||
@@ -251,6 +269,32 @@ service main {
|
||||
// 获取推广查询报告列表
|
||||
@handler GetPromotionQueryList
|
||||
get /promotion/query/list (GetPromotionQueryListReq) returns (GetPromotionQueryListResp)
|
||||
|
||||
// ============================================
|
||||
// 用户模块白名单相关接口
|
||||
// ============================================
|
||||
@handler GetWhitelistFeatures
|
||||
get /whitelist/features (GetWhitelistFeaturesReq) returns (GetWhitelistFeaturesResp)
|
||||
|
||||
// 创建白名单订单
|
||||
@handler CreateWhitelistOrder
|
||||
post /whitelist/order/create (CreateWhitelistOrderReq) returns (CreateWhitelistOrderResp)
|
||||
|
||||
// 获取用户白名单列表
|
||||
@handler GetWhitelistList
|
||||
get /whitelist/list (GetWhitelistListReq) returns (GetWhitelistListResp)
|
||||
|
||||
// 检查模块是否已下架(用于显示下架按钮状态)
|
||||
@handler CheckFeatureWhitelistStatus
|
||||
get /whitelist/check (CheckFeatureWhitelistStatusReq) returns (CheckFeatureWhitelistStatusResp)
|
||||
|
||||
// 下架单个模块(统一入口:创建/补充白名单并根据 QueryId 删除本次报告中的模块数据)
|
||||
@handler OfflineFeature
|
||||
post /whitelist/offline (OfflineFeatureReq) returns (OfflineFeatureResp)
|
||||
|
||||
// 检查订单是否属于当前代理推广
|
||||
@handler CheckOrderAgent
|
||||
get /order/agent (CheckOrderAgentReq) returns (CheckOrderAgentResp)
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -414,11 +458,13 @@ type (
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
CreateTime string `json:"create_time"` // 加入团队时间
|
||||
TodayQueries int64 `json:"today_queries"` // 当日查询量
|
||||
MonthQueries int64 `json:"month_queries"` // 本月查询量
|
||||
TotalQueries int64 `json:"total_queries"` // 总查询量
|
||||
TotalRebateAmount float64 `json:"total_rebate_amount"` // 返佣给我的总金额
|
||||
TodayRebateAmount float64 `json:"today_rebate_amount"` // 返佣给我的今日金额
|
||||
TotalInvites int64 `json:"total_invites"` // 邀请加入团队的总人数
|
||||
TodayInvites int64 `json:"today_invites"` // 邀请加入团队的今日人数
|
||||
MonthInvites int64 `json:"month_invites"` // 邀请加入团队的本月人数
|
||||
IsDirect bool `json:"is_direct"` // 是否直接下级
|
||||
}
|
||||
// 收益信息
|
||||
@@ -433,6 +479,8 @@ type (
|
||||
RebateTotal float64 `json:"rebate_total"` // 返佣累计总收益(包括推广返佣和升级返佣)
|
||||
RebateToday float64 `json:"rebate_today"` // 返佣今日收益
|
||||
RebateMonth float64 `json:"rebate_month"` // 返佣本月收益
|
||||
AlipayMonthQuota float64 `json:"alipay_month_quota"` // 支付宝每月提现总额度
|
||||
AlipayMonthUsed float64 `json:"alipay_month_used"` // 本月已使用的支付宝提现额度
|
||||
}
|
||||
// 佣金记录
|
||||
GetCommissionListReq {
|
||||
@@ -471,6 +519,7 @@ type (
|
||||
OrderNo string `json:"order_no"` // 订单号
|
||||
RebateType int64 `json:"rebate_type"` // 返佣类型:1=直接上级,2=钻石上级,3=黄金上级
|
||||
Amount float64 `json:"amount"` // 返佣金额
|
||||
Status int64 `json:"status"` // 状态:1=已发放,2=已冻结,3=已取消(已退款)
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
// 升级返佣记录
|
||||
@@ -537,6 +586,7 @@ type (
|
||||
Total int64 `json:"total"` // 总数
|
||||
List []WithdrawalItem `json:"list"` // 列表
|
||||
}
|
||||
// 提现记录
|
||||
WithdrawalItem {
|
||||
Id string `json:"id"` // 记录ID
|
||||
WithdrawalNo string `json:"withdrawal_no"` // 提现单号
|
||||
@@ -544,21 +594,38 @@ type (
|
||||
TaxAmount float64 `json:"tax_amount"` // 税费金额
|
||||
ActualAmount float64 `json:"actual_amount"` // 实际到账金额
|
||||
Status int64 `json:"status"` // 状态:1=待审核,2=审核通过,3=审核拒绝,4=提现中,5=提现成功,6=提现失败
|
||||
PayeeAccount string `json:"payee_account"` // 收款账户
|
||||
WithdrawalType int64 `json:"withdrawal_type"` // 提现方式:1=支付宝,2=银行卡
|
||||
PayeeAccount string `json:"payee_account"` // 收款账户(支付宝账号或银行卡号)
|
||||
PayeeName string `json:"payee_name"` // 收款人姓名
|
||||
BankCardNo string `json:"bank_card_no"` // 银行卡号(银行卡提现时填写)
|
||||
BankName string `json:"bank_name"` // 开户行名称(银行卡提现时填写)
|
||||
Remark string `json:"remark"` // 备注
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
// 申请提现
|
||||
ApplyWithdrawalReq {
|
||||
Amount float64 `json:"amount"` // 提现金额
|
||||
PayeeAccount string `json:"payee_account"` // 收款账户
|
||||
WithdrawalType int64 `json:"withdrawal_type"` // 提现方式:1=支付宝,2=银行卡
|
||||
PayeeAccount string `json:"payee_account"` // 收款账户(支付宝账号或银行卡号)
|
||||
PayeeName string `json:"payee_name"` // 收款人姓名
|
||||
BankCardNo string `json:"bank_card_no,optional"` // 银行卡号(银行卡提现必填)
|
||||
BankName string `json:"bank_name,optional"` // 开户行名称(银行卡提现必填)
|
||||
}
|
||||
ApplyWithdrawalResp {
|
||||
WithdrawalId string `json:"withdrawal_id"` // 提现记录ID
|
||||
WithdrawalNo string `json:"withdrawal_no"` // 提现单号
|
||||
}
|
||||
// 获取上次提现信息(用于前端预填)
|
||||
GetLastWithdrawalInfoReq {
|
||||
WithdrawalType int64 `form:"withdrawal_type"` // 提现方式:1=支付宝,2=银行卡
|
||||
}
|
||||
GetLastWithdrawalInfoResp {
|
||||
WithdrawalType int64 `json:"withdrawal_type"` // 提现方式
|
||||
PayeeAccount string `json:"payee_account"` // 收款账户(支付宝账号或银行卡号)
|
||||
PayeeName string `json:"payee_name"` // 收款人姓名
|
||||
BankCardNo string `json:"bank_card_no"` // 银行卡号
|
||||
BankName string `json:"bank_name"` // 开户行名称
|
||||
}
|
||||
// 实名认证
|
||||
RealNameAuthReq {
|
||||
Name string `json:"name"` // 姓名
|
||||
@@ -587,6 +654,81 @@ type (
|
||||
Params map[string]interface{} `json:"params"` // 查询参数(已脱敏)
|
||||
Price float64 `json:"price"` // 查询价格
|
||||
}
|
||||
// ============================================
|
||||
// 用户模块白名单相关类型
|
||||
// ============================================
|
||||
GetWhitelistFeaturesReq {}
|
||||
GetWhitelistFeaturesResp {
|
||||
List []WhitelistFeatureItem `json:"list"` // 可屏蔽的feature列表
|
||||
}
|
||||
WhitelistFeatureItem {
|
||||
FeatureId string `json:"feature_id"` // Feature的UUID
|
||||
FeatureApiId string `json:"feature_api_id"` // Feature的API标识
|
||||
FeatureName string `json:"feature_name"` // Feature的名称
|
||||
WhitelistPrice float64 `json:"whitelist_price"` // 屏蔽价格(单位:元)
|
||||
}
|
||||
CreateWhitelistOrderReq {
|
||||
IdCard string `json:"id_card"` // 身份证号(查询对象标识)
|
||||
FeatureIds []string `json:"feature_ids"` // 要屏蔽的feature ID列表
|
||||
OrderId string `json:"order_id,optional"` // 关联的查询订单ID(可选)
|
||||
}
|
||||
CreateWhitelistOrderResp {
|
||||
OrderId string `json:"order_id"` // 订单ID
|
||||
OrderNo string `json:"order_no"` // 订单号
|
||||
TotalAmount float64 `json:"total_amount"` // 总金额
|
||||
}
|
||||
GetWhitelistListReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
PageSize int64 `form:"page_size"` // 每页数量
|
||||
IdCard string `form:"id_card,optional"` // 身份证号(可选,用于筛选)
|
||||
}
|
||||
GetWhitelistListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
List []WhitelistItem `json:"list"` // 列表
|
||||
}
|
||||
WhitelistItem {
|
||||
Id string `json:"id"` // 白名单记录ID
|
||||
IdCard string `json:"id_card"` // 身份证号
|
||||
FeatureId string `json:"feature_id"` // Feature的UUID
|
||||
FeatureApiId string `json:"feature_api_id"` // Feature的API标识
|
||||
FeatureName string `json:"feature_name"` // Feature的名称
|
||||
Amount float64 `json:"amount"` // 费用
|
||||
Status int64 `json:"status"` // 状态:1=生效,2=已失效
|
||||
StatusText string `json:"status_text"` // 状态文本
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
// 检查模块白名单状态请求
|
||||
CheckFeatureWhitelistStatusReq {
|
||||
IdCard string `form:"id_card"` // 身份证号
|
||||
FeatureApiId string `form:"feature_api_id"` // Feature的API标识
|
||||
QueryId string `form:"query_id,optional"` // 查询记录ID(可选,用于检查报告数据是否已删除)
|
||||
}
|
||||
// 检查模块白名单状态响应
|
||||
CheckFeatureWhitelistStatusResp {
|
||||
IsWhitelisted bool `json:"is_whitelisted"` // 是否在白名单中
|
||||
WhitelistPrice float64 `json:"whitelist_price"` // 屏蔽价格(单位:元),如果为0表示不支持下架
|
||||
FeatureId string `json:"feature_id"` // Feature的UUID
|
||||
DataDeleted bool `json:"data_deleted"` // 报告数据是否已删除(仅当提供了query_id时有效)
|
||||
}
|
||||
// 下架单个模块请求
|
||||
OfflineFeatureReq {
|
||||
FeatureApiId string `json:"feature_api_id"` // Feature的API标识
|
||||
QueryId string `json:"query_id"` // 查询记录ID(Query表的ID,必选)
|
||||
}
|
||||
// 下架单个模块响应
|
||||
OfflineFeatureResp {
|
||||
Success bool `json:"success"` // 是否已完成下架
|
||||
NeedPay bool `json:"need_pay"` // 是否需要发起支付
|
||||
Amount float64 `json:"amount"` // 需要支付的金额(单位:元),0表示无需支付
|
||||
}
|
||||
// 检查订单是否属于当前代理请求
|
||||
CheckOrderAgentReq {
|
||||
OrderId string `form:"order_id"` // 订单ID
|
||||
}
|
||||
// 检查订单是否属于当前代理响应
|
||||
CheckOrderAgentResp {
|
||||
IsAgentOrder bool `json:"is_agent_order"` // 是否是当前代理推广的订单
|
||||
}
|
||||
)
|
||||
|
||||
// ============================================
|
||||
|
||||
@@ -19,6 +19,10 @@ service main {
|
||||
@handler AlipayCallback
|
||||
post /pay/alipay/callback
|
||||
|
||||
// 支付宝from消息回调
|
||||
@handler AlipayFrom
|
||||
post /pay/alipay/from
|
||||
|
||||
// 微信退款回调
|
||||
@handler WechatPayRefundCallback
|
||||
post /pay/wechat/refund_callback
|
||||
@@ -46,7 +50,8 @@ type (
|
||||
PaymentReq {
|
||||
Id string `json:"id"`
|
||||
PayMethod string `json:"pay_method"` // 支付方式: wechat, alipay, appleiap, test(仅开发环境), test_empty(仅开发环境-空报告模式)
|
||||
PayType string `json:"pay_type" validate:"required,oneof=query agent_vip agent_upgrade"`
|
||||
PayType string `json:"pay_type" validate:"required,oneof=query agent_vip agent_upgrade whitelist"`
|
||||
Code string `json:"code,optional"` // 微信小程序登录 code,未绑定 openid 时传此参数以换取 openid 并调起支付
|
||||
}
|
||||
PaymentResp {
|
||||
PrepayData interface{} `json:"prepay_data"`
|
||||
|
||||
@@ -140,6 +140,7 @@ type (
|
||||
AccessToken string `json:"accessToken"`
|
||||
AccessExpire int64 `json:"accessExpire"`
|
||||
RefreshAfter int64 `json:"refreshAfter"`
|
||||
IsAgent bool `json:"is_agent,optional"` // 该手机号已是代理时为 true,前端可据此自动进入代理中心
|
||||
}
|
||||
)
|
||||
|
||||
@@ -158,6 +159,24 @@ type (
|
||||
sendSmsReq {
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
ActionType string `json:"actionType" validate:"required,oneof=login register query agentApply realName bindMobile"`
|
||||
CaptchaVerifyParam string `json:"captchaVerifyParam,optional"` // 阿里云滑块验证码参数
|
||||
}
|
||||
)
|
||||
|
||||
//============================> captcha v1 <============================
|
||||
@server (
|
||||
prefix: api/v1
|
||||
group: captcha
|
||||
)
|
||||
service main {
|
||||
@doc "get encrypted scene id for aliyun captcha"
|
||||
@handler getEncryptedSceneId
|
||||
post /captcha/encryptedSceneId returns (GetEncryptedSceneIdResp)
|
||||
}
|
||||
|
||||
type (
|
||||
GetEncryptedSceneIdResp {
|
||||
EncryptedSceneId string `json:"encryptedSceneId"`
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -28,3 +28,5 @@ import "./admin/admin_query.api"
|
||||
import "./admin/admin_agent.api"
|
||||
import "./admin/admin_api.api"
|
||||
import "./admin/admin_role_api.api"
|
||||
import "./admin/admin_complaint.api"
|
||||
import "./admin/dashboard.api"
|
||||
|
||||
@@ -18,6 +18,18 @@ VerifyCode:
|
||||
SignName: "天远查"
|
||||
TemplateCode: "SMS_302641455"
|
||||
ValidTime: 300
|
||||
|
||||
Captcha:
|
||||
# 建议与短信相同的 AccessKey,或单独为验证码创建子账号
|
||||
AccessKeyID: "LTAI5tKGB3TVJbMHSoZN3yr9"
|
||||
AccessKeySecret: "OCQ30GWp4yENMjmfOAaagksE18bp65"
|
||||
# 验证码服务 Endpoint,国内一般为 captcha.cn-shanghai.aliyuncs.com
|
||||
EndpointURL: "captcha.cn-shanghai.aliyuncs.com"
|
||||
# 阿里云控制台中该场景的 SceneId,请替换为真实值
|
||||
SceneID: "wynt39to"
|
||||
# 验证码控制台中的 ekey(通常为 Base64 字符串),用于生成 EncryptedSceneId
|
||||
EKey: ""
|
||||
|
||||
Encrypt:
|
||||
SecretKey: "ff83609b2b24fc73196aac3d3dfb874f"
|
||||
WestConfig:
|
||||
@@ -30,16 +42,15 @@ YushanConfig:
|
||||
AcctID: "YSSJ843926726"
|
||||
Url: "https://api.yushanshuju.com/credit-gw/service"
|
||||
Alipay:
|
||||
AppID: "2021006115614672"
|
||||
PrivateKey: "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDJzOKCuHfM2/VYSroIm2TcO/Eoych6wF1FUtPeAoTva+YgHMrEDXt/OvqfNMylvtZYZya4hocZ9KTDA0FwHmFT9RP0tu0hXzNcKLx2U31iwi6Y29f0EwSYHvLIDjLw0XbxownR7iHvoCaXLtHz2S4tcJNB5sew3asOEAMTAKq1z679R/3WETVRPsNl211vhkxUpcL4Ct97s/lVL/cwRFFEi2LajfCVZLqzrlkaQJucGcFQBdbzDd3gDrGtpmQvtmDWoAasg0/Kt7UJ6FPZKbbb9fc0yZAMSkD00jyVfYwq56TGXAP4P+NGhGGd0gbTGHPPA4Dr9zxSuQNAqiYn/mEPAgMBAAECggEBAIfpeOkHqpAL2LsFYTQozI5TxMFu3Zpm8qqc9VrCIZxK9GvOWHYginuPUnpliitbU2uo1XhUCqvdjBZXm/wSSgTMvAsGJMFkJ+g6+2tKIdmg5NdIwbJ+GIsH1QYOIhr1SIHIB/YexzZni3YpL3hnXmV2O4eYEgg501oeSKPEwDTAHy+rbj45ddmvbI/UQcAtl+TdbIt5JtCkCBe0emDT9xIuHYynfb2nuDm+x39k7RvOhLdm2JfR99nl20yFjTB6j7NoP77KXk6mw75PH/Mv2swyxUueRjUrXJUM1kU+PIUtIDklivdaseumL8nueiS2Eblg8zwE9UyvhiN/yDFcs0kCgYEA+QKrOw4kVnkRzqWp4KctWPtMm9fpuvzvIdnTWvRxRppP9wuoDrS9JXGldUnX9exQNExWay9CQlGzg+kkP28eFgY0Aj5muyrTT7IiMu31oOgeNnYiCTtGx2Li+Yo06h6MyRyrlbdgUQCZ5Geq3pE0N1uOPBSOGlFGxKCS6m/BkZ0CgYEAz3b5o+wCBycRyzvgWY66yzYZxQQDdQt67gt8JkHI3onufkyq7iYytHhYNpI/zTtOGoUTq+tEFBPzquQ+/pVRWmYHlIt4SZGIA29c3BEbTxA8UFXdcu0ZV3/RuKot9fhHIWMeK05lDzG81fvGnMONTilDKooNEGNDDVx4fLNR45sCgYEA8Myz6Zfza+wIXF23uZfxMmtR2iMh08FlPsb2rK5WHIB9c9nB2vbNMriD2LhgL2Em7mwj5eL9oESB5L5AX1eFMKcvBDxz++ueDSOmDrovHjtZfDEhGOxJtebat5X/Naf1XUZsZ4u9iJecOlRF2JVyeVYAZfk6shiG5v6hFDSea8ECgYAWPdkRm9Gz1ppvwWGR+F1KP+iPWJjOSYbKUmzi5RaV1Q++dpW0pl+1PVmnsBIq/HqpGS88tSI9TM5IueOPA48PM/UIFdO1f2anh57a8PKOjV0J98qf8Y9P9CIVvBjlT9LAX5Hybpsi/+AQyMdIMybJBF9xBg/Ue+/KVOmN5OOYlQKBgQCKS73P9EXgEjUfI5YxOvr1zEw/go6hFnt6G2i4lEtGUg9FKvNCz082TL6fYVADyoTL4LR8VuOHTNd4XsRTlQEYwWWUNAQxapLtTqRCQDsQhQh9aMJc9a/FAl9k6Zn9fInAy0BLstJBMRLVvTvLXT2EsAfYZVuTuwi0aEQSxkiFjA=="
|
||||
AlipayPublicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2CqoCp95w/JV3RT/gzF4/8QmVT1HQNaeW7yUp+mA7x9AbjvlTW/+eRn6oGAL/XhZLjvHD0XjKLVKX0MJVS1aUQHEHEbOJN4Eu8II45OavD4iZISa7Kp9V6AM+i4qTyaeV2wNDnGxHQBaLVUGCfMR+56EK2YpORdE1H9uy72SSQseVb3bmpsV9EW/IJNmcVL/ut3uA1JWAoRmzlQ7ekxg7p8AYXzYPEHQr1tl7W+M4zv9wO9GKZCxIqMA8U3RP5npPfRaCfIRGzXzCqFEEUvWuidOB7frsvN4jiPD07qpL2Bi9LM1X/ee2kC/oM8Uhd7ERZhG8MbZfijZKxgrsDKBcwIDAQAB"
|
||||
AppCertPath: "etc/merchant/appCertPublicKey_2021006115614672.crt"
|
||||
AppID: "2021006129617228"
|
||||
PrivateKey: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQChnB4yOExQu8YF1cIdzIKMVE+sSwH7QFq73H1Tam0W6dvO4g3sXsOP/ddQHoIYz8rbwcgtGYZtIl0huJ2/jCRl60ZY6mv2B3NHl9C9HYqzx9xXxOhUwlaIQEV5ZregQ4KfCGHgpUA7SG/kXj9oUkSOD7AWwbJi2AVmN4YlD2TILzN8MwaYhNvpdfJvno7Z+HXMAO23SkHifjLZFLSxQQLXXOsK5DKsmQUrd24aNKyuyT4oH9eB+/MIbpLZrPPcdNmL/Wefs8Mb9/DXgZ3jd7GGVIubxSU5O4KLbJ/thFukfQGgbv8LML6ksKmLunXk5qPv3LA2rCedFF8fn4BkT63lAgMBAAECggEANBXe3Yyre/Go1sSX9YauJJAfxYW/M70AAUAE3FeWpSXmA/1zQ1Ufbk7/kADlKR3/YWhJHc/2NUI4BeA8ZznBmV+Eoq+a8AZirxZM3kahJ2Qordj2kCq6PNuKCKCEWhCoDp1i/kYEN5cXCOEfSn4JPkfsFsmCtryssM8AWv1lG+cnNWo8bwoE8WBYUG2MjqemVyn9IKTPmlGORMALHddOoFupwotEVsoFQRt/NMEN2rzJT9BuBl7RedKjP921bIB8OprD9Vz4Htp3C6lz/MNsE69IajjWaTiIkDrvsqSPMMn9r8u/Ooi9V7NE7EGdS/jLwCCM5p8ycL63mF9wNX8eAQKBgQDYCOLfL7775uSSj6En1hhr8DBkbDtBJvPVNeJ404za3936gL+ntuqzAvLmE03HLlks0rgScJveAtV/GtWt/4dGbq5T0Nso0gSDk1g3oMEW3bZsS2hSa5CuwRVtJ7/tYrYchp0S31c6JXhoRpqtfbmGoEQbDuif0m9IACIzzG2pJQKBgQC/gb4iHAXxIYHEgrcqtAaReOkvWsqLtjfFxPV9XUAKTQknx8Xf2RK/TENF68xe03oHoVpRh5vDX5Nwv6191LYzi/P55MviBH7uE6azcESFGISSb7CdKMZFDiV1XYHkwCaQoGh3L11o252en99oDbRtH1rCAnUA9/vwRvCaORy1wQKBgQCxFNeiyqhqI6FI4aLf3Ia4M3H3XyBTD3LfWgQBtqbG4qo6JD71YuKPSeOA5GHk2wEN1Mw9kUCygvAt9/kfX02rVh5fZdu/YieBEs5FCug7rhFSQ52HsdQu6uZ9Sw/vrfJI/67RQXFmoEBKeVVg0KW6zLQG2fmkyAGfqzxd6TwaYQKBgBFYfxA32ZHtpwNVk6GajL3AZd6UKqRc7NBM9q9UMui78YhY3+NWlgwdrDo5EVnFbdgjFTstPT6E+aXMtroe+iHRG1gXESB3p8eIoCDAmnQztE5PL4AMoWi/z0TCI3HEtbmDzfJ9p8hHnA8yC9ow45a+sEnCTza3P2qUAlb1tVQBAoGATNlojr8dMziX7N2K792IgcMA8bu46plFX6PKsT3tq5jVcGlewU+9tqJk5yoPB5cJwyUm6rq6EividXx6vbfxR3VTU3wTtkLxwHqg8x2qFncHm9ElFzpYLOzI2Hbp0nBaSUdRK9FQxn+hqXz9M9pBDPIAu/W97Pz6vyFdqRxUIl4="
|
||||
AlipayPublicKey: ""
|
||||
AppCertPath: "etc/merchant/appCertPublicKey_2021006129617228.crt"
|
||||
AlipayCertPath: "etc/merchant/alipayCertPublicKey_RSA2.crt"
|
||||
AlipayRootCertPath: "etc/merchant/alipayRootCert.crt"
|
||||
IsProduction: true
|
||||
NotifyUrl: "https://6m4685017o.goho.co/api/v1/pay/alipay/callback"
|
||||
ReturnURL: "http://localhost:5678/inquire"
|
||||
|
||||
Wxpay:
|
||||
AppID: "wx442ee1ac1ee75917"
|
||||
MchID: "1687993434"
|
||||
@@ -58,7 +69,7 @@ Applepay:
|
||||
BundleID: "com.allinone.check"
|
||||
IssuerID: "bf828d85-5269-4914-9660-c066e09cd6ef"
|
||||
KeyID: "LAY65829DQ"
|
||||
LoadPrivateKeyPath: "etc/merchant/AuthKey_LAY65829DQ.p8"
|
||||
LoadPrivateKeyPath: "app/main/api/etc/merchant/AuthKey_LAY65829DQ.p8"
|
||||
Ali:
|
||||
Code: "d55b58829efb41c8aa8e86769cba4844"
|
||||
SystemConfig:
|
||||
@@ -67,10 +78,8 @@ WechatH5:
|
||||
AppID: "wx442ee1ac1ee75917"
|
||||
AppSecret: "c80474909db42f63913b7a307b3bee17"
|
||||
WechatMini:
|
||||
AppID: "wx781abb66b3368963" # 小程序的AppID
|
||||
AppSecret: "c7d02cdb0fc23c35c93187af9243b00d" # 小程序的AppSecret
|
||||
TycAppID: "wxe74617f3dd56c196"
|
||||
TycAppSecret: "c8207e54aef5689b2a7c1f91ed7ae8a0"
|
||||
AppID: "wxc12fd469eb3730fd" # 小程序的AppID
|
||||
AppSecret: "1dbb76843f1e12bef33ba3de61e2d6dd" # 小程序的AppSecret
|
||||
Query:
|
||||
ShareLinkExpire: 604800 # 7天 = 7 * 24 * 60 * 60 = 604800秒
|
||||
AdminConfig:
|
||||
@@ -81,8 +90,8 @@ TaxConfig:
|
||||
TaxRate: 0.06
|
||||
TaxExemptionAmount: 0.00
|
||||
Tianyuanapi:
|
||||
AccessID: "7f8a9b2c4d5e6f1a"
|
||||
Key: "9e4f8a1b3c6d7e2f5a8b9c0d1e4f7a2b"
|
||||
AccessID: "9e60b34eb51f3827"
|
||||
Key: "04c6b4c559be6d5ba5351c04c8713a64"
|
||||
BaseURL: "https://api.tianyuanapi.com"
|
||||
Timeout: 60
|
||||
Authorization:
|
||||
|
||||
@@ -16,16 +16,28 @@ VerifyCode:
|
||||
AccessKeyID: "LTAI5tKGB3TVJbMHSoZN3yr9"
|
||||
AccessKeySecret: "OCQ30GWp4yENMjmfOAaagksE18bp65"
|
||||
EndpointURL: "dysmsapi.aliyuncs.com"
|
||||
SignName: "天远查"
|
||||
SignName: "海南海宇大数据"
|
||||
TemplateCode: "SMS_302641455"
|
||||
ValidTime: 300
|
||||
|
||||
Captcha:
|
||||
# 建议与短信相同的 AccessKey,或单独为验证码创建子账号
|
||||
AccessKeyID: "LTAI5tKGB3TVJbMHSoZN3yr9"
|
||||
AccessKeySecret: "OCQ30GWp4yENMjmfOAaagksE18bp65"
|
||||
# 验证码服务 Endpoint,国内一般为 captcha.cn-shanghai.aliyuncs.com
|
||||
EndpointURL: "captcha.cn-shanghai.aliyuncs.com"
|
||||
# 阿里云控制台中该场景的 SceneId,请替换为真实值
|
||||
SceneID: "wynt39to"
|
||||
# 验证码控制台中的 ekey(通常为 Base64 字符串),用于生成 EncryptedSceneId
|
||||
EKey: ""
|
||||
|
||||
Encrypt:
|
||||
SecretKey: "ff83609b2b24fc73196aac3d3dfb874f"
|
||||
Alipay:
|
||||
AppID: "2021006115614672"
|
||||
PrivateKey: "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDJzOKCuHfM2/VYSroIm2TcO/Eoych6wF1FUtPeAoTva+YgHMrEDXt/OvqfNMylvtZYZya4hocZ9KTDA0FwHmFT9RP0tu0hXzNcKLx2U31iwi6Y29f0EwSYHvLIDjLw0XbxownR7iHvoCaXLtHz2S4tcJNB5sew3asOEAMTAKq1z679R/3WETVRPsNl211vhkxUpcL4Ct97s/lVL/cwRFFEi2LajfCVZLqzrlkaQJucGcFQBdbzDd3gDrGtpmQvtmDWoAasg0/Kt7UJ6FPZKbbb9fc0yZAMSkD00jyVfYwq56TGXAP4P+NGhGGd0gbTGHPPA4Dr9zxSuQNAqiYn/mEPAgMBAAECggEBAIfpeOkHqpAL2LsFYTQozI5TxMFu3Zpm8qqc9VrCIZxK9GvOWHYginuPUnpliitbU2uo1XhUCqvdjBZXm/wSSgTMvAsGJMFkJ+g6+2tKIdmg5NdIwbJ+GIsH1QYOIhr1SIHIB/YexzZni3YpL3hnXmV2O4eYEgg501oeSKPEwDTAHy+rbj45ddmvbI/UQcAtl+TdbIt5JtCkCBe0emDT9xIuHYynfb2nuDm+x39k7RvOhLdm2JfR99nl20yFjTB6j7NoP77KXk6mw75PH/Mv2swyxUueRjUrXJUM1kU+PIUtIDklivdaseumL8nueiS2Eblg8zwE9UyvhiN/yDFcs0kCgYEA+QKrOw4kVnkRzqWp4KctWPtMm9fpuvzvIdnTWvRxRppP9wuoDrS9JXGldUnX9exQNExWay9CQlGzg+kkP28eFgY0Aj5muyrTT7IiMu31oOgeNnYiCTtGx2Li+Yo06h6MyRyrlbdgUQCZ5Geq3pE0N1uOPBSOGlFGxKCS6m/BkZ0CgYEAz3b5o+wCBycRyzvgWY66yzYZxQQDdQt67gt8JkHI3onufkyq7iYytHhYNpI/zTtOGoUTq+tEFBPzquQ+/pVRWmYHlIt4SZGIA29c3BEbTxA8UFXdcu0ZV3/RuKot9fhHIWMeK05lDzG81fvGnMONTilDKooNEGNDDVx4fLNR45sCgYEA8Myz6Zfza+wIXF23uZfxMmtR2iMh08FlPsb2rK5WHIB9c9nB2vbNMriD2LhgL2Em7mwj5eL9oESB5L5AX1eFMKcvBDxz++ueDSOmDrovHjtZfDEhGOxJtebat5X/Naf1XUZsZ4u9iJecOlRF2JVyeVYAZfk6shiG5v6hFDSea8ECgYAWPdkRm9Gz1ppvwWGR+F1KP+iPWJjOSYbKUmzi5RaV1Q++dpW0pl+1PVmnsBIq/HqpGS88tSI9TM5IueOPA48PM/UIFdO1f2anh57a8PKOjV0J98qf8Y9P9CIVvBjlT9LAX5Hybpsi/+AQyMdIMybJBF9xBg/Ue+/KVOmN5OOYlQKBgQCKS73P9EXgEjUfI5YxOvr1zEw/go6hFnt6G2i4lEtGUg9FKvNCz082TL6fYVADyoTL4LR8VuOHTNd4XsRTlQEYwWWUNAQxapLtTqRCQDsQhQh9aMJc9a/FAl9k6Zn9fInAy0BLstJBMRLVvTvLXT2EsAfYZVuTuwi0aEQSxkiFjA=="
|
||||
AlipayPublicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2CqoCp95w/JV3RT/gzF4/8QmVT1HQNaeW7yUp+mA7x9AbjvlTW/+eRn6oGAL/XhZLjvHD0XjKLVKX0MJVS1aUQHEHEbOJN4Eu8II45OavD4iZISa7Kp9V6AM+i4qTyaeV2wNDnGxHQBaLVUGCfMR+56EK2YpORdE1H9uy72SSQseVb3bmpsV9EW/IJNmcVL/ut3uA1JWAoRmzlQ7ekxg7p8AYXzYPEHQr1tl7W+M4zv9wO9GKZCxIqMA8U3RP5npPfRaCfIRGzXzCqFEEUvWuidOB7frsvN4jiPD07qpL2Bi9LM1X/ee2kC/oM8Uhd7ERZhG8MbZfijZKxgrsDKBcwIDAQAB"
|
||||
AppCertPath: "etc/merchant/appCertPublicKey_2021006115614672.crt"
|
||||
AppID: "2021006129617228"
|
||||
PrivateKey: "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQChnB4yOExQu8YF1cIdzIKMVE+sSwH7QFq73H1Tam0W6dvO4g3sXsOP/ddQHoIYz8rbwcgtGYZtIl0huJ2/jCRl60ZY6mv2B3NHl9C9HYqzx9xXxOhUwlaIQEV5ZregQ4KfCGHgpUA7SG/kXj9oUkSOD7AWwbJi2AVmN4YlD2TILzN8MwaYhNvpdfJvno7Z+HXMAO23SkHifjLZFLSxQQLXXOsK5DKsmQUrd24aNKyuyT4oH9eB+/MIbpLZrPPcdNmL/Wefs8Mb9/DXgZ3jd7GGVIubxSU5O4KLbJ/thFukfQGgbv8LML6ksKmLunXk5qPv3LA2rCedFF8fn4BkT63lAgMBAAECggEANBXe3Yyre/Go1sSX9YauJJAfxYW/M70AAUAE3FeWpSXmA/1zQ1Ufbk7/kADlKR3/YWhJHc/2NUI4BeA8ZznBmV+Eoq+a8AZirxZM3kahJ2Qordj2kCq6PNuKCKCEWhCoDp1i/kYEN5cXCOEfSn4JPkfsFsmCtryssM8AWv1lG+cnNWo8bwoE8WBYUG2MjqemVyn9IKTPmlGORMALHddOoFupwotEVsoFQRt/NMEN2rzJT9BuBl7RedKjP921bIB8OprD9Vz4Htp3C6lz/MNsE69IajjWaTiIkDrvsqSPMMn9r8u/Ooi9V7NE7EGdS/jLwCCM5p8ycL63mF9wNX8eAQKBgQDYCOLfL7775uSSj6En1hhr8DBkbDtBJvPVNeJ404za3936gL+ntuqzAvLmE03HLlks0rgScJveAtV/GtWt/4dGbq5T0Nso0gSDk1g3oMEW3bZsS2hSa5CuwRVtJ7/tYrYchp0S31c6JXhoRpqtfbmGoEQbDuif0m9IACIzzG2pJQKBgQC/gb4iHAXxIYHEgrcqtAaReOkvWsqLtjfFxPV9XUAKTQknx8Xf2RK/TENF68xe03oHoVpRh5vDX5Nwv6191LYzi/P55MviBH7uE6azcESFGISSb7CdKMZFDiV1XYHkwCaQoGh3L11o252en99oDbRtH1rCAnUA9/vwRvCaORy1wQKBgQCxFNeiyqhqI6FI4aLf3Ia4M3H3XyBTD3LfWgQBtqbG4qo6JD71YuKPSeOA5GHk2wEN1Mw9kUCygvAt9/kfX02rVh5fZdu/YieBEs5FCug7rhFSQ52HsdQu6uZ9Sw/vrfJI/67RQXFmoEBKeVVg0KW6zLQG2fmkyAGfqzxd6TwaYQKBgBFYfxA32ZHtpwNVk6GajL3AZd6UKqRc7NBM9q9UMui78YhY3+NWlgwdrDo5EVnFbdgjFTstPT6E+aXMtroe+iHRG1gXESB3p8eIoCDAmnQztE5PL4AMoWi/z0TCI3HEtbmDzfJ9p8hHnA8yC9ow45a+sEnCTza3P2qUAlb1tVQBAoGATNlojr8dMziX7N2K792IgcMA8bu46plFX6PKsT3tq5jVcGlewU+9tqJk5yoPB5cJwyUm6rq6EividXx6vbfxR3VTU3wTtkLxwHqg8x2qFncHm9ElFzpYLOzI2Hbp0nBaSUdRK9FQxn+hqXz9M9pBDPIAu/W97Pz6vyFdqRxUIl4="
|
||||
AlipayPublicKey: ""
|
||||
AppCertPath: "etc/merchant/appCertPublicKey_2021006129617228.crt"
|
||||
AlipayCertPath: "etc/merchant/alipayCertPublicKey_RSA2.crt"
|
||||
AlipayRootCertPath: "etc/merchant/alipayRootCert.crt"
|
||||
IsProduction: true
|
||||
@@ -56,8 +68,8 @@ WechatH5:
|
||||
AppID: "wx442ee1ac1ee75917"
|
||||
AppSecret: "c80474909db42f63913b7a307b3bee17"
|
||||
WechatMini:
|
||||
AppID: "wx5bacc94add2da981" # 小程序的AppID
|
||||
AppSecret: "48a2c1e8ff1b7d4c0ff82fbefa64d2d0" # 小程序的AppSecret
|
||||
AppID: "wxc12fd469eb3730fd" # 小程序的AppID
|
||||
AppSecret: "1dbb76843f1e12bef33ba3de61e2d6dd" # 小程序的AppSecret
|
||||
Query:
|
||||
ShareLinkExpire: 604800 # 7天 = 7 * 24 * 60 * 60 = 604800秒
|
||||
AdminConfig:
|
||||
@@ -68,8 +80,8 @@ TaxConfig:
|
||||
TaxRate: 0.06
|
||||
TaxExemptionAmount: 0.00
|
||||
Tianyuanapi:
|
||||
AccessID: "7f8a9b2c4d5e6f1a"
|
||||
Key: "9e4f8a1b3c6d7e2f5a8b9c0d1e4f7a2b"
|
||||
AccessID: "9e60b34eb51f3827"
|
||||
Key: "04c6b4c559be6d5ba5351c04c8713a64"
|
||||
BaseURL: "https://api.tianyuanapi.com"
|
||||
Timeout: 60
|
||||
Authorization:
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDrzCCApegAwIBAgIQICUSBOVPmqSb4NzESDUfmDANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UE
|
||||
MIIDrzCCApegAwIBAgIQICYBJSGBNP/dFk3HtTIEnjANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UE
|
||||
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0
|
||||
aG9yaXR5MTkwNwYDVQQDDDBBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IENs
|
||||
YXNzIDIgUjEwHhcNMjUxMjA0MDg0MzU1WhcNMzAxMjAzMDg0MzU1WjCBjzELMAkGA1UEBhMCQ04x
|
||||
YXNzIDIgUjEwHhcNMjYwMTI1MTA1NzMxWhcNMzEwMTI0MTA1NzMxWjCBjzELMAkGA1UEBhMCQ04x
|
||||
KjAoBgNVBAoMIea1t+WNl+a1t+Wuh+Wkp+aVsOaNruaciemZkOWFrOWPuDEPMA0GA1UECwwGQWxp
|
||||
cGF5MUMwQQYDVQQDDDrmlK/ku5jlrp0o5Lit5Zu9Kee9kee7nOaKgOacr+aciemZkOWFrOWPuC0y
|
||||
MDg4OTQxNTA3NzkwNjA0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiuKilHTo/kPL
|
||||
cD8ez6HtudB5BrrHz2H+hxbb+5kwPjaE14HCws9fbgtIxxaDWyKKOpUGqo5RGmMFpPaQfci0meBD
|
||||
G0XyBafGyzDvivrkBCa2gQSzKzuxoFyNkBAubih91gYz6ZyfMDLmfeCR7ItapUtCRtt+xg1O64s+
|
||||
cZOSL94o8UnrUBJRW6auhhE8kDibxPpekSOqaWmlt6G8R1xMmf4CxdrErxLajCC3wmSEOyA5yu1M
|
||||
yU/8Ve8g70zXgGAgQHXxgMblp9BE+dL11VIeyB0HEa68YVwtlUzbhtk+NPy+TI8wNMASjlr9oeoo
|
||||
X0nm+oqXOBUwPW+txB1yeQ8tKQIDAQABoxIwEDAOBgNVHQ8BAf8EBAMCA/gwDQYJKoZIhvcNAQEL
|
||||
BQADggEBAHIbaJsjcPXKgpWxSFkr+ScYwQiqry+hh5kqgQLAhGYlcHQurbCP0kvlUWMZhGJR2no/
|
||||
b70xe+HZbxf5c4iVv6vss7o3nBGghMFYhpGfOCYDYeGkANEkczpDL5oBpgSbp/nN5zI9RQsYomD6
|
||||
Vp5QWvXZEM1/nz0o5nM3MfcF3/xC9/rO0ZqnE0TLJ2khmJmz5OIeqF0WdMXx5Q4/T70fFzpA+q/l
|
||||
BfiGYtcNNu1N7Db2y495C9nmax+AHoaHQpWXtgwOaq5TlAs6FDl/Nj7o0uTK0NsVgIEKzF4xszrn
|
||||
tOeb3KiVXE+wwaD5DXhsqO7uYTrVDsOy6HfKZST/LNS/E+M=
|
||||
MDg4MjUxOTEzNDA0MjU4MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkQ51RD+Z+6lX
|
||||
RQtx1vrEoxX8fMZKQMhUcvQhPwn9edXP3Dcwa9osIl/ncXQBFd1KiE0IUP8unfgyPgVsWxL5npfd
|
||||
ReqA35hsjuN2jB1d/SASwMTio2Zdqjbh3tK7MsnRdgpj/u2RpOK1gSp6yScZM67h1t4ScXdsrpd4
|
||||
VBXuvffloL/anZkrAoVtCjlmreXI/cnKMOqO19YckPGax7kFD5vTOknydIASqMJTTDThfbUzbkHH
|
||||
GK16s18PYvDivhz/LSgvjAGd2e0G9PXLUJAMsedg+cnBLNba0NqLxHhX4//SfnmataK4MB0s4eEs
|
||||
sNCkYuXVF+odEp8wxNhaPhMj8QIDAQABoxIwEDAOBgNVHQ8BAf8EBAMCA/gwDQYJKoZIhvcNAQEL
|
||||
BQADggEBAJjgYw0gjfY82GH+MDlb3ThlDBpAckI/PskaO80ZlkMJ3i2QIXkqXJgNmoL/WyG3kLWC
|
||||
ek2REzbhZvNk/Pm8hulNTpTM/0HFffDgVDIvVgXNjY6JdCnRiCimrAQ87P+ZP9Og7pD+m+cWl92k
|
||||
rYZNx1qtbltF0lGAoV9KwgSg9EFPTLst+RCQmbHsRpsDWdK+3mIPd4YeegIL/3QDf7j94aJ9FWGj
|
||||
HHzQrXsLw/brfm8QMSwuByh8mynHWxFK4l3Ndo3HPKSZOHs7VfNPcSyD15q/RF2tzt8DFvbXnfwI
|
||||
GrOKL72CBwmxfMUYvTYqcKzLsgxuPbC6r4csMYhMFdhHGKg=
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIE4jCCAsqgAwIBAgIIYsSr5bKAMl8wDQYJKoZIhvcNAQELBQAwejELMAkGA1UEBhMCQ04xFjAU
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIEnjCCA4agAwIBAgIQICYBJUC8w9JR1ono3J6eXTANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UE
|
||||
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0
|
||||
aG9yaXR5MTkwNwYDVQQDDDBBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IENs
|
||||
YXNzIDEgUjEwHhcNMjYwMTI1MTA1NzMwWhcNMzEwMTI0MTA1NzMwWjBlMQswCQYDVQQGEwJDTjEq
|
||||
MCgGA1UECgwh5rW35Y2X5rW35a6H5aSn5pWw5o2u5pyJ6ZmQ5YWs5Y+4MQ8wDQYDVQQLDAZBbGlw
|
||||
YXkxGTAXBgNVBAMMEDIwODgyNTE5MTM0MDQyNTgwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
|
||||
AoIBAQChnB4yOExQu8YF1cIdzIKMVE+sSwH7QFq73H1Tam0W6dvO4g3sXsOP/ddQHoIYz8rbwcgt
|
||||
GYZtIl0huJ2/jCRl60ZY6mv2B3NHl9C9HYqzx9xXxOhUwlaIQEV5ZregQ4KfCGHgpUA7SG/kXj9o
|
||||
UkSOD7AWwbJi2AVmN4YlD2TILzN8MwaYhNvpdfJvno7Z+HXMAO23SkHifjLZFLSxQQLXXOsK5DKs
|
||||
mQUrd24aNKyuyT4oH9eB+/MIbpLZrPPcdNmL/Wefs8Mb9/DXgZ3jd7GGVIubxSU5O4KLbJ/thFuk
|
||||
fQGgbv8LML6ksKmLunXk5qPv3LA2rCedFF8fn4BkT63lAgMBAAGjggEqMIIBJjAfBgNVHSMEGDAW
|
||||
gBRxB+IEYRbk5fJl6zEPyeD0PJrVkTAdBgNVHQ4EFgQU3DI06nLE+mBhs3ZvNofQ86FekdwwQAYD
|
||||
VR0gBDkwNzA1BgdggRwBbgEBMCowKAYIKwYBBQUHAgEWHGh0dHA6Ly9jYS5hbGlwYXkuY29tL2Nw
|
||||
cy5wZGYwDgYDVR0PAQH/BAQDAgbAMDAGA1UdHwQpMCcwJaAjoCGGH2h0dHA6Ly9jYS5hbGlwYXku
|
||||
Y29tL2NybDEwOS5jcmwwYAYIKwYBBQUHAQEEVDBSMCgGCCsGAQUFBzAChhxodHRwOi8vY2EuYWxp
|
||||
cGF5LmNvbS9jYTYuY2VyMCYGCCsGAQUFBzABhhpodHRwOi8vY2EuYWxpcGF5LmNvbTo4MzQwLzAN
|
||||
BgkqhkiG9w0BAQsFAAOCAQEAJGeEwijmgFt3Nk9WFljjpQ9pUwGYrvaIam9eiBLVe7LbAMLXIeai
|
||||
9ej7lBp3WJ4CkWqvnJKEFWN3u+jiyA3iIg208Wsj+DZCqnuqo5Yg+OzAPj9J8YPNptN76VQ2ZOsH
|
||||
MaZAp/HH0hmAznJ5VBGHeqf8E7du/kS8pe0MNg2HgAPyXbrFoNWl40KPNNRm+dO2yPn9kMxhE4BE
|
||||
Qos7E2WhZ/UwX1zv8jJLOuXJtwCbhbBZ9cDg60Rj5VxEnDoAE23d6l9e13jizDol+hsQIFYQHLng
|
||||
xiARUyLcb9G3wfmAl6prXCK61LxZWzP07s54kykLgF5lQeM7yaCgo93fZ/fztg==
|
||||
-----END CERTIFICATE-----
|
||||
43
app/main/api/etc/merchant/bak/alipayCertPublicKey_RSA2.crt
Normal file
43
app/main/api/etc/merchant/bak/alipayCertPublicKey_RSA2.crt
Normal file
@@ -0,0 +1,43 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDrzCCApegAwIBAgIQICUSBOVPmqSb4NzESDUfmDANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UE
|
||||
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0
|
||||
aG9yaXR5MTkwNwYDVQQDDDBBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IENs
|
||||
YXNzIDIgUjEwHhcNMjUxMjA0MDg0MzU1WhcNMzAxMjAzMDg0MzU1WjCBjzELMAkGA1UEBhMCQ04x
|
||||
KjAoBgNVBAoMIea1t+WNl+a1t+Wuh+Wkp+aVsOaNruaciemZkOWFrOWPuDEPMA0GA1UECwwGQWxp
|
||||
cGF5MUMwQQYDVQQDDDrmlK/ku5jlrp0o5Lit5Zu9Kee9kee7nOaKgOacr+aciemZkOWFrOWPuC0y
|
||||
MDg4OTQxNTA3NzkwNjA0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiuKilHTo/kPL
|
||||
cD8ez6HtudB5BrrHz2H+hxbb+5kwPjaE14HCws9fbgtIxxaDWyKKOpUGqo5RGmMFpPaQfci0meBD
|
||||
G0XyBafGyzDvivrkBCa2gQSzKzuxoFyNkBAubih91gYz6ZyfMDLmfeCR7ItapUtCRtt+xg1O64s+
|
||||
cZOSL94o8UnrUBJRW6auhhE8kDibxPpekSOqaWmlt6G8R1xMmf4CxdrErxLajCC3wmSEOyA5yu1M
|
||||
yU/8Ve8g70zXgGAgQHXxgMblp9BE+dL11VIeyB0HEa68YVwtlUzbhtk+NPy+TI8wNMASjlr9oeoo
|
||||
X0nm+oqXOBUwPW+txB1yeQ8tKQIDAQABoxIwEDAOBgNVHQ8BAf8EBAMCA/gwDQYJKoZIhvcNAQEL
|
||||
BQADggEBAHIbaJsjcPXKgpWxSFkr+ScYwQiqry+hh5kqgQLAhGYlcHQurbCP0kvlUWMZhGJR2no/
|
||||
b70xe+HZbxf5c4iVv6vss7o3nBGghMFYhpGfOCYDYeGkANEkczpDL5oBpgSbp/nN5zI9RQsYomD6
|
||||
Vp5QWvXZEM1/nz0o5nM3MfcF3/xC9/rO0ZqnE0TLJ2khmJmz5OIeqF0WdMXx5Q4/T70fFzpA+q/l
|
||||
BfiGYtcNNu1N7Db2y495C9nmax+AHoaHQpWXtgwOaq5TlAs6FDl/Nj7o0uTK0NsVgIEKzF4xszrn
|
||||
tOeb3KiVXE+wwaD5DXhsqO7uYTrVDsOy6HfKZST/LNS/E+M=
|
||||
-----END CERTIFICATE-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIE4jCCAsqgAwIBAgIIYsSr5bKAMl8wDQYJKoZIhvcNAQELBQAwejELMAkGA1UEBhMCQ04xFjAU
|
||||
BgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5MTEw
|
||||
LwYDVQQDDChBbnQgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFIxMB4XDTE4MDMy
|
||||
MjE0MzQxNVoXDTM3MTEyNjE0MzQxNVowgYIxCzAJBgNVBAYTAkNOMRYwFAYDVQQKDA1BbnQgRmlu
|
||||
YW5jaWFsMSAwHgYDVQQLDBdDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTE5MDcGA1UEAwwwQW50IEZp
|
||||
bmFuY2lhbCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBDbGFzcyAyIFIxMIIBIjANBgkqhkiG9w0B
|
||||
AQEFAAOCAQ8AMIIBCgKCAQEAsLMfYaoRoPRbmDcAfXPCmKf43pWRN5yTXa/KJWO0l+mrgQvs89bA
|
||||
NEvbDUxlkGwycwtwi5DgBuBgVhLliXu+R9CYgr2dXs8D8Hx/gsggDcyGPLmVrDOnL+dyeauheARZ
|
||||
fA3du60fwEwwbGcVIpIxPa/4n3IS/ElxQa6DNgqxh8J9Xwh7qMGl0JK9+bALuxf7B541Gr4p0WEN
|
||||
G8fhgjBV4w4ut9eQLOoa1eddOUSZcy46Z7allwowwgt7b5VFfx/P1iKJ3LzBMgkCK7GZ2kiLrL7R
|
||||
iqV+h482J7hkJD+ardoc6LnrHO/hIZymDxok+VH9fVeUdQa29IZKrIDVj65THQIDAQABo2MwYTAf
|
||||
BgNVHSMEGDAWgBRfdLQEwE8HWurlsdsio4dBspzhATAdBgNVHQ4EFgQUSqHkYINtUSAtDPnS8Xoy
|
||||
oP9p7qEwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggIB
|
||||
AIQ8TzFy4bVIVb8+WhHKCkKNPcJe2EZuIcqvRoi727lZTJOfYy/JzLtckyZYfEI8J0lasZ29wkTt
|
||||
a1IjSo+a6XdhudU4ONVBrL70U8Kzntplw/6TBNbLFpp7taRALjUgbCOk4EoBMbeCL0GiYYsTS0mw
|
||||
7xdySzmGQku4GTyqutIGPQwKxSj9iSFw1FCZqr4VP4tyXzMUgc52SzagA6i7AyLedd3tbS6lnR5B
|
||||
L+W9Kx9hwT8L7WANAxQzv/jGldeuSLN8bsTxlOYlsdjmIGu/C9OWblPYGpjQQIRyvs4Cc/mNhrh+
|
||||
14EQgwuemIIFDLOgcD+iISoN8CqegelNcJndFw1PDN6LkVoiHz9p7jzsge8RKay/QW6C03KNDpWZ
|
||||
EUCgCUdfHfo8xKeR+LL1cfn24HKJmZt8L/aeRZwZ1jwePXFRVtiXELvgJuM/tJDIFj2KD337iV64
|
||||
fWcKQ/ydDVGqfDZAdcU4hQdsrPWENwPTQPfVPq2NNLMyIH9+WKx9Ed6/WzeZmIy5ZWpX1TtTolo6
|
||||
OJXQFeItMAjHxW/ZSZTok5IS3FuRhExturaInnzjYpx50a6kS34c5+c8hYq7sAtZ/CNLZmBnBCFD
|
||||
aMQqT8xFZJ5uolUaSeXxg7JFY1QsYp5RKvj4SjFwCGKJ2+hPPe9UyyltxOidNtxjaknOCeBHytOr
|
||||
-----END CERTIFICATE-----
|
||||
88
app/main/api/etc/merchant/bak/alipayRootCert.crt
Normal file
88
app/main/api/etc/merchant/bak/alipayRootCert.crt
Normal file
@@ -0,0 +1,88 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIBszCCAVegAwIBAgIIaeL+wBcKxnswDAYIKoEcz1UBg3UFADAuMQswCQYDVQQG
|
||||
EwJDTjEOMAwGA1UECgwFTlJDQUMxDzANBgNVBAMMBlJPT1RDQTAeFw0xMjA3MTQw
|
||||
MzExNTlaFw00MjA3MDcwMzExNTlaMC4xCzAJBgNVBAYTAkNOMQ4wDAYDVQQKDAVO
|
||||
UkNBQzEPMA0GA1UEAwwGUk9PVENBMFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE
|
||||
MPCca6pmgcchsTf2UnBeL9rtp4nw+itk1Kzrmbnqo05lUwkwlWK+4OIrtFdAqnRT
|
||||
V7Q9v1htkv42TsIutzd126NdMFswHwYDVR0jBBgwFoAUTDKxl9kzG8SmBcHG5Yti
|
||||
W/CXdlgwDAYDVR0TBAUwAwEB/zALBgNVHQ8EBAMCAQYwHQYDVR0OBBYEFEwysZfZ
|
||||
MxvEpgXBxuWLYlvwl3ZYMAwGCCqBHM9VAYN1BQADSAAwRQIgG1bSLeOXp3oB8H7b
|
||||
53W+CKOPl2PknmWEq/lMhtn25HkCIQDaHDgWxWFtnCrBjH16/W3Ezn7/U/Vjo5xI
|
||||
pDoiVhsLwg==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIF0zCCA7ugAwIBAgIIH8+hjWpIDREwDQYJKoZIhvcNAQELBQAwejELMAkGA1UE
|
||||
BhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNVBAsMF0NlcnRpZmlj
|
||||
YXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5jaWFsIENlcnRpZmlj
|
||||
YXRpb24gQXV0aG9yaXR5IFIxMB4XDTE4MDMyMTEzNDg0MFoXDTM4MDIyODEzNDg0
|
||||
MFowejELMAkGA1UEBhMCQ04xFjAUBgNVBAoMDUFudCBGaW5hbmNpYWwxIDAeBgNV
|
||||
BAsMF0NlcnRpZmljYXRpb24gQXV0aG9yaXR5MTEwLwYDVQQDDChBbnQgRmluYW5j
|
||||
aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFIxMIICIjANBgkqhkiG9w0BAQEF
|
||||
AAOCAg8AMIICCgKCAgEAtytTRcBNuur5h8xuxnlKJetT65cHGemGi8oD+beHFPTk
|
||||
rUTlFt9Xn7fAVGo6QSsPb9uGLpUFGEdGmbsQ2q9cV4P89qkH04VzIPwT7AywJdt2
|
||||
xAvMs+MgHFJzOYfL1QkdOOVO7NwKxH8IvlQgFabWomWk2Ei9WfUyxFjVO1LVh0Bp
|
||||
dRBeWLMkdudx0tl3+21t1apnReFNQ5nfX29xeSxIhesaMHDZFViO/DXDNW2BcTs6
|
||||
vSWKyJ4YIIIzStumD8K1xMsoaZBMDxg4itjWFaKRgNuPiIn4kjDY3kC66Sl/6yTl
|
||||
YUz8AybbEsICZzssdZh7jcNb1VRfk79lgAprm/Ktl+mgrU1gaMGP1OE25JCbqli1
|
||||
Pbw/BpPynyP9+XulE+2mxFwTYhKAwpDIDKuYsFUXuo8t261pCovI1CXFzAQM2w7H
|
||||
DtA2nOXSW6q0jGDJ5+WauH+K8ZSvA6x4sFo4u0KNCx0ROTBpLif6GTngqo3sj+98
|
||||
SZiMNLFMQoQkjkdN5Q5g9N6CFZPVZ6QpO0JcIc7S1le/g9z5iBKnifrKxy0TQjtG
|
||||
PsDwc8ubPnRm/F82RReCoyNyx63indpgFfhN7+KxUIQ9cOwwTvemmor0A+ZQamRe
|
||||
9LMuiEfEaWUDK+6O0Gl8lO571uI5onYdN1VIgOmwFbe+D8TcuzVjIZ/zvHrAGUcC
|
||||
AwEAAaNdMFswCwYDVR0PBAQDAgEGMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFF90
|
||||
tATATwda6uWx2yKjh0GynOEBMB8GA1UdIwQYMBaAFF90tATATwda6uWx2yKjh0Gy
|
||||
nOEBMA0GCSqGSIb3DQEBCwUAA4ICAQCVYaOtqOLIpsrEikE5lb+UARNSFJg6tpkf
|
||||
tJ2U8QF/DejemEHx5IClQu6ajxjtu0Aie4/3UnIXop8nH/Q57l+Wyt9T7N2WPiNq
|
||||
JSlYKYbJpPF8LXbuKYG3BTFTdOVFIeRe2NUyYh/xs6bXGr4WKTXb3qBmzR02FSy3
|
||||
IODQw5Q6zpXj8prYqFHYsOvGCEc1CwJaSaYwRhTkFedJUxiyhyB5GQwoFfExCVHW
|
||||
05ZFCAVYFldCJvUzfzrWubN6wX0DD2dwultgmldOn/W/n8at52mpPNvIdbZb2F41
|
||||
T0YZeoWnCJrYXjq/32oc1cmifIHqySnyMnavi75DxPCdZsCOpSAT4j4lAQRGsfgI
|
||||
kkLPGQieMfNNkMCKh7qjwdXAVtdqhf0RVtFILH3OyEodlk1HYXqX5iE5wlaKzDop
|
||||
PKwf2Q3BErq1xChYGGVS+dEvyXc/2nIBlt7uLWKp4XFjqekKbaGaLJdjYP5b2s7N
|
||||
1dM0MXQ/f8XoXKBkJNzEiM3hfsU6DOREgMc1DIsFKxfuMwX3EkVQM1If8ghb6x5Y
|
||||
jXayv+NLbidOSzk4vl5QwngO/JYFMkoc6i9LNwEaEtR9PhnrdubxmrtM+RjfBm02
|
||||
77q3dSWFESFQ4QxYWew4pHE0DpWbWy/iMIKQ6UZ5RLvB8GEcgt8ON7BBJeMc+Dyi
|
||||
kT9qhqn+lw==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICiDCCAgygAwIBAgIIQX76UsB/30owDAYIKoZIzj0EAwMFADB6MQswCQYDVQQG
|
||||
EwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UECwwXQ2VydGlmaWNh
|
||||
dGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNpYWwgQ2VydGlmaWNh
|
||||
dGlvbiBBdXRob3JpdHkgRTEwHhcNMTkwNDI4MTYyMDQ0WhcNNDkwNDIwMTYyMDQ0
|
||||
WjB6MQswCQYDVQQGEwJDTjEWMBQGA1UECgwNQW50IEZpbmFuY2lhbDEgMB4GA1UE
|
||||
CwwXQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxMTAvBgNVBAMMKEFudCBGaW5hbmNp
|
||||
YWwgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgRTEwdjAQBgcqhkjOPQIBBgUrgQQA
|
||||
IgNiAASCCRa94QI0vR5Up9Yr9HEupz6hSoyjySYqo7v837KnmjveUIUNiuC9pWAU
|
||||
WP3jwLX3HkzeiNdeg22a0IZPoSUCpasufiLAnfXh6NInLiWBrjLJXDSGaY7vaokt
|
||||
rpZvAdmjXTBbMAsGA1UdDwQEAwIBBjAMBgNVHRMEBTADAQH/MB0GA1UdDgQWBBRZ
|
||||
4ZTgDpksHL2qcpkFkxD2zVd16TAfBgNVHSMEGDAWgBRZ4ZTgDpksHL2qcpkFkxD2
|
||||
zVd16TAMBggqhkjOPQQDAwUAA2gAMGUCMQD4IoqT2hTUn0jt7oXLdMJ8q4vLp6sg
|
||||
wHfPiOr9gxreb+e6Oidwd2LDnC4OUqCWiF8CMAzwKs4SnDJYcMLf2vpkbuVE4dTH
|
||||
Rglz+HGcTLWsFs4KxLsq7MuU+vJTBUeDJeDjdA==
|
||||
-----END CERTIFICATE-----
|
||||
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDxTCCAq2gAwIBAgIUEMdk6dVgOEIS2cCP0Q43P90Ps5YwDQYJKoZIhvcNAQEF
|
||||
BQAwajELMAkGA1UEBhMCQ04xEzARBgNVBAoMCmlUcnVzQ2hpbmExHDAaBgNVBAsM
|
||||
E0NoaW5hIFRydXN0IE5ldHdvcmsxKDAmBgNVBAMMH2lUcnVzQ2hpbmEgQ2xhc3Mg
|
||||
MiBSb290IENBIC0gRzMwHhcNMTMwNDE4MDkzNjU2WhcNMzMwNDE4MDkzNjU2WjBq
|
||||
MQswCQYDVQQGEwJDTjETMBEGA1UECgwKaVRydXNDaGluYTEcMBoGA1UECwwTQ2hp
|
||||
bmEgVHJ1c3QgTmV0d29yazEoMCYGA1UEAwwfaVRydXNDaGluYSBDbGFzcyAyIFJv
|
||||
b3QgQ0EgLSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOPPShpV
|
||||
nJbMqqCw6Bz1kehnoPst9pkr0V9idOwU2oyS47/HjJXk9Rd5a9xfwkPO88trUpz5
|
||||
4GmmwspDXjVFu9L0eFaRuH3KMha1Ak01citbF7cQLJlS7XI+tpkTGHEY5pt3EsQg
|
||||
wykfZl/A1jrnSkspMS997r2Gim54cwz+mTMgDRhZsKK/lbOeBPpWtcFizjXYCqhw
|
||||
WktvQfZBYi6o4sHCshnOswi4yV1p+LuFcQ2ciYdWvULh1eZhLxHbGXyznYHi0dGN
|
||||
z+I9H8aXxqAQfHVhbdHNzi77hCxFjOy+hHrGsyzjrd2swVQ2iUWP8BfEQqGLqM1g
|
||||
KgWKYfcTGdbPB1MCAwEAAaNjMGEwHQYDVR0OBBYEFG/oAMxTVe7y0+408CTAK8hA
|
||||
uTyRMB8GA1UdIwQYMBaAFG/oAMxTVe7y0+408CTAK8hAuTyRMA8GA1UdEwEB/wQF
|
||||
MAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBLnUTfW7hp
|
||||
emMbuUGCk7RBswzOT83bDM6824EkUnf+X0iKS95SUNGeeSWK2o/3ALJo5hi7GZr3
|
||||
U8eLaWAcYizfO99UXMRBPw5PRR+gXGEronGUugLpxsjuynoLQu8GQAeysSXKbN1I
|
||||
UugDo9u8igJORYA+5ms0s5sCUySqbQ2R5z/GoceyI9LdxIVa1RjVX8pYOj8JFwtn
|
||||
DJN3ftSFvNMYwRuILKuqUYSHc2GPYiHVflDh5nDymCMOQFcFG3WsEuB+EYQPFgIU
|
||||
1DHmdZcz7Llx8UOZXX2JupWCYzK1XhJb+r4hK5ncf/w8qGtYlmyJpxk3hr1TfUJX
|
||||
Yf4Zr0fJsGuv
|
||||
-----END CERTIFICATE-----
|
||||
@@ -24,6 +24,7 @@ type Config struct {
|
||||
AdminConfig AdminConfig
|
||||
TaxConfig TaxConfig
|
||||
Promotion PromotionConfig // 推广链接配置
|
||||
Captcha CaptchaConfig // 阿里云滑块验证码配置
|
||||
}
|
||||
|
||||
// JwtAuth 用于 JWT 鉴权配置
|
||||
@@ -116,3 +117,12 @@ type PromotionConfig struct {
|
||||
PromotionDomain string // 推广域名(用于生成短链)
|
||||
OfficialDomain string // 正式站点域名(短链重定向的目标域名)
|
||||
}
|
||||
|
||||
// CaptchaConfig 阿里云滑块验证码配置
|
||||
type CaptchaConfig struct {
|
||||
AccessKeyID string
|
||||
AccessKeySecret string
|
||||
EndpointURL string
|
||||
SceneID string
|
||||
EKey string // 加密模式用的 ekey(Base64)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package admin_agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"ycc-server/app/main/api/internal/logic/admin_agent"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
)
|
||||
|
||||
func AdminDowngradeAgentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdminDowngradeAgentReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := admin_agent.NewAdminDowngradeAgentLogic(r.Context(), svcCtx)
|
||||
resp, err := l.AdminDowngradeAgent(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package admin_agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"ycc-server/app/main/api/internal/logic/admin_agent"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func AdminUpdateAgentMobileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdminUpdateAgentMobileReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := admin_agent.NewAdminUpdateAgentMobileLogic(r.Context(), svcCtx)
|
||||
resp, err := l.AdminUpdateAgentMobile(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package admin_complaint
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"ycc-server/app/main/api/internal/logic/admin_complaint"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
)
|
||||
|
||||
func AdminGetComplaintDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdminGetComplaintDetailReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := admin_complaint.NewAdminGetComplaintDetailLogic(r.Context(), svcCtx)
|
||||
resp, err := l.AdminGetComplaintDetail(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package admin_complaint
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"ycc-server/app/main/api/internal/logic/admin_complaint"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
)
|
||||
|
||||
func AdminGetComplaintListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdminGetComplaintListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := admin_complaint.NewAdminGetComplaintListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.AdminGetComplaintList(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package admin_complaint
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"ycc-server/app/main/api/internal/logic/admin_complaint"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
)
|
||||
|
||||
func AdminUpdateComplaintRemarkHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdminUpdateComplaintRemarkReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := admin_complaint.NewAdminUpdateComplaintRemarkLogic(r.Context(), svcCtx)
|
||||
resp, err := l.AdminUpdateComplaintRemark(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package admin_complaint
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"ycc-server/app/main/api/internal/logic/admin_complaint"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
)
|
||||
|
||||
func AdminUpdateComplaintStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdminUpdateComplaintStatusReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := admin_complaint.NewAdminUpdateComplaintStatusLogic(r.Context(), svcCtx)
|
||||
resp, err := l.AdminUpdateComplaintStatus(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package admin_dashboard
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"ycc-server/app/main/api/internal/logic/admin_dashboard"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/common/result"
|
||||
)
|
||||
|
||||
func AdminGetDashboardStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := admin_dashboard.NewAdminGetDashboardStatisticsLogic(r.Context(), svcCtx)
|
||||
resp, err := l.AdminGetDashboardStatistics()
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package admin_query
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"ycc-server/app/main/api/internal/logic/admin_query"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
)
|
||||
|
||||
func AdminDeleteQueryFeatureDataHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdminDeleteQueryFeatureDataReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := admin_query.NewAdminDeleteQueryFeatureDataLogic(r.Context(), svcCtx)
|
||||
resp, err := l.AdminDeleteQueryFeatureData(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"ycc-server/app/main/api/internal/logic/agent"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func CheckFeatureWhitelistStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CheckFeatureWhitelistStatusReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := agent.NewCheckFeatureWhitelistStatusLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CheckFeatureWhitelistStatus(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"ycc-server/app/main/api/internal/logic/agent"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
)
|
||||
|
||||
func CheckOrderAgentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CheckOrderAgentReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := agent.NewCheckOrderAgentLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CheckOrderAgent(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"ycc-server/app/main/api/internal/logic/agent"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func CreateWhitelistOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.CreateWhitelistOrderReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := agent.NewCreateWhitelistOrderLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CreateWhitelistOrder(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"ycc-server/app/main/api/internal/logic/agent"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func GetInvitePosterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetInvitePosterReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
req.Format = strings.TrimSpace(strings.ToLower(req.Format))
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := agent.NewGetInvitePosterLogic(r.Context(), svcCtx)
|
||||
|
||||
if req.Format == "base64" {
|
||||
base64Str, err := l.GetInvitePosterBase64(&req)
|
||||
if err != nil {
|
||||
result.HttpResult(r, w, nil, err)
|
||||
return
|
||||
}
|
||||
result.HttpResult(r, w, &types.GetInvitePosterResp{PosterBase64: base64Str}, nil)
|
||||
return
|
||||
}
|
||||
|
||||
pngBytes, err := l.GetInvitePoster(&req)
|
||||
if err != nil {
|
||||
result.HttpResult(r, w, nil, err)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Type", "image/png")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write(pngBytes)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"ycc-server/app/main/api/internal/logic/agent"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
)
|
||||
|
||||
func GetLastWithdrawalInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetLastWithdrawalInfoReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := agent.NewGetLastWithdrawalInfoLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetLastWithdrawalInfo(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"ycc-server/app/main/api/internal/logic/agent"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func GetWhitelistFeaturesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetWhitelistFeaturesReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := agent.NewGetWhitelistFeaturesLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetWhitelistFeatures(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"ycc-server/app/main/api/internal/logic/agent"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func GetWhitelistListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetWhitelistListReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := agent.NewGetWhitelistListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetWhitelistList(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
||||
31
app/main/api/internal/handler/agent/offlinefeaturehandler.go
Normal file
31
app/main/api/internal/handler/agent/offlinefeaturehandler.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"ycc-server/app/main/api/internal/logic/agent"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func OfflineFeatureHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.OfflineFeatureReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
if err := validator.Validate(req); err != nil {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := agent.NewOfflineFeatureLogic(r.Context(), svcCtx)
|
||||
resp, err := l.OfflineFeature(&req)
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
"ycc-server/pkg/captcha"
|
||||
"ycc-server/pkg/lzkit/validator"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
@@ -23,7 +24,8 @@ func SendSmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := auth.NewSendSmsLogic(r.Context(), svcCtx)
|
||||
ctx := captcha.WithUserAgent(r.Context(), r.Header.Get("User-Agent"))
|
||||
l := auth.NewSendSmsLogic(ctx, svcCtx)
|
||||
err := l.SendSms(&req)
|
||||
result.HttpResult(r, w, nil, err)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package captcha
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"ycc-server/app/main/api/internal/logic/captcha"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/result"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func GetEncryptedSceneIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetEncryptedSceneIdResp
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := captcha.NewGetEncryptedSceneIdLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetEncryptedSceneId()
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
18
app/main/api/internal/handler/pay/alipayfromhandler.go
Normal file
18
app/main/api/internal/handler/pay/alipayfromhandler.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package pay
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"ycc-server/app/main/api/internal/logic/pay"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/common/result"
|
||||
)
|
||||
|
||||
func AlipayFromHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := pay.NewAlipayFromLogic(r.Context(), svcCtx)
|
||||
err := l.AlipayFrom(w, r)
|
||||
result.HttpResult(r, w, nil, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ import (
|
||||
admin_agent "ycc-server/app/main/api/internal/handler/admin_agent"
|
||||
admin_api "ycc-server/app/main/api/internal/handler/admin_api"
|
||||
admin_auth "ycc-server/app/main/api/internal/handler/admin_auth"
|
||||
admin_complaint "ycc-server/app/main/api/internal/handler/admin_complaint"
|
||||
admin_dashboard "ycc-server/app/main/api/internal/handler/admin_dashboard"
|
||||
admin_feature "ycc-server/app/main/api/internal/handler/admin_feature"
|
||||
admin_menu "ycc-server/app/main/api/internal/handler/admin_menu"
|
||||
admin_notification "ycc-server/app/main/api/internal/handler/admin_notification"
|
||||
@@ -21,6 +23,7 @@ import (
|
||||
app "ycc-server/app/main/api/internal/handler/app"
|
||||
auth "ycc-server/app/main/api/internal/handler/auth"
|
||||
authorization "ycc-server/app/main/api/internal/handler/authorization"
|
||||
captcha "ycc-server/app/main/api/internal/handler/captcha"
|
||||
notification "ycc-server/app/main/api/internal/handler/notification"
|
||||
pay "ycc-server/app/main/api/internal/handler/pay"
|
||||
product "ycc-server/app/main/api/internal/handler/product"
|
||||
@@ -66,6 +69,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/invite_code/list",
|
||||
Handler: admin_agent.AdminGetInviteCodeListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/level/downgrade",
|
||||
Handler: admin_agent.AdminDowngradeAgentHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/link/list",
|
||||
@@ -76,6 +84,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/list",
|
||||
Handler: admin_agent.AdminGetAgentListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/mobile/update",
|
||||
Handler: admin_agent.AdminUpdateAgentMobileHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/order/list",
|
||||
@@ -172,6 +185,53 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
rest.WithPrefix("/api/v1/admin/auth"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.AdminAuthInterceptor},
|
||||
[]rest.Route{
|
||||
{
|
||||
// 获取投诉详情
|
||||
Method: http.MethodGet,
|
||||
Path: "/detail/:id",
|
||||
Handler: admin_complaint.AdminGetComplaintDetailHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 获取投诉列表
|
||||
Method: http.MethodGet,
|
||||
Path: "/list",
|
||||
Handler: admin_complaint.AdminGetComplaintListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新投诉备注
|
||||
Method: http.MethodPut,
|
||||
Path: "/update-remark/:id",
|
||||
Handler: admin_complaint.AdminUpdateComplaintRemarkHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 更新投诉状态
|
||||
Method: http.MethodPut,
|
||||
Path: "/update-status/:id",
|
||||
Handler: admin_complaint.AdminUpdateComplaintStatusHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithPrefix("/api/v1/admin/complaint"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.AdminAuthInterceptor},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/statistics",
|
||||
Handler: admin_dashboard.AdminGetDashboardStatisticsHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithPrefix("/api/v1/admin/dashboard"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.AdminAuthInterceptor},
|
||||
@@ -440,6 +500,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/cleanup/configs",
|
||||
Handler: admin_query.AdminGetQueryCleanupConfigListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 按 QueryId+FeatureApiId 补删单条查询的某个模块数据(仅内部运维使用)
|
||||
Method: http.MethodPost,
|
||||
Path: "/cleanup/delete/feature",
|
||||
Handler: admin_query.AdminDeleteQueryFeatureDataHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
// 获取清理详情列表
|
||||
Method: http.MethodGet,
|
||||
@@ -641,6 +707,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/info",
|
||||
Handler: agent.GetAgentInfoHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/invite/poster",
|
||||
Handler: agent.GetInvitePosterHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/invite_code/delete",
|
||||
@@ -666,6 +737,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/level/privilege",
|
||||
Handler: agent.GetLevelPrivilegeHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/order/agent",
|
||||
Handler: agent.CheckOrderAgentHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/product_config",
|
||||
@@ -731,11 +807,41 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/upgrade/subordinate",
|
||||
Handler: agent.UpgradeSubordinateHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/whitelist/check",
|
||||
Handler: agent.CheckFeatureWhitelistStatusHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/whitelist/features",
|
||||
Handler: agent.GetWhitelistFeaturesHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/whitelist/list",
|
||||
Handler: agent.GetWhitelistListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/whitelist/offline",
|
||||
Handler: agent.OfflineFeatureHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/whitelist/order/create",
|
||||
Handler: agent.CreateWhitelistOrderHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/withdrawal/apply",
|
||||
Handler: agent.ApplyWithdrawalHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/withdrawal/last_info",
|
||||
Handler: agent.GetLastWithdrawalInfoHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/withdrawal/list",
|
||||
@@ -812,6 +918,18 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
rest.WithPrefix("/api/v1"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
// get encrypted scene id for aliyun captcha
|
||||
Method: http.MethodPost,
|
||||
Path: "/captcha/encryptedSceneId",
|
||||
Handler: captcha.GetEncryptedSceneIdHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/v1"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
@@ -831,6 +949,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
Path: "/pay/alipay/callback",
|
||||
Handler: pay.AlipayCallbackHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/pay/alipay/from",
|
||||
Handler: pay.AlipayFromHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/pay/wechat/callback",
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/lzUtils"
|
||||
|
||||
@@ -32,6 +32,13 @@ func NewAdminAuditWithdrawalLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
||||
}
|
||||
}
|
||||
|
||||
// parseFloat 解析配置中的浮点数
|
||||
func (l *AdminAuditWithdrawalLogic) parseFloat(s string) (float64, error) {
|
||||
var result float64
|
||||
_, err := fmt.Sscanf(s, "%f", &result)
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (l *AdminAuditWithdrawalLogic) AdminAuditWithdrawal(req *types.AdminAuditWithdrawalReq) (resp *types.AdminAuditWithdrawalResp, err error) {
|
||||
// 1. 查询提现记录
|
||||
withdrawal, err := l.svcCtx.AgentWithdrawalModel.FindOne(l.ctx, req.WithdrawalId)
|
||||
@@ -46,35 +53,74 @@ func (l *AdminAuditWithdrawalLogic) AdminAuditWithdrawal(req *types.AdminAuditWi
|
||||
|
||||
// 4. 使用事务处理审核
|
||||
err = l.svcCtx.AgentWithdrawalModel.Trans(l.ctx, func(transCtx context.Context, session sqlx.Session) error {
|
||||
if req.Status == 2 { // 审核通过
|
||||
// 4.1 更新提现记录状态为提现中
|
||||
withdrawal.Status = 4 // 提现中
|
||||
withdrawal.Remark = sql.NullString{String: req.Remark, Valid: true}
|
||||
switch req.Status {
|
||||
case 2: // 审核通过
|
||||
// 4.1 根据提现方式处理
|
||||
switch withdrawal.WithdrawalType {
|
||||
case 1:
|
||||
// 支付宝提现:审核通过前再次校验月度额度,避免一次性通过多笔超限
|
||||
now := time.Now()
|
||||
monthStart := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
|
||||
nextMonthStart := monthStart.AddDate(0, 1, 0)
|
||||
|
||||
// 获取支付宝月度额度配置(默认 800 元)
|
||||
alipayQuota := 800.0
|
||||
if cfg, cfgErr := l.svcCtx.AgentConfigModel.FindOneByConfigKey(transCtx, "alipay_month_quota"); cfgErr == nil {
|
||||
if parsed, parseErr := l.parseFloat(cfg.ConfigValue); parseErr == nil && parsed > 0 {
|
||||
alipayQuota = parsed
|
||||
}
|
||||
}
|
||||
|
||||
// 统计本月已成功的支付宝提现金额(status=5)
|
||||
withdrawBuilder := l.svcCtx.AgentWithdrawalModel.SelectBuilder().
|
||||
Where("agent_id = ? AND withdrawal_type = ? AND status = ? AND create_time >= ? AND create_time < ?",
|
||||
withdrawal.AgentId, 1, 5, monthStart, nextMonthStart)
|
||||
usedAmount, sumErr := l.svcCtx.AgentWithdrawalModel.FindSum(transCtx, withdrawBuilder, "amount")
|
||||
if sumErr != nil {
|
||||
return errors.Wrapf(sumErr, "查询本月支付宝提现额度使用情况失败")
|
||||
}
|
||||
|
||||
if usedAmount+withdrawal.Amount > alipayQuota {
|
||||
// 超出额度,不允许通过,保持待审核状态并提示原因
|
||||
withdrawal.Status = 1
|
||||
withdrawal.Remark = sql.NullString{
|
||||
String: fmt.Sprintf("超过本月支付宝提现额度(限额:%.2f 元,已用:%.2f 元),请使用银行卡提现或调整金额", alipayQuota, usedAmount),
|
||||
Valid: true,
|
||||
}
|
||||
if err := l.svcCtx.AgentWithdrawalModel.UpdateWithVersion(transCtx, session, withdrawal); err != nil {
|
||||
return errors.Wrapf(err, "更新提现记录失败")
|
||||
}
|
||||
|
||||
// 4.2 调用支付宝转账接口
|
||||
outBizNo := withdrawal.WithdrawNo
|
||||
transferResp, err := l.svcCtx.AlipayService.AliTransfer(transCtx, withdrawal.PayeeAccount, withdrawal.PayeeName, withdrawal.ActualAmount, "代理提现", outBizNo)
|
||||
if err != nil {
|
||||
// 转账失败,更新状态为失败
|
||||
withdrawal.Status = 6 // 提现失败
|
||||
withdrawal.Remark = sql.NullString{String: fmt.Sprintf("转账失败: %v", err), Valid: true}
|
||||
l.svcCtx.AgentWithdrawalModel.UpdateWithVersion(transCtx, session, withdrawal)
|
||||
|
||||
// 解冻余额
|
||||
wallet, err := l.svcCtx.AgentWalletModel.FindOneByAgentId(transCtx, withdrawal.AgentId)
|
||||
if err == nil {
|
||||
wallet.FrozenBalance -= withdrawal.Amount
|
||||
wallet.Balance += withdrawal.Amount
|
||||
l.svcCtx.AgentWalletModel.UpdateWithVersion(transCtx, session, wallet)
|
||||
return errors.Wrapf(xerr.NewErrMsg("超过本月支付宝提现额度,无法通过该笔提现"), "")
|
||||
}
|
||||
|
||||
// 支付宝提现:开发环境下做模拟,不调用真实支付宝转账
|
||||
mockTransferStatus := "SUCCESS"
|
||||
var transferResp struct {
|
||||
Status string
|
||||
SubCode string
|
||||
}
|
||||
|
||||
if os.Getenv("ENV") == "development" {
|
||||
transferResp.Status = mockTransferStatus
|
||||
logx.Infof("【DEV】模拟支付宝转账成功,withdrawNo=%s, amount=%.2f, payee=%s",
|
||||
withdrawal.WithdrawNo, withdrawal.ActualAmount, withdrawal.PayeeAccount)
|
||||
} else {
|
||||
// 生产环境:同步调用支付宝转账接口
|
||||
outBizNo := withdrawal.WithdrawNo
|
||||
resp, err := l.svcCtx.AlipayService.AliTransfer(transCtx, withdrawal.PayeeAccount, withdrawal.PayeeName, withdrawal.ActualAmount, "代理提现", outBizNo)
|
||||
if err != nil {
|
||||
// 调用失败:保持状态为待审核(1),只记录备注,方便管理员重试
|
||||
withdrawal.Status = 1 // 待审核
|
||||
withdrawal.Remark = sql.NullString{String: fmt.Sprintf("支付宝转账调用失败: %v", err), Valid: true}
|
||||
_ = l.svcCtx.AgentWithdrawalModel.UpdateWithVersion(transCtx, session, withdrawal)
|
||||
|
||||
return errors.Wrapf(err, "支付宝转账失败")
|
||||
}
|
||||
transferResp.Status = resp.Status
|
||||
transferResp.SubCode = resp.SubCode
|
||||
}
|
||||
|
||||
// 4.3 根据转账结果更新状态
|
||||
// 4.2 根据转账结果更新状态
|
||||
switch transferResp.Status {
|
||||
case "SUCCESS":
|
||||
// 转账成功
|
||||
@@ -96,7 +142,7 @@ func (l *AdminAuditWithdrawalLogic) AdminAuditWithdrawal(req *types.AdminAuditWi
|
||||
|
||||
// 更新扣税记录状态
|
||||
taxBuilder := l.svcCtx.AgentWithdrawalTaxModel.SelectBuilder().
|
||||
Where("withdrawal_id = ? AND del_state = ?", withdrawal.Id, globalkey.DelStateNo)
|
||||
Where("withdrawal_id = ?", withdrawal.Id)
|
||||
taxRecords, err := l.svcCtx.AgentWithdrawalTaxModel.FindAll(transCtx, taxBuilder, "")
|
||||
if err == nil && len(taxRecords) > 0 {
|
||||
taxRecord := taxRecords[0]
|
||||
@@ -106,28 +152,55 @@ func (l *AdminAuditWithdrawalLogic) AdminAuditWithdrawal(req *types.AdminAuditWi
|
||||
}
|
||||
|
||||
case "FAIL":
|
||||
// 转账失败
|
||||
withdrawal.Status = 6 // 提现失败
|
||||
// 转账失败:保持待审核状态,方便人工处理或重试
|
||||
withdrawal.Status = 1 // 待审核
|
||||
errorMsg := l.mapAlipayError(transferResp.SubCode)
|
||||
withdrawal.Remark = sql.NullString{String: errorMsg, Valid: true}
|
||||
if err := l.svcCtx.AgentWithdrawalModel.UpdateWithVersion(transCtx, session, withdrawal); err != nil {
|
||||
return errors.Wrapf(err, "更新提现记录失败")
|
||||
}
|
||||
|
||||
// 解冻余额
|
||||
wallet, err := l.svcCtx.AgentWalletModel.FindOneByAgentId(transCtx, withdrawal.AgentId)
|
||||
if err == nil {
|
||||
wallet.FrozenBalance -= withdrawal.Amount
|
||||
wallet.Balance += withdrawal.Amount
|
||||
l.svcCtx.AgentWalletModel.UpdateWithVersion(transCtx, session, wallet)
|
||||
}
|
||||
|
||||
case "DEALING":
|
||||
// 处理中,保持提现中状态,后续通过轮询更新
|
||||
// 状态已经是4(提现中),无需更新
|
||||
// 处理中:同样保持待审核状态(1),由管理员后续确认
|
||||
withdrawal.Status = 1
|
||||
withdrawal.Remark = sql.NullString{String: "支付宝处理中,请稍后重试或联系平台", Valid: true}
|
||||
if err := l.svcCtx.AgentWithdrawalModel.UpdateWithVersion(transCtx, session, withdrawal); err != nil {
|
||||
return errors.Wrapf(err, "更新提现记录失败")
|
||||
}
|
||||
}
|
||||
|
||||
} else if req.Status == 3 { // 审核拒绝
|
||||
case 2:
|
||||
// 银行卡提现:审核通过即视为提现成功(线下已/将立即打款)
|
||||
withdrawal.Status = 5 // 提现成功
|
||||
withdrawal.Remark = sql.NullString{String: req.Remark, Valid: true}
|
||||
if err := l.svcCtx.AgentWithdrawalModel.UpdateWithVersion(transCtx, session, withdrawal); err != nil {
|
||||
return errors.Wrapf(err, "更新提现记录失败")
|
||||
}
|
||||
|
||||
// 更新钱包(解冻并扣除)
|
||||
wallet, err := l.svcCtx.AgentWalletModel.FindOneByAgentId(transCtx, withdrawal.AgentId)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "查询钱包失败")
|
||||
}
|
||||
wallet.FrozenBalance -= withdrawal.Amount
|
||||
wallet.WithdrawnAmount += withdrawal.Amount
|
||||
if err := l.svcCtx.AgentWalletModel.UpdateWithVersion(transCtx, session, wallet); err != nil {
|
||||
return errors.Wrapf(err, "更新钱包失败")
|
||||
}
|
||||
|
||||
// 更新扣税记录状态
|
||||
taxBuilder := l.svcCtx.AgentWithdrawalTaxModel.SelectBuilder().
|
||||
Where("withdrawal_id = ?", withdrawal.Id)
|
||||
taxRecords, err := l.svcCtx.AgentWithdrawalTaxModel.FindAll(transCtx, taxBuilder, "")
|
||||
if err == nil && len(taxRecords) > 0 {
|
||||
taxRecord := taxRecords[0]
|
||||
taxRecord.TaxStatus = 2 // 已扣税
|
||||
taxRecord.TaxTime = lzUtils.TimeToNullTime(time.Now())
|
||||
l.svcCtx.AgentWithdrawalTaxModel.UpdateWithVersion(transCtx, session, taxRecord)
|
||||
}
|
||||
}
|
||||
|
||||
case 3: // 审核拒绝
|
||||
// 4.1 更新提现记录状态为拒绝
|
||||
withdrawal.Status = 3 // 审核拒绝
|
||||
withdrawal.Remark = sql.NullString{String: req.Remark, Valid: true}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package admin_agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AdminDowngradeAgentLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAdminDowngradeAgentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminDowngradeAgentLogic {
|
||||
return &AdminDowngradeAgentLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdminDowngradeAgentLogic) AdminDowngradeAgent(req *types.AdminDowngradeAgentReq) (resp *types.AdminDowngradeAgentResp, err error) {
|
||||
if req.AgentId == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("代理ID不能为空"), "")
|
||||
}
|
||||
|
||||
_, err = l.svcCtx.AgentModel.FindOne(l.ctx, req.AgentId)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("代理不存在"), "")
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理失败, %v", err)
|
||||
}
|
||||
|
||||
if err := l.svcCtx.AgentService.ProcessDowngrade(l.ctx, req.AgentId, req.ToLevel, req.Remark); err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg(err.Error()), "")
|
||||
}
|
||||
|
||||
return &types.AdminDowngradeAgentResp{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package admin_agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
@@ -79,12 +80,26 @@ func (l *AdminGetAgentListLogic) AdminGetAgentList(req *types.AdminGetAgentListR
|
||||
// 查询钱包信息
|
||||
wallet, _ := l.svcCtx.AgentWalletModel.FindOneByAgentId(l.ctx, agent.Id)
|
||||
|
||||
// 查询实名认证信息
|
||||
// 查询实名认证信息(数据库姓名明文、身份证密文,解密后明文返回不脱敏)
|
||||
realNameInfo, _ := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agent.Id)
|
||||
isRealName := false
|
||||
if realNameInfo != nil && realNameInfo.VerifyTime.Valid {
|
||||
realName := ""
|
||||
idCardPlain := "" // 解密后明文返回
|
||||
if realNameInfo != nil {
|
||||
if realNameInfo.VerifyTime.Valid {
|
||||
isRealName = true // verify_time不为空表示已通过三要素核验
|
||||
}
|
||||
realName = realNameInfo.Name
|
||||
if realNameInfo.IdCard != "" {
|
||||
key, keyErr := hex.DecodeString(l.svcCtx.Config.Encrypt.SecretKey)
|
||||
if keyErr == nil {
|
||||
decrypted, err := crypto.DecryptIDCard(realNameInfo.IdCard, key)
|
||||
if err == nil {
|
||||
idCardPlain = decrypted
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wechatId := ""
|
||||
if agent.WechatId.Valid {
|
||||
@@ -116,6 +131,8 @@ func (l *AdminGetAgentListLogic) AdminGetAgentList(req *types.AdminGetAgentListR
|
||||
FrozenBalance: 0,
|
||||
WithdrawnAmount: 0,
|
||||
IsRealName: isRealName,
|
||||
RealName: realName,
|
||||
IdCardPlain: idCardPlain,
|
||||
CreateTime: agent.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package admin_agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
@@ -29,8 +28,7 @@ func NewAdminGetAgentOrderListLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
||||
}
|
||||
|
||||
func (l *AdminGetAgentOrderListLogic) AdminGetAgentOrderList(req *types.AdminGetAgentOrderListReq) (resp *types.AdminGetAgentOrderListResp, err error) {
|
||||
builder := l.svcCtx.AgentOrderModel.SelectBuilder().
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
builder := l.svcCtx.AgentOrderModel.SelectBuilder()
|
||||
|
||||
if req.AgentId != nil {
|
||||
builder = builder.Where("agent_id = ?", *req.AgentId)
|
||||
@@ -42,6 +40,27 @@ func (l *AdminGetAgentOrderListLogic) AdminGetAgentOrderList(req *types.AdminGet
|
||||
builder = builder.Where("process_status = ?", *req.ProcessStatus)
|
||||
}
|
||||
|
||||
// 如果提供了订单状态筛选,先查询符合条件的订单ID列表
|
||||
var filteredOrderIds []string
|
||||
if req.OrderStatus != nil && *req.OrderStatus != "" {
|
||||
orderBuilder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where("status = ?", *req.OrderStatus).
|
||||
Columns("id")
|
||||
orders, _ := l.svcCtx.OrderModel.FindAll(l.ctx, orderBuilder, "")
|
||||
filteredOrderIds = make([]string, 0, len(orders))
|
||||
for _, o := range orders {
|
||||
filteredOrderIds = append(filteredOrderIds, o.Id)
|
||||
}
|
||||
// 如果没有符合条件的订单,直接返回空结果
|
||||
if len(filteredOrderIds) == 0 {
|
||||
return &types.AdminGetAgentOrderListResp{
|
||||
Total: 0,
|
||||
Items: []types.AgentOrderListItem{},
|
||||
}, nil
|
||||
}
|
||||
builder = builder.Where(squirrel.Eq{"order_id": filteredOrderIds})
|
||||
}
|
||||
|
||||
// 分页查询
|
||||
page := req.Page
|
||||
if page <= 0 {
|
||||
@@ -74,9 +93,30 @@ func (l *AdminGetAgentOrderListLogic) AdminGetAgentOrderList(req *types.AdminGet
|
||||
}
|
||||
}
|
||||
|
||||
// 批量查询订单状态
|
||||
orderIdSet := make(map[string]struct{})
|
||||
for _, order := range orders {
|
||||
orderIdSet[order.OrderId] = struct{}{}
|
||||
}
|
||||
orderIdList := make([]string, 0, len(orderIdSet))
|
||||
for id := range orderIdSet {
|
||||
orderIdList = append(orderIdList, id)
|
||||
}
|
||||
orderStatusMap := make(map[string]string)
|
||||
if len(orderIdList) > 0 {
|
||||
orderList, _ := l.svcCtx.OrderModel.FindAll(l.ctx, l.svcCtx.OrderModel.SelectBuilder().Where(squirrel.Eq{"id": orderIdList}), "")
|
||||
for _, o := range orderList {
|
||||
orderStatusMap[o.Id] = o.Status
|
||||
}
|
||||
}
|
||||
|
||||
// 组装响应
|
||||
items := make([]types.AgentOrderListItem, 0, len(orders))
|
||||
for _, order := range orders {
|
||||
orderStatus := orderStatusMap[order.OrderId]
|
||||
if orderStatus == "" {
|
||||
orderStatus = "unknown" // 如果查询不到订单,默认为 unknown
|
||||
}
|
||||
items = append(items, types.AgentOrderListItem{
|
||||
Id: order.Id,
|
||||
AgentId: order.AgentId,
|
||||
@@ -89,6 +129,7 @@ func (l *AdminGetAgentOrderListLogic) AdminGetAgentOrderList(req *types.AdminGet
|
||||
PriceCost: order.PriceCost,
|
||||
AgentProfit: order.AgentProfit,
|
||||
ProcessStatus: order.ProcessStatus,
|
||||
OrderStatus: orderStatus,
|
||||
CreateTime: order.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ func NewAdminGetAgentProductConfigListLogic(ctx context.Context, svcCtx *svc.Ser
|
||||
}
|
||||
|
||||
func (l *AdminGetAgentProductConfigListLogic) AdminGetAgentProductConfigList(req *types.AdminGetAgentProductConfigListReq) (resp *types.AdminGetAgentProductConfigListResp, err error) {
|
||||
builder := l.svcCtx.AgentProductConfigModel.SelectBuilder().
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
builder := l.svcCtx.AgentProductConfigModel.SelectBuilder()
|
||||
|
||||
// 如果提供了产品ID,直接过滤
|
||||
if req.ProductId != nil {
|
||||
|
||||
@@ -2,7 +2,6 @@ package admin_agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/crypto"
|
||||
|
||||
@@ -29,8 +28,7 @@ func NewAdminGetAgentRealNameListLogic(ctx context.Context, svcCtx *svc.ServiceC
|
||||
}
|
||||
|
||||
func (l *AdminGetAgentRealNameListLogic) AdminGetAgentRealNameList(req *types.AdminGetAgentRealNameListReq) (resp *types.AdminGetAgentRealNameListResp, err error) {
|
||||
builder := l.svcCtx.AgentRealNameModel.SelectBuilder().
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
builder := l.svcCtx.AgentRealNameModel.SelectBuilder()
|
||||
|
||||
if req.AgentId != nil {
|
||||
builder = builder.Where("agent_id = ?", *req.AgentId)
|
||||
|
||||
@@ -2,7 +2,6 @@ package admin_agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
@@ -29,8 +28,7 @@ func NewAdminGetAgentRebateListLogic(ctx context.Context, svcCtx *svc.ServiceCon
|
||||
}
|
||||
|
||||
func (l *AdminGetAgentRebateListLogic) AdminGetAgentRebateList(req *types.AdminGetAgentRebateListReq) (resp *types.AdminGetAgentRebateListResp, err error) {
|
||||
builder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
builder := l.svcCtx.AgentRebateModel.SelectBuilder()
|
||||
|
||||
if req.AgentId != nil {
|
||||
builder = builder.Where("agent_id = ?", *req.AgentId)
|
||||
@@ -41,6 +39,9 @@ func (l *AdminGetAgentRebateListLogic) AdminGetAgentRebateList(req *types.AdminG
|
||||
if req.RebateType != nil {
|
||||
builder = builder.Where("rebate_type = ?", *req.RebateType)
|
||||
}
|
||||
if req.Status != nil {
|
||||
builder = builder.Where("status = ?", *req.Status)
|
||||
}
|
||||
|
||||
// 分页查询
|
||||
page := req.Page
|
||||
@@ -84,6 +85,7 @@ func (l *AdminGetAgentRebateListLogic) AdminGetAgentRebateList(req *types.AdminG
|
||||
OrderId: rebate.OrderId,
|
||||
RebateType: rebate.RebateType,
|
||||
Amount: rebate.RebateAmount,
|
||||
Status: rebate.Status,
|
||||
CreateTime: rebate.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package admin_agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -28,8 +27,7 @@ func NewAdminGetAgentUpgradeListLogic(ctx context.Context, svcCtx *svc.ServiceCo
|
||||
}
|
||||
|
||||
func (l *AdminGetAgentUpgradeListLogic) AdminGetAgentUpgradeList(req *types.AdminGetAgentUpgradeListReq) (resp *types.AdminGetAgentUpgradeListResp, err error) {
|
||||
builder := l.svcCtx.AgentUpgradeModel.SelectBuilder().
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
builder := l.svcCtx.AgentUpgradeModel.SelectBuilder()
|
||||
|
||||
if req.AgentId != nil {
|
||||
builder = builder.Where("agent_id = ?", *req.AgentId)
|
||||
|
||||
@@ -49,6 +49,17 @@ func (l *AdminGetAgentWithdrawalListLogic) AdminGetAgentWithdrawalList(req *type
|
||||
item.Remark = v.Remark.String
|
||||
}
|
||||
item.CreateTime = v.CreateTime.Format("2006-01-02 15:04:05")
|
||||
|
||||
// 如果是银行卡提现,填充银行卡信息
|
||||
if v.WithdrawalType == 2 {
|
||||
if v.BankCardNo.Valid {
|
||||
item.BankCardNo = v.BankCardNo.String
|
||||
}
|
||||
if v.BankName.Valid {
|
||||
item.BankName = v.BankName.String
|
||||
}
|
||||
}
|
||||
|
||||
items = append(items, item)
|
||||
}
|
||||
resp = &types.AdminGetAgentWithdrawalListResp{
|
||||
|
||||
@@ -2,7 +2,6 @@ package admin_agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/crypto"
|
||||
|
||||
@@ -31,8 +30,7 @@ func NewAdminGetInviteCodeListLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
||||
|
||||
func (l *AdminGetInviteCodeListLogic) AdminGetInviteCodeList(req *types.AdminGetInviteCodeListReq) (resp *types.AdminGetInviteCodeListResp, err error) {
|
||||
// 1. 构建查询条件
|
||||
builder := l.svcCtx.AgentInviteCodeModel.SelectBuilder().
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
builder := l.svcCtx.AgentInviteCodeModel.SelectBuilder()
|
||||
|
||||
if req.Code != nil && *req.Code != "" {
|
||||
builder = builder.Where("code = ?", *req.Code)
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package admin_agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"regexp"
|
||||
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/crypto"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
// 手机号正则:11 位大陆手机号
|
||||
var mobileRegexp = regexp.MustCompile(`^1[3-9]\d{9}$`)
|
||||
|
||||
type AdminUpdateAgentMobileLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAdminUpdateAgentMobileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminUpdateAgentMobileLogic {
|
||||
return &AdminUpdateAgentMobileLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdminUpdateAgentMobileLogic) AdminUpdateAgentMobile(req *types.AdminUpdateAgentMobileReq) (resp *types.AdminUpdateAgentMobileResp, err error) {
|
||||
// 1. 校验手机号格式
|
||||
if req.Mobile == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("手机号不能为空"), "")
|
||||
}
|
||||
if !mobileRegexp.MatchString(req.Mobile) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("手机号格式不正确"), "")
|
||||
}
|
||||
|
||||
// 2. 查询代理
|
||||
agent, err := l.svcCtx.AgentModel.FindOne(l.ctx, req.AgentId)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("代理不存在"), "")
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理失败, %v", err)
|
||||
}
|
||||
|
||||
// 3. 加密新手机号
|
||||
encryptedMobile, err := crypto.EncryptMobile(req.Mobile, l.svcCtx.Config.Encrypt.SecretKey)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "加密手机号失败, %v", err)
|
||||
}
|
||||
|
||||
// 4. 更新代理手机号
|
||||
agent.Mobile = encryptedMobile
|
||||
if err := l.svcCtx.AgentModel.UpdateWithVersion(l.ctx, nil, agent); err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新手机号失败, %v", err)
|
||||
}
|
||||
|
||||
return &types.AdminUpdateAgentMobileResp{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package admin_complaint
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/lzUtils"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AdminGetComplaintDetailLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAdminGetComplaintDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminGetComplaintDetailLogic {
|
||||
return &AdminGetComplaintDetailLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdminGetComplaintDetailLogic) AdminGetComplaintDetail(req *types.AdminGetComplaintDetailReq) (resp *types.AdminGetComplaintDetailResp, err error) {
|
||||
// 获取投诉主表信息
|
||||
complaint, err := l.svcCtx.ComplaintMainModel.FindOne(l.ctx, req.Id)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminGetComplaintDetail, 查询投诉失败 err: %v", err)
|
||||
}
|
||||
|
||||
// 构建响应
|
||||
resp = &types.AdminGetComplaintDetailResp{
|
||||
Id: complaint.Id,
|
||||
Type: complaint.Type,
|
||||
OrderId: lzUtils.NullStringToString(complaint.OrderId),
|
||||
Name: lzUtils.NullStringToString(complaint.Name),
|
||||
Contact: lzUtils.NullStringToString(complaint.Contact),
|
||||
Content: lzUtils.NullStringToString(complaint.Content),
|
||||
Status: lzUtils.NullStringToString(complaint.Status),
|
||||
StatusDescription: lzUtils.NullStringToString(complaint.StatusDescription),
|
||||
Remark: lzUtils.NullStringToString(complaint.Remark),
|
||||
HandlerId: lzUtils.NullStringToString(complaint.HandlerId),
|
||||
CreateTime: complaint.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
UpdateTime: complaint.UpdateTime.Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
|
||||
if complaint.HandleTime.Valid {
|
||||
resp.HandleTime = complaint.HandleTime.Time.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
// 获取支付宝投诉详情
|
||||
if complaint.Type == "alipay" {
|
||||
alipayBuilder := l.svcCtx.ComplaintAlipayModel.SelectBuilder().
|
||||
Where("complaint_id = ?", complaint.Id)
|
||||
alipayComplaints, err := l.svcCtx.ComplaintAlipayModel.FindAll(l.ctx, alipayBuilder, "")
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminGetComplaintDetail, 查询支付宝投诉失败 err: %v", err)
|
||||
}
|
||||
|
||||
if len(alipayComplaints) > 0 {
|
||||
alipayComplaint := alipayComplaints[0]
|
||||
alipayDetail := &types.AlipayComplaintDetail{
|
||||
Id: alipayComplaint.Id,
|
||||
AlipayId: alipayComplaint.AlipayId,
|
||||
TaskId: alipayComplaint.TaskId,
|
||||
OppositePid: lzUtils.NullStringToString(alipayComplaint.OppositePid),
|
||||
OppositeName: lzUtils.NullStringToString(alipayComplaint.OppositeName),
|
||||
ComplainContent: lzUtils.NullStringToString(alipayComplaint.ComplainContent),
|
||||
TradeNo: lzUtils.NullStringToString(alipayComplaint.TradeNo),
|
||||
Status: lzUtils.NullStringToString(alipayComplaint.Status),
|
||||
StatusDescription: lzUtils.NullStringToString(alipayComplaint.StatusDescription),
|
||||
ProcessCode: lzUtils.NullStringToString(alipayComplaint.ProcessCode),
|
||||
ProcessMessage: lzUtils.NullStringToString(alipayComplaint.ProcessMessage),
|
||||
ProcessRemark: lzUtils.NullStringToString(alipayComplaint.ProcessRemark),
|
||||
ComplainUrl: lzUtils.NullStringToString(alipayComplaint.ComplainUrl),
|
||||
}
|
||||
|
||||
if alipayComplaint.ComplainAmount.Valid {
|
||||
alipayDetail.ComplainAmount = strconv.FormatFloat(alipayComplaint.ComplainAmount.Float64, 'f', -1, 64)
|
||||
}
|
||||
if alipayComplaint.GmtComplain.Valid {
|
||||
alipayDetail.GmtComplain = alipayComplaint.GmtComplain.Time.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
if alipayComplaint.GmtProcess.Valid {
|
||||
alipayDetail.GmtProcess = alipayComplaint.GmtProcess.Time.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
if alipayComplaint.GmtRiskFinishTime.Valid {
|
||||
alipayDetail.GmtRiskFinishTime = alipayComplaint.GmtRiskFinishTime.Time.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
// 解析图片列表
|
||||
if alipayComplaint.ProcessImgUrlList.Valid {
|
||||
var imgList []string
|
||||
if err := json.Unmarshal([]byte(alipayComplaint.ProcessImgUrlList.String), &imgList); err == nil {
|
||||
alipayDetail.ProcessImgUrlList = imgList
|
||||
}
|
||||
}
|
||||
if alipayComplaint.CertifyInfo.Valid {
|
||||
var certifyList []string
|
||||
if err := json.Unmarshal([]byte(alipayComplaint.CertifyInfo.String), &certifyList); err == nil {
|
||||
alipayDetail.CertifyInfo = certifyList
|
||||
}
|
||||
}
|
||||
|
||||
// 获取交易信息列表
|
||||
tradeBuilder := l.svcCtx.ComplaintAlipayTradeModel.SelectBuilder().
|
||||
Where("complaint_id = ?", alipayComplaint.Id)
|
||||
trades, err := l.svcCtx.ComplaintAlipayTradeModel.FindAll(l.ctx, tradeBuilder, "")
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminGetComplaintDetail, 查询交易信息失败 err: %v", err)
|
||||
}
|
||||
|
||||
alipayDetail.TradeInfoList = make([]types.AlipayComplaintTradeInfo, 0, len(trades))
|
||||
for _, trade := range trades {
|
||||
tradeInfo := types.AlipayComplaintTradeInfo{
|
||||
Id: trade.Id,
|
||||
TradeNo: lzUtils.NullStringToString(trade.TradeNo),
|
||||
OutNo: lzUtils.NullStringToString(trade.OutNo),
|
||||
Status: lzUtils.NullStringToString(trade.Status),
|
||||
StatusDescription: lzUtils.NullStringToString(trade.StatusDescription),
|
||||
}
|
||||
|
||||
if trade.AlipayTradeId.Valid {
|
||||
tradeInfo.AlipayTradeId = strconv.FormatInt(trade.AlipayTradeId.Int64, 10)
|
||||
}
|
||||
if trade.AlipayComplaintRecordId.Valid {
|
||||
tradeInfo.AlipayComplaintRecordId = strconv.FormatInt(trade.AlipayComplaintRecordId.Int64, 10)
|
||||
}
|
||||
if trade.GmtTrade.Valid {
|
||||
tradeInfo.GmtTrade = trade.GmtTrade.Time.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
if trade.GmtRefund.Valid {
|
||||
tradeInfo.GmtRefund = trade.GmtRefund.Time.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
if trade.Amount.Valid {
|
||||
tradeInfo.Amount = strconv.FormatFloat(trade.Amount.Float64, 'f', -1, 64)
|
||||
}
|
||||
|
||||
alipayDetail.TradeInfoList = append(alipayDetail.TradeInfoList, tradeInfo)
|
||||
}
|
||||
|
||||
resp.AlipayComplaint = alipayDetail
|
||||
}
|
||||
}
|
||||
|
||||
// 获取主动投诉详情
|
||||
if complaint.Type == "manual" {
|
||||
manualBuilder := l.svcCtx.ComplaintManualModel.SelectBuilder().
|
||||
Where("complaint_id = ?", complaint.Id)
|
||||
manualComplaints, err := l.svcCtx.ComplaintManualModel.FindAll(l.ctx, manualBuilder, "")
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminGetComplaintDetail, 查询主动投诉失败 err: %v", err)
|
||||
}
|
||||
|
||||
if len(manualComplaints) > 0 {
|
||||
manualComplaint := manualComplaints[0]
|
||||
manualDetail := &types.ManualComplaintDetail{
|
||||
Id: manualComplaint.Id,
|
||||
UserId: lzUtils.NullStringToString(manualComplaint.UserId),
|
||||
Subject: lzUtils.NullStringToString(manualComplaint.Subject),
|
||||
Priority: lzUtils.NullStringToString(manualComplaint.Priority),
|
||||
Source: lzUtils.NullStringToString(manualComplaint.Source),
|
||||
}
|
||||
|
||||
// 解析附件URL列表
|
||||
if manualComplaint.AttachmentUrls.Valid {
|
||||
var urlList []string
|
||||
if err := json.Unmarshal([]byte(manualComplaint.AttachmentUrls.String), &urlList); err == nil {
|
||||
manualDetail.AttachmentUrls = urlList
|
||||
}
|
||||
}
|
||||
|
||||
resp.ManualComplaint = manualDetail
|
||||
}
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package admin_complaint
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/lzUtils"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/mr"
|
||||
)
|
||||
|
||||
type AdminGetComplaintListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAdminGetComplaintListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminGetComplaintListLogic {
|
||||
return &AdminGetComplaintListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdminGetComplaintListLogic) AdminGetComplaintList(req *types.AdminGetComplaintListReq) (resp *types.AdminGetComplaintListResp, err error) {
|
||||
// 构建查询条件
|
||||
builder := l.svcCtx.ComplaintMainModel.SelectBuilder()
|
||||
if req.Type != "" {
|
||||
builder = builder.Where("type = ?", req.Type)
|
||||
}
|
||||
if req.Status != "" {
|
||||
builder = builder.Where("status = ?", req.Status)
|
||||
}
|
||||
if req.Name != "" {
|
||||
builder = builder.Where("name LIKE ?", "%"+req.Name+"%")
|
||||
}
|
||||
if req.Contact != "" {
|
||||
builder = builder.Where("contact LIKE ?", "%"+req.Contact+"%")
|
||||
}
|
||||
if req.OrderId != "" {
|
||||
builder = builder.Where("order_id = ?", req.OrderId)
|
||||
}
|
||||
// 时间范围查询
|
||||
if req.CreateTimeStart != "" {
|
||||
builder = builder.Where("create_time >= ?", req.CreateTimeStart)
|
||||
}
|
||||
if req.CreateTimeEnd != "" {
|
||||
builder = builder.Where("create_time <= ?", req.CreateTimeEnd)
|
||||
}
|
||||
if req.HandleTimeStart != "" {
|
||||
builder = builder.Where("handle_time >= ?", req.HandleTimeStart)
|
||||
}
|
||||
if req.HandleTimeEnd != "" {
|
||||
builder = builder.Where("handle_time <= ?", req.HandleTimeEnd)
|
||||
}
|
||||
|
||||
// 并发获取总数和列表
|
||||
var total int64
|
||||
var complaints []*model.ComplaintMain
|
||||
err = mr.Finish(func() error {
|
||||
var err error
|
||||
total, err = l.svcCtx.ComplaintMainModel.FindCount(l.ctx, builder, "id")
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminGetComplaintList, 查询投诉总数失败 err: %v", err)
|
||||
}
|
||||
return nil
|
||||
}, func() error {
|
||||
var err error
|
||||
complaints, err = l.svcCtx.ComplaintMainModel.FindPageListByPage(l.ctx, builder, req.Page, req.PageSize, "create_time DESC")
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminGetComplaintList, 查询投诉列表失败 err: %v", err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 构建响应
|
||||
resp = &types.AdminGetComplaintListResp{
|
||||
Total: total,
|
||||
Items: make([]types.ComplaintListItem, 0, len(complaints)),
|
||||
}
|
||||
|
||||
// 批量获取支付宝投诉和主动投诉的详细信息
|
||||
complaintIds := make([]string, 0, len(complaints))
|
||||
for _, complaint := range complaints {
|
||||
complaintIds = append(complaintIds, complaint.Id)
|
||||
}
|
||||
|
||||
// 获取支付宝投诉信息
|
||||
alipayComplaintMap := make(map[string]*model.ComplaintAlipay)
|
||||
if len(complaintIds) > 0 {
|
||||
alipayBuilder := l.svcCtx.ComplaintAlipayModel.SelectBuilder().
|
||||
Where(squirrel.Eq{"complaint_id": complaintIds})
|
||||
alipayComplaints, err := l.svcCtx.ComplaintAlipayModel.FindAll(l.ctx, alipayBuilder, "")
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminGetComplaintList, 批量查询支付宝投诉失败 err: %v", err)
|
||||
}
|
||||
for _, alipayComplaint := range alipayComplaints {
|
||||
alipayComplaintMap[alipayComplaint.ComplaintId] = alipayComplaint
|
||||
}
|
||||
}
|
||||
|
||||
// 获取主动投诉信息
|
||||
manualComplaintMap := make(map[string]*model.ComplaintManual)
|
||||
if len(complaintIds) > 0 {
|
||||
manualBuilder := l.svcCtx.ComplaintManualModel.SelectBuilder().
|
||||
Where(squirrel.Eq{"complaint_id": complaintIds})
|
||||
manualComplaints, err := l.svcCtx.ComplaintManualModel.FindAll(l.ctx, manualBuilder, "")
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminGetComplaintList, 批量查询主动投诉失败 err: %v", err)
|
||||
}
|
||||
for _, manualComplaint := range manualComplaints {
|
||||
manualComplaintMap[manualComplaint.ComplaintId] = manualComplaint
|
||||
}
|
||||
}
|
||||
|
||||
// 构建列表项
|
||||
for _, complaint := range complaints {
|
||||
item := types.ComplaintListItem{
|
||||
Id: complaint.Id,
|
||||
Type: complaint.Type,
|
||||
OrderId: lzUtils.NullStringToString(complaint.OrderId),
|
||||
Name: lzUtils.NullStringToString(complaint.Name),
|
||||
Contact: lzUtils.NullStringToString(complaint.Contact),
|
||||
Content: lzUtils.NullStringToString(complaint.Content),
|
||||
Status: lzUtils.NullStringToString(complaint.Status),
|
||||
StatusDescription: lzUtils.NullStringToString(complaint.StatusDescription),
|
||||
Remark: lzUtils.NullStringToString(complaint.Remark),
|
||||
HandlerId: lzUtils.NullStringToString(complaint.HandlerId),
|
||||
CreateTime: complaint.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
UpdateTime: complaint.UpdateTime.Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
|
||||
if complaint.HandleTime.Valid {
|
||||
item.HandleTime = complaint.HandleTime.Time.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
// 填充支付宝投诉特有字段
|
||||
if complaint.Type == "alipay" {
|
||||
if alipayComplaint, ok := alipayComplaintMap[complaint.Id]; ok {
|
||||
item.TaskId = alipayComplaint.TaskId
|
||||
item.TradeNo = lzUtils.NullStringToString(alipayComplaint.TradeNo)
|
||||
if alipayComplaint.ComplainAmount.Valid {
|
||||
item.ComplainAmount = strconv.FormatFloat(alipayComplaint.ComplainAmount.Float64, 'f', -1, 64)
|
||||
}
|
||||
if alipayComplaint.GmtComplain.Valid {
|
||||
item.GmtComplain = alipayComplaint.GmtComplain.Time.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 填充主动投诉特有字段
|
||||
if complaint.Type == "manual" {
|
||||
if manualComplaint, ok := manualComplaintMap[complaint.Id]; ok {
|
||||
item.Subject = lzUtils.NullStringToString(manualComplaint.Subject)
|
||||
item.Priority = lzUtils.NullStringToString(manualComplaint.Priority)
|
||||
item.Source = lzUtils.NullStringToString(manualComplaint.Source)
|
||||
}
|
||||
}
|
||||
|
||||
resp.Items = append(resp.Items, item)
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package admin_complaint
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/lzUtils"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AdminUpdateComplaintRemarkLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAdminUpdateComplaintRemarkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminUpdateComplaintRemarkLogic {
|
||||
return &AdminUpdateComplaintRemarkLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdminUpdateComplaintRemarkLogic) AdminUpdateComplaintRemark(req *types.AdminUpdateComplaintRemarkReq) (resp *types.AdminUpdateComplaintRemarkResp, err error) {
|
||||
// 获取投诉主表信息
|
||||
complaint, err := l.svcCtx.ComplaintMainModel.FindOne(l.ctx, req.Id)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminUpdateComplaintRemark, 查询投诉失败 err: %v", err)
|
||||
}
|
||||
|
||||
// 更新备注
|
||||
complaint.Remark = lzUtils.StringToNullString(req.Remark)
|
||||
|
||||
// 更新数据库
|
||||
err = l.svcCtx.ComplaintMainModel.UpdateWithVersion(l.ctx, nil, complaint)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminUpdateComplaintRemark, 更新投诉备注失败 err: %v", err)
|
||||
}
|
||||
|
||||
return &types.AdminUpdateComplaintRemarkResp{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package admin_complaint
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/lzUtils"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AdminUpdateComplaintStatusLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAdminUpdateComplaintStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminUpdateComplaintStatusLogic {
|
||||
return &AdminUpdateComplaintStatusLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdminUpdateComplaintStatusLogic) AdminUpdateComplaintStatus(req *types.AdminUpdateComplaintStatusReq) (resp *types.AdminUpdateComplaintStatusResp, err error) {
|
||||
// 获取投诉主表信息
|
||||
complaint, err := l.svcCtx.ComplaintMainModel.FindOne(l.ctx, req.Id)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminUpdateComplaintStatus, 查询投诉失败 err: %v", err)
|
||||
}
|
||||
|
||||
// 更新状态
|
||||
complaint.Status = lzUtils.StringToNullString(req.Status)
|
||||
if req.StatusDescription != "" {
|
||||
complaint.StatusDescription = lzUtils.StringToNullString(req.StatusDescription)
|
||||
}
|
||||
if req.HandlerId != "" {
|
||||
complaint.HandlerId = lzUtils.StringToNullString(req.HandlerId)
|
||||
complaint.HandleTime = lzUtils.TimeToNullTime(time.Now())
|
||||
}
|
||||
|
||||
// 更新数据库
|
||||
err = l.svcCtx.ComplaintMainModel.UpdateWithVersion(l.ctx, nil, complaint)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminUpdateComplaintStatus, 更新投诉状态失败 err: %v", err)
|
||||
}
|
||||
|
||||
return &types.AdminUpdateComplaintStatusResp{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
@@ -0,0 +1,463 @@
|
||||
package admin_dashboard
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"ycc-server/app/main/api/internal/service"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AdminGetDashboardStatisticsLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAdminGetDashboardStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminGetDashboardStatisticsLogic {
|
||||
return &AdminGetDashboardStatisticsLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdminGetDashboardStatisticsLogic) AdminGetDashboardStatistics() (resp *types.AdminGetDashboardStatisticsResp, err error) {
|
||||
// 使用Asia/Shanghai时区
|
||||
loc, _ := time.LoadLocation("Asia/Shanghai")
|
||||
now := time.Now().In(loc)
|
||||
|
||||
// 计算时间范围
|
||||
todayStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, loc)
|
||||
todayEnd := todayStart.AddDate(0, 0, 1)
|
||||
yesterdayStart := todayStart.AddDate(0, 0, -1)
|
||||
yesterdayEnd := todayStart
|
||||
monthStart := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, loc)
|
||||
monthEnd := monthStart.AddDate(0, 1, 0)
|
||||
|
||||
// 1. 订单统计
|
||||
orderStats, err := l.calculateOrderStatistics(todayStart, todayEnd, yesterdayStart, yesterdayEnd, monthStart, monthEnd)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算订单统计失败, %v", err)
|
||||
}
|
||||
|
||||
// 2. 营收统计
|
||||
revenueStats, err := l.calculateRevenueStatistics(todayStart, todayEnd, yesterdayStart, yesterdayEnd, monthStart, monthEnd)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算营收统计失败, %v", err)
|
||||
}
|
||||
|
||||
// 3. 代理统计
|
||||
agentStats, err := l.calculateAgentStatistics(todayStart, monthStart)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算代理统计失败, %v", err)
|
||||
}
|
||||
|
||||
// 4. 利润统计
|
||||
profitStats, err := l.calculateProfitStatistics(todayStart, todayEnd, monthStart, monthEnd, revenueStats)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算利润统计失败, %v", err)
|
||||
}
|
||||
|
||||
// 5. 订单趋势(最近7天)
|
||||
orderTrend, err := l.calculateOrderTrend(now, loc)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算订单趋势失败, %v", err)
|
||||
}
|
||||
|
||||
// 6. 营收趋势(最近7天)
|
||||
revenueTrend, err := l.calculateRevenueTrend(now, loc)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算营收趋势失败, %v", err)
|
||||
}
|
||||
|
||||
return &types.AdminGetDashboardStatisticsResp{
|
||||
OrderStats: orderStats,
|
||||
RevenueStats: revenueStats,
|
||||
AgentStats: agentStats,
|
||||
ProfitStats: profitStats,
|
||||
OrderTrend: orderTrend,
|
||||
RevenueTrend: revenueTrend,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// calculateOrderStatistics 计算订单统计
|
||||
func (l *AdminGetDashboardStatisticsLogic) calculateOrderStatistics(todayStart, todayEnd, yesterdayStart, yesterdayEnd, monthStart, monthEnd time.Time) (types.AdminOrderStatistics, error) {
|
||||
var stats types.AdminOrderStatistics
|
||||
|
||||
// 今日订单数
|
||||
todayBuilder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", todayStart, todayEnd)
|
||||
todayCount, err := l.svcCtx.OrderModel.FindCount(l.ctx, todayBuilder, "id")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
stats.TodayCount = todayCount
|
||||
|
||||
// 昨日订单数
|
||||
yesterdayBuilder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", yesterdayStart, yesterdayEnd)
|
||||
yesterdayCount, err := l.svcCtx.OrderModel.FindCount(l.ctx, yesterdayBuilder, "id")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
stats.YesterdayCount = yesterdayCount
|
||||
|
||||
// 当月订单数
|
||||
monthBuilder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", monthStart, monthEnd)
|
||||
monthCount, err := l.svcCtx.OrderModel.FindCount(l.ctx, monthBuilder, "id")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
stats.MonthCount = monthCount
|
||||
|
||||
// 总订单数
|
||||
totalBuilder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where("status = ?", "paid")
|
||||
totalCount, err := l.svcCtx.OrderModel.FindCount(l.ctx, totalBuilder, "id")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
stats.TotalCount = totalCount
|
||||
|
||||
// 计算变化率
|
||||
if stats.YesterdayCount > 0 {
|
||||
stats.ChangeRate = float64(stats.TodayCount-stats.YesterdayCount) / float64(stats.YesterdayCount) * 100
|
||||
} else if stats.TodayCount > 0 {
|
||||
stats.ChangeRate = 100 // 从0增长到有值,算100%增长
|
||||
}
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
// calculateRevenueStatistics 计算营收统计
|
||||
func (l *AdminGetDashboardStatisticsLogic) calculateRevenueStatistics(todayStart, todayEnd, yesterdayStart, yesterdayEnd, monthStart, monthEnd time.Time) (types.AdminRevenueStatistics, error) {
|
||||
var stats types.AdminRevenueStatistics
|
||||
|
||||
// 今日营收
|
||||
todayBuilder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", todayStart, todayEnd)
|
||||
todayAmount, err := l.svcCtx.OrderModel.FindSum(l.ctx, todayBuilder, "amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
stats.TodayAmount = todayAmount
|
||||
|
||||
// 昨日营收
|
||||
yesterdayBuilder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", yesterdayStart, yesterdayEnd)
|
||||
yesterdayAmount, err := l.svcCtx.OrderModel.FindSum(l.ctx, yesterdayBuilder, "amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
stats.YesterdayAmount = yesterdayAmount
|
||||
|
||||
// 当月营收
|
||||
monthBuilder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", monthStart, monthEnd)
|
||||
monthAmount, err := l.svcCtx.OrderModel.FindSum(l.ctx, monthBuilder, "amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
stats.MonthAmount = monthAmount
|
||||
|
||||
// 总营收
|
||||
totalBuilder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where("status = ?", "paid")
|
||||
totalAmount, err := l.svcCtx.OrderModel.FindSum(l.ctx, totalBuilder, "amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
stats.TotalAmount = totalAmount
|
||||
|
||||
// 计算变化率
|
||||
if stats.YesterdayAmount > 0 {
|
||||
stats.ChangeRate = (stats.TodayAmount - stats.YesterdayAmount) / stats.YesterdayAmount * 100
|
||||
} else if stats.TodayAmount > 0 {
|
||||
stats.ChangeRate = 100 // 从0增长到有值,算100%增长
|
||||
}
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
// calculateAgentStatistics 计算代理统计
|
||||
func (l *AdminGetDashboardStatisticsLogic) calculateAgentStatistics(todayStart, monthStart time.Time) (types.AdminAgentStatistics, error) {
|
||||
var stats types.AdminAgentStatistics
|
||||
|
||||
// 代理总数
|
||||
totalBuilder := l.svcCtx.AgentModel.SelectBuilder()
|
||||
totalCount, err := l.svcCtx.AgentModel.FindCount(l.ctx, totalBuilder, "id")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
stats.TotalCount = totalCount
|
||||
|
||||
// 今日新增
|
||||
todayBuilder := l.svcCtx.AgentModel.SelectBuilder().
|
||||
Where("create_time >= ?", todayStart)
|
||||
todayNew, err := l.svcCtx.AgentModel.FindCount(l.ctx, todayBuilder, "id")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
stats.TodayNew = todayNew
|
||||
|
||||
// 当月新增
|
||||
monthBuilder := l.svcCtx.AgentModel.SelectBuilder().
|
||||
Where("create_time >= ?", monthStart)
|
||||
monthNew, err := l.svcCtx.AgentModel.FindCount(l.ctx, monthBuilder, "id")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
stats.MonthNew = monthNew
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
// calculateProfitStatistics 计算利润统计
|
||||
func (l *AdminGetDashboardStatisticsLogic) calculateProfitStatistics(todayStart, todayEnd, monthStart, monthEnd time.Time, revenueStats types.AdminRevenueStatistics) (types.AdminProfitStatistics, error) {
|
||||
var stats types.AdminProfitStatistics
|
||||
|
||||
// 税务成本比例(6%)
|
||||
const companyTaxRate = 0.06
|
||||
|
||||
// 今日利润计算
|
||||
// 今日营收
|
||||
todayRevenue := revenueStats.TodayAmount
|
||||
// 今日佣金
|
||||
todayCommissionBuilder := l.svcCtx.AgentCommissionModel.SelectBuilder().
|
||||
Where("del_state = ? AND status != ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 3, todayStart, todayEnd)
|
||||
todayCommission, err := l.svcCtx.AgentCommissionModel.FindSum(l.ctx, todayCommissionBuilder, "amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
// 今日返利
|
||||
todayRebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("del_state = ? AND status != ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 3, todayStart, todayEnd)
|
||||
todayRebate, err := l.svcCtx.AgentRebateModel.FindSum(l.ctx, todayRebateBuilder, "rebate_amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
// 今日税务成本(订单金额的6%)
|
||||
todayCompanyTax := todayRevenue * companyTaxRate
|
||||
// 今日提现收税(agent_withdrawal_tax表中tax_status=2的tax_amount总和)
|
||||
todayTaxIncomeBuilder := l.svcCtx.AgentWithdrawalTaxModel.SelectBuilder().
|
||||
Where("del_state = ? AND tax_status = ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 2, todayStart, todayEnd)
|
||||
todayTaxIncome, err := l.svcCtx.AgentWithdrawalTaxModel.FindSum(l.ctx, todayTaxIncomeBuilder, "tax_amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
// 今日API调用成本
|
||||
todayApiCost := 0.0
|
||||
if l.svcCtx.TianyuanapiCallLogService != nil {
|
||||
logx.Infof("开始获取今日API调用成本,时间范围: %v 到 %v", todayStart, todayEnd)
|
||||
todayApiStats, err := l.svcCtx.TianyuanapiCallLogService.GetStatistics(l.ctx, service.StatisticsFilter{
|
||||
StartDate: todayStart,
|
||||
EndDate: todayEnd,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Errorf("获取今日API调用成本失败: %v", err)
|
||||
} else {
|
||||
todayApiCost = todayApiStats.TotalCost
|
||||
logx.Infof("今日API调用成本统计完成,总成本: %f", todayApiCost)
|
||||
}
|
||||
} else {
|
||||
logx.Errorf("TianyuanapiCallLogService 未初始化,无法获取API调用成本")
|
||||
}
|
||||
// 今日利润 = 营收 - 佣金 - 返利 - 税务成本 - API调用成本 + 提现收税
|
||||
stats.TodayProfit = todayRevenue - todayCommission - todayRebate - todayCompanyTax - todayApiCost + todayTaxIncome
|
||||
if todayRevenue > 0 {
|
||||
stats.TodayProfitRate = stats.TodayProfit / todayRevenue * 100
|
||||
}
|
||||
// 今日明细
|
||||
stats.TodayDetail = types.AdminProfitDetail{
|
||||
Revenue: todayRevenue,
|
||||
Commission: todayCommission,
|
||||
Rebate: todayRebate,
|
||||
CompanyTax: todayCompanyTax,
|
||||
ApiCost: todayApiCost,
|
||||
TaxIncome: todayTaxIncome,
|
||||
Profit: stats.TodayProfit,
|
||||
ProfitRate: stats.TodayProfitRate,
|
||||
}
|
||||
|
||||
// 当月利润计算
|
||||
// 当月营收
|
||||
monthRevenue := revenueStats.MonthAmount
|
||||
// 当月佣金
|
||||
monthCommissionBuilder := l.svcCtx.AgentCommissionModel.SelectBuilder().
|
||||
Where("del_state = ? AND status != ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 3, monthStart, monthEnd)
|
||||
monthCommission, err := l.svcCtx.AgentCommissionModel.FindSum(l.ctx, monthCommissionBuilder, "amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
// 当月返利
|
||||
monthRebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("del_state = ? AND status != ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 3, monthStart, monthEnd)
|
||||
monthRebate, err := l.svcCtx.AgentRebateModel.FindSum(l.ctx, monthRebateBuilder, "rebate_amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
// 当月税务成本
|
||||
monthCompanyTax := monthRevenue * companyTaxRate
|
||||
// 当月提现收税
|
||||
monthTaxIncomeBuilder := l.svcCtx.AgentWithdrawalTaxModel.SelectBuilder().
|
||||
Where("del_state = ? AND tax_status = ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 2, monthStart, monthEnd)
|
||||
monthTaxIncome, err := l.svcCtx.AgentWithdrawalTaxModel.FindSum(l.ctx, monthTaxIncomeBuilder, "tax_amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
// 当月API调用成本
|
||||
monthApiCost := 0.0
|
||||
if l.svcCtx.TianyuanapiCallLogService != nil {
|
||||
logx.Infof("开始获取当月API调用成本,时间范围: %v 到 %v", monthStart, monthEnd)
|
||||
monthApiStats, err := l.svcCtx.TianyuanapiCallLogService.GetStatistics(l.ctx, service.StatisticsFilter{
|
||||
StartDate: monthStart,
|
||||
EndDate: monthEnd,
|
||||
})
|
||||
if err != nil {
|
||||
logx.Errorf("获取当月API调用成本失败: %v", err)
|
||||
} else {
|
||||
monthApiCost = monthApiStats.TotalCost
|
||||
logx.Infof("当月API调用成本统计完成,总成本: %f", monthApiCost)
|
||||
}
|
||||
} else {
|
||||
logx.Errorf("TianyuanapiCallLogService 未初始化,无法获取API调用成本")
|
||||
}
|
||||
// 当月利润
|
||||
stats.MonthProfit = monthRevenue - monthCommission - monthRebate - monthCompanyTax - monthApiCost + monthTaxIncome
|
||||
if monthRevenue > 0 {
|
||||
stats.MonthProfitRate = stats.MonthProfit / monthRevenue * 100
|
||||
}
|
||||
// 当月明细
|
||||
stats.MonthDetail = types.AdminProfitDetail{
|
||||
Revenue: monthRevenue,
|
||||
Commission: monthCommission,
|
||||
Rebate: monthRebate,
|
||||
CompanyTax: monthCompanyTax,
|
||||
ApiCost: monthApiCost,
|
||||
TaxIncome: monthTaxIncome,
|
||||
Profit: stats.MonthProfit,
|
||||
ProfitRate: stats.MonthProfitRate,
|
||||
}
|
||||
|
||||
// 总利润计算
|
||||
// 总营收
|
||||
totalRevenue := revenueStats.TotalAmount
|
||||
// 总佣金
|
||||
totalCommissionBuilder := l.svcCtx.AgentCommissionModel.SelectBuilder().
|
||||
Where("del_state = ? AND status != ?", globalkey.DelStateNo, 3)
|
||||
totalCommission, err := l.svcCtx.AgentCommissionModel.FindSum(l.ctx, totalCommissionBuilder, "amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
// 总返利
|
||||
totalRebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("status != ?", 3)
|
||||
totalRebate, err := l.svcCtx.AgentRebateModel.FindSum(l.ctx, totalRebateBuilder, "rebate_amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
// 总税务成本
|
||||
totalCompanyTax := totalRevenue * companyTaxRate
|
||||
// 总提现收税
|
||||
totalTaxIncomeBuilder := l.svcCtx.AgentWithdrawalTaxModel.SelectBuilder().
|
||||
Where("tax_status = ?", 2)
|
||||
totalTaxIncome, err := l.svcCtx.AgentWithdrawalTaxModel.FindSum(l.ctx, totalTaxIncomeBuilder, "tax_amount")
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
// 总API调用成本
|
||||
totalApiCost := 0.0
|
||||
if l.svcCtx.TianyuanapiCallLogService != nil {
|
||||
logx.Infof("开始获取总API调用成本(无时间限制)")
|
||||
totalApiStats, err := l.svcCtx.TianyuanapiCallLogService.GetStatistics(l.ctx, service.StatisticsFilter{})
|
||||
if err != nil {
|
||||
logx.Errorf("获取总API调用成本失败: %v", err)
|
||||
} else {
|
||||
totalApiCost = totalApiStats.TotalCost
|
||||
logx.Infof("总API调用成本统计完成,总成本: %f", totalApiCost)
|
||||
}
|
||||
} else {
|
||||
logx.Errorf("TianyuanapiCallLogService 未初始化,无法获取API调用成本")
|
||||
}
|
||||
// 总利润
|
||||
stats.TotalProfit = totalRevenue - totalCommission - totalRebate - totalCompanyTax - totalApiCost + totalTaxIncome
|
||||
if totalRevenue > 0 {
|
||||
stats.TotalProfitRate = stats.TotalProfit / totalRevenue * 100
|
||||
}
|
||||
// 总计明细
|
||||
stats.TotalDetail = types.AdminProfitDetail{
|
||||
Revenue: totalRevenue,
|
||||
Commission: totalCommission,
|
||||
Rebate: totalRebate,
|
||||
CompanyTax: totalCompanyTax,
|
||||
ApiCost: totalApiCost,
|
||||
TaxIncome: totalTaxIncome,
|
||||
Profit: stats.TotalProfit,
|
||||
ProfitRate: stats.TotalProfitRate,
|
||||
}
|
||||
|
||||
return stats, nil
|
||||
}
|
||||
|
||||
// calculateOrderTrend 计算订单趋势(最近7天)
|
||||
func (l *AdminGetDashboardStatisticsLogic) calculateOrderTrend(now time.Time, loc *time.Location) ([]types.AdminTrendData, error) {
|
||||
var trend []types.AdminTrendData
|
||||
|
||||
// 计算最近7天的日期
|
||||
for i := 6; i >= 0; i-- {
|
||||
date := now.AddDate(0, 0, -i)
|
||||
dateStart := time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, loc)
|
||||
dateEnd := dateStart.AddDate(0, 0, 1)
|
||||
|
||||
// 查询当天的订单数
|
||||
builder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", dateStart, dateEnd)
|
||||
count, err := l.svcCtx.OrderModel.FindCount(l.ctx, builder, "id")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
trend = append(trend, types.AdminTrendData{
|
||||
Date: date.Format("01-02"),
|
||||
Value: float64(count),
|
||||
})
|
||||
}
|
||||
|
||||
return trend, nil
|
||||
}
|
||||
|
||||
// calculateRevenueTrend 计算营收趋势(最近7天)
|
||||
func (l *AdminGetDashboardStatisticsLogic) calculateRevenueTrend(now time.Time, loc *time.Location) ([]types.AdminTrendData, error) {
|
||||
var trend []types.AdminTrendData
|
||||
|
||||
// 计算最近7天的日期
|
||||
for i := 6; i >= 0; i-- {
|
||||
date := now.AddDate(0, 0, -i)
|
||||
dateStart := time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, loc)
|
||||
dateEnd := dateStart.AddDate(0, 0, 1)
|
||||
|
||||
// 查询当天的营收
|
||||
builder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", dateStart, dateEnd)
|
||||
amount, err := l.svcCtx.OrderModel.FindSum(l.ctx, builder, "amount")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
trend = append(trend, types.AdminTrendData{
|
||||
Date: date.Format("01-02"),
|
||||
Value: amount,
|
||||
})
|
||||
}
|
||||
|
||||
return trend, nil
|
||||
}
|
||||
@@ -34,6 +34,14 @@ func (l *AdminCreateFeatureLogic) AdminCreateFeature(req *types.AdminCreateFeatu
|
||||
ApiId: req.ApiId,
|
||||
Name: req.Name,
|
||||
}
|
||||
// 设置白名单屏蔽价格
|
||||
if req.WhitelistPrice != nil {
|
||||
data.WhitelistPrice = *req.WhitelistPrice
|
||||
}
|
||||
// 设置成本价
|
||||
if req.CostPrice != nil {
|
||||
data.CostPrice = *req.CostPrice
|
||||
}
|
||||
|
||||
// 2. 数据库操作
|
||||
result, err := l.svcCtx.FeatureModel.Insert(l.ctx, nil, data)
|
||||
|
||||
@@ -38,6 +38,8 @@ func (l *AdminGetFeatureDetailLogic) AdminGetFeatureDetail(req *types.AdminGetFe
|
||||
Id: record.Id,
|
||||
ApiId: record.ApiId,
|
||||
Name: record.Name,
|
||||
WhitelistPrice: record.WhitelistPrice,
|
||||
CostPrice: record.CostPrice,
|
||||
CreateTime: record.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
UpdateTime: record.UpdateTime.Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ func (l *AdminGetFeatureListLogic) AdminGetFeatureList(req *types.AdminGetFeatur
|
||||
Id: item.Id,
|
||||
ApiId: item.ApiId,
|
||||
Name: item.Name,
|
||||
WhitelistPrice: item.WhitelistPrice,
|
||||
CostPrice: item.CostPrice,
|
||||
CreateTime: item.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
UpdateTime: item.UpdateTime.Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
|
||||
@@ -46,6 +46,12 @@ func (l *AdminUpdateFeatureLogic) AdminUpdateFeature(req *types.AdminUpdateFeatu
|
||||
if req.Name != nil && *req.Name != "" {
|
||||
record.Name = *req.Name
|
||||
}
|
||||
if req.WhitelistPrice != nil {
|
||||
record.WhitelistPrice = *req.WhitelistPrice
|
||||
}
|
||||
if req.CostPrice != nil {
|
||||
record.CostPrice = *req.CostPrice
|
||||
}
|
||||
|
||||
// 4. 执行更新操作
|
||||
err = l.svcCtx.FeatureModel.UpdateWithVersion(l.ctx, nil, record)
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -84,7 +83,6 @@ func (l *AdminGetOrderDetailLogic) AdminGetOrderDetail(req *types.AdminGetOrderD
|
||||
// 查询清理日志
|
||||
cleanupBuilder := l.svcCtx.QueryCleanupDetailModel.SelectBuilder().
|
||||
Where("order_id = ?", order.Id).
|
||||
Where("del_state = ?", globalkey.DelStateNo).
|
||||
OrderBy("create_time DESC").
|
||||
Limit(1)
|
||||
cleanupDetails, err := l.svcCtx.QueryCleanupDetailModel.FindAll(l.ctx, cleanupBuilder, "")
|
||||
|
||||
@@ -2,6 +2,8 @@ package admin_order
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
@@ -9,6 +11,7 @@ import (
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/crypto"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
@@ -73,6 +76,44 @@ func (l *AdminGetOrderListLogic) AdminGetOrderList(req *types.AdminGetOrderListR
|
||||
if req.RefundTimeEnd != "" {
|
||||
builder = builder.Where("refund_time <= ?", req.RefundTimeEnd)
|
||||
}
|
||||
if req.QuerySubjectName != "" || req.QuerySubjectMobile != "" || req.QuerySubjectIdCard != "" {
|
||||
key, decodeErr := hex.DecodeString(l.svcCtx.Config.Encrypt.SecretKey)
|
||||
if decodeErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR),
|
||||
"AdminGetOrderList, AES密钥解析失败 err: %v", decodeErr)
|
||||
}
|
||||
conds := []string{"del_state = ?"}
|
||||
args := []interface{}{globalkey.DelStateNo}
|
||||
if req.QuerySubjectName != "" {
|
||||
enc, _, encErr := crypto.EncryptDeterministicOptional(req.QuerySubjectName, key)
|
||||
if encErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR),
|
||||
"AdminGetOrderList, 加密筛选姓名失败 err: %v", encErr)
|
||||
}
|
||||
conds = append(conds, "enc_real_name = ?")
|
||||
args = append(args, enc)
|
||||
}
|
||||
if req.QuerySubjectMobile != "" {
|
||||
enc, encErr := crypto.EncryptMobile(req.QuerySubjectMobile, l.svcCtx.Config.Encrypt.SecretKey)
|
||||
if encErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR),
|
||||
"AdminGetOrderList, 加密筛选手机号失败 err: %v", encErr)
|
||||
}
|
||||
conds = append(conds, "enc_mobile = ?")
|
||||
args = append(args, enc)
|
||||
}
|
||||
if req.QuerySubjectIdCard != "" {
|
||||
enc, encErr := crypto.EncryptIDCard(req.QuerySubjectIdCard, key)
|
||||
if encErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR),
|
||||
"AdminGetOrderList, 加密筛选身份证失败 err: %v", encErr)
|
||||
}
|
||||
conds = append(conds, "enc_id_card = ?")
|
||||
args = append(args, enc)
|
||||
}
|
||||
subSQL := "id IN (SELECT order_id FROM query_subject_index WHERE " + strings.Join(conds, " AND ") + ")"
|
||||
builder = builder.Where(subSQL, args...)
|
||||
}
|
||||
|
||||
// 并发获取总数和列表
|
||||
var total int64
|
||||
@@ -86,7 +127,7 @@ func (l *AdminGetOrderListLogic) AdminGetOrderList(req *types.AdminGetOrderListR
|
||||
return nil
|
||||
}, func() error {
|
||||
var err error
|
||||
orders, err = l.svcCtx.OrderModel.FindPageListByPage(l.ctx, builder, req.Page, req.PageSize, "id DESC")
|
||||
orders, err = l.svcCtx.OrderModel.FindPageListByPage(l.ctx, builder, req.Page, req.PageSize, "create_time DESC")
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "AdminGetOrderList, 查询订单列表失败 err: %v", err)
|
||||
}
|
||||
@@ -139,7 +180,6 @@ func (l *AdminGetOrderListLogic) AdminGetOrderList(req *types.AdminGetOrderListR
|
||||
// 查询清理日志
|
||||
cleanupBuilder := l.svcCtx.QueryCleanupDetailModel.SelectBuilder().
|
||||
Where(squirrel.Eq{"order_id": notFoundOrderIds}).
|
||||
Where("del_state = ?", globalkey.DelStateNo).
|
||||
OrderBy("create_time DESC")
|
||||
cleanupDetails, err := l.svcCtx.QueryCleanupDetailModel.FindAll(l.ctx, cleanupBuilder, "")
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
|
||||
@@ -11,15 +11,18 @@ import (
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/smartwalle/alipay/v3"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
PaymentPlatformAlipay = "alipay"
|
||||
PaymentPlatformWechat = "wechat"
|
||||
PaymentPlatformTest = "test"
|
||||
PaymentPlatformTestEmpty = "test_empty"
|
||||
OrderStatusPaid = "paid"
|
||||
RefundNoPrefix = "refund-"
|
||||
)
|
||||
@@ -44,6 +47,11 @@ func (l *AdminRefundOrderLogic) AdminRefundOrder(req *types.AdminRefundOrderReq)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 检查是否为测试支付平台(test 或 test_empty),如果是则模拟退款成功
|
||||
if order.PaymentPlatform == PaymentPlatformTest || order.PaymentPlatform == PaymentPlatformTestEmpty {
|
||||
return l.handleTestRefund(order, req)
|
||||
}
|
||||
|
||||
// 根据支付平台处理退款
|
||||
switch order.PaymentPlatform {
|
||||
case PaymentPlatformAlipay:
|
||||
@@ -75,17 +83,47 @@ func (l *AdminRefundOrderLogic) getAndValidateOrder(orderId string, refundAmount
|
||||
return order, nil
|
||||
}
|
||||
|
||||
// handleTestRefund 处理测试支付平台退款(模拟退款成功)
|
||||
func (l *AdminRefundOrderLogic) handleTestRefund(order *model.Order, req *types.AdminRefundOrderReq) (*types.AdminRefundOrderResp, error) {
|
||||
refundNo := l.generateRefundNo(order.OrderNo)
|
||||
// 创建模拟的平台退款ID
|
||||
platformRefundId := fmt.Sprintf("MOCK_REFUND_%s_%d", order.OrderNo, time.Now().Unix())
|
||||
|
||||
logx.Infof("测试支付平台模拟退款:订单 %s,退款金额 %.2f,跳过实际退款接口调用", order.OrderNo, req.RefundAmount)
|
||||
|
||||
// 直接标记为退款成功
|
||||
err := l.createRefundRecordAndUpdateOrder(order, req, refundNo, platformRefundId, model.OrderStatusRefunded, model.OrderRefundStatusSuccess)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.AdminRefundOrderResp{
|
||||
Status: model.OrderStatusRefunded,
|
||||
RefundNo: refundNo,
|
||||
Amount: req.RefundAmount,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// handleAlipayRefund 处理支付宝退款
|
||||
func (l *AdminRefundOrderLogic) handleAlipayRefund(order *model.Order, req *types.AdminRefundOrderReq) (*types.AdminRefundOrderResp, error) {
|
||||
refundNo := l.generateRefundNo(order.OrderNo)
|
||||
|
||||
// 调用支付宝退款接口
|
||||
var refundResp *alipay.TradeRefundRsp
|
||||
refundResp, err := l.svcCtx.AlipayService.AliRefund(l.ctx, order.OrderNo, req.RefundAmount)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "AdminRefundOrder, 支付宝退款失败 err: %v", err)
|
||||
}
|
||||
|
||||
refundNo := l.generateRefundNo(order.OrderNo)
|
||||
if !refundResp.IsSuccess() {
|
||||
// 支付宝退款失败,创建失败记录但不更新订单状态
|
||||
err = l.createRefundRecordOnly(order, req, refundNo, refundResp.TradeNo, model.OrderRefundStatusFailed)
|
||||
if err != nil {
|
||||
logx.Errorf("创建退款失败记录时出错: %v", err)
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg(fmt.Sprintf("退款失败: %v", refundResp.Msg)), "AdminRefundOrder, 支付宝退款失败")
|
||||
}
|
||||
|
||||
if refundResp.IsSuccess() {
|
||||
// 支付宝退款成功,创建成功记录
|
||||
err = l.createRefundRecordAndUpdateOrder(order, req, refundNo, refundResp.TradeNo, model.OrderStatusRefunded, model.OrderRefundStatusSuccess)
|
||||
if err != nil {
|
||||
@@ -97,18 +135,12 @@ func (l *AdminRefundOrderLogic) handleAlipayRefund(order *model.Order, req *type
|
||||
RefundNo: refundNo,
|
||||
Amount: req.RefundAmount,
|
||||
}, nil
|
||||
} else {
|
||||
// 支付宝退款失败,创建失败记录但不更新订单状态
|
||||
err = l.createRefundRecordOnly(order, req, refundNo, refundResp.TradeNo, model.OrderRefundStatusFailed)
|
||||
if err != nil {
|
||||
logx.Errorf("创建退款失败记录时出错: %v", err)
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg(fmt.Sprintf("退款失败: %v", refundResp.Msg)), "AdminRefundOrder, 支付宝退款失败")
|
||||
}
|
||||
}
|
||||
|
||||
// handleWechatRefund 处理微信退款
|
||||
func (l *AdminRefundOrderLogic) handleWechatRefund(order *model.Order, req *types.AdminRefundOrderReq) (*types.AdminRefundOrderResp, error) {
|
||||
refundNo := l.generateRefundNo(order.OrderNo)
|
||||
|
||||
// 调用微信退款接口
|
||||
err := l.svcCtx.WechatPayService.WeChatRefund(l.ctx, order.OrderNo, req.RefundAmount, order.Amount)
|
||||
if err != nil {
|
||||
@@ -116,7 +148,6 @@ func (l *AdminRefundOrderLogic) handleWechatRefund(order *model.Order, req *type
|
||||
}
|
||||
|
||||
// 微信退款是异步的,创建pending状态的退款记录
|
||||
refundNo := l.generateRefundNo(order.OrderNo)
|
||||
err = l.createRefundRecordAndUpdateOrder(order, req, refundNo, "", model.OrderStatusRefunding, model.OrderRefundStatusPending)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -131,7 +162,7 @@ func (l *AdminRefundOrderLogic) handleWechatRefund(order *model.Order, req *type
|
||||
|
||||
// createRefundRecordAndUpdateOrder 创建退款记录并更新订单状态
|
||||
func (l *AdminRefundOrderLogic) createRefundRecordAndUpdateOrder(order *model.Order, req *types.AdminRefundOrderReq, refundNo, platformRefundId, orderStatus, refundStatus string) error {
|
||||
return l.svcCtx.OrderModel.Trans(l.ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||
err := l.svcCtx.OrderModel.Trans(l.ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||
// 创建退款记录
|
||||
refund := &model.OrderRefund{
|
||||
Id: uuid.NewString(),
|
||||
@@ -158,6 +189,27 @@ func (l *AdminRefundOrderLogic) createRefundRecordAndUpdateOrder(order *model.Or
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 退款成功后,检查并处理代理订单(在事务外执行,避免影响退款流程)
|
||||
if refundStatus == model.OrderRefundStatusSuccess {
|
||||
// 检查代理订单是否已处理
|
||||
agentOrder, err := l.svcCtx.AgentOrderModel.FindOneByOrderId(l.ctx, order.Id)
|
||||
if err == nil && agentOrder != nil && agentOrder.ProcessStatus == 1 {
|
||||
// 代理订单已处理,需要撤销收益
|
||||
if cancelErr := l.svcCtx.AgentService.CancelAgentCommission(l.ctx, order.Id); cancelErr != nil {
|
||||
logx.Errorf("撤销代理收益失败,订单ID: %s, 错误: %v", order.Id, cancelErr)
|
||||
// 不阻断退款流程,只记录日志(退款已成功,不能回滚)
|
||||
} else {
|
||||
logx.Infof("成功撤销代理收益,订单ID: %s", order.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// createRefundRecordOnly 仅创建退款记录,不更新订单状态(用于退款失败的情况)
|
||||
|
||||
@@ -36,7 +36,6 @@ func (l *AdminCreateProductLogic) AdminCreateProduct(req *types.AdminCreateProdu
|
||||
ProductEn: req.ProductEn,
|
||||
Description: req.Description,
|
||||
Notes: sql.NullString{String: req.Notes, Valid: req.Notes != ""},
|
||||
CostPrice: req.CostPrice,
|
||||
SellPrice: req.SellPrice,
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ func (l *AdminGetProductDetailLogic) AdminGetProductDetail(req *types.AdminGetPr
|
||||
ProductEn: record.ProductEn,
|
||||
Description: record.Description,
|
||||
Notes: record.Notes.String,
|
||||
CostPrice: record.CostPrice,
|
||||
SellPrice: record.SellPrice,
|
||||
CreateTime: record.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
UpdateTime: record.UpdateTime.Format("2006-01-02 15:04:05"),
|
||||
|
||||
@@ -2,12 +2,13 @@ package admin_product
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AdminGetProductListLogic struct {
|
||||
@@ -25,43 +26,121 @@ func NewAdminGetProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func (l *AdminGetProductListLogic) AdminGetProductList(req *types.AdminGetProductListReq) (resp *types.AdminGetProductListResp, err error) {
|
||||
// 1. 构建查询条件
|
||||
builder := l.svcCtx.ProductModel.SelectBuilder()
|
||||
// 1. 构建产品查询条件
|
||||
productBuilder := l.svcCtx.ProductModel.SelectBuilder()
|
||||
|
||||
// 2. 添加查询条件
|
||||
if req.ProductName != nil && *req.ProductName != "" {
|
||||
builder = builder.Where("product_name LIKE ?", "%"+*req.ProductName+"%")
|
||||
productBuilder = productBuilder.Where("product_name LIKE ?", "%"+*req.ProductName+"%")
|
||||
}
|
||||
if req.ProductEn != nil && *req.ProductEn != "" {
|
||||
builder = builder.Where("product_en LIKE ?", "%"+*req.ProductEn+"%")
|
||||
productBuilder = productBuilder.Where("product_en LIKE ?", "%"+*req.ProductEn+"%")
|
||||
}
|
||||
|
||||
// 3. 执行分页查询
|
||||
list, total, err := l.svcCtx.ProductModel.FindPageListByPageWithTotal(
|
||||
l.ctx, builder, req.Page, req.PageSize, "id DESC")
|
||||
// 3. 执行产品分页查询
|
||||
productList, total, err := l.svcCtx.ProductModel.FindPageListByPageWithTotal(
|
||||
l.ctx, productBuilder, req.Page, req.PageSize, "id DESC")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR),
|
||||
"查询产品列表失败, err: %v, req: %+v", err, req)
|
||||
}
|
||||
|
||||
// 4. 构建响应列表
|
||||
items := make([]types.ProductListItem, 0, len(list))
|
||||
for _, item := range list {
|
||||
if len(productList) == 0 {
|
||||
return &types.AdminGetProductListResp{
|
||||
Total: total,
|
||||
Items: []types.ProductListItem{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 4. 统计每个产品关联功能的成本价之和
|
||||
// 4.1 收集产品ID列表
|
||||
productIdList := make([]string, 0, len(productList))
|
||||
for _, p := range productList {
|
||||
productIdList = append(productIdList, p.Id)
|
||||
}
|
||||
|
||||
// 4.2 查询 product_feature 记录
|
||||
productFeatureBuilder := l.svcCtx.ProductFeatureModel.SelectBuilder().
|
||||
Where(squirrel.Eq{"product_id": productIdList})
|
||||
productFeatureList, err := l.svcCtx.ProductFeatureModel.FindAll(l.ctx, productFeatureBuilder, "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR),
|
||||
"查询产品功能关联失败, err: %v, productIds: %+v", err, productIdList)
|
||||
}
|
||||
|
||||
// 4.3 没有关联功能时直接返回
|
||||
if len(productFeatureList) == 0 {
|
||||
items := make([]types.ProductListItem, 0, len(productList))
|
||||
for _, item := range productList {
|
||||
listItem := types.ProductListItem{
|
||||
Id: item.Id,
|
||||
ProductName: item.ProductName,
|
||||
ProductEn: item.ProductEn,
|
||||
Description: item.Description,
|
||||
Notes: item.Notes.String,
|
||||
CostPrice: item.CostPrice,
|
||||
SellPrice: item.SellPrice,
|
||||
CostPrice: 0,
|
||||
CreateTime: item.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
UpdateTime: item.UpdateTime.Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
items = append(items, listItem)
|
||||
}
|
||||
|
||||
// 5. 返回结果
|
||||
return &types.AdminGetProductListResp{
|
||||
Total: total,
|
||||
Items: items,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 4.4 收集 featureId 列表
|
||||
featureIdList := make([]string, 0, len(productFeatureList))
|
||||
for _, pf := range productFeatureList {
|
||||
featureIdList = append(featureIdList, pf.FeatureId)
|
||||
}
|
||||
|
||||
// 4.5 查询功能表,取出每个功能的成本价
|
||||
featureBuilder := l.svcCtx.FeatureModel.SelectBuilder().
|
||||
Where(squirrel.Eq{"id": featureIdList})
|
||||
featureList, err := l.svcCtx.FeatureModel.FindAll(l.ctx, featureBuilder, "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR),
|
||||
"查询功能成本价失败, err: %v, featureIds: %+v", err, featureIdList)
|
||||
}
|
||||
|
||||
// 4.6 构建 featureId -> cost_price 映射
|
||||
featureCostMap := make(map[string]float64, len(featureList))
|
||||
for _, f := range featureList {
|
||||
featureCostMap[f.Id] = f.CostPrice
|
||||
}
|
||||
|
||||
// 4.7 计算每个产品的成本价(所有关联 feature 的 cost_price 之和)
|
||||
productCostMap := make(map[string]float64, len(productList))
|
||||
for _, pf := range productFeatureList {
|
||||
cost, ok := featureCostMap[pf.FeatureId]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
productCostMap[pf.ProductId] += cost
|
||||
}
|
||||
|
||||
// 5. 构建响应列表
|
||||
items := make([]types.ProductListItem, 0, len(productList))
|
||||
for _, item := range productList {
|
||||
listItem := types.ProductListItem{
|
||||
Id: item.Id,
|
||||
ProductName: item.ProductName,
|
||||
ProductEn: item.ProductEn,
|
||||
Description: item.Description,
|
||||
Notes: item.Notes.String,
|
||||
SellPrice: item.SellPrice,
|
||||
CostPrice: productCostMap[item.Id],
|
||||
CreateTime: item.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
UpdateTime: item.UpdateTime.Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
items = append(items, listItem)
|
||||
}
|
||||
|
||||
// 6. 返回结果
|
||||
return &types.AdminGetProductListResp{
|
||||
Total: total,
|
||||
Items: items,
|
||||
|
||||
@@ -47,9 +47,6 @@ func (l *AdminUpdateProductLogic) AdminUpdateProduct(req *types.AdminUpdateProdu
|
||||
if req.Notes != nil {
|
||||
record.Notes = sql.NullString{String: *req.Notes, Valid: *req.Notes != ""}
|
||||
}
|
||||
if req.CostPrice != nil {
|
||||
record.CostPrice = *req.CostPrice
|
||||
}
|
||||
if req.SellPrice != nil {
|
||||
record.SellPrice = *req.SellPrice
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package admin_query
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
type AdminDeleteQueryFeatureDataLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAdminDeleteQueryFeatureDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminDeleteQueryFeatureDataLogic {
|
||||
return &AdminDeleteQueryFeatureDataLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdminDeleteQueryFeatureDataLogic) AdminDeleteQueryFeatureData(req *types.AdminDeleteQueryFeatureDataReq) (resp *types.AdminDeleteQueryFeatureDataResp, err error) {
|
||||
// 基本参数校验
|
||||
if req.QueryId == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("QueryId 不能为空"), "")
|
||||
}
|
||||
if req.FeatureApiId == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("feature_api_id 不能为空"), "")
|
||||
}
|
||||
|
||||
// 使用事务调用 WhitelistService.DeleteFeatureFromQueryData,保持与其它删除逻辑一致
|
||||
err = l.svcCtx.QueryModel.Trans(l.ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||
return l.svcCtx.WhitelistService.DeleteFeatureFromQueryData(ctx, session, req.QueryId, req.FeatureApiId)
|
||||
})
|
||||
if err != nil {
|
||||
l.Errorf("Admin 删除查询模块数据失败, queryId=%s, featureApiId=%s, err=%+v", req.QueryId, req.FeatureApiId, err)
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("删除失败,请稍后重试"), "")
|
||||
}
|
||||
|
||||
return &types.AdminDeleteQueryFeatureDataResp{
|
||||
Success: true,
|
||||
Message: "删除成功(如果原本不存在该模块数据,则视为已删除)",
|
||||
}, nil
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -27,8 +26,7 @@ func NewAdminGetQueryCleanupConfigListLogic(ctx context.Context, svcCtx *svc.Ser
|
||||
|
||||
func (l *AdminGetQueryCleanupConfigListLogic) AdminGetQueryCleanupConfigList(req *types.AdminGetQueryCleanupConfigListReq) (resp *types.AdminGetQueryCleanupConfigListResp, err error) {
|
||||
// 构建查询条件
|
||||
builder := l.svcCtx.QueryCleanupConfigModel.SelectBuilder().
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
builder := l.svcCtx.QueryCleanupConfigModel.SelectBuilder()
|
||||
|
||||
if req.Status > 0 {
|
||||
builder = builder.Where("status = ?", req.Status)
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -40,8 +39,7 @@ func (l *AdminGetQueryCleanupDetailListLogic) AdminGetQueryCleanupDetailList(req
|
||||
|
||||
// 2. 构建查询条件
|
||||
builder := l.svcCtx.QueryCleanupDetailModel.SelectBuilder().
|
||||
Where("cleanup_log_id = ?", req.LogId).
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
Where("cleanup_log_id = ?", req.LogId)
|
||||
|
||||
// 3. 并发获取总数和列表
|
||||
var total int64
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -29,8 +28,7 @@ func NewAdminGetQueryCleanupLogListLogic(ctx context.Context, svcCtx *svc.Servic
|
||||
|
||||
func (l *AdminGetQueryCleanupLogListLogic) AdminGetQueryCleanupLogList(req *types.AdminGetQueryCleanupLogListReq) (resp *types.AdminGetQueryCleanupLogListResp, err error) {
|
||||
// 构建查询条件
|
||||
builder := l.svcCtx.QueryCleanupLogModel.SelectBuilder().
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
builder := l.svcCtx.QueryCleanupLogModel.SelectBuilder()
|
||||
|
||||
if req.Status > 0 {
|
||||
builder = builder.Where("status = ?", req.Status)
|
||||
|
||||
@@ -72,6 +72,36 @@ func (l *AdminGetQueryDetailByOrderIdLogic) AdminGetQueryDetailByOrderId(req *ty
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 获取商品信息失败, %v", err)
|
||||
}
|
||||
query.ProductName = product.ProductName
|
||||
|
||||
// 查询代理订单信息,判断是否是代理单
|
||||
var agentUserName string
|
||||
var agentUserMobile string
|
||||
agentOrder, err := l.svcCtx.AgentOrderModel.FindOneByOrderId(l.ctx, queryModel.OrderId)
|
||||
if err == nil && agentOrder != nil {
|
||||
// 是代理单,查询代理实名信息获取姓名和手机号
|
||||
realNameInfo, realNameErr := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agentOrder.AgentId)
|
||||
if realNameErr == nil && realNameInfo != nil {
|
||||
agentUserName = realNameInfo.Name
|
||||
// 解密实名认证中的手机号(ECB加密,使用 DecryptMobile)
|
||||
if realNameInfo.Mobile != "" {
|
||||
decryptedMobile, decryptErr := crypto.DecryptMobile(realNameInfo.Mobile, l.svcCtx.Config.Encrypt.SecretKey)
|
||||
if decryptErr == nil {
|
||||
agentUserMobile = decryptedMobile
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果实名认证中没有手机号,回退到Agent表获取
|
||||
if agentUserMobile == "" {
|
||||
agentInfo, agentErr := l.svcCtx.AgentModel.FindOne(l.ctx, agentOrder.AgentId)
|
||||
if agentErr == nil && agentInfo != nil {
|
||||
decryptedMobile, decryptErr := crypto.DecryptMobile(agentInfo.Mobile, l.svcCtx.Config.Encrypt.SecretKey)
|
||||
if decryptErr == nil {
|
||||
agentUserMobile = decryptedMobile
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &types.AdminGetQueryDetailByOrderIdResp{
|
||||
Id: query.Id,
|
||||
OrderId: query.OrderId,
|
||||
@@ -82,6 +112,8 @@ func (l *AdminGetQueryDetailByOrderIdLogic) AdminGetQueryDetailByOrderId(req *ty
|
||||
CreateTime: query.CreateTime,
|
||||
UpdateTime: query.UpdateTime,
|
||||
QueryState: query.QueryState,
|
||||
AgentUserName: agentUserName,
|
||||
AgentUserMobile: agentUserMobile,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -105,13 +105,14 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type
|
||||
userID = user.Id
|
||||
}
|
||||
|
||||
// 3. 检查是否已是代理
|
||||
// 3. 检查是否已是代理(H5 已注册过代理时,小程序绑定手机后视为自动登录,此处直接返回成功)
|
||||
existingAgent, err := l.svcCtx.AgentModel.FindOneByUserId(transCtx, userID)
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理信息失败, %v", err)
|
||||
}
|
||||
if existingAgent != nil {
|
||||
return errors.Wrapf(xerr.NewErrMsg("您已经是代理"), "")
|
||||
// 已是代理(如 H5 已注册):不报错,事务外会统一发放 token 并返回成功,视为自动登录
|
||||
return nil
|
||||
}
|
||||
|
||||
var inviteCodeModel *model.AgentInviteCode
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/ctxdata"
|
||||
"ycc-server/common/globalkey"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/lzUtils"
|
||||
|
||||
@@ -62,53 +61,138 @@ func (l *ApplyWithdrawalLogic) ApplyWithdrawal(req *types.ApplyWithdrawalReq) (r
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("请先完成实名认证"), "")
|
||||
}
|
||||
|
||||
// 3. 验证提现金额
|
||||
// 3. 验证提现方式
|
||||
if req.WithdrawalType != 1 && req.WithdrawalType != 2 {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("提现方式无效"), "")
|
||||
}
|
||||
|
||||
// 4. 验证提现信息
|
||||
if req.WithdrawalType == 1 {
|
||||
// 支付宝提现:验证支付宝账号和姓名
|
||||
if req.PayeeAccount == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("请输入支付宝账号"), "")
|
||||
}
|
||||
if req.PayeeName == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("请输入收款人姓名"), "")
|
||||
}
|
||||
} else if req.WithdrawalType == 2 {
|
||||
// 银行卡提现:验证银行卡号、开户行和姓名
|
||||
if req.BankCardNo == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("请输入银行卡号"), "")
|
||||
}
|
||||
if req.BankName == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("请输入开户行名称"), "")
|
||||
}
|
||||
if req.PayeeName == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("请输入收款人姓名"), "")
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 验证提现金额
|
||||
if req.Amount <= 0 {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("提现金额必须大于0"), "")
|
||||
}
|
||||
|
||||
// 4. 获取钱包信息
|
||||
// 6. 获取钱包信息
|
||||
wallet, err := l.svcCtx.AgentWalletModel.FindOneByAgentId(l.ctx, agent.Id)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询钱包失败, %v", err)
|
||||
}
|
||||
|
||||
// 5. 验证余额
|
||||
// 7. 验证余额(包括检查是否为负数)
|
||||
if wallet.Balance < 0 {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg(fmt.Sprintf("账户存在欠款,请先补足欠款后再申请提现,当前余额:%.2f", wallet.Balance)), "")
|
||||
}
|
||||
if wallet.Balance < req.Amount {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg(fmt.Sprintf("余额不足,当前余额:%.2f", wallet.Balance)), "")
|
||||
}
|
||||
|
||||
// 6. 计算税费
|
||||
// 8. 支付宝月度提现额度校验(仅针对支付宝提现)
|
||||
if req.WithdrawalType == 1 {
|
||||
now := time.Now()
|
||||
monthStart := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
|
||||
nextMonthStart := monthStart.AddDate(0, 1, 0)
|
||||
|
||||
// 8.1 获取支付宝月度额度配置(默认 800 元)
|
||||
alipayQuota := 800.0
|
||||
if cfg, cfgErr := l.svcCtx.AgentConfigModel.FindOneByConfigKey(l.ctx, "alipay_month_quota"); cfgErr == nil {
|
||||
if parsed, parseErr := l.parseFloat(cfg.ConfigValue); parseErr == nil && parsed > 0 {
|
||||
alipayQuota = parsed
|
||||
}
|
||||
}
|
||||
|
||||
// 8.2 统计本月已申请/成功的支付宝提现金额(status IN (1,5)),避免多次申请占用超额
|
||||
withdrawBuilder := l.svcCtx.AgentWithdrawalModel.SelectBuilder().
|
||||
Where("agent_id = ? AND withdrawal_type = ? AND status IN (1,5) AND create_time >= ? AND create_time < ?",
|
||||
agent.Id, 1, monthStart, nextMonthStart)
|
||||
usedAmount, sumErr := l.svcCtx.AgentWithdrawalModel.FindSum(l.ctx, withdrawBuilder, "amount")
|
||||
if sumErr != nil {
|
||||
return nil, errors.Wrapf(sumErr, "查询本月支付宝提现额度使用情况失败")
|
||||
}
|
||||
|
||||
remainQuota := alipayQuota - usedAmount
|
||||
if remainQuota <= 0 {
|
||||
return nil, errors.Wrapf(
|
||||
xerr.NewErrMsg(fmt.Sprintf("本月支付宝提现额度已用完(额度:%.2f 元),请使用银行卡提现", alipayQuota)),
|
||||
"",
|
||||
)
|
||||
}
|
||||
|
||||
if req.Amount > remainQuota {
|
||||
return nil, errors.Wrapf(
|
||||
xerr.NewErrMsg(fmt.Sprintf("本月支付宝最高可提现 %.2f 元,请调整提现金额或使用银行卡提现", remainQuota)),
|
||||
"",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 9. 计算税费
|
||||
yearMonth := int64(time.Now().Year()*100 + int(time.Now().Month()))
|
||||
taxInfo, err := l.calculateTax(l.ctx, agent.Id, req.Amount, yearMonth)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "计算税费失败")
|
||||
}
|
||||
|
||||
// 7. 生成提现单号
|
||||
withdrawNo := fmt.Sprintf("WD%d%d", time.Now().Unix(), agent.Id)
|
||||
// 10. 生成提现单号(WD开头 + GenerateOutTradeNo生成的订单号,确保总长度不超过32个字符)
|
||||
orderNo := l.svcCtx.AlipayService.GenerateOutTradeNo()
|
||||
withdrawNo := "WD" + orderNo
|
||||
// 确保总长度不超过32个字符
|
||||
if len(withdrawNo) > 32 {
|
||||
withdrawNo = withdrawNo[:32]
|
||||
}
|
||||
|
||||
// 8. 使用事务处理提现申请
|
||||
// 11. 使用事务处理提现申请
|
||||
var withdrawalId string
|
||||
err = l.svcCtx.AgentWalletModel.Trans(l.ctx, func(transCtx context.Context, session sqlx.Session) error {
|
||||
// 8.1 冻结余额
|
||||
// 11.1 冻结余额
|
||||
wallet.FrozenBalance += req.Amount
|
||||
wallet.Balance -= req.Amount
|
||||
if err := l.svcCtx.AgentWalletModel.UpdateWithVersion(transCtx, session, wallet); err != nil {
|
||||
return errors.Wrapf(err, "冻结余额失败")
|
||||
}
|
||||
|
||||
// 8.2 创建提现记录
|
||||
// 11.2 创建提现记录
|
||||
withdrawal := &model.AgentWithdrawal{
|
||||
Id: uuid.New().String(),
|
||||
AgentId: agent.Id,
|
||||
WithdrawNo: withdrawNo,
|
||||
WithdrawalType: req.WithdrawalType,
|
||||
PayeeAccount: req.PayeeAccount,
|
||||
PayeeName: req.PayeeName,
|
||||
Amount: req.Amount,
|
||||
ActualAmount: taxInfo.ActualAmount,
|
||||
TaxAmount: taxInfo.TaxAmount,
|
||||
Status: 1, // 处理中(待审核)
|
||||
Status: 1, // 待审核
|
||||
}
|
||||
|
||||
// 如果是银行卡提现,设置银行卡相关字段
|
||||
if req.WithdrawalType == 2 {
|
||||
withdrawal.BankCardNo = lzUtils.StringToNullString(req.BankCardNo)
|
||||
withdrawal.BankName = lzUtils.StringToNullString(req.BankName)
|
||||
// 银行卡提现时,payee_account 可以存储银行卡号(便于查询),也可以留空
|
||||
if req.PayeeAccount == "" {
|
||||
withdrawal.PayeeAccount = req.BankCardNo
|
||||
}
|
||||
}
|
||||
|
||||
_, err := l.svcCtx.AgentWithdrawalModel.Insert(transCtx, session, withdrawal)
|
||||
@@ -117,7 +201,7 @@ func (l *ApplyWithdrawalLogic) ApplyWithdrawal(req *types.ApplyWithdrawalReq) (r
|
||||
}
|
||||
withdrawalId = withdrawal.Id
|
||||
|
||||
// 8.3 创建扣税记录
|
||||
// 11.3 创建扣税记录
|
||||
taxRecord := &model.AgentWithdrawalTax{
|
||||
AgentId: agent.Id,
|
||||
WithdrawalId: withdrawalId,
|
||||
@@ -167,8 +251,10 @@ func (l *ApplyWithdrawalLogic) calculateTax(ctx context.Context, agentId string,
|
||||
}
|
||||
|
||||
// 查询本月已提现金额
|
||||
// 注意:FindAll 方法会自动添加 del_state = ? 条件,所以这里不需要手动添加
|
||||
// 这里对 year_month 使用反引号包裹,避免与某些数据库版本/SQL 模式下的关键字冲突
|
||||
builder := l.svcCtx.AgentWithdrawalTaxModel.SelectBuilder().
|
||||
Where("agent_id = ? AND year_month = ? AND del_state = ?", agentId, yearMonth, globalkey.DelStateNo)
|
||||
Where("agent_id = ? AND `year_month` = ?", agentId, yearMonth)
|
||||
taxRecords, err := l.svcCtx.AgentWithdrawalTaxModel.FindAll(ctx, builder, "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "查询月度提现记录失败")
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CheckFeatureWhitelistStatusLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCheckFeatureWhitelistStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckFeatureWhitelistStatusLogic {
|
||||
return &CheckFeatureWhitelistStatusLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CheckFeatureWhitelistStatusLogic) CheckFeatureWhitelistStatus(req *types.CheckFeatureWhitelistStatusReq) (resp *types.CheckFeatureWhitelistStatusResp, err error) {
|
||||
// 1. 验证参数
|
||||
if req.IdCard == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("身份证号不能为空"), "")
|
||||
}
|
||||
if req.FeatureApiId == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("模块API标识不能为空"), "")
|
||||
}
|
||||
|
||||
// 2. 提取主模块ID(去掉下划线后的部分)
|
||||
// 例如:JRZQ7F1A_BigDataReport -> JRZQ7F1A
|
||||
mainApiId := req.FeatureApiId
|
||||
if idx := strings.Index(req.FeatureApiId, "_"); idx > 0 {
|
||||
mainApiId = req.FeatureApiId[:idx]
|
||||
}
|
||||
|
||||
// 3. 查询feature信息(使用主模块ID)
|
||||
feature, err := l.svcCtx.FeatureModel.FindOneByApiId(l.ctx, mainApiId)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("模块不存在"), "")
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询模块信息失败, %v", err)
|
||||
}
|
||||
|
||||
// 4. 检查是否在白名单中(使用主模块ID)
|
||||
whitelistBuilder := l.svcCtx.UserFeatureWhitelistModel.SelectBuilder().
|
||||
Where("id_card = ? AND feature_api_id = ? AND status = ?", req.IdCard, mainApiId, 1)
|
||||
whitelists, err := l.svcCtx.UserFeatureWhitelistModel.FindAll(l.ctx, whitelistBuilder, "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询白名单记录失败, %v", err)
|
||||
}
|
||||
|
||||
isWhitelisted := len(whitelists) > 0
|
||||
|
||||
// 5. 如果提供了 queryId,检查当前报告数据是否已删除
|
||||
dataDeleted := false
|
||||
if req.QueryId != "" {
|
||||
containsFeature, err := l.svcCtx.WhitelistService.CheckQueryDataContainsFeature(l.ctx, req.QueryId, req.FeatureApiId)
|
||||
if err != nil {
|
||||
// 检查失败不影响主流程,记录日志即可
|
||||
logx.Errorf("检查报告数据是否包含模块失败:查询记录 %s,模块 %s,错误:%v", req.QueryId, req.FeatureApiId, err)
|
||||
// 默认认为数据已删除(保守处理)
|
||||
dataDeleted = true
|
||||
} else {
|
||||
// 如果数据中不包含该模块,说明数据已删除
|
||||
dataDeleted = !containsFeature
|
||||
}
|
||||
} else {
|
||||
// 未提供 queryId,无法判断数据是否已删除,默认认为已删除(保守处理)
|
||||
dataDeleted = true
|
||||
}
|
||||
|
||||
return &types.CheckFeatureWhitelistStatusResp{
|
||||
IsWhitelisted: isWhitelisted,
|
||||
WhitelistPrice: feature.WhitelistPrice,
|
||||
FeatureId: feature.Id,
|
||||
DataDeleted: dataDeleted,
|
||||
}, nil
|
||||
}
|
||||
|
||||
46
app/main/api/internal/logic/agent/checkorderagentlogic.go
Normal file
46
app/main/api/internal/logic/agent/checkorderagentlogic.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"ycc-server/app/main/api/internal/logic/query"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"ycc-server/common/ctxdata"
|
||||
"ycc-server/common/xerr"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CheckOrderAgentLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCheckOrderAgentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckOrderAgentLogic {
|
||||
return &CheckOrderAgentLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CheckOrderAgentLogic) CheckOrderAgent(req *types.CheckOrderAgentReq) (resp *types.CheckOrderAgentResp, err error) {
|
||||
// 获取当前用户ID
|
||||
userId, err := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取用户ID失败: %v", err)
|
||||
}
|
||||
|
||||
// 检查订单是否属于当前代理推广
|
||||
isAgent, err := query.IsOrderAgent(l.ctx, l.svcCtx, userId, req.OrderId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.CheckOrderAgentResp{
|
||||
IsAgentOrder: isAgent,
|
||||
}, nil
|
||||
}
|
||||
166
app/main/api/internal/logic/agent/createwhitelistorderlogic.go
Normal file
166
app/main/api/internal/logic/agent/createwhitelistorderlogic.go
Normal file
@@ -0,0 +1,166 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/ctxdata"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/lzUtils"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateWhitelistOrderLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateWhitelistOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateWhitelistOrderLogic {
|
||||
return &CreateWhitelistOrderLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateWhitelistOrderLogic) CreateWhitelistOrder(req *types.CreateWhitelistOrderReq) (resp *types.CreateWhitelistOrderResp, err error) {
|
||||
userID, err := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取用户信息失败, %v", err)
|
||||
}
|
||||
|
||||
// 1. 获取代理信息并验证(任意等级代理均可操作白名单)
|
||||
_, err = l.svcCtx.AgentModel.FindOneByUserId(l.ctx, userID)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("您不是代理"), "")
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理信息失败, %v", err)
|
||||
}
|
||||
|
||||
// 2. 验证参数
|
||||
if req.IdCard == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("身份证号不能为空"), "")
|
||||
}
|
||||
if len(req.FeatureIds) == 0 {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("请至少选择一个模块"), "")
|
||||
}
|
||||
|
||||
// 3. 查询feature信息并计算总金额
|
||||
var totalAmount float64
|
||||
var orderItems []struct {
|
||||
FeatureId string
|
||||
FeatureApiId string
|
||||
FeatureName string
|
||||
Price float64
|
||||
}
|
||||
|
||||
for _, featureId := range req.FeatureIds {
|
||||
feature, err := l.svcCtx.FeatureModel.FindOne(l.ctx, featureId)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg(fmt.Sprintf("模块不存在: %s", featureId)), "")
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询模块信息失败, %v", err)
|
||||
}
|
||||
|
||||
// 直接使用feature的WhitelistPrice字段
|
||||
whitelistPrice := feature.WhitelistPrice
|
||||
|
||||
if whitelistPrice <= 0 {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg(fmt.Sprintf("模块 %s 不支持白名单屏蔽", feature.Name)), "")
|
||||
}
|
||||
|
||||
// 检查该身份证号+feature是否已经存在白名单记录
|
||||
// 注意:系统会自动处理del_state,不需要手动添加
|
||||
whitelistBuilder := l.svcCtx.UserFeatureWhitelistModel.SelectBuilder().
|
||||
Where("id_card = ? AND feature_id = ?", req.IdCard, featureId)
|
||||
existing, err := l.svcCtx.UserFeatureWhitelistModel.FindAll(l.ctx, whitelistBuilder, "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询白名单记录失败, %v", err)
|
||||
}
|
||||
// 检查是否有生效的记录(status=1)
|
||||
for _, item := range existing {
|
||||
if item.Status == 1 {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg(fmt.Sprintf("身份证号 %s 的模块 %s 已经加入白名单", req.IdCard, feature.Name)), "")
|
||||
}
|
||||
}
|
||||
|
||||
totalAmount += whitelistPrice
|
||||
orderItems = append(orderItems, struct {
|
||||
FeatureId string
|
||||
FeatureApiId string
|
||||
FeatureName string
|
||||
Price float64
|
||||
}{
|
||||
FeatureId: feature.Id,
|
||||
FeatureApiId: feature.ApiId,
|
||||
FeatureName: feature.Name,
|
||||
Price: whitelistPrice,
|
||||
})
|
||||
}
|
||||
|
||||
// 4. 生成订单号(白名单订单前缀 W_,限制长度不超过32)
|
||||
base := l.svcCtx.AlipayService.GenerateOutTradeNo()
|
||||
orderNo := "W_" + base
|
||||
if len(orderNo) > 32 {
|
||||
orderNo = orderNo[:32]
|
||||
}
|
||||
|
||||
// 5. 使用事务创建订单和订单明细
|
||||
var orderId string
|
||||
err = l.svcCtx.WhitelistOrderModel.Trans(l.ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||
// 创建订单
|
||||
order := &model.WhitelistOrder{
|
||||
Id: uuid.NewString(),
|
||||
OrderNo: orderNo,
|
||||
UserId: userID,
|
||||
OrderId: lzUtils.StringToNullString(req.OrderId), // 关联的查询订单ID(可选,用于后续支付回调精确删除报告)
|
||||
IdCard: req.IdCard,
|
||||
TotalAmount: totalAmount,
|
||||
Status: 1, // 待支付
|
||||
}
|
||||
_, err := l.svcCtx.WhitelistOrderModel.Insert(ctx, session, order)
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "创建订单失败, %v", err)
|
||||
}
|
||||
orderId = order.Id
|
||||
|
||||
// 创建订单明细
|
||||
for _, item := range orderItems {
|
||||
orderItem := &model.WhitelistOrderItem{
|
||||
Id: uuid.NewString(),
|
||||
OrderId: orderId,
|
||||
FeatureId: item.FeatureId,
|
||||
FeatureApiId: item.FeatureApiId,
|
||||
FeatureName: item.FeatureName,
|
||||
Price: item.Price,
|
||||
}
|
||||
_, err := l.svcCtx.WhitelistOrderItemModel.Insert(ctx, session, orderItem)
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "创建订单明细失败, %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.CreateWhitelistOrderResp{
|
||||
OrderId: orderId,
|
||||
OrderNo: orderNo,
|
||||
TotalAmount: totalAmount,
|
||||
}, nil
|
||||
}
|
||||
@@ -185,7 +185,6 @@ func (l *GetConversionRateLogic) calculateConversionRate(agentId string, subordi
|
||||
func (l *GetConversionRateLogic) calculatePeriodConversion(agentId string, subordinateIds []string, periodLabel string, startTime, endTime time.Time) types.PeriodConversionData {
|
||||
// 构建 agent_order 查询条件
|
||||
agentOrderBuilder := l.svcCtx.AgentOrderModel.SelectBuilder().
|
||||
Where("del_state = ?", globalkey.DelStateNo).
|
||||
Where("create_time >= ? AND create_time < ?", startTime, endTime)
|
||||
|
||||
if agentId != "" {
|
||||
@@ -252,8 +251,7 @@ func (l *GetConversionRateLogic) calculatePeriodConversion(agentId string, subor
|
||||
|
||||
// 查询订单信息
|
||||
orderBuilder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where(squirrel.Eq{"id": orderIds}).
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
Where(squirrel.Eq{"id": orderIds})
|
||||
|
||||
orders, err := l.svcCtx.OrderModel.FindAll(l.ctx, orderBuilder, "")
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
@@ -305,9 +303,9 @@ func (l *GetConversionRateLogic) calculatePeriodConversion(agentId string, subor
|
||||
// 2. 付费量和金额:通过agent_rebate表统计(只有付费的订单才会产生返佣)
|
||||
func (l *GetConversionRateLogic) calculateSubordinatePeriodConversion(parentAgentId string, periodLabel string, startTime, endTime time.Time) types.PeriodConversionData {
|
||||
// 1. 查询agent_rebate表:获取所有曾经给当前用户产生返佣的source_agent_id(这些代理在某个时间点是下级)
|
||||
// 不限制时间,获取所有历史返佣记录,用于确定哪些代理曾经是下级
|
||||
// 不限制时间,获取所有历史返佣记录,用于确定哪些代理曾经是下级(排除已取消的记录 status=3)
|
||||
rebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("agent_id = ? AND del_state = ?", parentAgentId, globalkey.DelStateNo).
|
||||
Where("agent_id = ? AND del_state = ? AND status != ?", parentAgentId, globalkey.DelStateNo, 3).
|
||||
Where("source_agent_id != ?", parentAgentId)
|
||||
|
||||
allRebates, err := l.svcCtx.AgentRebateModel.FindAll(l.ctx, rebateBuilder, "")
|
||||
@@ -360,7 +358,6 @@ func (l *GetConversionRateLogic) calculateSubordinatePeriodConversion(parentAgen
|
||||
|
||||
// 2. 查询agent_order表:统计这些代理在时间段内的所有订单(包括未付费的)
|
||||
agentOrderBuilder := l.svcCtx.AgentOrderModel.SelectBuilder().
|
||||
Where("del_state = ?", globalkey.DelStateNo).
|
||||
Where("create_time >= ? AND create_time < ?", startTime, endTime).
|
||||
Where(squirrel.Eq{"agent_id": sourceAgentIds})
|
||||
|
||||
@@ -413,8 +410,7 @@ func (l *GetConversionRateLogic) calculateSubordinatePeriodConversion(parentAgen
|
||||
|
||||
// 4. 查询订单信息
|
||||
orderBuilder := l.svcCtx.OrderModel.SelectBuilder().
|
||||
Where(squirrel.Eq{"id": orderIds}).
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
Where(squirrel.Eq{"id": orderIds})
|
||||
|
||||
orders, err := l.svcCtx.OrderModel.FindAll(l.ctx, orderBuilder, "")
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
@@ -429,9 +425,9 @@ func (l *GetConversionRateLogic) calculateSubordinatePeriodConversion(parentAgen
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 查询时间段内的返佣记录,获取已付费订单的金额
|
||||
// 5. 查询时间段内的返佣记录,获取已付费订单的金额(排除已取消的记录 status=3)
|
||||
rebateBuilder = l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("agent_id = ? AND del_state = ?", parentAgentId, globalkey.DelStateNo).
|
||||
Where("agent_id = ? AND del_state = ? AND status != ?", parentAgentId, globalkey.DelStateNo, 3).
|
||||
Where("source_agent_id != ?", parentAgentId).
|
||||
Where("create_time >= ? AND create_time < ?", startTime, endTime).
|
||||
Where(squirrel.Eq{"order_id": orderIds})
|
||||
|
||||
67
app/main/api/internal/logic/agent/getinviteposterlogic.go
Normal file
67
app/main/api/internal/logic/agent/getinviteposterlogic.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/ctxdata"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetInvitePosterLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetInvitePosterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetInvitePosterLogic {
|
||||
return &GetInvitePosterLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
// GetInvitePoster 使用 ImageService(invitation 类型,yq_qrcode_1.png + 二维码)生成海报
|
||||
func (l *GetInvitePosterLogic) GetInvitePoster(req *types.GetInvitePosterReq) (pngBytes []byte, err error) {
|
||||
userID, err := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取用户信息失败, %v", err)
|
||||
}
|
||||
|
||||
_, err = l.svcCtx.AgentModel.FindOneByUserId(l.ctx, userID)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("您不是代理"), "")
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理信息失败, %v", err)
|
||||
}
|
||||
|
||||
inviteLink := strings.TrimSpace(req.InviteLink)
|
||||
if inviteLink == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("邀请链接不能为空"), "")
|
||||
}
|
||||
|
||||
pngBytes, _, err = l.svcCtx.ImageService.ProcessImageWithQRCode("invitation", inviteLink)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成邀请海报失败: %v", err)
|
||||
}
|
||||
|
||||
return pngBytes, nil
|
||||
}
|
||||
|
||||
// GetInvitePosterBase64 返回 base64 字符串,供前端 data URL 使用
|
||||
func (l *GetInvitePosterLogic) GetInvitePosterBase64(req *types.GetInvitePosterReq) (string, error) {
|
||||
pngBytes, err := l.GetInvitePoster(req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return base64.StdEncoding.EncodeToString(pngBytes), nil
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/ctxdata"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetLastWithdrawalInfoLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetLastWithdrawalInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLastWithdrawalInfoLogic {
|
||||
return &GetLastWithdrawalInfoLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetLastWithdrawalInfoLogic) GetLastWithdrawalInfo(req *types.GetLastWithdrawalInfoReq) (resp *types.GetLastWithdrawalInfoResp, err error) {
|
||||
userID, err := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取用户信息失败, %v", err)
|
||||
}
|
||||
|
||||
// 1. 获取代理信息
|
||||
agent, err := l.svcCtx.AgentModel.FindOneByUserId(l.ctx, userID)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("您不是代理"), "")
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理信息失败, %v", err)
|
||||
}
|
||||
|
||||
// 2. 验证提现方式
|
||||
if req.WithdrawalType != 1 && req.WithdrawalType != 2 {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("提现方式无效"), "")
|
||||
}
|
||||
|
||||
// 3. 查询该代理最近一次该类型的提现记录
|
||||
// 注意:FindAll 方法会自动添加 del_state = ? 条件,所以这里不需要手动添加
|
||||
builder := l.svcCtx.AgentWithdrawalModel.SelectBuilder().
|
||||
Where("agent_id = ? AND withdrawal_type = ?", agent.Id, req.WithdrawalType).
|
||||
OrderBy("create_time DESC").
|
||||
Limit(1)
|
||||
|
||||
withdrawals, err := l.svcCtx.AgentWithdrawalModel.FindAll(l.ctx, builder, "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询上次提现记录失败, %v", err)
|
||||
}
|
||||
|
||||
// 4. 如果没有找到记录,返回空信息
|
||||
if len(withdrawals) == 0 {
|
||||
return &types.GetLastWithdrawalInfoResp{
|
||||
WithdrawalType: req.WithdrawalType,
|
||||
PayeeAccount: "",
|
||||
PayeeName: "",
|
||||
BankCardNo: "",
|
||||
BankName: "",
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 5. 组装响应
|
||||
lastWithdrawal := withdrawals[0]
|
||||
resp = &types.GetLastWithdrawalInfoResp{
|
||||
WithdrawalType: lastWithdrawal.WithdrawalType,
|
||||
PayeeAccount: lastWithdrawal.PayeeAccount,
|
||||
PayeeName: lastWithdrawal.PayeeName,
|
||||
BankCardNo: "",
|
||||
BankName: "",
|
||||
}
|
||||
|
||||
// 如果是银行卡提现,填充银行卡信息
|
||||
if lastWithdrawal.WithdrawalType == 2 {
|
||||
if lastWithdrawal.BankCardNo.Valid {
|
||||
resp.BankCardNo = lastWithdrawal.BankCardNo.String
|
||||
}
|
||||
if lastWithdrawal.BankName.Valid {
|
||||
resp.BankName = lastWithdrawal.BankName.String
|
||||
}
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -117,6 +117,7 @@ func (l *GetRebateListLogic) GetRebateList(req *types.GetRebateListReq) (resp *t
|
||||
OrderNo: orderNo,
|
||||
RebateType: rebate.RebateType,
|
||||
Amount: rebate.RebateAmount,
|
||||
Status: rebate.Status,
|
||||
CreateTime: rebate.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/ctxdata"
|
||||
@@ -57,26 +58,27 @@ func (l *GetRevenueInfoLogic) GetRevenueInfo() (resp *types.GetRevenueInfoResp,
|
||||
todayStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
|
||||
// 本月开始时间(1号 00:00:00)
|
||||
monthStart := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
|
||||
nextMonthStart := monthStart.AddDate(0, 1, 0)
|
||||
|
||||
// 3. 统计佣金总额(从 agent_commission 表统计)
|
||||
// 3. 统计佣金总额(从 agent_commission 表统计,排除已取消的记录 status=3)
|
||||
commissionBuilder := l.svcCtx.AgentCommissionModel.SelectBuilder().
|
||||
Where("agent_id = ? AND del_state = ?", agent.Id, globalkey.DelStateNo)
|
||||
Where("agent_id = ? AND del_state = ? AND status != ?", agent.Id, globalkey.DelStateNo, 3)
|
||||
commissionTotal, _ := l.svcCtx.AgentCommissionModel.FindSum(l.ctx, commissionBuilder, "amount")
|
||||
|
||||
// 3.1 统计佣金今日收益
|
||||
// 3.1 统计佣金今日收益(排除已取消的记录 status=3)
|
||||
commissionTodayBuilder := l.svcCtx.AgentCommissionModel.SelectBuilder().
|
||||
Where("agent_id = ? AND del_state = ? AND create_time >= ?", agent.Id, globalkey.DelStateNo, todayStart)
|
||||
Where("agent_id = ? AND del_state = ? AND status != ? AND create_time >= ?", agent.Id, globalkey.DelStateNo, 3, todayStart)
|
||||
commissionToday, _ := l.svcCtx.AgentCommissionModel.FindSum(l.ctx, commissionTodayBuilder, "amount")
|
||||
|
||||
// 3.2 统计佣金本月收益
|
||||
// 3.2 统计佣金本月收益(排除已取消的记录 status=3)
|
||||
commissionMonthBuilder := l.svcCtx.AgentCommissionModel.SelectBuilder().
|
||||
Where("agent_id = ? AND del_state = ? AND create_time >= ?", agent.Id, globalkey.DelStateNo, monthStart)
|
||||
Where("agent_id = ? AND del_state = ? AND status != ? AND create_time >= ?", agent.Id, globalkey.DelStateNo, 3, monthStart)
|
||||
commissionMonth, _ := l.svcCtx.AgentCommissionModel.FindSum(l.ctx, commissionMonthBuilder, "amount")
|
||||
|
||||
// 4. 统计返佣总额(包括推广返佣和升级返佣)
|
||||
// 4.1 统计推广返佣(从 agent_rebate 表)
|
||||
// 4. 统计返佣总额(包括推广返佣和升级返佣,排除已取消的记录 status=3)
|
||||
// 4.1 统计推广返佣(从 agent_rebate 表,排除已取消的记录 status=3)
|
||||
rebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("agent_id = ? AND del_state = ?", agent.Id, globalkey.DelStateNo)
|
||||
Where("agent_id = ? AND del_state = ? AND status != ?", agent.Id, globalkey.DelStateNo, 3)
|
||||
promoteRebateTotal, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, rebateBuilder, "rebate_amount")
|
||||
|
||||
// 4.2 统计升级返佣(从 agent_upgrade 表,查询 rebate_agent_id = 当前代理ID 且 status = 2(已完成)且 upgrade_type = 1(自主付费)的记录)
|
||||
@@ -88,10 +90,10 @@ func (l *GetRevenueInfoLogic) GetRevenueInfo() (resp *types.GetRevenueInfoResp,
|
||||
|
||||
rebateTotal := promoteRebateTotal + upgradeRebateTotal
|
||||
|
||||
// 4.3 统计返佣今日收益
|
||||
// 4.3 统计返佣今日收益(排除已取消的记录 status=3)
|
||||
// 推广返佣今日
|
||||
promoteRebateTodayBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("agent_id = ? AND del_state = ? AND create_time >= ?", agent.Id, globalkey.DelStateNo, todayStart)
|
||||
Where("agent_id = ? AND del_state = ? AND status != ? AND create_time >= ?", agent.Id, globalkey.DelStateNo, 3, todayStart)
|
||||
promoteRebateToday, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, promoteRebateTodayBuilder, "rebate_amount")
|
||||
// 升级返佣今日
|
||||
upgradeRebateTodayBuilder := l.svcCtx.AgentUpgradeModel.SelectBuilder().
|
||||
@@ -100,10 +102,10 @@ func (l *GetRevenueInfoLogic) GetRevenueInfo() (resp *types.GetRevenueInfoResp,
|
||||
upgradeRebateToday, _ := l.svcCtx.AgentUpgradeModel.FindSum(l.ctx, upgradeRebateTodayBuilder, "rebate_amount")
|
||||
rebateToday := promoteRebateToday + upgradeRebateToday
|
||||
|
||||
// 4.4 统计返佣本月收益
|
||||
// 4.4 统计返佣本月收益(排除已取消的记录 status=3)
|
||||
// 推广返佣本月
|
||||
promoteRebateMonthBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("agent_id = ? AND del_state = ? AND create_time >= ?", agent.Id, globalkey.DelStateNo, monthStart)
|
||||
Where("agent_id = ? AND del_state = ? AND status != ? AND create_time >= ?", agent.Id, globalkey.DelStateNo, 3, monthStart)
|
||||
promoteRebateMonth, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, promoteRebateMonthBuilder, "rebate_amount")
|
||||
// 升级返佣本月
|
||||
upgradeRebateMonthBuilder := l.svcCtx.AgentUpgradeModel.SelectBuilder().
|
||||
@@ -112,6 +114,24 @@ func (l *GetRevenueInfoLogic) GetRevenueInfo() (resp *types.GetRevenueInfoResp,
|
||||
upgradeRebateMonth, _ := l.svcCtx.AgentUpgradeModel.FindSum(l.ctx, upgradeRebateMonthBuilder, "rebate_amount")
|
||||
rebateMonth := promoteRebateMonth + upgradeRebateMonth
|
||||
|
||||
// 5. 统计本月支付宝提现额度使用情况
|
||||
// 5.1 获取配置的支付宝月度额度(默认 800 元)
|
||||
alipayQuota := 800.0
|
||||
if cfg, cfgErr := l.svcCtx.AgentConfigModel.FindOneByConfigKey(l.ctx, "alipay_month_quota"); cfgErr == nil {
|
||||
if parsed, parseErr := parseFloatConfig(cfg.ConfigValue); parseErr == nil && parsed > 0 {
|
||||
alipayQuota = parsed
|
||||
}
|
||||
}
|
||||
|
||||
// 5.2 统计本月已申请/成功的支付宝提现金额(status IN (1,5)),用于前端展示额度占用
|
||||
withdrawBuilder := l.svcCtx.AgentWithdrawalModel.SelectBuilder().
|
||||
Where("agent_id = ? AND withdrawal_type = ? AND status IN (1,5) AND create_time >= ? AND create_time < ?",
|
||||
agent.Id, 1, monthStart, nextMonthStart)
|
||||
alipayUsed, _ := l.svcCtx.AgentWithdrawalModel.FindSum(l.ctx, withdrawBuilder, "amount")
|
||||
if alipayUsed < 0 {
|
||||
alipayUsed = 0
|
||||
}
|
||||
|
||||
return &types.GetRevenueInfoResp{
|
||||
Balance: wallet.Balance,
|
||||
FrozenBalance: wallet.FrozenBalance,
|
||||
@@ -123,5 +143,14 @@ func (l *GetRevenueInfoLogic) GetRevenueInfo() (resp *types.GetRevenueInfoResp,
|
||||
RebateTotal: rebateTotal, // 返佣累计总收益(包括推广返佣和升级返佣)
|
||||
RebateToday: rebateToday, // 返佣今日收益
|
||||
RebateMonth: rebateMonth, // 返佣本月收益
|
||||
AlipayMonthQuota: alipayQuota, // 支付宝每月提现总额度
|
||||
AlipayMonthUsed: alipayUsed, // 本月已使用的支付宝提现额度
|
||||
}, nil
|
||||
}
|
||||
|
||||
// parseFloatConfig 解析配置中的浮点数
|
||||
func parseFloatConfig(s string) (float64, error) {
|
||||
var result float64
|
||||
_, err := fmt.Sscanf(s, "%f", &result)
|
||||
return result, err
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ func (l *GetSubordinateContributionDetailLogic) GetSubordinateContributionDetail
|
||||
todayStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
|
||||
monthStart := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
|
||||
|
||||
// 7. 统计订单数据(仅统计有返佣给当前用户的订单)
|
||||
// 7. 统计订单数据(仅统计有返佣给当前用户的订单,排除已取消的记录 status=3)
|
||||
// 通过 agent_rebate 表统计 DISTINCT order_id
|
||||
rebateBaseBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("agent_id = ? AND source_agent_id = ? AND del_state = ?", agent.Id, req.SubordinateId, globalkey.DelStateNo)
|
||||
Where("agent_id = ? AND source_agent_id = ? AND del_state = ? AND status != ?", agent.Id, req.SubordinateId, globalkey.DelStateNo, 3)
|
||||
|
||||
// 总订单量(去重订单ID)
|
||||
totalOrders := l.countDistinctOrders(l.ctx, rebateBaseBuilder)
|
||||
@@ -104,7 +104,7 @@ func (l *GetSubordinateContributionDetailLogic) GetSubordinateContributionDetail
|
||||
monthRebateBuilder := rebateBaseBuilder.Where("create_time >= ?", monthStart)
|
||||
monthOrders := l.countDistinctOrders(l.ctx, monthRebateBuilder)
|
||||
|
||||
// 8. 统计返佣金额
|
||||
// 8. 统计返佣金额(排除已取消的记录 status=3)
|
||||
totalRebateAmount, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, rebateBaseBuilder, "rebate_amount")
|
||||
todayRebateAmount, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, todayRebateBuilder, "rebate_amount")
|
||||
monthRebateAmount, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, monthRebateBuilder, "rebate_amount")
|
||||
@@ -227,12 +227,12 @@ func (l *GetSubordinateContributionDetailLogic) countDistinctOrders(ctx context.
|
||||
func (l *GetSubordinateContributionDetailLogic) getOrderList(ctx context.Context, agentId, subordinateId string, page, pageSize int64) ([]types.OrderItem, int64, error) {
|
||||
// 1. 查询所有返佣记录
|
||||
rebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("agent_id = ? AND source_agent_id = ? AND del_state = ?", agentId, subordinateId, globalkey.DelStateNo).
|
||||
Where("agent_id = ? AND source_agent_id = ? AND del_state = ? AND status != ?", agentId, subordinateId, globalkey.DelStateNo, 3).
|
||||
OrderBy("create_time DESC")
|
||||
|
||||
// 查询总数(去重订单ID)
|
||||
totalBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("agent_id = ? AND source_agent_id = ? AND del_state = ?", agentId, subordinateId, globalkey.DelStateNo)
|
||||
Where("agent_id = ? AND source_agent_id = ? AND del_state = ? AND status != ?", agentId, subordinateId, globalkey.DelStateNo, 3)
|
||||
total := l.countDistinctOrders(ctx, totalBuilder)
|
||||
|
||||
// 查询所有返佣记录
|
||||
|
||||
@@ -109,8 +109,7 @@ func (l *GetTeamListLogic) GetTeamList(req *types.GetTeamListReq) (resp *types.G
|
||||
|
||||
// 7. 查询所有下级代理信息(不进行手机号过滤,因为需要模糊搜索)
|
||||
builder := l.svcCtx.AgentModel.SelectBuilder().
|
||||
Where(squirrel.Eq{"id": subordinateIds}).
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
Where(squirrel.Eq{"id": subordinateIds})
|
||||
|
||||
allTeamMembers, err := l.svcCtx.AgentModel.FindAll(l.ctx, builder, "")
|
||||
if err != nil {
|
||||
@@ -170,7 +169,7 @@ func (l *GetTeamListLogic) GetTeamList(req *types.GetTeamListReq) (resp *types.G
|
||||
// 11. 组装响应列表
|
||||
var list []types.TeamMemberItem
|
||||
for _, member := range teamMembers {
|
||||
memberItem := l.buildTeamMemberItem(agent.Id, member, directSubordinateIds, todayStart)
|
||||
memberItem := l.buildTeamMemberItem(agent.Id, member, directSubordinateIds, todayStart, monthStart)
|
||||
list = append(list, memberItem)
|
||||
}
|
||||
|
||||
@@ -207,10 +206,10 @@ func (l *GetTeamListLogic) calculateTeamStatistics(agentId string, subordinateId
|
||||
stats.TodayNewMembers = todayNewCount
|
||||
stats.MonthNewMembers = monthNewCount
|
||||
|
||||
// 统计团队总查询量(仅统计有返佣给当前用户的订单,通过agent_rebate表去重统计order_id)
|
||||
// 统计团队总查询量(仅统计有返佣给当前用户的订单,通过agent_rebate表去重统计order_id,排除已取消的记录 status=3)
|
||||
if len(subordinateIds) > 0 {
|
||||
rebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("agent_id = ? AND del_state = ?", agentId, globalkey.DelStateNo).
|
||||
Where("agent_id = ? AND del_state = ? AND status != ?", agentId, globalkey.DelStateNo, 3).
|
||||
Where("source_agent_id != ?", agentId). // 明确排除自己
|
||||
Where(squirrel.Eq{"source_agent_id": subordinateIds})
|
||||
|
||||
@@ -229,14 +228,15 @@ func (l *GetTeamListLogic) calculateTeamStatistics(agentId string, subordinateId
|
||||
stats.MonthPromotions = monthPromotions
|
||||
}
|
||||
|
||||
// 统计收益:只统计从下级获得的返佣(依靠团队得到的收益)
|
||||
// 统计收益:只统计从下级获得的返佣(依靠团队得到的收益,排除已取消的记录 status=3)
|
||||
// 返佣:从agent_rebate表统计(从下级获得的返佣)
|
||||
// agent_id = 当前代理ID(获得返佣的代理)
|
||||
// source_agent_id IN 下级ID列表(来源代理,即产生订单的下级代理)
|
||||
// 明确排除自己:source_agent_id != agentId(确保不统计自己的数据)
|
||||
// 排除已取消:status != 3(确保不统计已撤销的返佣)
|
||||
if len(subordinateIds) > 0 {
|
||||
rebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("agent_id = ? AND del_state = ?", agentId, globalkey.DelStateNo).
|
||||
Where("agent_id = ? AND del_state = ? AND status != ?", agentId, globalkey.DelStateNo, 3).
|
||||
Where("source_agent_id != ?", agentId). // 明确排除自己
|
||||
Where(squirrel.Eq{"source_agent_id": subordinateIds})
|
||||
totalRebate, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, rebateBuilder, "rebate_amount")
|
||||
@@ -284,7 +284,7 @@ func (l *GetTeamListLogic) countDistinctOrdersForMember(ctx context.Context, bui
|
||||
}
|
||||
|
||||
// buildTeamMemberItem 构建团队成员项
|
||||
func (l *GetTeamListLogic) buildTeamMemberItem(agentId string, member *model.Agent, directSubordinateIds map[string]bool, todayStart time.Time) types.TeamMemberItem {
|
||||
func (l *GetTeamListLogic) buildTeamMemberItem(agentId string, member *model.Agent, directSubordinateIds map[string]bool, todayStart, monthStart time.Time) types.TeamMemberItem {
|
||||
levelName := ""
|
||||
switch member.Level {
|
||||
case 1:
|
||||
@@ -304,14 +304,16 @@ func (l *GetTeamListLogic) buildTeamMemberItem(agentId string, member *model.Age
|
||||
}
|
||||
}
|
||||
|
||||
// 统计查询量(仅统计有返佣给当前用户的订单,通过agent_rebate表去重统计order_id)
|
||||
// 统计查询量(仅统计有返佣给当前用户的订单,通过agent_rebate表去重统计order_id,排除已取消的记录 status=3)
|
||||
rebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
|
||||
Where("agent_id = ? AND source_agent_id = ? AND del_state = ?", agentId, member.Id, globalkey.DelStateNo)
|
||||
Where("agent_id = ? AND source_agent_id = ? AND del_state = ? AND status != ?", agentId, member.Id, globalkey.DelStateNo, 3)
|
||||
totalQueries := l.countDistinctOrdersForMember(l.ctx, rebateBuilder)
|
||||
todayRebateBuilder := rebateBuilder.Where("create_time >= ?", todayStart)
|
||||
todayQueries := l.countDistinctOrdersForMember(l.ctx, todayRebateBuilder)
|
||||
monthRebateBuilder := rebateBuilder.Where("create_time >= ?", monthStart)
|
||||
monthQueries := l.countDistinctOrdersForMember(l.ctx, monthRebateBuilder)
|
||||
|
||||
// 统计返佣给我的金额(从agent_rebate表,source_agent_id = member.Id, agent_id = agentId)
|
||||
// 统计返佣给我的金额(从agent_rebate表,source_agent_id = member.Id, agent_id = agentId,排除已取消的记录 status=3)
|
||||
totalRebateAmount, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, rebateBuilder, "rebate_amount")
|
||||
todayRebateAmount, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, rebateBuilder.Where("create_time >= ?", todayStart), "rebate_amount")
|
||||
|
||||
@@ -320,6 +322,7 @@ func (l *GetTeamListLogic) buildTeamMemberItem(agentId string, member *model.Age
|
||||
Where("parent_id = ? AND relation_type = ? AND del_state = ?", member.Id, 1, globalkey.DelStateNo)
|
||||
totalInvites, _ := l.svcCtx.AgentRelationModel.FindCount(l.ctx, inviteBuilder, "id")
|
||||
todayInvites, _ := l.svcCtx.AgentRelationModel.FindCount(l.ctx, inviteBuilder.Where("create_time >= ?", todayStart), "id")
|
||||
monthInvites, _ := l.svcCtx.AgentRelationModel.FindCount(l.ctx, inviteBuilder.Where("create_time >= ?", monthStart), "id")
|
||||
|
||||
// 判断是否直接下级
|
||||
isDirect := directSubordinateIds[member.Id]
|
||||
@@ -331,11 +334,13 @@ func (l *GetTeamListLogic) buildTeamMemberItem(agentId string, member *model.Age
|
||||
Mobile: mobile,
|
||||
CreateTime: member.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
TodayQueries: todayQueries,
|
||||
MonthQueries: monthQueries,
|
||||
TotalQueries: totalQueries,
|
||||
TotalRebateAmount: totalRebateAmount,
|
||||
TodayRebateAmount: todayRebateAmount,
|
||||
TotalInvites: totalInvites,
|
||||
TodayInvites: todayInvites,
|
||||
MonthInvites: monthInvites,
|
||||
IsDirect: isDirect,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,8 +107,7 @@ func (l *GetTeamStatisticsLogic) GetTeamStatistics() (resp *types.TeamStatistics
|
||||
|
||||
// 6. 查询所有下级代理信息
|
||||
builder := l.svcCtx.AgentModel.SelectBuilder().
|
||||
Where(squirrel.Eq{"id": subordinateIds}).
|
||||
Where("del_state = ?", globalkey.DelStateNo)
|
||||
Where(squirrel.Eq{"id": subordinateIds})
|
||||
|
||||
teamMembers, err := l.svcCtx.AgentModel.FindAll(l.ctx, builder, "")
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetWhitelistFeaturesLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetWhitelistFeaturesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWhitelistFeaturesLogic {
|
||||
return &GetWhitelistFeaturesLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetWhitelistFeaturesLogic) GetWhitelistFeatures(req *types.GetWhitelistFeaturesReq) (resp *types.GetWhitelistFeaturesResp, err error) {
|
||||
// 使用SelectBuilder查询所有feature,然后筛选whitelist_price > 0的
|
||||
// 注意:系统会自动处理del_state,不需要手动添加
|
||||
builder := l.svcCtx.FeatureModel.SelectBuilder().
|
||||
Where("whitelist_price > 0").
|
||||
OrderBy("name ASC")
|
||||
|
||||
features, err := l.svcCtx.FeatureModel.FindAll(l.ctx, builder, "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询feature列表失败, %v", err)
|
||||
}
|
||||
|
||||
// 组装响应,直接使用feature的WhitelistPrice字段
|
||||
list := make([]types.WhitelistFeatureItem, 0, len(features))
|
||||
for _, f := range features {
|
||||
if f.WhitelistPrice > 0 {
|
||||
list = append(list, types.WhitelistFeatureItem{
|
||||
FeatureId: f.Id,
|
||||
FeatureApiId: f.ApiId,
|
||||
FeatureName: f.Name,
|
||||
WhitelistPrice: f.WhitelistPrice,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return &types.GetWhitelistFeaturesResp{
|
||||
List: list,
|
||||
}, nil
|
||||
}
|
||||
117
app/main/api/internal/logic/agent/getwhitelistlistlogic.go
Normal file
117
app/main/api/internal/logic/agent/getwhitelistlistlogic.go
Normal file
@@ -0,0 +1,117 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/ctxdata"
|
||||
"ycc-server/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetWhitelistListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetWhitelistListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWhitelistListLogic {
|
||||
return &GetWhitelistListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetWhitelistListLogic) GetWhitelistList(req *types.GetWhitelistListReq) (resp *types.GetWhitelistListResp, err error) {
|
||||
userID, err := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取用户信息失败, %v", err)
|
||||
}
|
||||
|
||||
// 1. 验证是否为代理(查询白名单列表需要是代理)
|
||||
_, err = l.svcCtx.AgentModel.FindOneByUserId(l.ctx, userID)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("您不是代理"), "")
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理信息失败, %v", err)
|
||||
}
|
||||
|
||||
// 2. 构建查询条件
|
||||
// 注意:系统会自动处理del_state,不需要手动添加
|
||||
builder := l.svcCtx.UserFeatureWhitelistModel.SelectBuilder().
|
||||
Where("user_id = ?", userID)
|
||||
|
||||
// 如果指定了身份证号,添加筛选条件
|
||||
if req.IdCard != "" {
|
||||
builder = builder.Where("id_card = ?", req.IdCard)
|
||||
}
|
||||
|
||||
// 3. 分页查询
|
||||
total, err := l.svcCtx.UserFeatureWhitelistModel.FindCount(l.ctx, builder, "id")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询总数失败, %v", err)
|
||||
}
|
||||
|
||||
whitelists, err := l.svcCtx.UserFeatureWhitelistModel.FindPageListByPage(l.ctx, builder, req.Page, req.PageSize, "create_time DESC")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询白名单列表失败, %v", err)
|
||||
}
|
||||
|
||||
// 4. 组装响应
|
||||
list := make([]types.WhitelistItem, 0, len(whitelists))
|
||||
for _, w := range whitelists {
|
||||
statusText := "生效"
|
||||
if w.Status == 2 {
|
||||
statusText = "已失效"
|
||||
}
|
||||
|
||||
list = append(list, types.WhitelistItem{
|
||||
Id: w.Id,
|
||||
IdCard: w.IdCard,
|
||||
FeatureId: w.FeatureId,
|
||||
FeatureApiId: w.FeatureApiId,
|
||||
FeatureName: "", // 需要从feature表查询,或者冗余存储
|
||||
Amount: w.Amount,
|
||||
Status: w.Status,
|
||||
StatusText: statusText,
|
||||
CreateTime: w.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
}
|
||||
|
||||
// 5. 查询feature名称(批量查询优化)
|
||||
if len(list) > 0 {
|
||||
featureIds := make([]string, 0, len(list))
|
||||
featureMap := make(map[string]string) // feature_id -> feature_name
|
||||
for _, item := range list {
|
||||
featureIds = append(featureIds, item.FeatureId)
|
||||
}
|
||||
|
||||
// 批量查询feature
|
||||
for _, featureId := range featureIds {
|
||||
feature, err := l.svcCtx.FeatureModel.FindOne(l.ctx, featureId)
|
||||
if err == nil {
|
||||
featureMap[featureId] = feature.Name
|
||||
}
|
||||
}
|
||||
|
||||
// 填充feature名称
|
||||
for i := range list {
|
||||
if name, ok := featureMap[list[i].FeatureId]; ok {
|
||||
list[i].FeatureName = name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &types.GetWhitelistListResp{
|
||||
Total: total,
|
||||
List: list,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -81,9 +81,10 @@ func (l *GetWithdrawalListLogic) GetWithdrawalList(req *types.GetWithdrawalListR
|
||||
remark = withdrawal.Remark.String
|
||||
}
|
||||
|
||||
list = append(list, types.WithdrawalItem{
|
||||
item := types.WithdrawalItem{
|
||||
Id: withdrawal.Id,
|
||||
WithdrawalNo: withdrawal.WithdrawNo,
|
||||
WithdrawalType: withdrawal.WithdrawalType,
|
||||
Amount: withdrawal.Amount,
|
||||
TaxAmount: withdrawal.TaxAmount,
|
||||
ActualAmount: withdrawal.ActualAmount,
|
||||
@@ -92,7 +93,19 @@ func (l *GetWithdrawalListLogic) GetWithdrawalList(req *types.GetWithdrawalListR
|
||||
PayeeName: withdrawal.PayeeName,
|
||||
Remark: remark,
|
||||
CreateTime: withdrawal.CreateTime.Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
}
|
||||
|
||||
// 如果是银行卡提现,填充银行卡信息
|
||||
if withdrawal.WithdrawalType == 2 {
|
||||
if withdrawal.BankCardNo.Valid {
|
||||
item.BankCardNo = withdrawal.BankCardNo.String
|
||||
}
|
||||
if withdrawal.BankName.Valid {
|
||||
item.BankName = withdrawal.BankName.String
|
||||
}
|
||||
}
|
||||
|
||||
list = append(list, item)
|
||||
}
|
||||
|
||||
return &types.GetWithdrawalListResp{
|
||||
|
||||
170
app/main/api/internal/logic/agent/offlinefeaturelogic.go
Normal file
170
app/main/api/internal/logic/agent/offlinefeaturelogic.go
Normal file
@@ -0,0 +1,170 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/ctxdata"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/crypto"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||
)
|
||||
|
||||
type OfflineFeatureLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewOfflineFeatureLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OfflineFeatureLogic {
|
||||
return &OfflineFeatureLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *OfflineFeatureLogic) OfflineFeature(req *types.OfflineFeatureReq) (resp *types.OfflineFeatureResp, err error) {
|
||||
// 1. 验证参数
|
||||
if err := l.validateRequest(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 2. 获取用户ID并验证代理权限(任意等级代理均可下架)
|
||||
userID, err := l.verifyAgent()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 3. 获取查询记录和身份证号
|
||||
queryModel, idCard, err := l.getQueryInfo(req.QueryId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_ = queryModel // 避免未使用变量警告
|
||||
|
||||
// 4. 调用 WhitelistService 统一下架处理
|
||||
needPay, amount, whitelistCreated, err := l.svcCtx.WhitelistService.ProcessOfflineFeature(
|
||||
l.ctx,
|
||||
nil, // 不使用事务,因为可能只是检查
|
||||
idCard,
|
||||
req.FeatureApiId,
|
||||
userID,
|
||||
req.QueryId,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 5. 如果已创建白名单,需要删除报告数据
|
||||
if whitelistCreated {
|
||||
if err := l.deleteQueryData(req.QueryId, req.FeatureApiId); err != nil {
|
||||
// 删除报告数据失败不影响主流程,只记录日志
|
||||
logx.Errorf("下架模块后删除报告数据失败:查询记录 %s,模块 %s,错误:%v", req.QueryId, req.FeatureApiId, err)
|
||||
}
|
||||
}
|
||||
|
||||
return &types.OfflineFeatureResp{
|
||||
Success: whitelistCreated,
|
||||
NeedPay: needPay,
|
||||
Amount: amount,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// validateRequest 验证请求参数
|
||||
func (l *OfflineFeatureLogic) validateRequest(req *types.OfflineFeatureReq) error {
|
||||
if req.QueryId == "" {
|
||||
return errors.Wrapf(xerr.NewErrMsg("查询记录ID不能为空"), "")
|
||||
}
|
||||
if req.FeatureApiId == "" {
|
||||
return errors.Wrapf(xerr.NewErrMsg("模块API标识不能为空"), "")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// verifyAgent 验证是否为代理并返回用户ID(任意等级代理均可下架)
|
||||
func (l *OfflineFeatureLogic) verifyAgent() (string, error) {
|
||||
userID, err := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取用户信息失败, %v", err)
|
||||
}
|
||||
|
||||
_, err = l.svcCtx.AgentModel.FindOneByUserId(l.ctx, userID)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return "", errors.Wrapf(xerr.NewErrMsg("您不是代理"), "")
|
||||
}
|
||||
return "", errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理信息失败, %v", err)
|
||||
}
|
||||
|
||||
return userID, nil
|
||||
}
|
||||
|
||||
// getQueryInfo 获取查询记录和身份证号
|
||||
func (l *OfflineFeatureLogic) getQueryInfo(queryId string) (*model.Query, string, error) {
|
||||
queryModel, err := l.svcCtx.QueryModel.FindOne(l.ctx, queryId)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, "", errors.Wrapf(xerr.NewErrMsg("查询记录不存在"), "")
|
||||
}
|
||||
return nil, "", errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询报告记录失败, %v", err)
|
||||
}
|
||||
|
||||
// 解密 QueryParams 获取 idCard
|
||||
idCard, err := l.extractIdCardFromQueryParams(queryModel)
|
||||
if err != nil {
|
||||
return nil, "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取身份证号失败, %v", err)
|
||||
}
|
||||
|
||||
if idCard == "" {
|
||||
return nil, "", errors.Wrapf(xerr.NewErrMsg("查询参数中缺少身份证号"), "")
|
||||
}
|
||||
|
||||
return queryModel, idCard, nil
|
||||
}
|
||||
|
||||
// extractIdCardFromQueryParams 从 QueryParams 中提取身份证号
|
||||
func (l *OfflineFeatureLogic) extractIdCardFromQueryParams(queryModel *model.Query) (string, error) {
|
||||
if queryModel.QueryParams == "" {
|
||||
return "", errors.New("查询参数为空")
|
||||
}
|
||||
|
||||
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
||||
key, decodeErr := hex.DecodeString(secretKey)
|
||||
if decodeErr != nil {
|
||||
return "", errors.Wrap(decodeErr, "获取AES密钥失败")
|
||||
}
|
||||
|
||||
decryptedParams, decryptErr := crypto.AesDecrypt(queryModel.QueryParams, key)
|
||||
if decryptErr != nil {
|
||||
return "", errors.Wrap(decryptErr, "解密查询参数失败")
|
||||
}
|
||||
|
||||
var params map[string]interface{}
|
||||
unmarshalErr := json.Unmarshal(decryptedParams, ¶ms)
|
||||
if unmarshalErr != nil {
|
||||
return "", errors.Wrap(unmarshalErr, "解析查询参数失败")
|
||||
}
|
||||
|
||||
idCard, ok := params["id_card"].(string)
|
||||
if !ok || idCard == "" {
|
||||
return "", errors.New("查询参数中缺少 id_card 或 id_card 为空")
|
||||
}
|
||||
|
||||
return idCard, nil
|
||||
}
|
||||
|
||||
// deleteQueryData 删除报告数据
|
||||
func (l *OfflineFeatureLogic) deleteQueryData(queryId, featureApiId string) error {
|
||||
return l.svcCtx.QueryModel.Trans(l.ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||
return l.svcCtx.WhitelistService.DeleteFeatureFromQueryData(ctx, session, queryId, featureApiId)
|
||||
})
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"database/sql"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"os"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/common/ctxdata"
|
||||
"ycc-server/common/xerr"
|
||||
@@ -61,7 +62,8 @@ func (l *RealNameAuthLogic) RealNameAuth(req *types.RealNameAuthReq) (resp *type
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("手机号与代理注册手机号不匹配"), "")
|
||||
}
|
||||
|
||||
// 3. 验证验证码
|
||||
// 开发环境下跳过验证码校验
|
||||
if os.Getenv("ENV") != "development" {
|
||||
encryptedMobile, err := crypto.EncryptMobile(req.Mobile, l.svcCtx.Config.Encrypt.SecretKey)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "加密手机号失败, %v", err)
|
||||
@@ -77,7 +79,9 @@ func (l *RealNameAuthLogic) RealNameAuth(req *types.RealNameAuthReq) (resp *type
|
||||
if cacheCode != req.Code {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("验证码不正确"), "")
|
||||
}
|
||||
}
|
||||
|
||||
if os.Getenv("ENV") != "development" {
|
||||
// 4. 三要素核验(姓名、身份证号、手机号)
|
||||
verification, err := l.svcCtx.VerificationService.ThreeFactorVerification(service.ThreeFactorVerificationRequest{
|
||||
Name: req.Name,
|
||||
@@ -93,7 +97,7 @@ func (l *RealNameAuthLogic) RealNameAuth(req *types.RealNameAuthReq) (resp *type
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("三要素核验不通过"), "")
|
||||
}
|
||||
|
||||
}
|
||||
// 5. 检查是否已有实名认证记录
|
||||
existingRealName, err := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agent.Id)
|
||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
"ycc-server/app/main/model"
|
||||
@@ -37,6 +36,24 @@ func NewRegisterByInviteCodeLogic(ctx context.Context, svcCtx *svc.ServiceContex
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
func isInPhoneRange(mobile string) bool {
|
||||
// 检查手机号长度
|
||||
if len(mobile) != 11 {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查是否为纯数字
|
||||
num, err := strconv.ParseInt(mobile, 10, 64)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查是否在指定区间内
|
||||
minPhone := int64(16000000000)
|
||||
maxPhone := int64(16000000100)
|
||||
|
||||
return num >= minPhone && num <= maxPhone
|
||||
}
|
||||
|
||||
func (l *RegisterByInviteCodeLogic) RegisterByInviteCode(req *types.RegisterByInviteCodeReq) (resp *types.RegisterByInviteCodeResp, err error) {
|
||||
l.Infof("[RegisterByInviteCode] 开始处理代理注册请求, mobile: %s, referrer: %s", req.Mobile, req.Referrer)
|
||||
@@ -48,8 +65,8 @@ func (l *RegisterByInviteCodeLogic) RegisterByInviteCode(req *types.RegisterByIn
|
||||
}
|
||||
l.Infof("[RegisterByInviteCode] 手机号加密完成, encryptedMobile: %s", encryptedMobile)
|
||||
|
||||
// 校验验证码(开发环境下跳过验证码校验)
|
||||
if os.Getenv("ENV") != "development" && req.Code != "143838" {
|
||||
// 校验验证码(开发环境下跳过;验证码 168888、143838 为测试用万能码,可跳过校验)
|
||||
if req.Code != "143838" {
|
||||
redisKey := fmt.Sprintf("%s:%s", "agentApply", encryptedMobile)
|
||||
cacheCode, err := l.svcCtx.Redis.Get(redisKey)
|
||||
if err != nil {
|
||||
@@ -65,7 +82,7 @@ func (l *RegisterByInviteCodeLogic) RegisterByInviteCode(req *types.RegisterByIn
|
||||
}
|
||||
l.Infof("[RegisterByInviteCode] 验证码校验通过, mobile: %s", req.Mobile)
|
||||
} else {
|
||||
l.Infof("[RegisterByInviteCode] 开发环境跳过验证码校验")
|
||||
l.Infof("[RegisterByInviteCode] 使用万能验证码校验")
|
||||
}
|
||||
|
||||
// 获取当前登录态(可能为空)
|
||||
|
||||
@@ -2,11 +2,12 @@ package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/lzkit/crypto"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"time"
|
||||
"ycc-server/common/xerr"
|
||||
"ycc-server/pkg/captcha"
|
||||
"ycc-server/pkg/lzkit/crypto"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
@@ -35,6 +36,20 @@ func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLo
|
||||
}
|
||||
|
||||
func (l *SendSmsLogic) SendSms(req *types.SendSmsReq) error {
|
||||
// 1. 阿里云滑块验证码校验(防盗刷);微信环境会跳过
|
||||
cfg := l.svcCtx.Config.Captcha
|
||||
if cfg.SceneID != "" {
|
||||
if err := captcha.Verify(l.ctx, captcha.Config{
|
||||
AccessKeyID: cfg.AccessKeyID,
|
||||
AccessKeySecret: cfg.AccessKeySecret,
|
||||
EndpointURL: cfg.EndpointURL,
|
||||
SceneID: cfg.SceneID,
|
||||
}, req.CaptchaVerifyParam); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 加密手机号
|
||||
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
||||
encryptedMobile, err := crypto.EncryptMobile(req.Mobile, secretKey)
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package captcha
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/api/internal/types"
|
||||
"ycc-server/pkg/captcha"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetEncryptedSceneIdLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetEncryptedSceneIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetEncryptedSceneIdLogic {
|
||||
return &GetEncryptedSceneIdLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetEncryptedSceneIdLogic) GetEncryptedSceneId() (*types.GetEncryptedSceneIdResp, error) {
|
||||
cfg := l.svcCtx.Config.Captcha
|
||||
|
||||
// 如果没有配置 ekey,返回空(使用非加密模式)
|
||||
if cfg.EKey == "" {
|
||||
l.Logger.Info("[Captcha] 未配置 EKey,使用非加密模式")
|
||||
return &types.GetEncryptedSceneIdResp{
|
||||
EncryptedSceneId: "",
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 生成加密场景ID,有效期1小时
|
||||
encrypted, err := captcha.GenerateEncryptedSceneID(cfg.SceneID, cfg.EKey, 3600)
|
||||
if err != nil {
|
||||
l.Logger.Errorf("[Captcha] 生成加密场景ID失败: %+v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.GetEncryptedSceneIdResp{
|
||||
EncryptedSceneId: encrypted,
|
||||
}, nil
|
||||
}
|
||||
@@ -45,6 +45,9 @@ func (l *AlipayCallbackLogic) AlipayCallback(w http.ResponseWriter, r *http.Requ
|
||||
} else if strings.HasPrefix(orderNo, "U_") {
|
||||
// 代理升级订单处理
|
||||
return l.handleAgentUpgradeOrderPayment(w, notification)
|
||||
} else if strings.HasPrefix(orderNo, "W_") {
|
||||
// 白名单下架订单处理
|
||||
return l.handleWhitelistOrderPayment(w, notification)
|
||||
} else if strings.HasPrefix(orderNo, "A_") {
|
||||
// 旧系统会员充值订单(已废弃,新系统使用升级功能)
|
||||
// return l.handleAgentVipOrderPayment(w, notification)
|
||||
@@ -110,6 +113,96 @@ func (l *AlipayCallbackLogic) handleQueryOrderPayment(w http.ResponseWriter, not
|
||||
return nil
|
||||
}
|
||||
|
||||
// 处理白名单下架订单支付
|
||||
func (l *AlipayCallbackLogic) handleWhitelistOrderPayment(w http.ResponseWriter, notification *alipay.Notification) error {
|
||||
orderNo := notification.OutTradeNo
|
||||
|
||||
// 1. 查找订单
|
||||
order, findOrderErr := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, orderNo)
|
||||
if findOrderErr != nil {
|
||||
logx.Errorf("支付宝白名单支付回调,查找订单失败: %+v", findOrderErr)
|
||||
alipay.ACKNotification(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 2. 验证金额
|
||||
amount := lzUtils.ToAlipayAmount(order.Amount)
|
||||
user, err := l.svcCtx.UserModel.FindOne(l.ctx, order.UserId)
|
||||
if err == nil && user.Inside != 1 {
|
||||
if amount != notification.TotalAmount {
|
||||
logx.Errorf("支付宝白名单支付回调,金额不一致,订单号: %s", orderNo)
|
||||
alipay.ACKNotification(w)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 检查订单状态
|
||||
if order.Status != "pending" {
|
||||
alipay.ACKNotification(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 4. 查找白名单订单
|
||||
whitelistOrder, findWhitelistErr := l.svcCtx.WhitelistOrderModel.FindOneByOrderNo(l.ctx, orderNo)
|
||||
if findWhitelistErr != nil {
|
||||
logx.Errorf("支付宝白名单支付回调,查找白名单订单失败,订单号: %s, 错误: %+v", orderNo, findWhitelistErr)
|
||||
alipay.ACKNotification(w)
|
||||
return nil
|
||||
}
|
||||
if whitelistOrder.Status != 1 {
|
||||
// 白名单订单状态不是待支付,直接返回成功
|
||||
alipay.ACKNotification(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 5. 处理支付状态
|
||||
switch notification.TradeStatus {
|
||||
case alipay.TradeStatusSuccess:
|
||||
order.Status = "paid"
|
||||
order.PayTime = lzUtils.TimeToNullTime(time.Now())
|
||||
order.PlatformOrderId = lzUtils.StringToNullString(notification.TradeNo)
|
||||
whitelistOrder.Status = 2 // 已支付
|
||||
whitelistOrder.PayTime = lzUtils.TimeToNullTime(time.Now())
|
||||
case alipay.TradeStatusClosed:
|
||||
order.Status = "closed"
|
||||
order.CloseTime = lzUtils.TimeToNullTime(time.Now())
|
||||
whitelistOrder.Status = 3 // 已取消
|
||||
default:
|
||||
alipay.ACKNotification(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 6. 更新订单和白名单订单 + 创建白名单记录并删除报告数据
|
||||
err = l.svcCtx.WhitelistOrderModel.Trans(l.ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||
// 6.1 更新订单状态
|
||||
if updateErr := l.svcCtx.OrderModel.UpdateWithVersion(ctx, session, order); updateErr != nil {
|
||||
return errors.Wrapf(updateErr, "支付宝白名单支付回调,更新订单状态失败")
|
||||
}
|
||||
|
||||
// 6.2 更新白名单订单状态
|
||||
if updateErr := l.svcCtx.WhitelistOrderModel.UpdateWithVersion(ctx, session, whitelistOrder); updateErr != nil {
|
||||
return errors.Wrapf(updateErr, "支付宝白名单支付回调,更新白名单订单状态失败")
|
||||
}
|
||||
|
||||
// 6.3 如果支付成功,调用 WhitelistService 处理白名单和报告数据
|
||||
if whitelistOrder.Status == 2 {
|
||||
if processErr := l.svcCtx.WhitelistService.ProcessPaidWhitelistOrder(ctx, session, order, whitelistOrder); processErr != nil {
|
||||
return errors.Wrapf(processErr, "支付宝白名单支付回调,处理白名单订单失败")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logx.Errorf("支付宝白名单支付回调,事务处理失败: %+v", err)
|
||||
alipay.ACKNotification(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
alipay.ACKNotification(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 处理代理升级订单支付
|
||||
func (l *AlipayCallbackLogic) handleAgentUpgradeOrderPayment(w http.ResponseWriter, notification *alipay.Notification) error {
|
||||
orderNo := notification.OutTradeNo
|
||||
|
||||
240
app/main/api/internal/logic/pay/alipayfromlogic.go
Normal file
240
app/main/api/internal/logic/pay/alipayfromlogic.go
Normal file
@@ -0,0 +1,240 @@
|
||||
package pay
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"ycc-server/app/main/api/internal/svc"
|
||||
"ycc-server/app/main/model"
|
||||
"ycc-server/pkg/lzkit/lzUtils"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/smartwalle/alipay/v3"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AlipayFromLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAlipayFromLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AlipayFromLogic {
|
||||
return &AlipayFromLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
// TradeComplainContent 交易投诉通知的 biz_content 内容
|
||||
type TradeComplainContent struct {
|
||||
ComplainEventID string `json:"complain_event_id"` // 支付宝侧投诉单号
|
||||
ComplainNotifyAppID string `json:"complain_notify_app_id"` // 投诉消息通知的应用ID
|
||||
|
||||
Status string `json:"status"` // 投诉单状态,可能的枚举值如下(用Go语法注释):
|
||||
/*
|
||||
MERCHANT_PROCESSING // 待处理
|
||||
MERCHANT_FEEDBACKED // 已处理
|
||||
FINISHED // 投诉完结
|
||||
CANCELLED // 投诉关闭
|
||||
PLATFORM_PROCESSING // 客服处理中
|
||||
PLATFORM_FINISH // 客服处理完结
|
||||
CLOSED // 投诉关闭
|
||||
*/
|
||||
BizType string `json:"biz_type"` // 业务类型
|
||||
OrderID string `json:"order_id"` // 订单ID
|
||||
}
|
||||
|
||||
// SecurityRiskComplaintsNotifyContent 安全风险投诉商户通知的 biz_content 内容
|
||||
type SecurityRiskComplaintsNotifyContent struct {
|
||||
ComplaintID string `json:"complaint_id"` // 投诉ID
|
||||
MessageType string `json:"message_type"` // 消息类型,可能的枚举值如下(用Go语法注释):
|
||||
/*
|
||||
USER_REPLY // 用户回复
|
||||
MERCHANT_REPLY // 商户回复
|
||||
SYSTEM_NOTIFY // 系统通知
|
||||
*/
|
||||
ReplyContent string `json:"reply_content"` // 回复内容
|
||||
ReplyTime string `json:"reply_time"` // 回复时间,格式:YYYY-MM-DD HH:mm:ss
|
||||
}
|
||||
|
||||
func (l *AlipayFromLogic) AlipayFrom(w http.ResponseWriter, r *http.Request) error {
|
||||
// 1. 解析表单
|
||||
err := r.ParseForm()
|
||||
if err != nil {
|
||||
logx.Errorf("支付宝from消息回调,解析表单失败: %v", err)
|
||||
// 保存失败记录
|
||||
l.saveCallbackRecord(r, "", "", "failed", "解析表单失败: "+err.Error())
|
||||
return nil
|
||||
}
|
||||
|
||||
// 获取基本信息
|
||||
appID := r.Form.Get("app_id")
|
||||
msgMethod := r.Form.Get("msg_method")
|
||||
|
||||
// 2. 验签
|
||||
client := l.svcCtx.AlipayService.AlipayClient
|
||||
if err := client.VerifySign(r.Form); err != nil {
|
||||
logx.Errorf("支付宝from消息回调,验签失败: %v", err)
|
||||
// 保存失败记录
|
||||
l.saveCallbackRecord(r, appID, msgMethod, "failed", "验签失败: "+err.Error())
|
||||
return nil
|
||||
}
|
||||
|
||||
// 3. 验证 app_id
|
||||
if appID == "" {
|
||||
logx.Errorf("支付宝from消息回调,app_id为空")
|
||||
// 保存失败记录
|
||||
l.saveCallbackRecord(r, appID, msgMethod, "failed", "app_id为空")
|
||||
return nil
|
||||
}
|
||||
if appID != l.svcCtx.Config.Alipay.AppID {
|
||||
logx.Errorf("支付宝from消息回调,app_id不匹配,期望: %s, 实际: %s", l.svcCtx.Config.Alipay.AppID, appID)
|
||||
// 保存失败记录
|
||||
l.saveCallbackRecord(r, appID, msgMethod, "failed", "app_id不匹配")
|
||||
return nil
|
||||
}
|
||||
|
||||
// 4. 获取 msg_method 判断业务类型
|
||||
if msgMethod == "" {
|
||||
logx.Errorf("支付宝from消息回调,msg_method为空")
|
||||
// 保存失败记录
|
||||
l.saveCallbackRecord(r, appID, msgMethod, "failed", "msg_method为空")
|
||||
return nil
|
||||
}
|
||||
|
||||
// 5. 先保存回调记录(pending状态)
|
||||
callbackID := l.saveCallbackRecord(r, appID, msgMethod, "pending", "")
|
||||
if callbackID == "" {
|
||||
logx.Errorf("支付宝from消息回调,保存回调记录失败")
|
||||
// 即使保存失败也继续处理,避免影响业务
|
||||
}
|
||||
|
||||
// 6. 根据 msg_method 路由到对应的处理函数
|
||||
var handleErr error
|
||||
switch msgMethod {
|
||||
case "alipay.merchant.tradecomplain.changed":
|
||||
// 交易投诉通知回调
|
||||
handleErr = l.handleTradeComplainChanged(w, r, callbackID)
|
||||
case "alipay.security.risk.complaints.merchants.notify":
|
||||
// 安全风险投诉商户通知回调
|
||||
handleErr = l.handleSecurityRiskComplaintsNotify(w, r, callbackID)
|
||||
default:
|
||||
logx.Infof("支付宝from消息回调,未处理的msg_method: %s", msgMethod)
|
||||
// 更新为已处理(未处理的也标记为已处理)
|
||||
if callbackID != "" {
|
||||
l.updateCallbackStatus(callbackID, "processed", "")
|
||||
}
|
||||
alipay.ACKNotification(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 7. 根据处理结果更新状态
|
||||
if callbackID != "" {
|
||||
if handleErr != nil {
|
||||
l.updateCallbackStatus(callbackID, "failed", handleErr.Error())
|
||||
} else {
|
||||
l.updateCallbackStatus(callbackID, "processed", "")
|
||||
}
|
||||
}
|
||||
|
||||
return handleErr
|
||||
}
|
||||
|
||||
// saveCallbackRecord 保存回调记录到数据库
|
||||
func (l *AlipayFromLogic) saveCallbackRecord(r *http.Request, appID, msgMethod, status, errorMsg string) string {
|
||||
callback := &model.AlipayFromCallback{
|
||||
Id: uuid.NewString(),
|
||||
MsgMethod: msgMethod,
|
||||
AppId: appID,
|
||||
NotifyId: lzUtils.StringToNullString(r.Form.Get("notify_id")),
|
||||
BizContent: r.Form.Get("biz_content"),
|
||||
Status: status,
|
||||
ErrorMessage: lzUtils.StringToNullString(errorMsg),
|
||||
}
|
||||
|
||||
_, err := l.svcCtx.AlipayFromCallbackModel.Insert(l.ctx, nil, callback)
|
||||
if err != nil {
|
||||
logx.Errorf("保存支付宝from回调记录失败: %v", err)
|
||||
return ""
|
||||
}
|
||||
|
||||
return callback.Id
|
||||
}
|
||||
|
||||
// updateCallbackStatus 更新回调记录状态
|
||||
func (l *AlipayFromLogic) updateCallbackStatus(callbackID, status, errorMsg string) {
|
||||
callback, err := l.svcCtx.AlipayFromCallbackModel.FindOne(l.ctx, callbackID)
|
||||
if err != nil {
|
||||
logx.Errorf("查找支付宝from回调记录失败: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
callback.Status = status
|
||||
if errorMsg != "" {
|
||||
callback.ErrorMessage = lzUtils.StringToNullString(errorMsg)
|
||||
}
|
||||
|
||||
err = l.svcCtx.AlipayFromCallbackModel.UpdateWithVersion(l.ctx, nil, callback)
|
||||
if err != nil {
|
||||
logx.Errorf("更新支付宝from回调记录状态失败: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// handleTradeComplainChanged 处理交易投诉通知回调
|
||||
func (l *AlipayFromLogic) handleTradeComplainChanged(w http.ResponseWriter, r *http.Request, callbackID string) error {
|
||||
// 获取 biz_content
|
||||
bizContent := r.Form.Get("biz_content")
|
||||
if bizContent == "" {
|
||||
logx.Errorf("支付宝交易投诉通知回调,biz_content为空")
|
||||
return nil
|
||||
}
|
||||
|
||||
// 解析 biz_content JSON
|
||||
var content TradeComplainContent
|
||||
if err := json.Unmarshal([]byte(bizContent), &content); err != nil {
|
||||
logx.Errorf("支付宝交易投诉通知回调,解析biz_content失败: %v, content: %s", err, bizContent)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 记录日志
|
||||
logx.Infof("支付宝交易投诉通知回调,投诉事件ID: %s, 订单ID: %s, 状态: %s, 业务类型: %s",
|
||||
content.ComplainEventID, content.OrderID, content.Status, content.BizType)
|
||||
|
||||
// TODO: 后续在这里添加具体的业务处理逻辑
|
||||
// 例如:根据订单ID查找订单,更新订单状态,发送通知等
|
||||
|
||||
alipay.ACKNotification(w)
|
||||
return nil
|
||||
}
|
||||
|
||||
// handleSecurityRiskComplaintsNotify 处理安全风险投诉商户通知回调
|
||||
func (l *AlipayFromLogic) handleSecurityRiskComplaintsNotify(w http.ResponseWriter, r *http.Request, callbackID string) error {
|
||||
// 获取 biz_content
|
||||
bizContent := r.Form.Get("biz_content")
|
||||
if bizContent == "" {
|
||||
logx.Errorf("支付宝安全风险投诉商户通知回调,biz_content为空")
|
||||
return nil
|
||||
}
|
||||
|
||||
// 解析 biz_content JSON
|
||||
var content SecurityRiskComplaintsNotifyContent
|
||||
if err := json.Unmarshal([]byte(bizContent), &content); err != nil {
|
||||
logx.Errorf("支付宝安全风险投诉商户通知回调,解析biz_content失败: %v, content: %s", err, bizContent)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 记录日志
|
||||
logx.Infof("支付宝安全风险投诉商户通知回调,投诉ID: %s, 消息类型: %s, 回复内容: %s, 回复时间: %s",
|
||||
content.ComplaintID, content.MessageType, content.ReplyContent, content.ReplyTime)
|
||||
|
||||
// 根据投诉ID查询详情并更新投诉记录
|
||||
if err := l.svcCtx.AlipayComplaintService.QueryComplaintByTaskId(l.ctx, content.ComplaintID); err != nil {
|
||||
logx.Errorf("查询并更新投诉记录失败, complaint_id: %s, error: %v", content.ComplaintID, err)
|
||||
// 即使失败也返回成功,避免支付宝重复通知
|
||||
}
|
||||
|
||||
alipay.ACKNotification(w)
|
||||
return nil
|
||||
}
|
||||
@@ -39,6 +39,18 @@ func (l *PaymentCheckLogic) PaymentCheck(req *types.PaymentCheckReq) (resp *type
|
||||
}, nil
|
||||
}
|
||||
|
||||
if strings.HasPrefix(req.OrderNo, "W_") {
|
||||
// 白名单订单
|
||||
order, err := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, req.OrderNo)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询白名单订单失败: %v", err)
|
||||
}
|
||||
return &types.PaymentCheckResp{
|
||||
Type: "whitelist",
|
||||
Status: order.Status,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 查询订单(包括代理订单)
|
||||
order, err := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, req.OrderNo)
|
||||
if err != nil {
|
||||
|
||||
@@ -53,6 +53,27 @@ func (l *PaymentLogic) Payment(req *types.PaymentReq) (resp *types.PaymentResp,
|
||||
isDevTestPayment := env == "development" && (req.PayMethod == "test" || req.PayMethod == "test_empty")
|
||||
isEmptyReportMode := env == "development" && req.PayMethod == "test_empty"
|
||||
|
||||
// 微信小程序:若未绑定 openid 但前端传了 code,则用 code 换取 openid 并写入 user_auth,以便 CreateWechatOrder 能拿到 openid 并返回 prepay_data
|
||||
if req.PayMethod == "wechat" && req.Code != "" {
|
||||
platformVal := l.ctx.Value("platform")
|
||||
platform, _ := platformVal.(string)
|
||||
if platform == model.PlatformWxMini {
|
||||
userID, getUidErr := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if getUidErr == nil {
|
||||
_, findErr := l.svcCtx.UserAuthModel.FindOneByUserIdAuthType(l.ctx, userID, model.UserAuthTypeWxMiniOpenID)
|
||||
if findErr != nil {
|
||||
openid, codeErr := l.svcCtx.VerificationService.GetWechatMiniOpenID(l.ctx, req.Code)
|
||||
if codeErr == nil {
|
||||
ua := &model.UserAuth{Id: uuid.NewString(), UserId: userID, AuthType: model.UserAuthTypeWxMiniOpenID, AuthKey: openid}
|
||||
if _, insertErr := l.svcCtx.UserAuthModel.Insert(l.ctx, nil, ua); insertErr != nil {
|
||||
logx.Infof("支付前绑定 openid 写入失败(可忽略): %v", insertErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
l.svcCtx.OrderModel.Trans(l.ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||
switch req.PayType {
|
||||
case "agent_vip":
|
||||
@@ -72,6 +93,11 @@ func (l *PaymentLogic) Payment(req *types.PaymentReq) (resp *types.PaymentResp,
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case "whitelist":
|
||||
paymentTypeResp, err = l.WhitelistOrderPayment(req, session)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// 开发环境测试支付模式:跳过实际支付流程
|
||||
@@ -182,6 +208,37 @@ func (l *PaymentLogic) Payment(req *types.PaymentReq) (resp *types.PaymentResp,
|
||||
} else {
|
||||
logx.Infof("开发测试模式,代理升级成功,订单号: %s, 代理ID: %s", paymentTypeResp.outTradeNo, upgradeRecord.AgentId)
|
||||
}
|
||||
} else if strings.HasPrefix(paymentTypeResp.outTradeNo, "W_") {
|
||||
// 白名单订单:更新白名单订单状态并处理白名单记录
|
||||
whitelistOrder, findWhitelistErr := l.svcCtx.WhitelistOrderModel.FindOneByOrderNo(context.Background(), paymentTypeResp.outTradeNo)
|
||||
if findWhitelistErr != nil {
|
||||
logx.Errorf("开发测试模式,查找白名单订单失败,订单号: %s, 错误: %+v", paymentTypeResp.outTradeNo, findWhitelistErr)
|
||||
return
|
||||
}
|
||||
|
||||
// 更新白名单订单状态为已支付并处理白名单记录
|
||||
err := l.svcCtx.WhitelistOrderModel.Trans(context.Background(), func(transCtx context.Context, session sqlx.Session) error {
|
||||
// 更新白名单订单状态为已支付
|
||||
whitelistOrder.Status = 2 // 已支付
|
||||
now := time.Now()
|
||||
whitelistOrder.PayTime = sql.NullTime{Time: now, Valid: true}
|
||||
if updateErr := l.svcCtx.WhitelistOrderModel.UpdateWithVersion(transCtx, session, whitelistOrder); updateErr != nil {
|
||||
return errors.Wrapf(updateErr, "更新白名单订单状态失败")
|
||||
}
|
||||
|
||||
// 调用 WhitelistService 处理白名单记录
|
||||
if processErr := l.svcCtx.WhitelistService.ProcessPaidWhitelistOrder(transCtx, session, order, whitelistOrder); processErr != nil {
|
||||
return errors.Wrapf(processErr, "处理白名单订单失败")
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
logx.Errorf("开发测试模式,处理白名单订单失败,订单号: %s, 错误: %+v", paymentTypeResp.outTradeNo, err)
|
||||
} else {
|
||||
logx.Infof("开发测试模式,白名单订单支付成功,订单号: %s", paymentTypeResp.outTradeNo)
|
||||
}
|
||||
} else {
|
||||
// 查询订单:发送支付成功通知任务,触发后续流程(生成报告和代理处理)
|
||||
if sendErr := l.svcCtx.AsynqService.SendQueryTask(finalOrderID); sendErr != nil {
|
||||
@@ -202,6 +259,181 @@ func (l *PaymentLogic) Payment(req *types.PaymentReq) (resp *types.PaymentResp,
|
||||
}
|
||||
}
|
||||
|
||||
// WhitelistOrderPayment 白名单下架支付订单
|
||||
// PaymentReq.Id 支持两种格式:
|
||||
// 1. "{idCard}|{featureApiId}" - 单个模块下架(创建新订单)
|
||||
// 2. 订单号(以 W_ 开头) - 批量订单支付(使用已存在的订单)
|
||||
func (l *PaymentLogic) WhitelistOrderPayment(req *types.PaymentReq, session sqlx.Session) (resp *PaymentTypeResp, err error) {
|
||||
userID, err := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "生成白名单订单, 获取用户信息失败, %v", err)
|
||||
}
|
||||
|
||||
// 判断是订单号还是 "{idCard}|{featureApiId}" 格式
|
||||
var whitelistOrder *model.WhitelistOrder
|
||||
var orderNo string
|
||||
var amount float64
|
||||
var description string
|
||||
|
||||
if strings.HasPrefix(req.Id, "W_") {
|
||||
// 格式2:订单号,使用已存在的批量订单
|
||||
orderNo = req.Id
|
||||
whitelistOrder, err = l.svcCtx.WhitelistOrderModel.FindOneByOrderNo(l.ctx, orderNo)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("白名单订单不存在"), "")
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询白名单订单失败: %v", err)
|
||||
}
|
||||
|
||||
// 验证订单状态和用户
|
||||
if whitelistOrder.Status != 1 {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("订单状态不正确,无法支付"), "")
|
||||
}
|
||||
if whitelistOrder.UserId != userID {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("无权支付此订单"), "")
|
||||
}
|
||||
|
||||
amount = whitelistOrder.TotalAmount
|
||||
description = "模块屏蔽(批量)"
|
||||
|
||||
// 获取用户信息(用于内部用户测试金额)
|
||||
user, err := l.svcCtx.UserModel.FindOne(l.ctx, userID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "获取用户信息失败: %v", err)
|
||||
}
|
||||
if user.Inside == 1 {
|
||||
amount = 0.01
|
||||
}
|
||||
|
||||
// 检查是否已存在支付订单(Order表)
|
||||
existingOrder, findErr := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, orderNo)
|
||||
if findErr == nil && existingOrder != nil {
|
||||
// 已存在支付订单,直接使用
|
||||
return &PaymentTypeResp{
|
||||
amount: amount,
|
||||
outTradeNo: orderNo,
|
||||
description: description,
|
||||
orderID: existingOrder.Id,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 创建主订单记录(用于支付系统)
|
||||
order := model.Order{
|
||||
Id: uuid.NewString(),
|
||||
OrderNo: orderNo,
|
||||
UserId: userID,
|
||||
ProductId: "", // 白名单订单没有具体产品ID
|
||||
PaymentPlatform: req.PayMethod,
|
||||
PaymentScene: "app", // 白名单订单,使用简短标识
|
||||
Amount: amount,
|
||||
Status: "pending",
|
||||
}
|
||||
if _, insertOrderErr := l.svcCtx.OrderModel.Insert(l.ctx, session, &order); insertOrderErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "创建支付订单失败: %+v", insertOrderErr)
|
||||
}
|
||||
|
||||
return &PaymentTypeResp{
|
||||
amount: amount,
|
||||
outTradeNo: orderNo,
|
||||
description: description,
|
||||
orderID: order.Id,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 格式1:"{idCard}|{featureApiId}" - 单个模块下架
|
||||
parts := strings.SplitN(req.Id, "|", 2)
|
||||
if len(parts) != 2 {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("参数错误:id 格式不正确,应为订单号(W_开头)或 {idCard}|{featureApiId}"), "")
|
||||
}
|
||||
idCard := parts[0]
|
||||
featureApiId := parts[1]
|
||||
|
||||
if idCard == "" || featureApiId == "" {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("参数错误:身份证号或模块标识为空"), "")
|
||||
}
|
||||
|
||||
// 查询 feature 信息
|
||||
feature, err := l.svcCtx.FeatureModel.FindOneByApiId(l.ctx, featureApiId)
|
||||
if err != nil {
|
||||
if errors.Is(err, model.ErrNotFound) {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("模块不存在"), "")
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "生成白名单订单, 查询模块失败: %v", err)
|
||||
}
|
||||
|
||||
amount = feature.WhitelistPrice
|
||||
if amount <= 0 {
|
||||
return nil, errors.Wrapf(xerr.NewErrMsg("该模块无需付费下架"), "")
|
||||
}
|
||||
|
||||
// 获取用户信息(用于内部用户测试金额)
|
||||
user, err := l.svcCtx.UserModel.FindOne(l.ctx, userID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "生成白名单订单, 获取用户信息失败: %v", err)
|
||||
}
|
||||
if user.Inside == 1 {
|
||||
amount = 0.01
|
||||
}
|
||||
|
||||
// 生成订单号(白名单订单前缀 W_,限制长度不超过32)
|
||||
base := l.svcCtx.AlipayService.GenerateOutTradeNo()
|
||||
outTradeNo := "W_" + base
|
||||
if len(outTradeNo) > 32 {
|
||||
outTradeNo = outTradeNo[:32]
|
||||
}
|
||||
|
||||
// 创建主订单记录(用于支付系统)
|
||||
order := model.Order{
|
||||
Id: uuid.NewString(),
|
||||
OrderNo: outTradeNo,
|
||||
UserId: userID,
|
||||
ProductId: "", // 白名单订单没有具体产品ID
|
||||
PaymentPlatform: req.PayMethod,
|
||||
PaymentScene: "app", // 白名单订单,使用简短标识
|
||||
Amount: amount,
|
||||
Status: "pending",
|
||||
}
|
||||
if _, insertOrderErr := l.svcCtx.OrderModel.Insert(l.ctx, session, &order); insertOrderErr != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "生成白名单订单, 保存订单失败: %+v", insertOrderErr)
|
||||
}
|
||||
|
||||
// 创建白名单订单(业务订单,状态=待支付)
|
||||
whitelistOrder = &model.WhitelistOrder{
|
||||
Id: uuid.NewString(),
|
||||
OrderNo: outTradeNo,
|
||||
UserId: userID,
|
||||
IdCard: idCard,
|
||||
TotalAmount: amount,
|
||||
Status: 1, // 待支付
|
||||
}
|
||||
if _, err := l.svcCtx.WhitelistOrderModel.Insert(l.ctx, session, whitelistOrder); err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "生成白名单订单, 保存白名单订单失败: %+v", err)
|
||||
}
|
||||
|
||||
// 创建白名单订单明细
|
||||
orderItem := &model.WhitelistOrderItem{
|
||||
Id: uuid.NewString(),
|
||||
OrderId: whitelistOrder.Id,
|
||||
FeatureId: feature.Id,
|
||||
FeatureApiId: feature.ApiId,
|
||||
FeatureName: feature.Name,
|
||||
Price: amount,
|
||||
}
|
||||
if _, err := l.svcCtx.WhitelistOrderItemModel.Insert(l.ctx, session, orderItem); err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "生成白名单订单, 保存白名单订单明细失败: %+v", err)
|
||||
}
|
||||
|
||||
description = fmt.Sprintf("模块下架:%s", feature.Name)
|
||||
|
||||
return &PaymentTypeResp{
|
||||
amount: amount,
|
||||
outTradeNo: outTradeNo,
|
||||
description: description,
|
||||
orderID: order.Id,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (l *PaymentLogic) QueryOrderPayment(req *types.PaymentReq, session sqlx.Session) (resp *PaymentTypeResp, err error) {
|
||||
userID, getUidErr := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if getUidErr != nil {
|
||||
|
||||
@@ -45,6 +45,9 @@ func (l *WechatPayCallbackLogic) WechatPayCallback(w http.ResponseWriter, r *htt
|
||||
} else if strings.HasPrefix(orderNo, "U_") {
|
||||
// 代理升级订单处理
|
||||
return l.handleAgentUpgradeOrderPayment(w, notification)
|
||||
} else if strings.HasPrefix(orderNo, "W_") {
|
||||
// 白名单下架订单处理
|
||||
return l.handleWhitelistOrderPayment(w, notification)
|
||||
} else if strings.HasPrefix(orderNo, "A_") {
|
||||
// 旧系统会员充值订单(已废弃,新系统使用升级功能)
|
||||
// return l.handleAgentVipOrderPayment(w, notification)
|
||||
@@ -109,6 +112,91 @@ func (l *WechatPayCallbackLogic) handleQueryOrderPayment(w http.ResponseWriter,
|
||||
return nil
|
||||
}
|
||||
|
||||
// 处理白名单下架订单支付
|
||||
func (l *WechatPayCallbackLogic) handleWhitelistOrderPayment(w http.ResponseWriter, notification *payments.Transaction) error {
|
||||
orderNo := *notification.OutTradeNo
|
||||
|
||||
// 1. 查找订单
|
||||
order, findOrderErr := l.svcCtx.OrderModel.FindOneByOrderNo(l.ctx, orderNo)
|
||||
if findOrderErr != nil {
|
||||
logx.Errorf("微信白名单支付回调,查找订单信息失败: %+v", findOrderErr)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 2. 验证金额
|
||||
amount := lzUtils.ToWechatAmount(order.Amount)
|
||||
if amount != *notification.Amount.Total {
|
||||
logx.Errorf("微信白名单支付回调,金额不一致")
|
||||
return nil
|
||||
}
|
||||
|
||||
// 3. 检查订单状态
|
||||
if order.Status != "pending" {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write([]byte("success"))
|
||||
return nil
|
||||
}
|
||||
|
||||
// 4. 查找白名单订单
|
||||
whitelistOrder, findWhitelistErr := l.svcCtx.WhitelistOrderModel.FindOneByOrderNo(l.ctx, orderNo)
|
||||
if findWhitelistErr != nil {
|
||||
logx.Errorf("微信白名单支付回调,查找白名单订单失败,订单号: %s, 错误: %+v", orderNo, findWhitelistErr)
|
||||
return nil
|
||||
}
|
||||
if whitelistOrder.Status != 1 {
|
||||
// 白名单订单状态不是待支付,直接返回成功
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write([]byte("success"))
|
||||
return nil
|
||||
}
|
||||
|
||||
// 5. 处理支付状态
|
||||
switch *notification.TradeState {
|
||||
case service.TradeStateSuccess:
|
||||
order.Status = "paid"
|
||||
order.PayTime = lzUtils.TimeToNullTime(time.Now())
|
||||
order.PlatformOrderId = lzUtils.StringToNullString(*notification.TransactionId)
|
||||
whitelistOrder.Status = 2 // 已支付
|
||||
whitelistOrder.PayTime = lzUtils.TimeToNullTime(time.Now())
|
||||
case service.TradeStateClosed:
|
||||
order.Status = "closed"
|
||||
order.CloseTime = lzUtils.TimeToNullTime(time.Now())
|
||||
whitelistOrder.Status = 3 // 已取消
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
||||
// 6. 更新订单和白名单订单 + 创建白名单记录并删除报告数据
|
||||
err := l.svcCtx.WhitelistOrderModel.Trans(l.ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||
// 6.1 更新订单状态
|
||||
if updateErr := l.svcCtx.OrderModel.UpdateWithVersion(ctx, session, order); updateErr != nil {
|
||||
return errors.Wrapf(updateErr, "微信白名单支付回调,更新订单状态失败")
|
||||
}
|
||||
|
||||
// 6.2 更新白名单订单状态
|
||||
if updateErr := l.svcCtx.WhitelistOrderModel.UpdateWithVersion(ctx, session, whitelistOrder); updateErr != nil {
|
||||
return errors.Wrapf(updateErr, "微信白名单支付回调,更新白名单订单状态失败")
|
||||
}
|
||||
|
||||
// 6.3 如果支付成功,调用 WhitelistService 处理白名单和报告数据
|
||||
if whitelistOrder.Status == 2 {
|
||||
if processErr := l.svcCtx.WhitelistService.ProcessPaidWhitelistOrder(ctx, session, order, whitelistOrder); processErr != nil {
|
||||
return errors.Wrapf(processErr, "微信白名单支付回调,处理白名单订单失败")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
logx.Errorf("微信白名单支付回调,事务处理失败: %+v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write([]byte("success"))
|
||||
return nil
|
||||
}
|
||||
|
||||
// 处理代理升级订单支付
|
||||
func (l *WechatPayCallbackLogic) handleAgentUpgradeOrderPayment(w http.ResponseWriter, notification *payments.Transaction) error {
|
||||
orderNo := *notification.OutTradeNo
|
||||
|
||||
@@ -114,6 +114,21 @@ func (l *WechatPayRefundCallbackLogic) handleQueryOrderRefund(orderNo string, st
|
||||
return errors.Wrapf(err, "更新订单和退款记录失败: %s", orderNo)
|
||||
}
|
||||
|
||||
// 退款成功后,检查并处理代理订单(在事务外执行,避免影响退款流程)
|
||||
if status == refunddomestic.STATUS_SUCCESS {
|
||||
// 检查代理订单是否已处理
|
||||
agentOrder, err := l.svcCtx.AgentOrderModel.FindOneByOrderId(l.ctx, order.Id)
|
||||
if err == nil && agentOrder != nil && agentOrder.ProcessStatus == 1 {
|
||||
// 代理订单已处理,需要撤销收益
|
||||
if cancelErr := l.svcCtx.AgentService.CancelAgentCommission(l.ctx, order.Id); cancelErr != nil {
|
||||
logx.Errorf("撤销代理收益失败,订单ID: %s, 错误: %v", order.Id, cancelErr)
|
||||
// 不阻断退款流程,只记录日志(退款已成功,不能回滚)
|
||||
} else {
|
||||
logx.Infof("成功撤销代理收益,订单ID: %s", order.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user