2.从系统导出的excel数据,在外部对excel某一列进行更改时,新增的要回传到原来的地方;并对改动的地方进行覆盖。
3.销售单管理、出库管理、发货单三个接口里面展示第三方订单编号和快递单号
4.选择多个仓库时,只要选择发货单子就会报错
5.在这个/api/split-account-deduction-log/create接口里,当传参时,如果参数 total_amount 是0,则会报错 {"code":204,"data":{},"msg":"TotalAmount不能为空"} 0是金额数字,不能当空值进行判断(T)
传递参数created_by,没有往数据表里写入
6.商品销毁的同时写入日志,也能通过读取这个日志,还原销毁的商品。传出这个新增的接口
7.新增一个不需要签名认证的分帐扣钱日志列表接口,新增一个返回字段buniness_no,并对这个字段进行模糊查询。
测试接口:/open/split-account-deduction-log/list
8.增加个新接口:首先 调用 /api/sales-order/create 创建销售订单的时候会锁定库存,
现在我需要一个解锁库存的接口,传递参数是订单编号
POST /api/sales-order/unlock-inventory // 解锁销售订单库存
/api/split-account-deduction-log/update /api/sales-order/unlock-inventory 在这两个接口里不需要签名认证
/api/sales-order/unlock-inventory 在这个接口里面返回解锁的所有商品信息
/api/split-account-deduction-log/update 在这个接口里面的status也需要更改,status没有变化
166 lines
5.4 KiB
Go
166 lines
5.4 KiB
Go
package controllers
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/sirupsen/logrus"
|
|
"net/http"
|
|
"psi/constant"
|
|
"psi/database"
|
|
systemReq "psi/models/request"
|
|
systemRes "psi/models/response"
|
|
"psi/service"
|
|
"psi/utils"
|
|
)
|
|
|
|
type SplitAccountDeductionLogApi struct{}
|
|
|
|
var splitAccountDeductionLogService = service.SplitAccountDeductionLogService{}
|
|
|
|
// GetOpenSplitAccountDeductionLogList 公开获取分账扣钱日志列表(无需签名认证)
|
|
func (r *SplitAccountDeductionLogApi) GetOpenSplitAccountDeductionLogList(c *gin.Context) {
|
|
var req systemReq.GetSplitAccountDeductionLogListRequest
|
|
|
|
if err := c.ShouldBindQuery(&req); err != nil {
|
|
ValidAndFail(constant.LoggerChannelRequest, "公开分账扣钱日志列表请求参数异常", "参数错误: "+err.Error(), c, err)
|
|
return
|
|
}
|
|
|
|
result, err := splitAccountDeductionLogService.GetSplitAccountDeductionLogList(req, database.GetDB(c))
|
|
if err != nil {
|
|
utils.FailWithRequestLog(constant.LoggerChannelWork, "公开分账扣钱日志列表异常", err, c, req)
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"code": 200,
|
|
"data": result,
|
|
})
|
|
}
|
|
|
|
// GetSplitAccountDeductionLogList 获取分账扣钱日志列表
|
|
func (r *SplitAccountDeductionLogApi) GetSplitAccountDeductionLogList(c *gin.Context) {
|
|
var req systemReq.GetSplitAccountDeductionLogListRequest
|
|
|
|
if err := c.ShouldBindQuery(&req); err != nil {
|
|
ValidAndFail(constant.LoggerChannelRequest, "分账扣钱日志列表请求参数异常", "参数错误: "+err.Error(), c, err)
|
|
return
|
|
}
|
|
|
|
result, err := splitAccountDeductionLogService.GetSplitAccountDeductionLogList(req, database.GetDB(c))
|
|
if err != nil {
|
|
utils.FailWithRequestLog(constant.LoggerChannelWork, "分账扣钱日志列表异常", err, c, req)
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"code": 200,
|
|
"data": result,
|
|
})
|
|
}
|
|
|
|
// GetSplitAccountDeductionLogDetail 获取分账扣钱日志详情
|
|
func (r *SplitAccountDeductionLogApi) GetSplitAccountDeductionLogDetail(c *gin.Context) {
|
|
idStr := c.Param("id")
|
|
|
|
if idStr == "" {
|
|
utils.ErrorLog(constant.LoggerChannelRequest, logrus.Fields{
|
|
"source": "获取分账扣钱日志详情请求参数异常",
|
|
"err_msg": "ID参数不能为空",
|
|
})
|
|
systemRes.FailWithValidateMessage("参数错误: ID不能为空", c)
|
|
return
|
|
}
|
|
|
|
var id int64
|
|
if _, err := fmt.Sscanf(idStr, "%d", &id); err != nil || id <= 0 {
|
|
utils.ErrorLog(constant.LoggerChannelRequest, logrus.Fields{
|
|
"source": "获取分账扣钱日志详情请求参数异常",
|
|
"err_msg": "ID格式错误: " + idStr,
|
|
})
|
|
systemRes.FailWithValidateMessage("参数错误: ID格式不正确", c)
|
|
return
|
|
}
|
|
|
|
result, err := splitAccountDeductionLogService.GetSplitAccountDeductionLogDetail(id, database.GetDB(c))
|
|
if err != nil {
|
|
utils.FailWithRequestLog(constant.LoggerChannelWork, "分账扣钱日志详情异常", err, c, gin.H{"id": id})
|
|
return
|
|
}
|
|
|
|
systemRes.OkWithDetailed(result, "查询成功", c)
|
|
}
|
|
|
|
// CreateSplitAccountDeductionLog 创建分账扣钱日志
|
|
func (r *SplitAccountDeductionLogApi) CreateSplitAccountDeductionLog(c *gin.Context) {
|
|
var req systemReq.AddSplitAccountDeductionLogRequest
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
ValidAndFail(constant.LoggerChannelRequest, "创建分账扣钱日志请求参数异常", "参数错误: "+err.Error(), c, err)
|
|
return
|
|
}
|
|
|
|
if req.TotalAmount == nil {
|
|
systemRes.FailWithValidateMessage("TotalAmount不能为空", c)
|
|
return
|
|
}
|
|
if req.DeductionAmount == nil {
|
|
systemRes.FailWithValidateMessage("DeductionAmount不能为空", c)
|
|
return
|
|
}
|
|
if req.RemainingAmount == nil {
|
|
systemRes.FailWithValidateMessage("RemainingAmount不能为空", c)
|
|
return
|
|
}
|
|
|
|
userInfo := utils.GetUserInfo(c)
|
|
createdBy := req.CreatedBy
|
|
if createdBy == "" {
|
|
createdBy = userInfo.Username
|
|
}
|
|
id, err := splitAccountDeductionLogService.CreateSplitAccountDeductionLog(req, createdBy, database.GetDB(c))
|
|
if err != nil {
|
|
utils.FailWithRequestLog(constant.LoggerChannelWork, "创建分账扣钱日志异常", err, c, req)
|
|
return
|
|
}
|
|
systemRes.OkWithDetailed(gin.H{"id": id}, "创建成功", c)
|
|
}
|
|
|
|
// UpdateSplitAccountDeductionLog 更新分账扣钱日志
|
|
func (r *SplitAccountDeductionLogApi) UpdateSplitAccountDeductionLog(c *gin.Context) {
|
|
var req systemReq.UpdateSplitAccountDeductionLogRequest
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
ValidAndFail(constant.LoggerChannelRequest, "更新分账扣钱日志请求参数异常", "参数错误: "+err.Error(), c, err)
|
|
return
|
|
}
|
|
|
|
userInfo := utils.GetUserInfo(c)
|
|
err := splitAccountDeductionLogService.UpdateSplitAccountDeductionLog(req, userInfo.Username, database.GetDB(c))
|
|
if err != nil {
|
|
utils.FailWithRequestLog(constant.LoggerChannelWork, "更新分账扣钱日志异常", err, c, req)
|
|
return
|
|
}
|
|
|
|
systemRes.OkWithMessage("更新成功", c)
|
|
}
|
|
|
|
// DeleteSplitAccountDeductionLog 删除分账扣钱日志
|
|
func (r *SplitAccountDeductionLogApi) DeleteSplitAccountDeductionLog(c *gin.Context) {
|
|
var req systemReq.DeleteSplitAccountDeductionLogRequest
|
|
|
|
if err := c.ShouldBind(&req); err != nil {
|
|
ValidAndFail(constant.LoggerChannelRequest, "删除分账扣钱日志请求参数异常", "参数错误: "+err.Error(), c, err)
|
|
return
|
|
}
|
|
|
|
userInfo := utils.GetUserInfo(c)
|
|
err := splitAccountDeductionLogService.DeleteSplitAccountDeductionLog(req, userInfo.Username, database.GetDB(c))
|
|
if err != nil {
|
|
utils.FailWithRequestLog(constant.LoggerChannelWork, "删除分账扣钱日志异常", err, c, req)
|
|
return
|
|
}
|
|
|
|
systemRes.OkWithMessage("删除成功", c)
|
|
}
|