|
@@ -4,6 +4,7 @@ import (
|
|
|
"eta/eta_mini_ht_api/common/exception"
|
|
|
"eta/eta_mini_ht_api/common/utils/page"
|
|
|
"eta/eta_mini_ht_api/controllers"
|
|
|
+ "eta/eta_mini_ht_api/service/facade"
|
|
|
"eta/eta_mini_ht_api/service/order"
|
|
|
"eta/eta_mini_ht_api/service/user"
|
|
|
)
|
|
@@ -31,6 +32,56 @@ func (o *OrderController) PreviewProductOrder(productId int) {
|
|
|
o.FailedResult("预览订单失败,产品编号非法", result)
|
|
|
return
|
|
|
}
|
|
|
+ if code := orderRateLimitFilter(userInfo.Id); code != 200 {
|
|
|
+ err = exception.New(exception.SubscribeFailed)
|
|
|
+ o.FailedResult("操作太频繁了,请稍后再试", result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //校验是否已经购买并且在有效期内
|
|
|
+ //是否开户
|
|
|
+ //未开户
|
|
|
+ officialUser, err := user.GetUserByTemplateUserId(userInfo.Id)
|
|
|
+ if err != nil {
|
|
|
+ if err.Error() == exception.GetMsg(exception.OfficialUserNotFound) {
|
|
|
+ err = exception.New(exception.OfficialUserNotFound)
|
|
|
+ result.Ret = AccountNotOpen
|
|
|
+ o.FailedResult("用户未开通账户", result)
|
|
|
+ } else {
|
|
|
+ o.FailedResult("获取用户账户信息失败", result)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ switch officialUser.AccountStatus {
|
|
|
+ case "unopen":
|
|
|
+ result.Ret = AccountNotOpen
|
|
|
+ err = exception.New(exception.AccountNotOpen)
|
|
|
+ o.FailedResult("用户未开通账户", result)
|
|
|
+ return
|
|
|
+ case "opening":
|
|
|
+ result.Ret = AccountOpening
|
|
|
+ err = exception.New(exception.AccountNotOpen)
|
|
|
+ o.FailedResult("用户开户中", result)
|
|
|
+ return
|
|
|
+ case "opened":
|
|
|
+ default:
|
|
|
+ err = exception.New(exception.IllegalAccountStatus)
|
|
|
+ o.FailedResult(result.Msg, result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //证件信息是否过期
|
|
|
+ if !officialUser.IDValid {
|
|
|
+ err = exception.New(exception.IDExpired)
|
|
|
+ result.Ret = IDExpired
|
|
|
+ o.FailedResult("用户证件有效期过期", result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //主动发起查询最新风险测评(获取失败用系统中原有的测评信息)
|
|
|
+ code, err := facade.CheckUserRiskLevel(userInfo.Id, productId, officialUser)
|
|
|
+ if err != nil {
|
|
|
+ result.Ret = code
|
|
|
+ o.FailedResult("校验用户风险等级失败", result)
|
|
|
+ return
|
|
|
+ }
|
|
|
//创单
|
|
|
//返回订单信息、商品信息
|
|
|
orderInfo, err := order.PreViewProductOrder(userInfo, productId)
|