已完成用户APP首期功能开发
交付用户端首期页面、配套接口、后台资源及测试文档。用户APP构建、静态分析和三个管理后台构建通过;完整测试仍有2项失败,后端模型注释检查未通过,详见交付记录。
This commit is contained in:
59
backend/api/internal/logic/client/user/gas_confirm.go
Normal file
59
backend/api/internal/logic/client/user/gas_confirm.go
Normal file
@@ -0,0 +1,59 @@
|
||||
// 功能描述:用户本人确认供气签收,原子记录证据与释放气瓶占用;版本:1.0.0。
|
||||
package user
|
||||
|
||||
import (
|
||||
"git.apinb.com/bsm-sdk/core/errcode"
|
||||
"git.apinb.com/bsm-sdk/core/infra"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/impl"
|
||||
common "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/common"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ConfirmGasReceipt JWT用户确认只处理待签收订单;已完成重试无二次写入。
|
||||
func ConfirmGasReceipt(ctx *gin.Context) {
|
||||
account, ok := common.UserAccount(ctx)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var request struct {
|
||||
RequestNo string `json:"request_no" binding:"required,max=128"`
|
||||
}
|
||||
if ctx.ShouldBindJSON(&request) != nil {
|
||||
infra.Response.Error(ctx, errcode.ErrInvalidArgument)
|
||||
return
|
||||
}
|
||||
err := impl.DBService.Transaction(func(tx *gorm.DB) error {
|
||||
var order models.GasorderBasic
|
||||
if err := tx.Clauses(clause.Locking{Strength: "UPDATE"}).Where("identity = ? AND user_account_id = ? AND status <> ?", ctx.Param("identity"), account.ID, common.StatusArchived).First(&order).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if order.OrderStatus == common.StatusCompleted {
|
||||
return nil
|
||||
}
|
||||
if order.OrderStatus != common.StatusAwaitingConfirmation {
|
||||
return errcode.ErrInvalidArgument
|
||||
}
|
||||
now := time.Now()
|
||||
// user_app表示本人通过已认证会话明确确认,不伪造手写签名、签收码或图片。
|
||||
confirm := models.GasorderConfirm{Entity: common.NewEntity(common.StatusEnable), GasorderBasicID: order.ID, RequestNo: request.RequestNo, ConfirmType: "user_app", RecipientName: account.Name, RecipientPhone: account.Phone, ConfirmedAt: now, Remark: "本人通过用户端确认收货"}
|
||||
if err := tx.Create(&confirm).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Model(&order).Update("order_status", common.StatusCompleted).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Model(&models.GasorderItem{}).Where("gasorder_basic_id = ?", order.ID).Update("active", false).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.Create(&models.GasorderStatus{Entity: common.NewEntity(common.StatusEnable), GasorderBasicID: order.ID, FromStatus: common.StatusAwaitingConfirmation, ToStatus: common.StatusCompleted, OperatorIdentity: account.Identity, OperatorName: account.Name, OccurredAt: now, Reason: "本人通过用户端确认收货"}).Error
|
||||
})
|
||||
if err != nil {
|
||||
gasDetailError(ctx, err)
|
||||
return
|
||||
}
|
||||
infra.Response.Success(ctx, gin.H{"confirmed": true, "order_status": common.StatusCompleted})
|
||||
}
|
||||
Reference in New Issue
Block a user