service

package
v1.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2026 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MetricOrderCreated = promauto.NewCounter(prometheus.CounterOpts{
		Name: "goshop_order_created_total",
		Help: "Total number of orders created",
	})
	MetricPaySuccess = promauto.NewCounter(prometheus.CounterOpts{
		Name: "goshop_pay_success_total",
		Help: "Total number of successful payments",
	})
	MetricPayTotal = promauto.NewCounter(prometheus.CounterOpts{
		Name: "goshop_pay_total",
		Help: "Total number of payment attempts (notify received)",
	})
	MetricRefundSuccess = promauto.NewCounter(prometheus.CounterOpts{
		Name: "goshop_refund_success_total",
		Help: "Total number of successful refunds",
	})
)

业务指标:下单/支付/退款计数器。 在关键路径上 Inc,Prometheus 抓取后可用于告警和 Dashboard。

View Source
var AppVersion = "dev"

AppVersion 由构建时 -ldflags 注入,默认 dev。

Functions

func AddBrowseHistory

func AddBrowseHistory(userID, goodsID uint)

func AddCart

func AddCart(userID uint, req *AddCartReq) (*model.Cart, error)

func AddErrorLog

func AddErrorLog(typ, content, url, ip string)

---- 错误日志 ----

func AddInventoryLog

func AddInventoryLog(orderID, goodsID, skuID uint, quantity int, typ, remark string)

库存变动日志

func AddOrderStatusHistory

func AddOrderStatusHistory(orderID uint, oldStatus, newStatus int8, msg, creator string)

---- 订单状态历史 ----

func AddOrderTraceSource

func AddOrderTraceSource(orderID, userID uint, source, params string)

---- 订单溯源 ----

func AddPayRequestLog

func AddPayRequestLog(payLogID uint, request, response, business string)

func AddSearchHistory

func AddSearchHistory(userID uint, keyword string)

func AdminDelete

func AdminDelete(id uint) error

func AdminDetail

func AdminDetail(id uint) (*model.Admin, error)

==================== Admin ====================

func AdminDisableUser added in v1.5.5

func AdminDisableUser(userID uint) error

AdminDisableUser 管理后台将用户设为禁用(不物理删除,保留订单等关联数据)。

func AdminGetAftersaleList

func AdminGetAftersaleList(page, pageSize int, status *int8) ([]model.OrderAftersale, int64, error)

func AdminOrderPayUnderLine

func AdminOrderPayUnderLine(orderID, adminID uint) error

AdminOrderPayUnderLine 管理员确认线下支付收款

func AdminOrderServiceList

func AdminOrderServiceList(status *int8, page, pageSize int) ([]model.OrderService, int64, error)

func AdminSave

func AdminSave(id uint, nickname string, roleID uint) error

func AftersaleAudit

func AftersaleAudit(asID uint) error

管理员审核通过(收到退货后)

func AftersaleCancel

func AftersaleCancel(userID, asID uint) error

func AftersaleConfirm

func AftersaleConfirm(asID uint) error

管理员确认(仅退款直接退,退货退款等用户发货)

func AftersaleCreate

func AftersaleCreate(userID uint, req *AftersaleCreateReq) (*model.OrderAftersale, error)

func AftersaleDelivery

func AftersaleDelivery(userID, asID uint, req *AftersaleDeliveryReq) error

func AftersaleRefuse

func AftersaleRefuse(asID uint, reason string) error

func AgreementGet

func AgreementGet(name string) *model.Agreement

---- 协议 ----

func AgreementSave

func AgreementSave(name, content string) error

func AlipayGatewayDoURL added in v1.6.0

func AlipayGatewayDoURL() string

