1.更新商品资料后同步更新库存商品信息;
2.添加展示所有订单的接口;
This commit is contained in:
parent
0bdbfeb908
commit
e8a7739fb1
|
@ -7,6 +7,7 @@ import (
|
|||
"go-admin/app/admin/middleware"
|
||||
"go-admin/app/admin/models"
|
||||
orm "go-admin/common/global"
|
||||
"go-admin/logger"
|
||||
"go-admin/tools/app"
|
||||
"io"
|
||||
"net/http"
|
||||
|
@ -251,13 +252,13 @@ func CommodityEdit(c *gin.Context) {
|
|||
|
||||
err := c.ShouldBindJSON(&req)
|
||||
if err != nil {
|
||||
//logger.Error(err)
|
||||
logger.Error("ShouldBindJSON err:", logger.Field("err", err))
|
||||
app.Error(c, http.StatusBadRequest, errors.New("para err"), "参数错误:"+err.Error())
|
||||
return
|
||||
}
|
||||
barCode := ""
|
||||
if req.ErpBarcode != "" { // 条码不为空则校验
|
||||
barCode, err = models.CheckAndConvertBarcode(req.ErpBarcode)
|
||||
barCode, err = models.CheckBarcodeById(req.ErpBarcode, req.Id)
|
||||
if err != nil {
|
||||
app.Error(c, http.StatusBadRequest, errors.New("param err"), "参数错误:"+err.Error())
|
||||
return
|
||||
|
@ -295,31 +296,46 @@ func CommodityEdit(c *gin.Context) {
|
|||
commodity.ID = req.Id
|
||||
err = commodity.SetErpCategory()
|
||||
if err != nil {
|
||||
//logger.Error("set erp category err:", err)
|
||||
logger.Error("set erp category err:", logger.Field("err", err))
|
||||
app.Error(c, http.StatusInternalServerError, err, "操作失败")
|
||||
return
|
||||
}
|
||||
commodity.IdInit()
|
||||
|
||||
var catCommodity models.ErpCommodity
|
||||
//err = orm.Eloquent.Table("erp_commodity").Where("erp_category_id=?", req.Id).Limit(1).Find(&catCommodity).Error
|
||||
err = orm.Eloquent.Table("erp_commodity").Where("id=?", req.Id).Find(&catCommodity).Error
|
||||
if err != nil {
|
||||
//logger.Error("cat erp commodity err:", err)
|
||||
logger.Error("cat erp commodity err:", logger.Field("err", err))
|
||||
app.Error(c, http.StatusInternalServerError, err, "操作失败")
|
||||
return
|
||||
}
|
||||
commodity.Number = catCommodity.Number
|
||||
commodity.SerialNumber = catCommodity.SerialNumber
|
||||
|
||||
err = orm.Eloquent.Save(commodity).Error
|
||||
begin := orm.Eloquent.Begin()
|
||||
err = begin.Save(commodity).Error
|
||||
if err != nil {
|
||||
//logger.Error("create commodity err:", err)
|
||||
logger.Error("create commodity err:", logger.Field("err", err))
|
||||
app.Error(c, http.StatusInternalServerError, err, "操作失败")
|
||||
return
|
||||
}
|
||||
|
||||
// todo 同步更新库存表和库存商品表的"指导零售价"和"最低零售价"
|
||||
// 同步更新库存表和库存商品表的"指导零售价"和"最低零售价"
|
||||
err = models.UpdateErpStockAmountInfo(begin, req.Id, req.RetailPrice, req.MinRetailPrice)
|
||||
if err != nil {
|
||||
begin.Rollback()
|
||||
logger.Error("UpdateErpStockAmountInfo err:", logger.Field("err", err))
|
||||
app.Error(c, http.StatusInternalServerError, err, "操作失败")
|
||||
return
|
||||
}
|
||||
|
||||
err = begin.Commit().Error
|
||||
if err != nil {
|
||||
begin.Rollback()
|
||||
logger.Error("commit err:", logger.Field("err", err))
|
||||
app.Error(c, http.StatusInternalServerError, err, "操作失败")
|
||||
return
|
||||
}
|
||||
|
||||
app.OK(c, commodity, "")
|
||||
return
|
||||
|
|
|
@ -153,6 +153,14 @@ func ErpOrderAudit(c *gin.Context) {
|
|||
app.Error(c, http.StatusBadRequest, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
sysUser, err := model.GetSysUserByCtx(c)
|
||||
if err != nil {
|
||||
logger.Errorf("err:%#v", err)
|
||||
app.Error(c, http.StatusInternalServerError, errors.New("order list err"), "获取订单列表失败")
|
||||
return
|
||||
}
|
||||
|
||||
var erpOrder model.ErpOrder
|
||||
err = orm.Eloquent.Table("erp_order").Where("bill_sn = ?", req.BillSn).Find(&erpOrder).Error
|
||||
if err != nil {
|
||||
|
@ -202,6 +210,8 @@ func ErpOrderAudit(c *gin.Context) {
|
|||
"state": orderState,
|
||||
"pay_status": nPayStatus,
|
||||
"audit_time": time.Now(),
|
||||
"auditor_name": sysUser.NickName,
|
||||
"auditor_id": sysUser.UserId,
|
||||
}).Error
|
||||
if err != nil {
|
||||
begin.Rollback()
|
||||
|
@ -494,3 +504,36 @@ func ErpOrderReceiptData(c *gin.Context) {
|
|||
app.OK(c, resp, "")
|
||||
return
|
||||
}
|
||||
|
||||
// ErpOrderShowAllData 展示所有订单
|
||||
// @Summary 展示所有订单
|
||||
// @Tags 零售订单
|
||||
// @Produce json
|
||||
// @Accept json
|
||||
// @Param request body models.ErpOrderShowConfig true "展示所有订单模型"
|
||||
// @Success 200 {object} app.Response
|
||||
// @Router /api/v1/erp_order/show_all_data [post]
|
||||
func ErpOrderShowAllData(c *gin.Context) {
|
||||
var req = new(model.ErpOrderShowConfig)
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
logger.Error("ShouldBindJSON err:", logger.Field("err", err))
|
||||
app.Error(c, http.StatusBadRequest, err, "参数错误:"+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err := tools.Validate(req) //必填参数校验
|
||||
if err != nil {
|
||||
app.Error(c, http.StatusBadRequest, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err = model.SetErpOrderShowConfig(req)
|
||||
if err != nil {
|
||||
logger.Error("SetErpOrderShowConfig err:", logger.Field("err", err))
|
||||
app.Error(c, http.StatusInternalServerError, err, "设置失败:"+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
app.OK(c, nil, "")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -2063,6 +2063,51 @@ func CheckAndConvertBarcode(input string) (string, error) {
|
|||
return input, nil
|
||||
}
|
||||
|
||||
// CheckBarcodeById 校验输入的条码数据是否正确
|
||||
func CheckBarcodeById(input string, commodityId uint32) (string, error) {
|
||||
// 1. 检查总长度不超过100字符
|
||||
if utf8.RuneCountInString(input) > 100 {
|
||||
return "", errors.New("error: Total length exceeds 100 characters")
|
||||
}
|
||||
|
||||
// 2. 转换中文逗号为英文逗号
|
||||
input = strings.ReplaceAll(input, ",", ",")
|
||||
|
||||
// 3. 两个逗号之前需要有数据,不能是空格或无数据
|
||||
parts := strings.Split(input, ",")
|
||||
for _, part := range parts {
|
||||
trimmedPart := strings.TrimSpace(part)
|
||||
if trimmedPart == "" {
|
||||
return "", errors.New("error: Two commas should have data in between")
|
||||
}
|
||||
}
|
||||
|
||||
// 4.判断逗号隔开的数据数据库是否已存在
|
||||
for _, part := range parts {
|
||||
// 检查生成的条码是否已存在
|
||||
exist, err := QueryRecordExist(fmt.Sprintf("SELECT * FROM erp_commodity WHERE FIND_IN_SET(%s, erp_barcode) > 0", part))
|
||||
if err != nil {
|
||||
logger.Error("exist sn err")
|
||||
}
|
||||
if exist {
|
||||
var commodityInfo ErpCommodity
|
||||
err = orm.Eloquent.Table("erp_commodity").Where("id=?", commodityId).Find(&commodityInfo).Error
|
||||
if err != nil {
|
||||
logger.Errorf("get erp_commodity err:", err)
|
||||
return "", err
|
||||
}
|
||||
if commodityInfo.ErpBarcode == input {
|
||||
return input, nil
|
||||
} else {
|
||||
return "", errors.New("[" + part + "]" + "该条码已存在,请检查")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果通过所有检查,返回处理后的字符串
|
||||
return input, nil
|
||||
}
|
||||
|
||||
// GenerateBarcode 系统生成条码
|
||||
func GenerateBarcode(categoryCode uint32) (string, error) {
|
||||
category := new(Category)
|
||||
|
|
|
@ -36,6 +36,7 @@ const (
|
|||
ConfigActivityRenewal = "activity_renewal_config" // 活动配置
|
||||
ConfigRecycleCard = "recycle_card_config" // 回收卡配置
|
||||
ConfigCooperativePayInfo = "cooperative_pay_info" // 合作商支付设置
|
||||
ConfigErpOrderShowInfo = "erp_order_show_config" // 零售订单显示设置
|
||||
)
|
||||
|
||||
func PayConfigInfo() (*PayConfig, error) {
|
||||
|
@ -298,6 +299,7 @@ type CooperativePayInfo struct {
|
|||
WxAppMchSecret string `json:"wx_app_mchSecret" gorm:"index"` // 微信支付商户密钥
|
||||
}
|
||||
|
||||
// SetPayInfo 设置合作商的支付信息(聚合支付、微信支付等)
|
||||
func SetPayInfo(req *CooperativeSetPayInfoReq) error {
|
||||
payInfo := CooperativePayInfo{
|
||||
CooperativeBusinessId: req.CooperativeBusinessId,
|
||||
|
@ -316,7 +318,7 @@ func SetPayInfo(req *CooperativeSetPayInfoReq) error {
|
|||
var configInfo Config
|
||||
err = orm.Eloquent.Table("config").Where("name=?", ConfigCooperativePayInfo).Find(&configInfo).Error
|
||||
if err != nil {
|
||||
logger.Error("query erp_order err:", logger.Field("err", err))
|
||||
logger.Error("query config err:", logger.Field("err", err))
|
||||
return errors.New("操作失败:" + err.Error())
|
||||
}
|
||||
|
||||
|
@ -344,6 +346,7 @@ func SetPayInfo(req *CooperativeSetPayInfoReq) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetPayInfo 获取合作商的支付信息(聚合支付、微信支付等)
|
||||
func GetPayInfo() (*CooperativePayInfo, error) {
|
||||
payConfig := new(CooperativePayInfo)
|
||||
var configAllocation Config
|
||||
|
@ -361,3 +364,69 @@ func GetPayInfo() (*CooperativePayInfo, error) {
|
|||
|
||||
return payConfig, nil
|
||||
}
|
||||
|
||||
type ErpOrderShowConfig struct {
|
||||
ShowAll string `json:"show_all" binding:"required"` // 展示所有订单配置:ON-打开,OFF-关闭
|
||||
}
|
||||
|
||||
// SetErpOrderShowConfig 设置零售订单展示配置信息
|
||||
func SetErpOrderShowConfig(req *ErpOrderShowConfig) error {
|
||||
showInfo := ErpOrderShowConfig{
|
||||
ShowAll: req.ShowAll,
|
||||
}
|
||||
|
||||
jShowInfo, err := json.Marshal(showInfo)
|
||||
if err != nil {
|
||||
logger.Errorf("ConfigErpOrderShowInfo marshal err:", logger.Field("err", err))
|
||||
return err
|
||||
}
|
||||
|
||||
var configInfo Config
|
||||
err = orm.Eloquent.Table("config").Where("name=?", ConfigErpOrderShowInfo).Find(&configInfo).Error
|
||||
if err != nil {
|
||||
logger.Error("query config err:", logger.Field("err", err))
|
||||
return errors.New("操作失败:" + err.Error())
|
||||
}
|
||||
|
||||
if errors.Is(err, RecordNotFound) || configInfo.ID == 0 { // 没有记录则新增
|
||||
configInfo.Name = ConfigErpOrderShowInfo
|
||||
configInfo.Value = string(jShowInfo)
|
||||
err = orm.Eloquent.Create(&configInfo).Error
|
||||
if err != nil {
|
||||
logger.Errorf("create ConfigErpOrderShowInfo err:", logger.Field("err", err))
|
||||
return errors.New("保存失败:" + err.Error())
|
||||
}
|
||||
} else { // 有记录则更新
|
||||
var updateConfigInfo Config
|
||||
updateConfigInfo.ID = configInfo.ID
|
||||
updateConfigInfo.Name = ConfigErpOrderShowInfo
|
||||
updateConfigInfo.Value = string(jShowInfo)
|
||||
|
||||
err = orm.Eloquent.Model(&Config{}).Where("id = ?", configInfo.ID).Updates(updateConfigInfo).Error
|
||||
if err != nil {
|
||||
logger.Error("update ConfigErpOrderShowInfo err:", logger.Field("err", err))
|
||||
return errors.New("保存失败:" + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetErpOrderShowConfig 获取零售订单展示配置信息
|
||||
func GetErpOrderShowConfig() (*ErpOrderShowConfig, error) {
|
||||
erpOrderShowConfig := new(ErpOrderShowConfig)
|
||||
var configAllocation Config
|
||||
err := orm.Eloquent.Table("config").Where("name=?", ConfigErpOrderShowInfo).Find(&configAllocation).Error
|
||||
if err != nil {
|
||||
logger.Errorf("err:", err)
|
||||
return erpOrderShowConfig, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal([]byte(configAllocation.Value), erpOrderShowConfig)
|
||||
if err != nil {
|
||||
logger.Errorf("err:", err)
|
||||
return erpOrderShowConfig, err
|
||||
}
|
||||
|
||||
return erpOrderShowConfig, nil
|
||||
}
|
||||
|
|
|
@ -402,6 +402,11 @@ type TableData struct {
|
|||
|
||||
// List 查询零售订单列表
|
||||
func (m *ErpOrderListReq) List() (*ErpOrderListResp, error) {
|
||||
showConfig, err := GetErpOrderShowConfig()
|
||||
if err != nil {
|
||||
logger.Errorf("List err:", err)
|
||||
showConfig.ShowAll = "ON"
|
||||
}
|
||||
resp := &ErpOrderListResp{
|
||||
PageIndex: m.PageIndex,
|
||||
PageSize: m.PageSize,
|
||||
|
@ -414,14 +419,17 @@ func (m *ErpOrderListReq) List() (*ErpOrderListResp, error) {
|
|||
m.PageSize = 10
|
||||
}
|
||||
if m.ScanCode != "" { // 扫描了串码,需要查询已售的商品数据
|
||||
return QueryListByScanCode(m.ScanCode)
|
||||
return QueryListByScanCode(m.ScanCode, showConfig.ShowAll)
|
||||
}
|
||||
|
||||
if m.CommodityName != "" { // 输入了商品名称进行查询
|
||||
return QueryListByCommodityName(m)
|
||||
return QueryListByCommodityName(m, showConfig.ShowAll)
|
||||
}
|
||||
|
||||
qs := orm.Eloquent.Table("erp_order")
|
||||
if showConfig.ShowAll == "OFF" {
|
||||
qs = qs.Where("invoice_code != ?", 0)
|
||||
}
|
||||
if m.BillSn != "" {
|
||||
qs = qs.Where("bill_sn=?", m.BillSn)
|
||||
} else {
|
||||
|
@ -464,7 +472,7 @@ func (m *ErpOrderListReq) List() (*ErpOrderListResp, error) {
|
|||
}
|
||||
|
||||
var count int64
|
||||
err := qs.Count(&count).Error
|
||||
err = qs.Count(&count).Error
|
||||
if err != nil {
|
||||
logger.Error("count err:", logger.Field("err", err))
|
||||
return resp, err
|
||||
|
@ -491,7 +499,7 @@ func (m *ErpOrderListReq) List() (*ErpOrderListResp, error) {
|
|||
}
|
||||
|
||||
// QueryListByScanCode 通过扫描串码查询列表
|
||||
func QueryListByScanCode(scanCode string) (*ErpOrderListResp, error) {
|
||||
func QueryListByScanCode(scanCode, showConfig string) (*ErpOrderListResp, error) {
|
||||
resp := &ErpOrderListResp{}
|
||||
|
||||
var commodity ErpOrderCommodity
|
||||
|
@ -502,7 +510,11 @@ func QueryListByScanCode(scanCode string) (*ErpOrderListResp, error) {
|
|||
}
|
||||
|
||||
var orders []ErpOrder
|
||||
if showConfig == "OFF" {
|
||||
err = orm.Eloquent.Table("erp_order").Where("id = ? and pay_status = ? and invoice_code != ?", commodity.ErpOrderId, HavePaid, 0).Find(&orders).Error
|
||||
} else {
|
||||
err = orm.Eloquent.Table("erp_order").Where("id = ? and pay_status = ?", commodity.ErpOrderId, HavePaid).Find(&orders).Error
|
||||
}
|
||||
if err != nil && err != RecordNotFound {
|
||||
logger.Error("get erp_order err:", logger.Field("err", err))
|
||||
return resp, err
|
||||
|
@ -523,7 +535,7 @@ func QueryListByScanCode(scanCode string) (*ErpOrderListResp, error) {
|
|||
}
|
||||
|
||||
// QueryListByCommodityName 通过商品名称查询列表
|
||||
func QueryListByCommodityName(req *ErpOrderListReq) (*ErpOrderListResp, error) {
|
||||
func QueryListByCommodityName(req *ErpOrderListReq, showConfig string) (*ErpOrderListResp, error) {
|
||||
resp := &ErpOrderListResp{
|
||||
PageIndex: req.PageIndex,
|
||||
PageSize: req.PageSize,
|
||||
|
@ -544,6 +556,10 @@ func QueryListByCommodityName(req *ErpOrderListReq) (*ErpOrderListResp, error) {
|
|||
qs = qs.Where("erp_order_commodity.erp_commodity_name like ?", "%"+req.CommodityName+"%")
|
||||
}
|
||||
|
||||
if showConfig == "OFF" {
|
||||
qs = qs.Where("invoice_code != ?", 0)
|
||||
}
|
||||
|
||||
if req.Tel != "" { // 用户手机号
|
||||
qs = qs.Where("erp_order.tel=?", req.Tel)
|
||||
}
|
||||
|
@ -1327,6 +1343,11 @@ func CommodityIsHaveStock(req ErpOrderCommodity, storeId uint32) bool {
|
|||
|
||||
// QueryStoreManageData 查询门店经营数据
|
||||
func QueryStoreManageData(req *ErpOrderStoreManageDataReq) (*ErpOrderStoreManageDataResp, error) {
|
||||
showConfig, err := GetErpOrderShowConfig()
|
||||
if err != nil {
|
||||
logger.Errorf("List err:", err)
|
||||
showConfig.ShowAll = "ON"
|
||||
}
|
||||
resp := &ErpOrderStoreManageDataResp{
|
||||
PageIndex: req.PageIndex,
|
||||
PageSize: req.PageSize,
|
||||
|
@ -1345,6 +1366,9 @@ func QueryStoreManageData(req *ErpOrderStoreManageDataReq) (*ErpOrderStoreManage
|
|||
if req.StoreId != 0 {
|
||||
qs = qs.Where("store_id = ?", req.StoreId)
|
||||
}
|
||||
if showConfig.ShowAll == "OFF" {
|
||||
qs = qs.Where("invoice_code != ?", 0)
|
||||
}
|
||||
|
||||
if req.StartTime != "" && req.EndTime != "" {
|
||||
startTime, err := time.Parse(QueryTimeFormat, req.StartTime)
|
||||
|
@ -1366,7 +1390,7 @@ func QueryStoreManageData(req *ErpOrderStoreManageDataReq) (*ErpOrderStoreManage
|
|||
es := qs
|
||||
|
||||
// 获取总条数
|
||||
err := es.Select("DATE_FORMAT(maker_time, '%Y-%m-%d') AS date, SUM(total_amount) AS total_sales_amount, " +
|
||||
err = es.Select("DATE_FORMAT(maker_time, '%Y-%m-%d') AS date, SUM(total_amount) AS total_sales_amount, " +
|
||||
"(SUM(total_retail_price) - SUM(total_amount)) AS promotion_fee, " +
|
||||
"SUM(total_sales_profit) AS sales_profit, SUM(total_staff_profit) AS staff_profit, SUM(total_count) AS count").
|
||||
Group("date").
|
||||
|
@ -1546,6 +1570,11 @@ func retailMarginDataExport(req *ErpOrderRetailMarginResp) (string, error) {
|
|||
|
||||
// QueryRetailMargin 查询零售毛利汇总数据
|
||||
func QueryRetailMargin(req *ErpOrderRetailMarginReq) (*ErpOrderRetailMarginResp, error) {
|
||||
showConfig, err := GetErpOrderShowConfig()
|
||||
if err != nil {
|
||||
logger.Errorf("List err:", err)
|
||||
showConfig.ShowAll = "ON"
|
||||
}
|
||||
resp := &ErpOrderRetailMarginResp{
|
||||
PageIndex: req.PageIndex,
|
||||
PageSize: req.PageSize,
|
||||
|
@ -1590,6 +1619,9 @@ func QueryRetailMargin(req *ErpOrderRetailMarginReq) (*ErpOrderRetailMarginResp,
|
|||
logger.Errorf("QueryRetailMargin time end parse err:", err.Error())
|
||||
}
|
||||
}
|
||||
if showConfig.ShowAll == "OFF" {
|
||||
qs = qs.Where("erp_order.invoice_code != ?", 0)
|
||||
}
|
||||
|
||||
var result []struct {
|
||||
ErpOrderCommodity
|
||||
|
@ -1980,6 +2012,11 @@ type RetailDetailByJoin struct {
|
|||
|
||||
// 联表查询
|
||||
func queryRetailDetailByJoin(req *ErpOrderRetailDetailReq) (*ErpOrderRetailDetailResp, error) {
|
||||
showConfig, err := GetErpOrderShowConfig()
|
||||
if err != nil {
|
||||
logger.Errorf("List err:", err)
|
||||
showConfig.ShowAll = "ON"
|
||||
}
|
||||
resp := &ErpOrderRetailDetailResp{
|
||||
PageIndex: req.PageIndex,
|
||||
PageSize: req.PageSize,
|
||||
|
@ -2033,6 +2070,9 @@ func queryRetailDetailByJoin(req *ErpOrderRetailDetailReq) (*ErpOrderRetailDetai
|
|||
parse = parse.AddDate(0, 0, 1)
|
||||
qs = qs.Where("erp_order.audit_time < ?", parse)
|
||||
}
|
||||
if showConfig.ShowAll == "OFF" {
|
||||
qs = qs.Where("erp_order.invoice_code != ?", 0)
|
||||
}
|
||||
qs.Where("erp_order.pay_status = ?", HavePaid)
|
||||
es := qs
|
||||
|
||||
|
@ -2040,7 +2080,7 @@ func queryRetailDetailByJoin(req *ErpOrderRetailDetailReq) (*ErpOrderRetailDetai
|
|||
orderSumQs := qs
|
||||
totalPerQs := qs
|
||||
cashierQs := qs
|
||||
err := orderSumQs.Debug().Select("SUM(erp_order_commodity.count) as count, " +
|
||||
err = orderSumQs.Debug().Select("SUM(erp_order_commodity.count) as count, " +
|
||||
"SUM(erp_order_commodity.retail_price) as retail_price, " +
|
||||
"SUM(erp_order_commodity.sale_price) as sale_price, " +
|
||||
"SUM(erp_order_commodity.sale_discount) as sale_discount, " +
|
||||
|
@ -2234,6 +2274,11 @@ func packData(result []RetailDetailByJoin) []ErpOrder {
|
|||
|
||||
// 普通单表查询,然后补充收款数据和商品数据
|
||||
func queryRetailDetailCommon(req *ErpOrderRetailDetailReq) (*ErpOrderRetailDetailResp, error) {
|
||||
showConfig, err := GetErpOrderShowConfig()
|
||||
if err != nil {
|
||||
logger.Errorf("List err:", err)
|
||||
showConfig.ShowAll = "ON"
|
||||
}
|
||||
resp := &ErpOrderRetailDetailResp{
|
||||
PageIndex: req.PageIndex,
|
||||
PageSize: req.PageSize,
|
||||
|
@ -2248,6 +2293,9 @@ func queryRetailDetailCommon(req *ErpOrderRetailDetailReq) (*ErpOrderRetailDetai
|
|||
}
|
||||
|
||||
qs := orm.Eloquent.Table("erp_order")
|
||||
if showConfig.ShowAll == "OFF" {
|
||||
qs = qs.Where("invoice_code != ?", 0)
|
||||
}
|
||||
if req.BillSn != "" { // 订单编号
|
||||
qs = qs.Where("bill_sn=?", req.BillSn)
|
||||
} else {
|
||||
|
@ -2288,7 +2336,7 @@ func queryRetailDetailCommon(req *ErpOrderRetailDetailReq) (*ErpOrderRetailDetai
|
|||
orderSumQs := qs
|
||||
totalPerQs := qs
|
||||
cashierQs := qs
|
||||
err := orderSumQs.Debug().Select("SUM(erp_order_commodity.count) as count, " +
|
||||
err = orderSumQs.Debug().Select("SUM(erp_order_commodity.count) as count, " +
|
||||
"SUM(erp_order_commodity.retail_price) as retail_price, " +
|
||||
"SUM(erp_order_commodity.sale_price) as sale_price, " +
|
||||
"SUM(erp_order_commodity.sale_discount) as sale_discount, " +
|
||||
|
@ -2606,7 +2654,7 @@ func checkOrderData(req *ErpOrderCreateReq, sysUser *SysUser) (*ErpOrder, error)
|
|||
erpOrder := &ErpOrder{
|
||||
BillSn: NewErpBillSn(),
|
||||
RetailType: req.RetailType,
|
||||
Uid: sysUser.UserId,
|
||||
Uid: sysUser.UserId, // todo 待修改为用户id
|
||||
Tel: req.Tel,
|
||||
StoreId: req.StoreId,
|
||||
StoreName: req.StoreName,
|
||||
|
|
|
@ -1028,3 +1028,28 @@ func GenerateSerialNumber(categoryId uint32) (string, error) {
|
|||
fmt.Println("商品编号:", serialNumber)
|
||||
return serialNumber, nil
|
||||
}
|
||||
|
||||
// UpdateErpStockAmountInfo 更新库存和库存商品表的金额:指导零售价、最低零售价
|
||||
func UpdateErpStockAmountInfo(begin *gorm.DB, commodityId, retailPrice, minRetailPrice uint32) error {
|
||||
// 更新库存表
|
||||
err := begin.Table("erp_stock").Where("erp_commodity_id=?", commodityId).
|
||||
Updates(map[string]interface{}{
|
||||
"retail_price": retailPrice,
|
||||
"min_retail_price": minRetailPrice,
|
||||
}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 更新库存商品表
|
||||
err = begin.Table("erp_stock_commodity").Where("erp_commodity_id=? and state not in (2,5)", commodityId).
|
||||
Updates(map[string]interface{}{
|
||||
"retail_price": retailPrice,
|
||||
"min_retail_price": minRetailPrice,
|
||||
}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@ import (
|
|||
|
||||
func registerCommodityRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
r := v1.Group("/commodity").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||
r.POST("create", basic.CommodityCreate)
|
||||
r.POST("edit", basic.CommodityEdit)
|
||||
r.POST("delete", basic.CommodityDel)
|
||||
r.POST("list", basic.CommodityList)
|
||||
r.POST("detail", basic.CommodityDetail)
|
||||
r.POST("import_commodity_view", basic.CommodityImportView)
|
||||
r.POST("import_commodity", basic.CommodityImport)
|
||||
r.POST("create", basic.CommodityCreate) // 新增商品
|
||||
r.POST("edit", basic.CommodityEdit) // 编辑商品
|
||||
r.POST("delete", basic.CommodityDel) // 删除商品
|
||||
r.POST("list", basic.CommodityList) // 商品列表
|
||||
r.POST("detail", basic.CommodityDetail) // 商品详情
|
||||
r.POST("import_commodity_view", basic.CommodityImportView) // 导入商品资料预览
|
||||
r.POST("import_commodity", basic.CommodityImport) // 导入商品资料
|
||||
}
|
||||
|
|
|
@ -22,4 +22,5 @@ func registerErpOrderManageRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJW
|
|||
r.POST("retail_margin", erpordermanage.ErpOrderRetailMargin) // 查询商品零售毛利汇总
|
||||
r.POST("retail_detail", erpordermanage.ErpOrderRetailDetail) // 查询零售明细
|
||||
r.POST("receipt_data", erpordermanage.ErpOrderReceiptData) // 查询小票数据
|
||||
r.POST("show_all_data", erpordermanage.ErpOrderShowAllData) // 展示所有订单
|
||||
}
|
||||
|
|
45
docs/docs.go
45
docs/docs.go
|
@ -2052,6 +2052,39 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/erp_order/show_all_data": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"零售订单"
|
||||
],
|
||||
"summary": "展示所有订单",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "展示所有订单模型",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.ErpOrderShowConfig"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/app.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/erp_order/store_manage_data": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
|
@ -6776,6 +6809,18 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"models.ErpOrderShowConfig": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"show_all"
|
||||
],
|
||||
"properties": {
|
||||
"show_all": {
|
||||
"description": "展示所有订单配置:ON-打开,OFF-关闭",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.ErpOrderStoreManageDataReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
@ -2041,6 +2041,39 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/erp_order/show_all_data": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"零售订单"
|
||||
],
|
||||
"summary": "展示所有订单",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "展示所有订单模型",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/models.ErpOrderShowConfig"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/app.Response"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v1/erp_order/store_manage_data": {
|
||||
"post": {
|
||||
"consumes": [
|
||||
|
@ -6765,6 +6798,18 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"models.ErpOrderShowConfig": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"show_all"
|
||||
],
|
||||
"properties": {
|
||||
"show_all": {
|
||||
"description": "展示所有订单配置:ON-打开,OFF-关闭",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.ErpOrderStoreManageDataReq": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
|
|
@ -1781,6 +1781,14 @@ definitions:
|
|||
required:
|
||||
- uid
|
||||
type: object
|
||||
models.ErpOrderShowConfig:
|
||||
properties:
|
||||
show_all:
|
||||
description: 展示所有订单配置:ON-打开,OFF-关闭
|
||||
type: string
|
||||
required:
|
||||
- show_all
|
||||
type: object
|
||||
models.ErpOrderStoreManageDataReq:
|
||||
properties:
|
||||
end_time:
|
||||
|
@ -5490,6 +5498,27 @@ paths:
|
|||
summary: 查询商品零售毛利汇总
|
||||
tags:
|
||||
- 零售报表
|
||||
/api/v1/erp_order/show_all_data:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
parameters:
|
||||
- description: 展示所有订单模型
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/models.ErpOrderShowConfig'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/app.Response'
|
||||
summary: 展示所有订单
|
||||
tags:
|
||||
- 零售订单
|
||||
/api/v1/erp_order/store_manage_data:
|
||||
post:
|
||||
consumes:
|
||||
|
|
Loading…
Reference in New Issue
Block a user