AlipayGatewayDoURL 返回支付宝 OpenAPI 网关完整地址(以 /gateway.do 结尾)。 配置 alipay.gateway_url 可为沙箱(如 https://openapi.alipaydev.com/gateway.do)或自定义网关;仅填 origin 时自动补全 /gateway.do。

func AlipayQueryTrade added in v1.6.0

func AlipayQueryTrade(ctx context.Context, outTradeNo string) (tradeStatus, alipayTradeNo string, err error)

AlipayQueryTrade 调用官方 alipay.trade.query(商户订单号 out_trade_no)。同步响应经 RSA2 验签;网关地址见 alipay.gateway_url。

func AlipayTradePaid added in v1.6.0

func AlipayTradePaid(status string) bool

AlipayTradePaid 判断支付宝 trade.query 返回的 trade_status 是否表示已支付。

func AlipayUserAuth

func AlipayUserAuth(appID, code string) (string, error)

func AlipayVerifyGatewaySyncSign added in v1.6.0

func AlipayVerifyGatewaySyncSign(content, signBase64, publicKeyPEM string) bool

AlipayVerifyGatewaySyncSign 校验支付宝 OpenAPI 同步 JSON 中业务报文体(如 alipay_trade_query_response)的 RSA2 签名。 content 必须是网关响应里该字段的原文(解析为 json.RawMessage 后转 string),不得用 json.Marshal 重新序列化,避免字段顺序变化导致验签失败。

func AlipayVerifySign added in v1.5.0

func AlipayVerifySign(params map[string]string, publicKeyPEM string) bool

AlipayVerifySign 验证支付宝回调签名(RSA2-SHA256)

func AppAccountsBindVerifySendHandle

func AppAccountsBindVerifySendHandle(account, typ string) error

AppAccountsBindVerifySendHandle 绑定验证码发送处理

func AppAccountsBindhHandle

func AppAccountsBindhHandle(userID uint, platform, openID string) error

AppAccountsBindhHandle 账号绑定处理

func AppBaseConfig

func AppBaseConfig() map[string]string

func AppCenterNavCreate

func AppCenterNavCreate(n *model.AppCenterNav) error

func AppCenterNavDelete

func AppCenterNavDelete(id uint) error

func AppCenterNavList

func AppCenterNavList() ([]model.AppCenterNav, error)

func AppCenterNavStatusUpdate

func AppCenterNavStatusUpdate(id uint, status int8) error

==================== AppCenterNav ====================

func AppClientHomeDiyData

func AppClientHomeDiyData() map[string]interface{}

func AppClientHomeDiyId

func AppClientHomeDiyId() uint

func AppCustomerServiceConfig

func AppCustomerServiceConfig() map[string]string

func AppEmailBind

func AppEmailBind(userID uint, email, code string) error

AppEmailBind 邮箱绑定

func AppEmailBindVerifySend

func AppEmailBindVerifySend(email string) error

AppEmailBindVerifySend 邮箱绑定验证码

func AppHomeNavCreate

func AppHomeNavCreate(n *model.AppHomeNav) error

func AppHomeNavDelete

func AppHomeNavDelete(id uint) error

func AppHomeNavList

func AppHomeNavList() ([]model.AppHomeNav, error)

---- APP导航 ----

func AppHomeNavStatusUpdate

func AppHomeNavStatusUpdate(id uint, status int8) error

==================== AppHomeNav ====================

func AppMiniConfig

func AppMiniConfig(platform string) map[string]string

func AppMiniDetail

func AppMiniDetail(id uint) *model.AppMini

func AppMiniOnekeyUserMobileBind

func AppMiniOnekeyUserMobileBind(userID uint, mobile string) error

AppMiniOnekeyUserMobileBind 一键手机号绑定(小程序获取手机号)

func AppMiniUserInfo

func AppMiniUserInfo(userID uint, platform string) (*model.UserPlatform, error)

AppMiniUserInfo 获取各平台用户信息

func AppMobileBind

func AppMobileBind(userID uint, req *BindMobileReq) error

AppMobileBind 手机绑定(别名)

func AppMobileBindVerifySend

func AppMobileBindVerifySend(mobile string) error

AppMobileBindVerifySend 手机绑定验证码

func AppTabbarList

func AppTabbarList() ([]model.AppTabbar, error)

func AppTabbarSave

func AppTabbarSave(items []model.AppTabbar) error

func AppUserInfoHandle

func AppUserInfoHandle(user *model.User) map[string]interface{}

AppUserInfoHandle APP用户信息处理

func ApplyDistributor added in v1.5.0

func ApplyDistributor(userID, parentID uint) (*model.Distributor, error)

func AppointGoodsList

func AppointGoodsList(ids []uint) []model.Goods

AppointGoodsList 指定ID商品列表

func ArticleCategoryDelete

func ArticleCategoryDelete(id uint) error

func ArticleCategoryStatusUpdate

func ArticleCategoryStatusUpdate(id uint, status int8) error

==================== ArticleCategory ====================

func ArticleDeleteFull

func ArticleDeleteFull(id uint) error

func ArticleStatusUpdate

func ArticleStatusUpdate(id uint, status int8) error

==================== Article ====================

func ArticleTotal

func ArticleTotal(catID uint) int64

func AttachmentApiCategoryDelete

func AttachmentApiCategoryDelete(id uint) error

func AttachmentApiCategoryList

func AttachmentApiCategoryList() ([]model.AttachmentCategory, error)

func AttachmentApiCategorySave

func AttachmentApiCategorySave(name string) error

func AttachmentApiDelete

func AttachmentApiDelete(id uint) error

func AttachmentApiList

func AttachmentApiList(categoryID uint, page, pageSize int) ([]model.Attachment, int64, error)

func AttachmentApiSave

func AttachmentApiSave(a *model.Attachment) error

func AttachmentCategoryDelete

func AttachmentCategoryDelete(id uint) error

func AttachmentCategoryList

func AttachmentCategoryList() ([]model.AttachmentCategory, error)

func AttachmentCategorySave

func AttachmentCategorySave(id uint, name string) error

func AttachmentCategoryStatusUpdate

func AttachmentCategoryStatusUpdate(id uint, status int8) error

==================== AttachmentCategory ====================

func AttachmentDelete

func AttachmentDelete(id uint) error

==================== Attachment ====================

func AttachmentDetail

func AttachmentDetail(id uint) *model.Attachment

func AttachmentDiskFilesToDb

func AttachmentDiskFilesToDb(path, pathType string)

func AttachmentList

func AttachmentList(categoryID uint, page, pageSize int) ([]model.Attachment, int64, error)

---- 附件 ----

func AttachmentListHandle

func AttachmentListHandle(list []model.Attachment) []model.Attachment

func AttachmentSave

func AttachmentSave(a *model.Attachment) error

func AttachmentTotal

func AttachmentTotal(categoryID uint) int64

func AuditWithdraw added in v1.5.0

func AuditWithdraw(id uint, approve bool, reason string) error

AuditWithdraw 管理员审核提现。

  1. 通过 FOR UPDATE 行锁 + 事务保证单次性,避免并发双审;
  2. 拒绝分支整个退款流程(退余额 + 写流水 + 改状态)在同一事务内完成;
  3. Status != 0 直接返回 "已处理",实现幂等。

func AuthUserProgram

func AuthUserProgram(userID uint) bool

AuthUserProgram 用户授权程序

func AutoGoodsBrowseList

func AutoGoodsBrowseList(userID uint, limit int) []model.BrowseHistory

func AutoGoodsList

func AutoGoodsList(categoryID uint, orderBy string, limit int) []model.Goods

AutoGoodsList 自动商品列表(按条件)

func BaiduUserAuth

func BaiduUserAuth(appID, secret, code string) (string, error)

func BindMobile

func BindMobile(userID uint, req *BindMobileReq) error

func BookingConfirm

func BookingConfirm(orderID uint) error

BookingConfirm 管理员确认预约订单(从预约状态变为待支付)

func BottomNavigationData

func BottomNavigationData() []model.Navigation

func BrandCategoryDelete

func BrandCategoryDelete(id uint) error

==================== BrandCategory ====================

func BrandDeleteFull

func BrandDeleteFull(id uint) error

func BrandStatusUpdate

func BrandStatusUpdate(id uint, status int8) error

==================== Brand ====================

func BrandTotal

func BrandTotal() int64

func BuyDataDelete

func BuyDataDelete(userID uint)

func BuyDataRead

func BuyDataRead(userID uint) (map[string]interface{}, error)

func BuyDataStorage

func BuyDataStorage(userID uint, data interface{}) error

BuyDataStorage 购买数据临时存储(Redis)

func BuyDefaultPayment

func BuyDefaultPayment(platform string) uint

func BuyGoodsCheck

func BuyGoodsCheck(goodsID, skuID uint, quantity int) error

BuyGoodsCheck 购买前商品校验

func BuyOrderPayBeginGoodsCheck

func BuyOrderPayBeginGoodsCheck(cartIDs []uint, userID uint) error

func CacheLoginUserInfo

func CacheLoginUserInfo(userID uint) *model.User

CacheLoginUserInfo 缓存登录用户信息(Go用JWT无需session缓存)

func CacheUserTokenData

func CacheUserTokenData(userID uint) (string, error)

CacheUserTokenData 缓存Token数据

func CalcCouponDiscount

func CalcCouponDiscount(coupon *model.Coupon, orderAmount int64) (int64, error)

CalcCouponDiscount 计算优惠券抵扣金额

func CancelOrder

func CancelOrder(userID, orderID uint) error

func CategoryBrandList

func CategoryBrandList(categoryID uint) []model.Brand

CategoryBrandList 指定分类下的品牌列表

func CategoryGoodsList

func CategoryGoodsList(categoryID uint, page, pageSize int) ([]model.Goods, int64)

CategoryGoodsList 分类下商品列表

func CategoryGoodsTotal

func CategoryGoodsTotal(categoryID uint) int64

CategoryGoodsTotal 分类下商品总数

func ChangePoints

func ChangePoints(userID uint, points int, typ string, refID uint, remark string) error

ChangePoints 变动积分(通用方法)

func CheckPower

func CheckPower(roleID uint, power string) bool

func CheckVerifyCode

func CheckVerifyCode(account, code, typ string) error

CheckVerifyCode 校验验证码

func ClearBrowseHistory

func ClearBrowseHistory(userID uint) error

func ClearCache

func ClearCache(cacheType string) error

func ClearSearchHistory

func ClearSearchHistory(userID uint) error

func ConfigContentRow

func ConfigContentRow(key string) string

func ConfigInit

func ConfigInit()

func ConfigList

func ConfigList() ([]model.Config, error)

ConfigList 获取所有配置

func ConfigSave

func ConfigSave(key, value, group, desc string) error

func ConfirmReceive

func ConfirmReceive(userID, orderID uint) error

func CreateAddress

func CreateAddress(userID uint, req *AddressReq) (*model.Address, error)

func CreateAdmin

func CreateAdmin(req *CreateAdminReq) (*model.Admin, error)

func CreateAnswer

func CreateAnswer(userID uint, req *AnswerCreateReq) (*model.Answer, error)

func CreateArticle

func CreateArticle(req *ArticleReq) (*model.Article, error)

func CreateArticleCategory

func CreateArticleCategory(name string, sort int) (*model.ArticleCategory, error)

func CreateAttachmentCategory

func CreateAttachmentCategory(name string) error

func CreateBrand

func CreateBrand(name, logo, desc string, sort int) (*model.Brand, error)

func CreateBrandCategoryRecord

func CreateBrandCategoryRecord(name string, sort int) *model.BrandCategory

func CreateCategory

func CreateCategory(req *CategoryReq) (*model.Category, error)

func CreateCoupon

func CreateCoupon(req *CreateCouponReq) (*model.Coupon, error)

func CreateExpress

func CreateExpress(name, code, icon string, sort int) (*model.Express, error)

快递公司

func CreateGoods

func CreateGoods(req *CreateGoodsReq) (*model.Goods, error)

func CreateGroupBuy added in v1.5.0

func CreateGroupBuy(req *GroupBuyReq) (*model.Promotion, error)
func CreateLink(l *model.Link) error

func CreateNavigation

func CreateNavigation(n *model.Navigation) error

func CreateOrder

func CreateOrder(userID uint, req *CreateOrderReq) (*model.Order, error)

func CreateOrderReviewsShopXO added in v1.6.0

func CreateOrderReviewsShopXO(userID, orderID uint, goodsIDs []uint, ratings []int, contents, imageJSONs []string) error

CreateOrderReviewsShopXO 对应 shopxo-uniapp order/commentssave:按订单批量评价多商品。

func CreateOrderService

func CreateOrderService(orderID, userID uint, typ, content string) (*model.OrderService, error)

OrderService

func CreateParamsTemplate

func CreateParamsTemplate(req *ParamsTemplateReq) (*model.GoodsParamsTemplate, error)

func CreatePayLog

func CreatePayLog(userID uint, orderIDs []uint, paymentID uint, clientType string) (*model.PayLog, error)

CreatePayLog 创建支付日志(支持合并支付多个订单)。clientType 为渠道/来源标识(如 api、shopxo)。

func CreatePayment

func CreatePayment(p *model.Payment) error

func CreatePower

func CreatePower(parentID uint, name, control string, sort int) (*model.Power, error)

func CreatePromotion

func CreatePromotion(req *CreatePromotionReq) (*model.Promotion, error)

func CreateRefundLog

func CreateRefundLog(orderID, payLogID, userID uint, refundPrice int64, reason string) *model.RefundLog

CreateRefundLog 创建退款日志

func CreateReview

func CreateReview(userID uint, req *CreateReviewReq) (*model.Review, error)

func CreateRole

func CreateRole(req *RoleReq) (*model.Role, error)

func CreateSeckill added in v1.5.0

func CreateSeckill(req *SeckillReq) (*model.Promotion, error)

func CreateSlide

func CreateSlide(s *model.Slide) error

func CreateSpecTemplate

func CreateSpecTemplate(req *SpecTemplateReq) (*model.SpecTemplate, error)

func CreateWarehouse

func CreateWarehouse(req *WarehouseReq) (*model.Warehouse, error)

func CronGoodsGiveIntegral

func CronGoodsGiveIntegral(deps *app.Deps) (sucs, fail int)

CronGoodsGiveIntegral 商品赠送积分(订单完成后延迟赠送)

func CronIntegralRelease

func CronIntegralRelease(deps *app.Deps, limitMinutes int) (sucs, fail int)

CronIntegralRelease 定时释放锁定积分(赠送后N天释放)

func CronOrderAutoReceive

func CronOrderAutoReceive(deps *app.Deps, days int) (sucs, fail int)

CronOrderAutoReceive 自动确认收货(默认15天)

func CronOrderClose

func CronOrderClose(deps *app.Deps, minutes int) (sucs, fail int)

CronOrderClose 自动关闭超时未支付订单(默认30分钟)

func CronRefundReconcile added in v1.6.1

func CronRefundReconcile(deps *app.Deps) (sucs, fail int)

CronRefundReconcile 扫描长时间处于 "处理中"(status=0)的退款单,尝试恢复其本地落账。

场景:RefundOrder 第三步(事务化更新订单+回库存+标记 RefundLog=1)可能因进程崩溃或 DB 抖动 失败,此时第三方往往已退款成功,但本地订单仍是 Paid/Shipped。本 cron 的职责是:

  1. 订单已为 Refunded → RefundLog 只需刷新状态(历史原因的清理);
  2. 订单仍在 Paid/Shipped → 在事务内完成状态+库存更新并置 RefundLog=1;
  3. 状态异常(Cancelled/Completed 等)→ 保留 status=0,落 slog 告警;
  4. 超过 retentionHours 未恢复 → 落 WARN 告警,留待人工介入(不自动改为 2,避免误判)。

返回 sucs/fail:成功恢复数、告警计数(含 stuck 超时)。

func CustomViewCreate

func CustomViewCreate(title, content string) (*model.CustomView, error)

func CustomViewDelete

func CustomViewDelete(id uint) error

func CustomViewList

func CustomViewList() ([]model.CustomView, error)

---- 自定义页面 ----

func CustomViewStatusUpdate

func CustomViewStatusUpdate(id uint, status int8) error

==================== CustomView ====================

func CustomerServiceCustom added in v1.5.5

func CustomerServiceCustom() string

*

  • CustomerServiceCustom 读取客服自定义文案/链接等扩展配置。
  • 优先 common_app_customer_service_custom,回退 app_customer_service_custom。

func CustomerServiceTel added in v1.5.5

func CustomerServiceTel() string

*

  • CustomerServiceTel 读取客服电话,与 InitDefaultConfig 中 common_app_customer_service_tel 一致。
  • 若为空则回退 app_customer_service_tel(历史错误 key,兼容旧数据)。

func DefaultTheme

func DefaultTheme() *model.ThemeData

func DeleteAddress

func DeleteAddress(userID, addrID uint) error

func DeleteAnswer

func DeleteAnswer(id uint) error

func DeleteAppMini

func DeleteAppMini(id uint) error

func DeleteArticle

func DeleteArticle(id uint) error

func DeleteAttachment

func DeleteAttachment(id uint) error

func DeleteBrand

func DeleteBrand(id uint) error

func DeleteCart

func DeleteCart(userID uint, ids []uint) error

func DeleteExpress

func DeleteExpress(id uint) error

func DeleteOrder

func DeleteOrder(userID, orderID uint) error

订单软删除

func DeletePower

func DeletePower(id uint) error

func DeleteRole

func DeleteRole(id uint) error

func DeleteSpecTemplate

func DeleteSpecTemplate(id uint) error

func DeleteWarehouse

func DeleteWarehouse(id uint) error

func DesignAccessCountInc

func DesignAccessCountInc(id uint)

func DesignCreate

func DesignCreate(name, data string) (*model.Design, error)

func DesignDelete

func DesignDelete(id uint) error

func DesignDownload

func DesignDownload(id uint) (string, error)

func DesignList

func DesignList() ([]model.Design, error)

Design

func DesignSave

func DesignSave(id uint, name, data string) error

func DesignStatusUpdate

func DesignStatusUpdate(id uint, status int8) error

==================== Design ====================

func DesignSync

func DesignSync(id uint) error

func DesignUpdate

func DesignUpdate(id uint, data string) error

func DesignUpload

func DesignUpload(zipPath string) (uint, error)

func DiyAccessCountInc

func DiyAccessCountInc(id uint)

func DiyApiArticleAutoData

func DiyApiArticleAutoData(categoryID uint, limit int) ([]model.Article, error)

func DiyApiBrandAutoData

func DiyApiBrandAutoData(limit int) ([]model.Brand, error)

func DiyApiCustomInit

func DiyApiCustomInit(diyID uint) (map[string]interface{}, error)

DiyApiCustomInit DIY自定义组件初始化

func DiyApiGoodsAutoData

func DiyApiGoodsAutoData(p *DiyApiParams) ([]model.Goods, error)

func DiyApiGoodsBrowseAutoData

func DiyApiGoodsBrowseAutoData(userID uint, limit int) ([]model.BrowseHistory, error)

func DiyApiGoodsFavorAutoData

func DiyApiGoodsFavorAutoData(userID uint, limit int) ([]model.Favorite, error)

func DiyApiUserHeadData

func DiyApiUserHeadData(userID uint) map[string]int64

DiyApiUserHeadData 用户头部数据(消息数+购物车数+收藏数)

func DiyCreate

func DiyCreate(name, data string) (*model.Diy, error)

func DiyData

func DiyData(id uint) *model.Diy

func DiyDelete

func DiyDelete(id uint) error

func DiyDownload

func DiyDownload(id uint) (string, error)

func DiyList

func DiyList() ([]model.Diy, error)

---- DIY ----

func DiyPreviewData

func DiyPreviewData(id uint) map[string]interface{}

func DiySave

func DiySave(id uint, name, data string) error

func DiyStatusUpdate

func DiyStatusUpdate(id uint, status int8) error

==================== Diy ====================

func DiyUpdate

func DiyUpdate(id uint, data string) error

func DiyUpload

func DiyUpload(zipPath string) (uint, error)

func EmailLogAdd

func EmailLogAdd(email, title, content string, status int8)

func EmailLogAllDelete

func EmailLogAllDelete() error

func EmailLogDelete

func EmailLogDelete(ids []uint) error

func EmailLogList

func EmailLogList(page, pageSize int) ([]model.EmailLog, int64, error)

func ErrorLogAllDelete

func ErrorLogAllDelete() error

func ErrorLogDelete

func ErrorLogDelete(ids []uint) error

==================== ErrorLog ====================

func ExchangePoints

func ExchangePoints(userID uint, points int) (int64, error)

ExchangePoints 积分抵扣(100积分=1元)

func ExecuteSQL

func ExecuteSQL(sqlStr string) ([]map[string]interface{}, error)

func ExportData

func ExportData(w io.Writer, req *ExportReq) error

func ExpressDelete

func ExpressDelete(id uint) error

func ExpressDetail

func ExpressDetail(id uint) *model.Express

func ExpressSave

func ExpressSave(e *model.Express) error

func ExpressStatusUpdate

func ExpressStatusUpdate(id uint, status int8) error

==================== Express ====================

func ForgetPassword

func ForgetPassword(req *ForgetPwdReq) error

func ForgetPwd

func ForgetPwd(req *ForgetPwdReq) error

ForgetPwd 忘记密码(别名)

func ForgetPwdVerifySend

func ForgetPwdVerifySend(account string) error

ForgetPwdVerifySend 忘记密码验证码发送

func FormInputApiDelete

func FormInputApiDelete(id, userID uint) error

FormInputApiDelete Form表单API删除数据

func FormInputApiDetail

func FormInputApiDetail(id uint) (*model.FormInput, error)

FormInputApiDetail Form表单API详情

func FormInputApiList

func FormInputApiList(page, pageSize int) ([]model.FormInput, int64, error)

FormInputApiList Form表单API列表

func FormInputApiSave

func FormInputApiSave(formID, userID uint, data string) error

FormInputApiSave Form表单API保存数据

func FormInputCreate

func FormInputCreate(name, config string) error

func FormInputDataDetailForUser added in v1.6.0

func FormInputDataDetailForUser(userID, rowID uint) (map[string]interface{}, error)

FormInputDataDetailForUser shopxo-uniapp forminputdata/detail:单条提交记录 + 字段定义。

func FormInputDataList

func FormInputDataList(formID uint, page, pageSize int) ([]model.FormInputData, int64, error)

func FormInputDataSubmit

func FormInputDataSubmit(formID, userID uint, data string) error

func FormInputDelete

func FormInputDelete(id uint) error

func FormInputDetail

func FormInputDetail(id uint) *model.FormInput

func FormInputDownload

func FormInputDownload(id uint) (string, error)

FormInput zip导入导出

func FormInputList

func FormInputList() ([]model.FormInput, error)

---- 表单 ----

func FormInputPreview

func FormInputPreview(id uint) map[string]interface{}

func FormInputStatusUpdate

func FormInputStatusUpdate(id uint, status int8) error

==================== FormInput ====================

func FormInputUpload

func FormInputUpload(zipPath string) error

func FormTableQuery

func FormTableQuery(p *FormTableParams) (int64, []map[string]interface{}, error)

func GenerateQRCodeURL

func GenerateQRCodeURL(content string) string

func GetActiveGroupBuys added in v1.5.0

func GetActiveGroupBuys() ([]model.Promotion, error)

func GetActivePromotions

func GetActivePromotions() ([]model.Promotion, error)

func GetActiveSeckills added in v1.5.0

func GetActiveSeckills() ([]model.Promotion, error)

func GetAddress added in v1.5.5

func GetAddress(userID, addrID uint) (*model.Address, error)

*

  • GetAddress 返回单条收货地址(校验归属用户)。

func GetAddressList

func GetAddressList(userID uint) ([]model.Address, error)

func GetAdminList

func GetAdminList(page, pageSize int) (int64, []model.Admin, error)

func GetAftersaleDetail

func GetAftersaleDetail(userID, asID uint) (*model.OrderAftersale, error)

func GetAftersaleList

func GetAftersaleList(userID uint, page, pageSize int) ([]model.OrderAftersale, int64, error)

func GetAnswerList

func GetAnswerList(goodsID uint, page, pageSize int) ([]model.Answer, int64, error)

func GetAppMiniList

func GetAppMiniList() ([]model.AppMini, error)

func GetArticleCategoryList

func GetArticleCategoryList() ([]model.ArticleCategory, error)

func GetArticleDetail

func GetArticleDetail(id uint) (*model.Article, error)

func GetArticleList

func GetArticleList(categoryID uint, page, pageSize int) ([]model.Article, int64, error)

func GetBrandCategoryListRecords

func GetBrandCategoryListRecords() []model.BrandCategory

func GetBrandList

func GetBrandList() ([]model.Brand, error)

func GetBrowseHistory

func GetBrowseHistory(userID uint, page, pageSize int) ([]model.BrowseHistory, int64, error)

func GetCacheStats

func GetCacheStats() map[string]interface{}

func GetCartList

func GetCartList(userID uint) ([]model.Cart, error)

func GetCategoryTree

func GetCategoryTree() ([]model.Category, error)

func GetCommissionLogs added in v1.5.0

func GetCommissionLogs(distributorID uint, page, pageSize int) (int64, []model.CommissionLog, error)

func GetConfig

func GetConfig(key string) string

---- 系统配置 ----

func GetConfigGroup

func GetConfigGroup(group string) ([]model.Config, error)

func GetCouponList

func GetCouponList() ([]model.Coupon, error)

func GetDistributorByUser added in v1.5.0

func GetDistributorByUser(userID uint) (*model.Distributor, error)

func GetDistributorList added in v1.5.0

func GetDistributorList(page, pageSize int) (int64, []model.Distributor, error)

func GetErrorLogList

func GetErrorLogList(page, pageSize int) ([]model.ErrorLog, int64, error)

func GetExpressList

func GetExpressList() ([]model.Express, error)

func GetFavorites

func GetFavorites(userID uint, page, pageSize int) ([]model.Favorite, int64, error)

func GetFormFields

func GetFormFields(formID uint) ([]model.FormTableUserFields, error)

func GetFormGoodsContentAppParams

func GetFormGoodsContentAppParams(goodsID uint) string

GetFormGoodsContentAppParams 表单APP详情参数

func GetFormGoodsPhotoParams

func GetFormGoodsPhotoParams(goodsID uint) ([]model.GoodsPhoto, error)

GetFormGoodsPhotoParams 表单相册参数

func GetFormGoodsSpecificationsBaseParams

func GetFormGoodsSpecificationsBaseParams(goodsID uint) ([]model.GoodsSpecBase, error)

GetFormGoodsSpecificationsBaseParams 表单规格基础参数

func GetFormGoodsSpecificationsParams

func GetFormGoodsSpecificationsParams(goodsID uint) map[string]interface{}

GetFormGoodsSpecificationsParams 表单规格参数

func GetGoodsContentApp

func GetGoodsContentApp(goodsID uint) string

func GetGoodsDetail

func GetGoodsDetail(id uint) (*model.Goods, error)

func GetGoodsParams

func GetGoodsParams(goodsID uint) ([]model.GoodsParams, error)

func GetGoodsPhotos

func GetGoodsPhotos(goodsID uint) ([]model.GoodsPhoto, error)

func GetGoodsReviews

func GetGoodsReviews(goodsID uint, page, pageSize int) ([]model.Review, int64, error)

func GetGoodsSpecBase

func GetGoodsSpecBase(goodsID uint) ([]model.GoodsSpecBase, error)

func GetGroupBuyList added in v1.5.0

func GetGroupBuyList(page, pageSize int) (int64, []model.Promotion, error)

func GetGroupOrderDetail added in v1.5.0

func GetGroupOrderDetail(id uint) (*model.GroupOrder, []model.GroupOrderMember, error)

GetGroupOrderDetail 获取拼团详情

func GetHotKeywords

func GetHotKeywords(limit int) ([]string, error)

func GetInventoryLogList

func GetInventoryLogList(goodsID uint, page, pageSize int) ([]model.InventoryLog, int64, error)

func GetLangPack

func GetLangPack(lang, module string) (map[string]string, error)

GetLangPack 获取语言包(从config表读取,key格式: lang_{code}_{module}_{key})

func GetMessages

func GetMessages(userID uint, page, pageSize int) ([]model.Message, int64, error)

func GetMyCoupons

func GetMyCoupons(userID uint, status *int8) ([]model.UserCoupon, error)

func GetOrderDetail

func GetOrderDetail(userID, orderID uint) (*model.Order, error)

func GetOrderStatusHistory

func GetOrderStatusHistory(orderID uint) ([]model.OrderStatusHistory, error)

func GetOrderTraceSource

func GetOrderTraceSource(orderID uint) ([]model.OrderTraceSource, error)

func GetParamsTemplateList

func GetParamsTemplateList() ([]model.GoodsParamsTemplate, error)

func GetPayLogList

func GetPayLogList(userID uint, page, pageSize int) ([]model.PayLog, int64, error)

func GetPointsLog

func GetPointsLog(userID uint, page, pageSize int) ([]model.PointsLog, int64, error)

func GetPowerTree

func GetPowerTree() ([]model.Power, error)

func GetPromoPrice

func GetPromoPrice(skuID uint) (int64, error)

GetPromoPrice 获取 SKU 的促销价,无促销返回 0

func GetPromotionAdminList added in v1.5.5

func GetPromotionAdminList(page, pageSize int, keyword string) (int64, []model.Promotion, error)

*

  • GetPromotionAdminList 管理后台:仅普通促销 type=promo,分页。

func GetRefundLogList

func GetRefundLogList(page, pageSize int) ([]model.RefundLog, int64, error)

func GetRegionList

func GetRegionList(parentID uint) ([]model.Region, error)

---- 地区 ----

func GetRoleList

func GetRoleList() ([]model.Role, error)

func GetRolePluginIDs added in v1.5.5

func GetRolePluginIDs(roleID uint) ([]uint, error)

GetRolePluginIDs 返回角色已绑定的插件 ID 列表。

func GetRolePowers

func GetRolePowers(roleID uint) ([]uint, error)

func GetScreeningPrices

func GetScreeningPrices() ([]model.ScreeningPrice, error)

func GetSearchHistory

func GetSearchHistory(userID uint) ([]model.SearchHistory, error)

func GetSeckillList added in v1.5.0

func GetSeckillList(page, pageSize int) (int64, []model.Promotion, error)

func GetSelfExtractionAddressList

func GetSelfExtractionAddressList() []map[string]interface{}

func GetShipment

func GetShipment(orderID uint) (*model.Shipment, error)

func GetSiteConfig

func GetSiteConfig() map[string]string

func GetSpecTemplateList

func GetSpecTemplateList() ([]model.SpecTemplate, error)

func GetSubDistributors added in v1.5.0

func GetSubDistributors(userID uint) ([]model.Distributor, error)

func GetUserByID

func GetUserByID(id uint) (*model.User, error)

func GetUserPlatforms

func GetUserPlatforms(userID uint) ([]model.UserPlatform, error)

GetUserPlatforms 获取用户绑定的平台

func GetUserViewInfo

func GetUserViewInfo(userID uint) map[string]interface{}

GetUserViewInfo 用户展示信息(脱敏)

func GetWarehouseList

func GetWarehouseList() ([]model.Warehouse, error)

func GetWithdrawList added in v1.5.0

func GetWithdrawList(page, pageSize int, status *int8) (int64, []model.WithdrawRequest, error)

func GoodsAccessCountInc

func GoodsAccessCountInc(goodsID uint)

GoodsAccessCountInc 商品访问量增加

func GoodsAppData

func GoodsAppData(goodsID uint) map[string]interface{}

GoodsAppData APP端商品数据

func GoodsBaseFieldsRequiredConfigData

func GoodsBaseFieldsRequiredConfigData() map[string]bool

GoodsBaseFieldsRequiredConfigData 基础字段必填配置

func GoodsBaseForbidOperateData

func GoodsBaseForbidOperateData(goodsID uint) map[string]bool

GoodsBaseForbidOperateData 禁止操作数据

func GoodsBaseTemplate

func GoodsBaseTemplate() map[string]interface{}

GoodsBaseTemplate 商品基础模板数据

func GoodsBrowseDelete

func GoodsBrowseDelete(ids []uint, userID uint) error

==================== GoodsBrowse ====================

func GoodsBrowseList

func GoodsBrowseList(userID uint, page, pageSize int) ([]model.BrowseHistory, int64, error)

func GoodsBrowseListHandle

func GoodsBrowseListHandle(list []model.BrowseHistory) []model.BrowseHistory

func GoodsBuyButtonList

func GoodsBuyButtonList(goods *model.Goods) []map[string]string

GoodsBuyButtonList 购买按钮列表

func GoodsBuyLeftNavList

func GoodsBuyLeftNavList() []map[string]string

GoodsBuyLeftNavList 购买左侧导航

func GoodsCartListHandle

func GoodsCartListHandle(list []model.Cart) []model.Cart

func GoodsCartSave

func GoodsCartSave(userID uint, req *AddCartReq) (*model.Cart, error)

func GoodsCartSaveHandle

func GoodsCartSaveHandle(userID uint, goodsID, skuID uint, quantity int) (*model.Cart, error)

func GoodsCartStock

func GoodsCartStock(cartID uint) (int, error)

func GoodsCartTotal

func GoodsCartTotal(userID uint) int64

==================== GoodsCart ====================

func GoodsCategoryAll

func GoodsCategoryAll() []model.Category

func GoodsCategoryDelete

func GoodsCategoryDelete(id uint) error

func GoodsCategoryInsert

func GoodsCategoryInsert(goodsID uint, catIDs []uint)

GoodsCategoryInsert 保存商品分类关联

func GoodsCategoryItemsIds

func GoodsCategoryItemsIds(ids []uint, deep int) []uint

func GoodsCategoryLevel

func GoodsCategoryLevel() int

func GoodsCategoryName

func GoodsCategoryName(id uint) string

func GoodsCategoryNames

func GoodsCategoryNames(ids []uint) map[uint]string

func GoodsCategoryParentIds

func GoodsCategoryParentIds(id uint) []uint

func GoodsCategoryStatusUpdate

func GoodsCategoryStatusUpdate(id uint, status int8) error

==================== GoodsCategory ====================

func GoodsCommentsDelete

func GoodsCommentsDelete(id uint) error

func GoodsCommentsDeleteForUser added in v1.5.5

func GoodsCommentsDeleteForUser(id, userID uint) error

*

  • GoodsCommentsDeleteForUser 仅允许删除当前用户的评价。

func GoodsCommentsList

func GoodsCommentsList(goodsID uint, page, pageSize int) ([]model.Review, int64, error)

func GoodsCommentsListHandle

func GoodsCommentsListHandle(list []model.Review) []model.Review

func GoodsCommentsSave

func GoodsCommentsSave(userID uint, req *CreateReviewReq) (*model.Review, error)

func GoodsCommentsStatusUpdate

func GoodsCommentsStatusUpdate(id uint, status int8) error

==================== GoodsComments ====================

func GoodsCommentsTotal

func GoodsCommentsTotal(goodsID uint) int64

func GoodsContentAppInsert

func GoodsContentAppInsert(goodsID uint, content string) error

GoodsContentAppInsert 保存APP详情

func GoodsData

func GoodsData(id uint) *model.Goods

GoodsData 获取单个商品数据

func GoodsDataEditStatusCheck

func GoodsDataEditStatusCheck(id uint) error

GoodsDataEditStatusCheck 编辑状态检查

func GoodsDeleteFull

func GoodsDeleteFull(id uint) error

func GoodsDetailGuessYouLikeData

func GoodsDetailGuessYouLikeData(goodsID uint, limit int) []model.Goods

GoodsDetailGuessYouLikeData 猜你喜欢(详情页)

func GoodsDetailMiddleTabsNavList

func GoodsDetailMiddleTabsNavList(goodsID uint) []map[string]interface{}

GoodsDetailMiddleTabsNavList 详情页中间导航

func GoodsDetailSeeingYouData

func GoodsDetailSeeingYouData(goodsID uint, limit int) []model.Goods

GoodsDetailSeeingYouData 看了又看

func GoodsEditParameters

func GoodsEditParameters(goodsID uint) map[string]interface{}

GoodsEditParameters 编辑页参数数据

func GoodsEditSpecifications

func GoodsEditSpecifications(goodsID uint) map[string]interface{}

GoodsEditSpecifications 编辑页规格数据

func GoodsFavorDelete

func GoodsFavorDelete(ids []uint, userID uint) error

func GoodsFavorList

func GoodsFavorList(userID uint, page, pageSize int) ([]model.Favorite, int64, error)

func GoodsFavorListHandle

func GoodsFavorListHandle(list []model.Favorite) []model.Favorite

func GoodsFavorTotal

func GoodsFavorTotal(userID uint) int64

==================== GoodsFavor ====================

func GoodsFirstSeveralComments

func GoodsFirstSeveralComments(goodsID uint, n int) []model.Review

func GoodsImagesCoverHandle

func GoodsImagesCoverHandle(goods *model.Goods) string

GoodsImagesCoverHandle 封面图处理

func GoodsListHandle

func GoodsListHandle(list []model.Goods) []model.Goods

func GoodsParametersData

func GoodsParametersData(goodsID uint) ([]model.GoodsParams, error)

GoodsParametersData 商品参数数据

func GoodsParamsInsert

func GoodsParamsInsert(goodsID uint, params []ParamsConfigItem) error

GoodsParamsInsert 保存参数

func GoodsParamsOperateData

func GoodsParamsOperateData(goodsID uint) map[string]interface{}

GoodsParamsOperateData 参数操作数据

func GoodsPhotoData

func GoodsPhotoData(goodsID uint) ([]model.GoodsPhoto, error)

GoodsPhotoData 商品相册数据

func GoodsPhotoInsert

func GoodsPhotoInsert(goodsID uint, images []string) error

GoodsPhotoInsert 保存相册

func GoodsQrcode

func GoodsQrcode(id uint) string

GoodsQrcode 商品二维码

func GoodsSalesCountInc

func GoodsSalesCountInc(goodsID uint, count int)

GoodsSalesCountInc 商品销量增加

func GoodsSalesModelType

func GoodsSalesModelType(goods *model.Goods) string

GoodsSalesModelType 销售模式类型

func GoodsSave

func GoodsSave(id uint, req *GoodsSaveReq) (*model.Goods, error)

func GoodsSaveBaseUpdate

func GoodsSaveBaseUpdate(id uint, updates map[string]interface{}) error

GoodsSaveBaseUpdate 仅更新基础信息

func GoodsSearchList

func GoodsSearchList(keyword string, categoryID, brandID uint, page, pageSize int) ([]model.Goods, int64)

GoodsSearchList 商品搜索列表(含关键字+分类+品牌)

func GoodsSearchListForWarehouse

func GoodsSearchListForWarehouse(warehouseID uint, keyword string) []model.Goods

func GoodsSpecBaseFields

func GoodsSpecBaseFields() []string

GoodsSpecBaseFields 规格基础字段

func GoodsSpecChangeInventorySync

func GoodsSpecChangeInventorySync(goodsID uint) error

GoodsSpecChangeInventorySync 商品规格变更后同步仓库库存结构

func GoodsSpecDefaultName

func GoodsSpecDefaultName() string

GoodsSpecDefaultName 默认规格名称

func GoodsSpecInventorySync

func GoodsSpecInventorySync(goodsID uint) error

GoodsSpecInventorySync 仓库库存同步到商品SKU库存(所有启用仓库的该商品库存求和)

func GoodsSpecOperateData

func GoodsSpecOperateData(goodsID uint) map[string]interface{}

GoodsSpecOperateData 规格操作数据

func GoodsSpecType

func GoodsSpecType(goodsID uint) []model.SpecType

GoodsSpecType 获取规格类型

func GoodsSpecificationsActual

func GoodsSpecificationsActual(goodsID uint) ([]model.GoodsSpecBase, error)

GoodsSpecificationsActual 获取实际规格组合

func GoodsSpecificationsConcise

func GoodsSpecificationsConcise(goodsID uint) []string

GoodsSpecificationsConcise 规格简洁数据

func GoodsSpecificationsData

func GoodsSpecificationsData(goodsID uint) ([]model.GoodsSKU, error)

GoodsSpecificationsData 获取商品规格数据

func GoodsSpecificationsExtends

func GoodsSpecificationsExtends(goodsID uint) map[string]interface{}

GoodsSpecificationsExtends 规格扩展数据

func GoodsSpecificationsInsert

func GoodsSpecificationsInsert(goodsID uint, specs []SpecBaseReq) error

GoodsSpecificationsInsert 保存规格

func GoodsStatusUpdate

func GoodsStatusUpdate(id uint, status int8) error

==================== Goods ====================

func GoodsStock

func GoodsStock(goodsID uint, spec string) (int, error)

GoodsStock 查询商品库存(按规格)

func GoodsTotal

func GoodsTotal(status *int8) int64

func GoodsUrlCreate

func GoodsUrlCreate(id uint) string

GoodsUrlCreate 生成商品URL

func GuessYouLike

func GuessYouLike(userID uint, limit int) []model.Goods

GuessYouLike 猜你喜欢(基于浏览记录+销量)

func HandlePayNotify

func HandlePayNotify(outTradeNo string, transactionID string) error

HandlePayNotify 处理支付回调:先按订单号单笔;否则按 PayLog.pay_no(合并支付)。 幂等保护:通过 WHERE status = pending 条件更新,并发重复回调只有一个能成功。 成功单笔更新后调用 postPaidHook 触发订单历史与通知(与合并支付路径 PayLogSuccess 行为一致)。

func HomeHavTopRight

func HomeHavTopRight() bool

func InferPaymentKeyFromPaymentName added in v1.5.5

func InferPaymentKeyFromPaymentName(name string) string

InferPaymentKeyFromPaymentName 根据支付方式展示名称猜测内部 payment_key(与 ShopXO PHP 类名无关)。

func InitOrderService added in v1.5.5

func InitOrderService(svc *OrderService)

InitOrderService 注册进程内单例;在 main 启动路径上仅应调用一次。

func IntegralLogList

func IntegralLogList(userID uint, page, pageSize int) ([]model.PointsLog, int64, error)

func IntegralLogListHandle

func IntegralLogListHandle(list []model.PointsLog) []model.PointsLog

func IntegralLogTotal

func IntegralLogTotal(userID uint) int64

func InvalidateCategoryCache added in v1.5.5

func InvalidateCategoryCache()

func IsBookingMode

func IsBookingMode() bool

func IsExistAccounts

func IsExistAccounts(account string) bool

IsExistAccounts 检查账号是否存在

func IsGoodsSiteTypeConsistent

func IsGoodsSiteTypeConsistent(goodsID uint) bool

IsGoodsSiteTypeConsistent 商品站点类型一致性检查

func IsImaVerify

func IsImaVerify() bool

IsImaVerify 是否需要图形验证码

func IsSuperAdmin added in v1.5.0

func IsSuperAdmin(roleID uint) bool

IsSuperAdmin 判断角色是否为超级管理员(Powers包含"*")

func JoinGroup added in v1.5.0

func JoinGroup(userID, groupOrderID uint) error

JoinGroup 参团:锁团单行、扣库存、插入成员、递增人数与成团判定在同一事务内完成。

func KuaishouUserAuth

func KuaishouUserAuth(appID, secret, code string) (string, error)

func LayoutList

func LayoutList() ([]model.Layout, error)

Layout

func LayoutSave

func LayoutSave(name, typ, data string) error

func LevelOneNav

func LevelOneNav() []model.Navigation

func LinkDelete

func LinkDelete(id uint) error
func LinkList() ([]model.Link, error)

func LinkListHandle

func LinkListHandle(list []model.Link) []model.Link

func LinkSave

func LinkSave(l *model.Link) error

func LinkStatusUpdate

func LinkStatusUpdate(id uint, status int8) error

==================== Link ====================

func LoginUserInfo

func LoginUserInfo(userID uint) *model.User

LoginUserInfo 获取当前登录用户信息

func LoginVerifySend

func LoginVerifySend(account string) error

LoginVerifySend 登录验证码发送

func Logout

func Logout(userID uint) error

Logout 退出(别名)

func MatchingUserPlatformData

func MatchingUserPlatformData(userID uint) []model.UserPlatform

MatchingUserPlatformData 匹配用户平台数据

func MessageDelete

func MessageDelete(ids []uint, userID uint) error

func MessageListHandle

func MessageListHandle(list []model.Message) []model.Message

func MessageListWhere

func MessageListWhere(userID uint) []model.Message

func MessageTotal

func MessageTotal(userID uint) int64

==================== Message ====================

func MoreOrderPayBeginCheck

func MoreOrderPayBeginCheck(userID uint, orderIDs []uint) error

MoreOrderPayBeginCheck 多订单合并支付前校验

func MultilingualGetUserValue

func MultilingualGetUserValue(userID uint) string

func MultilingualSetUserValue

func MultilingualSetUserValue(userID uint, lang string)

MultilingualSetUserValue 设置用户语言偏好

func NavDataAll() []model.Navigation
func NavDataDealWith(list []model.Navigation) []model.Navigation
func NavDelete(id uint) error
func NavSave(n *model.Navigation) error
func NavStatusUpdate(id uint, status int8) error

==================== Navigation ====================

func NavigationHandle(list []model.Navigation) []model.Navigation
func NavigationList(typ string) ([]model.Navigation, error)

func NotifyOrderStatus

func NotifyOrderStatus(userID, orderID uint, orderNo, status string)

NotifyOrderStatus 订单状态变更通知(站内信+微信)

func OpenGroup added in v1.5.0

func OpenGroup(userID, itemID uint) (*model.GroupOrder, error)

OpenGroup 开团:扣活动库存、写入团单与团长成员在同一事务内完成。

func OrderAddressData

func OrderAddressData(order *model.Order) map[string]interface{}

OrderAddressData 订单地址数据

func OrderAftersaleCalculation

func OrderAftersaleCalculation(orderDetailID uint, number int) int64

OrderAftersaleCalculation 自动计算退款金额

func OrderAftersaleChoiceTypeList

func OrderAftersaleChoiceTypeList(orderID uint) []map[string]interface{}

OrderAftersaleChoiceTypeList 可选售后类型

func OrderAftersaleDelete

func OrderAftersaleDelete(id uint) error

func OrderAftersaleDetailData

func OrderAftersaleDetailData(id uint) map[string]interface{}

func OrderAftersaleListHandle

func OrderAftersaleListHandle(list []model.OrderAftersale) []model.OrderAftersale

func OrderAftersaleListWhere

func OrderAftersaleListWhere(userID uint) []model.OrderAftersale

func OrderAftersaleReturnGoodsAddress

func OrderAftersaleReturnGoodsAddress(orderID uint) map[string]string

OrderAftersaleReturnGoodsAddress 退货地址(优先仓库地址)

func OrderAftersaleStepData

func OrderAftersaleStepData(asID uint) []model.AftersaleHistory

OrderAftersaleStepData 售后进度

func OrderAftersaleTipsMsg

func OrderAftersaleTipsMsg(status int8) string

OrderAftersaleTipsMsg 售后提示信息

func OrderAftersaleTotal

func OrderAftersaleTotal(userID uint, status *int8) int64

OrderAftersaleTotal 售后总数

func OrderConfirm

func OrderConfirm(orderID, adminID uint) error

OrderConfirm 管理员确认订单(预约模式)

func OrderDeliverySyncWeixin

func OrderDeliverySyncWeixin(orderNo, tradeNo, openID, goodsTitle, expressName, expressNumber, tel string, orderModel int8) error

func OrderDirectSuccess

func OrderDirectSuccess(orderID uint) error

OrderDirectSuccess 虚拟商品直接完成

func OrderGoodsIntegralGiving

func OrderGoodsIntegralGiving(userID, orderID uint, payAmount int64) error

OrderGoodsIntegralGiving 订单完成后赠送积分(先锁定)

func OrderGoodsIntegralRollback

func OrderGoodsIntegralRollback(orderID, orderDetailID uint, refundAmount int64) error

OrderGoodsIntegralRollback 售后退款扣减锁定积分

func OrderIsCanLaunchAftersale

func OrderIsCanLaunchAftersale(orderID, userID uint) bool

OrderIsCanLaunchAftersale 判断订单是否可发起售后

func OrderItemList

func OrderItemList(orderID uint) []model.OrderItem

OrderItemList 独立获取订单商品列表

func OrderListHandle

func OrderListHandle(list []model.Order) []model.Order

OrderListHandle 订单列表数据处理

func OrderPayCheck

func OrderPayCheck(userID, orderID uint) (*model.Order, error)

OrderPayCheck 支付前校验

func OrderPayLogInsert

func OrderPayLogInsert(userID uint, orderIDs []uint, paymentID uint, clientType string) (*model.PayLog, error)

OrderPayLogInsert 订单支付日志插入

func OrderPayLogValueList

func OrderPayLogValueList(payLogID uint) []model.PayLogValue

OrderPayLogValueList 支付日志关联订单

func OrderRewardPoints

func OrderRewardPoints(userID, orderID uint, payAmount int64) error

OrderRewardPoints 订单完成奖励积分(每消费1元=1积分)

func OrderServiceData

func OrderServiceData(orderID uint) []model.OrderService

OrderServiceData 订单服务数据

func OrderServiceList

func OrderServiceList(orderID uint) ([]model.OrderService, error)

func OrderSplitHandle

func OrderSplitHandle(userID uint, req *CreateOrderReq) ([]*model.Order, error)

func OrderStatusGroupTotal

func OrderStatusGroupTotal(userID uint) map[string]int64

OrderStatusGroupTotal 订单状态分组统计

func OrderTraceSourceData

func OrderTraceSourceData(orderID uint) ([]model.OrderTraceSource, error)

OrderTraceSourceData 订单溯源数据

func PayLogClose

func PayLogClose(payNo string) error

PayLogClose 关闭支付日志

func PayLogData

func PayLogData(payNo string) *model.PayLog

func PayLogListHandle

func PayLogListHandle(list []model.PayLog) []model.PayLog

func PayLogMenuRowsShopXO added in v1.6.0

func PayLogMenuRowsShopXO(userID uint) []map[string]string

PayLogMenuRowsShopXO shopxo-uniapp paylog/index:name + url 列表。

func PayLogOrderRowsShopXO added in v1.6.0

func PayLogOrderRowsShopXO(userID, payLogID uint) ([]map[string]string, error)

PayLogOrderRowsShopXO shopxo-uniapp paylog/detail:订单号与详情链接。

func PayLogPagesDetailData

func PayLogPagesDetailData(id uint) *model.PayLog

func PayLogPagesListData

func PayLogPagesListData(page, pageSize int) ([]model.PayLog, int64, error)

func PayLogSuccess

func PayLogSuccess(payNo, tradeNo string) error

PayLogSuccess 支付成功回调处理

func PayLogTypeList

func PayLogTypeList() []map[string]string

PayLogTypeList 支付日志业务类型列表

func PayOrder

func PayOrder(userID uint, req *PayOrderReq) (*jsapi.PrepayWithRequestPaymentResponse, error)

PayOrder 发起支付,返回小程序调起支付的参数

func PaymentDelete

func PaymentDelete(id uint) error

func PaymentDriverKeyFromPayment added in v1.5.5

func PaymentDriverKeyFromPayment(p *model.Payment) (string, error)

PaymentDriverKeyFromPayment 从配置 JSON 读取 payment_key;不含 ShopXO 的 payment 类名字段。 /api.php 与 PHP 迁移数据请用 compat/shopxo.PaymentDriverKeyFromPayment。

func PaymentEntranceCreate

func PaymentEntranceCreate(payment string) error

func PaymentEntranceDelete

func PaymentEntranceDelete(payment string) error

func PaymentList

func PaymentList() ([]model.Payment, error)

---- 支付方式 ----

func PaymentOpenUserUpdate

func PaymentOpenUserUpdate(id uint, open int8) error

func PaymentSave

func PaymentSave(p *model.Payment) error

func PaymentStatusUpdate

func PaymentStatusUpdate(id uint, status int8) error

func PaymentUpgradeInfo

func PaymentUpgradeInfo() []map[string]interface{}

func PersonalSave

func PersonalSave(userID uint, req *PersonalSaveReq) error

func PluginConfigGet

func PluginConfigGet(pluginID uint, key string) string

PluginsDataConfig

func PluginConfigSet

func PluginConfigSet(pluginID uint, key, value string) error

func PluginInstall

func PluginInstall(name, title, desc, author, version string) error

func PluginList

func PluginList() ([]model.Plugin, error)

---- 插件 ----

func PluginUninstall

func PluginUninstall(id uint) error

func PluginsAdminDelete

func PluginsAdminDelete(id uint) error

func PluginsAdminList

func PluginsAdminList() ([]model.Plugin, error)

func PluginsAdminSave

func PluginsAdminSave(id uint, config string) error

func PluginsAdminStatusUpdate

func PluginsAdminStatusUpdate(id uint, status int8) error

func PluginsBaseList

func PluginsBaseList() ([]model.Plugin, error)

func PluginsCategoryDelete

func PluginsCategoryDelete(id uint) error

func PluginsCategoryList

func PluginsCategoryList() []model.PluginCategory

func PluginsCategorySave

func PluginsCategorySave(name string, sort int) error

==================== PluginsCategory ====================

func PluginsCheck

func PluginsCheck(name string) bool

func PluginsControlCall

func PluginsControlCall(name, method string, params map[string]interface{}) interface{}

func PluginsData

func PluginsData(id uint) *model.Plugin

func PluginsDataHandle

func PluginsDataHandle(list []model.Plugin) []model.Plugin

func PluginsDataSave

func PluginsDataSave(id uint, config string) error

func PluginsEventCall

func PluginsEventCall(hookName string, params map[string]interface{})

func PluginsField

func PluginsField(name, field string) string

func PluginsHomeDataList

func PluginsHomeDataList() []model.Plugin

func PluginsNewVersionCheck

func PluginsNewVersionCheck() bool

func PluginsSortList

func PluginsSortList() []model.Plugin

func PluginsStatus

func PluginsStatus(id uint, status int8) error

func PowerSave

func PowerSave(p *model.Power) error

func PowerStatusUpdate

func PowerStatusUpdate(id uint, status int8) error

==================== Power ====================

func QQUserAuth

func QQUserAuth(appID, secret, code string) (string, error)

func QuickNavCreate

func QuickNavCreate(n *model.QuickNav) error

func QuickNavDelete

func QuickNavDelete(id uint) error

func QuickNavList

func QuickNavList() ([]model.QuickNav, error)

QuickNav

func QuickNavStatusUpdate

func QuickNavStatusUpdate(id uint, status int8) error

==================== QuickNav ====================

func ReadAllMessages

func ReadAllMessages(userID uint) error

func ReadMessage

func ReadMessage(userID, msgID uint) error

func ReceiveCoupon

func ReceiveCoupon(userID, couponID uint) error

func ReconcileAlipayPayments added in v1.6.0

func ReconcileAlipayPayments(ctx context.Context, deps *app.Deps) (payLogsFixed, ordersFixed int)

ReconcileAlipayPayments 主动查询支付宝订单状态,补回调丢失(合并 PayLog.out_trade_no = pay_no,单笔为 order_no)。

func ReconcileWechatPayments added in v1.6.0

func ReconcileWechatPayments(ctx context.Context, deps *app.Deps) (payLogsFixed, ordersFixed int)

ReconcileWechatPayments 主动查询微信订单状态,补「回调丢失」场景:合并支付 PayLog + 单笔订单号。

func RefundOrder

func RefundOrder(userID uint, req *RefundReq) error

RefundOrder 申请退款:分三步

  1. 事务内幂等预检 + 插入 RefundLog(status=0)。
  2. 调支付驱动退款(支付驱动由 order.PaymentID 解析,兼容微信/支付宝/钱包/线下/PayPal)。
  3. 第三方成功后事务化更新订单状态为 Refunded + 回库存 + 标记 RefundLog=1。

幂等:同一订单已有 status IN (0, 1) 的 RefundLog 时拒绝重复申请。 事务失败后 RefundLog 会留在 status=0(处理中),可由 reconcile cron 或人工处理。

func Reg

func Reg(req *RegisterReq) (*model.User, error)

Reg 注册(别名)

func RegVerifySend

func RegVerifySend(account string) error

RegVerifySend 注册验证码发送

func RegionAll

func RegionAll() []model.Region

func RegionCodeData

func RegionCodeData(id uint) *model.Region

func RegionDelete

func RegionDelete(id uint) error

func RegionItemsIds

func RegionItemsIds(pid uint) []uint

func RegionName

func RegionName(id uint) string

func RegionNodeSon

func RegionNodeSon(pid uint) []model.Region

func RegionSave

func RegionSave(r *model.Region) error

==================== Region ====================

func RegionStatusUpdate

func RegionStatusUpdate(id uint, status int8) error

func Register

func Register(req *RegisterReq) (*model.User, error)

func RegisterPayEventListeners added in v1.8.0

func RegisterPayEventListeners()

RegisterPayEventListeners 注册支付成功后的事件监听器。应在 main 启动时调用一次。

func ReplyAnswer

func ReplyAnswer(id uint, reply string) error

func ReplyOrderService

func ReplyOrderService(id, adminID uint, reply string) error

func ReplyReview

func ReplyReview(reviewID uint, reply string) error

func RequestWithdraw added in v1.5.0

func RequestWithdraw(userID uint, amount int64, accountType, accountNo, accountName string) error

RequestWithdraw 用户申请提现:扣余额 + 写 WithdrawRequest + 写流水在同一事务内完成。 任一步失败整体回滚,避免"余额扣了但申请/流水没写"造成资金漂移。

func RunInDBTx added in v1.6.0

func RunInDBTx(db *gorm.DB, fn func(tx *gorm.DB) error) error

*

  • RunInDBTx 在 (*gorm.DB).Transaction 内执行 fn:fn 返回非 nil 时自动回滚,nil 时提交。
  • 全库多语句写库请优先用此,避免手写 Begin/Commit/Rollback。

func SaveAppMini

func SaveAppMini(req *AppMiniReq) error

func SaveFormFields

func SaveFormFields(formID uint, fields []model.FormTableUserFields) error

FormTableUserFields

func SaveGoodsCategoryJoinRecords

func SaveGoodsCategoryJoinRecords(goodsID uint, categoryIDs []uint)

func SaveGoodsContentApp

func SaveGoodsContentApp(goodsID uint, content string) error

GoodsContentApp

func SaveGoodsParams

func SaveGoodsParams(goodsID uint, params []ParamsConfigItem) error

func SaveGoodsPhotos

func SaveGoodsPhotos(goodsID uint, images []string) error

SaveGoodsPhotos 保存商品相册

func SaveGoodsSpecBase

func SaveGoodsSpecBase(goodsID uint, specs []SpecBaseReq) error

func SaveOrderCurrency

func SaveOrderCurrency(orderID uint, amount int64)

SaveOrderCurrency 订单创建时保存货币信息

func SaveRolePlugins

func SaveRolePlugins(roleID uint, pluginIDs []uint) error

RolePlugins

func SaveRolePowers

func SaveRolePowers(roleID uint, powerIDs []uint) error

func SaveSelfExtractionAddress

func SaveSelfExtractionAddress(list []map[string]interface{})

func SaveSiteConfig

func SaveSiteConfig(configs map[string]string)

func ScreeningPriceDelete

func ScreeningPriceDelete(id uint) error

func ScreeningPriceSave

func ScreeningPriceSave(s *model.ScreeningPrice) error

==================== ScreeningPrice ====================

func SearchAdd

func SearchAdd(userID uint, keyword string)

func SearchGoodsMaxPrice

func SearchGoodsMaxPrice() int64

func SearchGoodsProduceRegionList

func SearchGoodsProduceRegionList() []string

SearchGoodsProduceRegionList 获取所有产地列表

func SearchIsLoginCheck

func SearchIsLoginCheck() bool

func SearchKeywordsList

func SearchKeywordsList() []string

func SearchMapHandle

func SearchMapHandle(params map[string]interface{}) map[string]interface{}

func SearchMapInfo

func SearchMapInfo(params map[