瀏覽代碼

接口文档优化

zoie 1 年之前
父節點
當前提交
52de2f9fc7

+ 2 - 0
app/admin/controller/address.go

@@ -20,6 +20,8 @@ type AddressController struct {
 // @Summary 获取收货地址列表
 // @Description 获取收货地址列表
 // @Tags 收货地址
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Address}} "{"code": 200, "data": [...]}"
 // @Router /api/address [get]
 // @Security Bearer

+ 33 - 5
app/admin/controller/applet_customer.go

@@ -13,11 +13,10 @@ type AppletCustomerController struct {
 	api.Api
 }
 
-// GetPage 获取客户信息列表
-// @Summary 获取客户信息列表
-// @Description 获取客户信息列表
-// @Tags 客户信息
-// @Param name query string false "客户信息名称"
+// Login 小程序登录
+// @Summary 小程序登录
+// @Description 小程序登录
+// @Tags 客户小程序
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Customer}} "{"code": 200, "data": [...]}"
 // @Router /api/customer [get]
 // @Security Bearer
@@ -46,3 +45,32 @@ func (e AppletCustomerController) Login(c *gin.Context) {
 	}
 	e.OK(data, "查询成功")
 }
+
+// Register 注册
+// @Summary 小程序登录
+// @Description 小程序登录
+// @Tags 客户小程序
+// @Success 200 {object} response.Response{data=response.Page{list=[]model.Customer}} "{"code": 200, "data": [...]}"
+// @Router /api/customer [get]
+// @Security Bearer
+func (e AppletCustomerController) Register(c *gin.Context) {
+	s := service.AppletCustomer{}
+	req := dto.AppletCustomerRegisterReq{}
+	err := e.MakeContext(c).
+		MakeOrm().
+		Bind(&req, binding.JSON).
+		MakeService(&s.Service).
+		Errors
+	if err != nil {
+		e.Logger.Error(err)
+		e.Error(500, err, err.Error())
+		return
+	}
+
+	err = s.Register(&req)
+	if err != nil {
+		e.Error(500, err, err.Error())
+		return
+	}
+	e.OK(nil, "注册成功")
+}

+ 3 - 1
app/admin/controller/car_info.go

@@ -20,7 +20,9 @@ type CarInfoController struct {
 // @Summary 获取车辆信息列表
 // @Description 获取车辆信息列表
 // @Tags 车辆信息
-// @Param deptName query string false "车辆信息名称"
+// @Param carNo query string false "车牌号"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.CarInfo}} "{"code": 200, "data": [...]}"
 // @Router /api/car-info [get]
 // @Security Bearer

+ 5 - 1
app/admin/controller/customer.go

@@ -21,7 +21,11 @@ type CustomerController struct {
 // @Summary 获取客户信息列表
 // @Description 获取客户信息列表
 // @Tags 客户信息
-// @Param name query string false "客户信息名称"
+// @Param principalPhone query string false "电话"
+// @Param type           query string false "类型"
+// @Param address        query string false "地址"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Customer}} "{"code": 200, "data": [...]}"
 // @Router /api/customer [get]
 // @Security Bearer

+ 3 - 1
app/admin/controller/device.go

@@ -20,7 +20,9 @@ type DeviceController struct {
 // @Summary 获取设备列表
 // @Description 获取设备列表
 // @Tags 设备
-// @Param deptName query string false "设备名称"
+// @Param sn query string false "设备编码"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Device}} "{"code": 200, "data": [...]}"
 // @Router /api/device [get]
 // @Security Bearer

+ 3 - 1
app/admin/controller/dispatch_cost.go

@@ -20,7 +20,9 @@ type DispatchCostController struct {
 // @Summary 获取派费列表
 // @Description 获取派费列表
 // @Tags 派费
-// @Param deptName query string false "派费名称"
+// @Param name query string false "派费名称"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.DispatchCost}} "{"code": 200, "data": [...]}"
 // @Router /api/dispatch-cost [get]
 // @Security Bearer

+ 3 - 0
app/admin/controller/fill_check.go

@@ -20,6 +20,9 @@ type FillCheckController struct {
 // @Summary 获取充气前后检查列表
 // @Description 获取充气前后检查列表
 // @Tags 充气前后检查
+// @Param innerCode query string false "单位内编码"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.FillCheck}} "{"code": 200, "data": [...]}"
 // @Router /api/fill-check [get]
 // @Security Bearer

+ 8 - 1
app/admin/controller/fill_data.go

@@ -19,7 +19,14 @@ type FillDataController struct {
 // @Summary 获取上报实时充装数据
 // @Description 获取上报实时充装数据
 // @Tags 上报实时充装数据
-// @Param deptName query string false "上报实时充装数据名称"
+// @Param stationId      query string false "气站id"
+// @Param userId         query string false "充装人员id"
+// @Param innerCode      query string false "气瓶单位内编码"
+// @Param chipId         query string false "高频编码"
+// @Param startFillTime  query string false "充装开始时间"
+// @Param endFillTime    query string false "充装结束时间"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.FillData}} "{"code": 200, "data": [...]}"
 // @Router /api/goods [get]
 // @Security Bearer

+ 5 - 2
app/admin/controller/fill_gun.go

@@ -20,7 +20,11 @@ type FillGunController struct {
 // @Summary 获取充装枪列表
 // @Description 获取充装枪列表
 // @Tags 充装枪
-// @Param deptName query string false "充装枪名称"
+// @Param GunCode     query string false "充装枪编码"
+// @Param ScanGunCode query string false "扫描枪编码"
+// @Param PersonCode  query string false "充装人员编码"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.FillGun}} "{"code": 200, "data": [...]}"
 // @Router /api/goods [get]
 // @Security Bearer
@@ -193,4 +197,3 @@ func (e FillGunController) Delete(c *gin.Context) {
 	}
 	e.OK(req.GetId(), "删除成功")
 }
-

+ 22 - 20
app/admin/controller/gas_cylinder.go

@@ -15,12 +15,14 @@ type GasCylinderController struct {
 	api.Api
 }
 
-// GetPage 获取派费列表
-// @Summary 获取派费列表
-// @Description 获取派费列表
-// @Tags 派费
-// @Param deptName query string false "派费名称"
-// @Success 200 {object} response.Response{data=response.Page{list=[]model.GasCylinderSpec}} "{"code": 200, "data": [...]}"
+// GetPage 获取钢瓶档案列表
+// @Summary 获取钢瓶档案列表
+// @Description 获取钢瓶档案列表
+// @Tags 钢瓶档案
+// @Param innerCode query string false "单位内编码"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
+// @Success 200 {object} response.Response{data=response.Page{list=[]model.GasCylinder}} "{"code": 200, "data": [...]}"
 // @Router /api/dispatch-cost [get]
 // @Security Bearer
 func (e GasCylinderController) GetPage(c *gin.Context) {
@@ -51,11 +53,11 @@ func (e GasCylinderController) GetPage(c *gin.Context) {
 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
 }
 
-// Get 通过id获取商品
-// @Summary 通过id获取商品
-// @Description 通过id获取商品
-// @Tags 商品
-// @Param id path string true "商品id"
+// Get 通过id获取钢瓶档案
+// @Summary 通过id获取钢瓶档案
+// @Description 通过id获取钢瓶档案
+// @Tags 钢瓶档案
+// @Param id path string true "钢瓶档案id"
 // @Success 200 {object} response.Response{data=model.GasCylinder} "{"code": 200, "data": [...]}"
 // @Router /api/goods/{id} [get]
 // @Security Bearer
@@ -85,11 +87,11 @@ func (e GasCylinderController) Get(c *gin.Context) {
 	e.OK(object, "查询成功")
 }
 
-// Get 通过id获取商品
-// @Summary 通过id获取商品
-// @Description 通过id获取商品
-// @Tags 商品
-// @Param id path string true "商品id"
+// GetByUid 通过高频编码获取钢瓶信息
+// @Summary 通过高频编码获取钢瓶信息
+// @Description 通过高频编码获取钢瓶信息
+// @Tags 钢瓶档案
+// @Param chipUid path string true "高频编码"
 // @Success 200 {object} response.Response{data=model.GasCylinder} "{"code": 200, "data": [...]}"
 // @Router /api/goods/{id} [get]
 // @Security Bearer
@@ -130,10 +132,10 @@ func (e GasCylinderController) GetByUid(c *gin.Context) {
 }
 
 // Mock 模拟气瓶数据
-// @Summary 通过id获取商品
-// @Description 通过id获取商品
-// @Tags 商品
-// @Param id path string true "商品id"
+// @Summary 模拟气瓶数据
+// @Description 模拟气瓶数据
+// @Tags 钢瓶档案
+// @Param data body dto.GasCylinderMockReq true "data"
 // @Success 200 {object} response.Response{data=model.GasCylinder} "{"code": 200, "data": [...]}"
 // @Router /api/goods/{id} [get]
 // @Security Bearer

+ 24 - 22
app/admin/controller/gas_cylinder_spec.go

@@ -16,11 +16,11 @@ type GasCylinderSpecController struct {
 	api.Api
 }
 
-// GetPage 获取派费列表
-// @Summary 获取派费列表
-// @Description 获取派费列表
-// @Tags 派费
-// @Param deptName query string false "派费名称"
+// GetPage 获取钢瓶规格列表
+// @Summary 获取钢瓶规格列表
+// @Description 获取钢瓶规格列表
+// @Tags 钢瓶规格
+// @Param name query string false "钢瓶规格名称"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.GasCylinderSpec}} "{"code": 200, "data": [...]}"
 // @Router /api/dispatch-cost [get]
 // @Security Bearer
@@ -52,11 +52,11 @@ func (e GasCylinderSpecController) GetPage(c *gin.Context) {
 	e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
 }
 
-// Get 通过id获取派费
-// @Summary 通过id获取派费
-// @Description 通过id获取派费
-// @Tags 派费
-// @Param id path string true "派费id"
+// Get 通过id获取钢瓶规格
+// @Summary 通过id获取钢瓶规格
+// @Description 通过id获取钢瓶规格
+// @Tags 钢瓶规格
+// @Param id path string true "钢瓶规格id"
 // @Success 200 {object} response.Response{data=model.GasCylinderSpec} "{"code": 200, "data": [...]}"
 // @Router /api/dispatch-cost/{id} [get]
 // @Security Bearer
@@ -86,13 +86,15 @@ func (e GasCylinderSpecController) Get(c *gin.Context) {
 	e.OK(object, "查询成功")
 }
 
-// Insert 添加派费
-// @Summary 添加派费
-// @Description 添加派费
-// @Tags 派费
+// Insert 添加钢瓶规格
+// @Summary 添加钢瓶规格
+// @Description 添加钢瓶规格
+// @Tags 钢瓶规格
 // @Accept  application/json
 // @Product application/json
 // @Param data body dto.GasCylinderSpecInsertReq true "data"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {string} string	"{"code": 200, "message": "添加成功"}"
 // @Success 200 {string} string	"{"code": -1, "message": "添加失败"}"
 // @Router /api/dispatch-cost [post]
@@ -122,10 +124,10 @@ func (e GasCylinderSpecController) Insert(c *gin.Context) {
 	e.OK(req.GetId(), "创建成功")
 }
 
-// Update 修改派费
-// @Summary 修改派费
-// @Description 修改派费
-// @Tags 派费
+// Update 修改钢瓶规格
+// @Summary 修改钢瓶规格
+// @Description 修改钢瓶规格
+// @Tags 钢瓶规格
 // @Accept  application/json
 // @Product application/json
 // @Param data body dto.GasCylinderSpecUpdateReq true "body"
@@ -157,10 +159,10 @@ func (e GasCylinderSpecController) Update(c *gin.Context) {
 	e.OK(req.GetId(), "更新成功")
 }
 
-// Delete 删除派费
-// @Summary 删除派费
-// @Description 删除派费
-// @Tags 派费
+// Delete 删除钢瓶规格
+// @Summary 删除钢瓶规格
+// @Description 删除钢瓶规格
+// @Tags 钢瓶规格
 // @Accept  application/json
 // @Product application/json
 // @Param data body dto.GasCylinderSpecDeleteReq true "body"

+ 3 - 1
app/admin/controller/goods.go

@@ -20,7 +20,9 @@ type GoodsController struct {
 // @Summary 获取商品列表
 // @Description 获取商品列表
 // @Tags 商品
-// @Param deptName query string false "商品名称"
+// @Param name      query string false "商品名称"
+// @Param mediaType query string false "介质类型"
+// @Param isShow    query int false "是否展示 1-展示 2-不展示"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Goods}} "{"code": 200, "data": [...]}"
 // @Router /api/goods [get]
 // @Security Bearer

+ 7 - 1
app/admin/controller/inspect_record.go

@@ -20,7 +20,13 @@ type InspectRecordController struct {
 // @Summary 获取入户安全检查列表
 // @Description 获取入户安全检查列表
 // @Tags 入户安全检查
-// @Param deptName query string false "入户安全检查名称"
+// @Param state            query int false "订单状态 状态 0-待整改 1-整改中 2-已整改 -1 合格"
+// @Param inspectStartTime query string false "检查开始时间"
+// @Param inspectEndTime   query string false "检查结束时间"
+// @Param customerName     query string false "客户名称"
+// @Param inspectorName    query string false "检查人"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.InspectRecord}} "{"code": 200, "data": [...]}"
 // @Router /api/goods [get]
 // @Security Bearer

+ 4 - 1
app/admin/controller/operation_log.go

@@ -19,7 +19,10 @@ type OperationLogController struct {
 // @Summary 获取操作记录列表
 // @Description 获取操作记录列表
 // @Tags 操作记录
-// @Param deptName query string false "操作记录名称"
+// @Param optType   query int false "气瓶流转步骤"
+// @Param innerCode query string false "单位内编码"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.OperationLog}} "{"code": 200, "data": [...]}"
 // @Router /api/operation-log [get]
 // @Security Bearer

+ 11 - 3
app/admin/controller/order.go

@@ -15,10 +15,18 @@ type OrderController struct {
 	api.Api
 }
 
-// GetPage 获取单列表
-// @Summary 获取单列表
-// @Description 获取单列表
+// GetPage 获取单列表
+// @Summary 获取单列表
+// @Description 获取单列表
 // @Tags 订单
+// @Param state          query int false "订单状态 1-已下单 2-已派送 3-已送达 4-已取消"
+// @Param source         query int false "订单状态 1-坐席下单 2-小程序"
+// @Param orderStartTime query string false "下单开始时间"
+// @Param orderEndTime   query string false "下单结束时间"
+// @Param phone          query string false "客户电话"
+// @Param customerId     query string false "客户id"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Order}} "{"code": 200, "data": [...]}"
 // @Router /api/Order [get]
 // @Security Bearer

+ 3 - 1
app/admin/controller/real_fill_data.go

@@ -20,7 +20,9 @@ type RealFillDataController struct {
 // @Summary 获取上报实时充装数据
 // @Description 获取上报实时充装数据
 // @Tags 上报实时充装数据
-// @Param deptName query string false "上报实时充装数据名称"
+// @Param gunCode query string false "充装枪编码"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.RealFillData}} "{"code": 200, "data": [...]}"
 // @Router /api/goods [get]
 // @Security Bearer

+ 1 - 1
app/admin/controller/sys_role.go

@@ -27,7 +27,7 @@ type SysRoleController struct {
 // @Tags 角色
 // @Param roleName query string false "角色名称"
 // @Param pageSize query int false "页条数"
-// @Param pageIndex query int false "页码"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.SysRole}} "{"code": 200, "data": [...]}"
 // @Router /api/role [get]
 // @Security Bearer

+ 1 - 1
app/admin/controller/sys_user.go

@@ -36,7 +36,7 @@ type SysUser struct {
 // @Param postId query string false "岗位id"
 // @Param status query string false "状态 1-停用 2-正常"
 // @Param pageSize query int false "页条数"
-// @Param pageIndex query int false "页码"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.SysUser}}  "{"code": 200, "data": [...]}"
 // @Router /api/sys-user [get]
 // @Security Bearer

+ 1 - 1
app/admin/controller/truck_enterprise.go

@@ -21,7 +21,7 @@ type TruckEnterpriseController struct {
 // @Summary 获取运输企业列表
 // @Description 获取运输企业列表
 // @Tags 运输企业
-// @Param deptName query string false "运输企业名称"
+// @Param name query string false "运输企业名称"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.SysDept}} "{"code": 200, "data": [...]}"
 // @Router /api/truck-enterprise [get]
 // @Security Bearer

+ 3 - 1
app/admin/controller/warehouse.go

@@ -20,7 +20,9 @@ type WarehouseController struct {
 // @Summary 获取仓库列表
 // @Description 获取仓库列表
 // @Tags 仓库
-// @Param deptName query string false "仓库名称"
+// @Param name query string false "仓库名称"
+// @Param pageSize query int false "页条数"
+// @Param page query int false "页码"
 // @Success 200 {object} response.Response{data=response.Page{list=[]model.Warehouse}} "{"code": 200, "data": [...]}"
 // @Router /api/warehouse [get]
 // @Security Bearer

+ 17 - 0
app/admin/model/customer.go

@@ -2,6 +2,7 @@ package model
 
 import (
 	model2 "gas-cylinder-api/common/model"
+	"golang.org/x/crypto/bcrypt"
 )
 
 type ProvCustomer struct {
@@ -25,6 +26,7 @@ type Customer struct {
 	Openid     string `json:"openid"`                         // 微信id
 	State      int    `json:"state" gorm:"size:6;default:-1"` // 0-待整改 1-整改中 2-已整改 合格
 	Name       string `json:"principalName" gorm:"size:128;"`
+	Password   string `json:"-" gorm:"size:128;comment:密码"`
 	model2.ControlBy
 	model2.ModelTime
 	model2.DeptBy
@@ -44,3 +46,18 @@ type CustomerOmit struct {
 func (CustomerOmit) TableName() string {
 	return "customer"
 }
+
+// 加密
+func (e *Customer) Encrypt() (err error) {
+	if e.Password == "" {
+		return
+	}
+
+	var hash []byte
+	if hash, err = bcrypt.GenerateFromPassword([]byte(e.Password), bcrypt.DefaultCost); err != nil {
+		return
+	} else {
+		e.Password = string(hash)
+		return
+	}
+}

+ 1 - 1
app/admin/model/inspect_record.go

@@ -25,7 +25,7 @@ type ProvInspectRecord struct {
 	InspectTime       string            `json:"inspectTime" gorm:"size:19"  swaggerignore:"true"`   //检查时间
 	BeforeRectifyImg  string            `json:"beforeRectifyImg" gorm:"type:text"`                  //整改前图片
 	AfterRectifyImg   string            `json:"afterRectifyImg" gorm:"type:text"`                   //整改后图片
-	State             int               `json:"state" gorm:"size:4"`                                //状态 0-待整改 1-整改中 2-已整改
+	State             int               `json:"state" gorm:"size:4"`                                //状态 0-待整改 1-整改中 2-已整改 -1 合格
 	Remark            string            `json:"remark" gorm:"size:512"`                             //备注
 	CreatorId         string            `json:"creatorId" gorm:"size:36"  swaggerignore:"true"`     //创建人员id
 	InspectExpandList InspectExpandList `json:"inspectExpandList"`                                  //安全检查项目列表

+ 1 - 2
app/admin/model/sys_user.go

@@ -29,8 +29,7 @@ type ProvUser struct {
 	JobCategory string `json:"jobCategory" gorm:"size:64"`                  // 岗位类别
 	PersonQual  string `json:"personQual" gorm:"size:128"`                  // 资质
 	Isorders    int    `json:"isorders" gorm:"size:4"`                      // 用户类型 0-送气员 1-库管 userType=3时必填
-	CmpCode     string `json:"cmpCode" gorm:"size:48"`                      // 所属机构登记编
-
+	CmpCode     string `json:"cmpCode" gorm:"size:48"`                      // 所属机
 }
 
 // 送气人员绑定资质信息《燃气从业资格证》

+ 1 - 0
app/admin/router/applet_customer.go

@@ -83,6 +83,7 @@ func AppletCustomerRouterInit(v1 *gin.RouterGroup) {
 	r := v1.Group("/applet")
 	{
 		r.POST("/login", cont.Login)
+		r.POST("/register", cont.Register)
 
 	}
 }

+ 74 - 1
app/admin/service/applet_customer.go

@@ -9,6 +9,7 @@ import (
 	"gas-cylinder-api/conf"
 	"github.com/dgrijalva/jwt-go"
 	"github.com/gin-gonic/gin"
+	"gogs.baozhida.cn/zoie/OAuth-core/pkg"
 	"gogs.baozhida.cn/zoie/OAuth-core/pkg/utils"
 	"gogs.baozhida.cn/zoie/OAuth-core/service"
 	"gorm.io/gorm"
@@ -29,7 +30,7 @@ func GetAppletCustomerId(c *gin.Context) string {
 }
 
 // GetPage 获取Customer列表
-func (e *AppletCustomer) Login(c *dto.AppletCustomerLoginReq) (token, expiresAt string, err error) {
+func (e *AppletCustomer) WxLogin(c *dto.AppletCustomerWxLoginReq) (token, expiresAt string, err error) {
 	var data model.Customer
 
 	url := "https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code"
@@ -88,6 +89,78 @@ func (e *AppletCustomer) Login(c *dto.AppletCustomerLoginReq) (token, expiresAt
 	return token, expiresAt, nil
 
 }
+func (e *AppletCustomer) Login(c *dto.AppletCustomerLoginReq) (token, expiresAt string, err error) {
+	var data model.Customer
+
+	err = e.Orm.Where("principal_phone = ?", c.Phone).First(&data).Error
+	id := data.Id
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			return token, expiresAt, errors.New("用户名或密码错误")
+		} else {
+			return token, expiresAt, err
+		}
+	}
+
+	_, err = pkg.CompareHashAndPassword(data.Password, c.Password)
+	if err != nil {
+		e.Log.Errorf("user login error, %s", err.Error())
+		return token, expiresAt, errors.New("用户名或密码错误")
+	}
+
+	token, expiresAt, _ = e.GeneratorToken(id)
+	return token, expiresAt, nil
+
+}
+func (e *AppletCustomer) Register(c *dto.AppletCustomerRegisterReq) (err error) {
+	var data model.Customer
+
+	err = e.Orm.Where("principal_phone = ?", c.Phone).First(&data).Error
+	id := data.Id
+	if err != nil {
+		if errors.Is(err, gorm.ErrRecordNotFound) {
+			// 添加客户
+			for {
+				var count int64
+				id = utils.GetUUID()
+				var i int64
+				err = e.Orm.Model(&data).Where("id = ?", id).Count(&count).Error
+				if err != nil {
+					continue
+				}
+				if i == 0 {
+					break
+				}
+			}
+			err = e.Orm.Create(&model.Customer{
+				ProvCustomer: model.ProvCustomer{
+					Id:             id,
+					PrincipalPhone: c.Phone,
+				},
+				//Openid: wxRes.Openid,
+				Password: c.Password,
+			}).Error
+		} else {
+			return err
+		}
+	}
+
+	if len(data.Id) > 0 {
+		if len(data.Password) > 0 {
+			return errors.New("该手机号已注册")
+		} else {
+			data.Password = c.Password
+			err = e.Orm.Save(&data).Error
+			if err != nil {
+				return err
+			}
+		}
+
+	}
+
+	return nil
+
+}
 
 func (e *AppletCustomer) GeneratorToken(customerId string) (string, string, error) {
 	// 创建一个我们自己的声明

+ 10 - 6
app/admin/service/dto/applet_customer.go

@@ -1,12 +1,17 @@
 package dto
 
-import common "gas-cylinder-api/common/model"
-
 // 小程序客户登录
 type AppletCustomerLoginReq struct {
-	Phone            string `json:"phone"` // 手机号
-	Code             string `json:"code"`  // 收货人名称
-	common.ControlBy `swaggerignore:"true"`
+	Phone    string `json:"phone"`    // 手机号
+	Password string `json:"password"` // 密码
+}
+type AppletCustomerWxLoginReq struct {
+	Phone string `json:"phone"` // 手机号
+	Code  string `json:"code"`  // 密码
+}
+type AppletCustomerRegisterReq struct {
+	Phone    string `json:"phone"`    // 手机号
+	Password string `json:"password"` // 密码
 }
 
 type AppletCustomerLoginResp struct {
@@ -15,5 +20,4 @@ type AppletCustomerLoginResp struct {
 	Unionid     string `json:"unionid"`     // 用户在开放平台的唯一标识符,若当前小程序已绑定到微信开放平台帐号下会返回
 	Errcode     int    `json:"errcode"`     //错误码: -1、0、40029、 45011、 40226  (具体说明,请阅读 接口文档)
 	Errmsg      string `json:"errmsg"`      //错误信息
-
 }

+ 1 - 1
app/admin/service/dto/fill_data.go

@@ -9,7 +9,7 @@ type FillDataGetPageReq struct {
 	dto.Pagination `search:"-"`
 	StationId      string `form:"stationId" search:"type:contains;column:station_id;table:fill_data"` // 气站id
 	UserId         string `form:"userId" search:"type:contains;column:user_id;table:fill_data"`       // 充装人员id
-	InnerCode      string `form:"innerCode" search:"-"`                                               // 气瓶内编码
+	InnerCode      string `form:"innerCode" search:"-"`                                               // 气瓶单位内编码
 	ChipId         string `form:"chipId" search:"-"`                                                  // 高频编码
 	StartFillTime  string `form:"startFillTime" search:"-"`                                           // 充装开始时间
 	EndFillTime    string `form:"endFillTime" search:"-"`                                             // 充装结束时间

+ 1 - 1
app/admin/service/dto/inspect_record.go

@@ -10,7 +10,7 @@ import (
 // 入库安全检查
 type InspectRecordGetPageReq struct {
 	dto.Pagination   `search:"-"`
-	State            int    `form:"state" search:"type:exact;column:state;table:inspect_record"`                 // 订单状态 状态 0-待整改 1-整改中 2-已整改
+	State            int    `form:"state" search:"type:exact;column:state;table:inspect_record"`                 // 订单状态 状态 0-待整改 1-整改中 2-已整改 -1 合格
 	InspectStartTime string `form:"inspectStartTime" search:"type:gte;column:inspect_time;table:inspect_record"` // 检查开始时间
 	InspectEndTime   string `form:"inspectEndTime" search:"type:lte;column:inspect_time;table:inspect_record"`   // 检查结束时间
 	CustomerName     string `form:"customerName" search:"-"`                                                     // 客户名称

+ 1 - 1
app/admin/service/dto/real_fill_data.go

@@ -7,7 +7,7 @@ import (
 
 type RealFillDataGetPageReq struct {
 	dto.Pagination `search:"-"`
-	GunCode        int `form:"gunCode" search:"type:exact;column:state;table:real_fill_data"` // 枪编码
+	GunCode        int `form:"gunCode" search:"type:exact;column:state;table:real_fill_data"` // 充装枪编码
 	RealFillDataOrder
 }
 

+ 2 - 2
app/admin/service/dto/store.go

@@ -8,8 +8,8 @@ import (
 
 // SysDeptGetPageReq 列表或者搜索使用结构体
 type StoreGetPageReq struct {
-	Name   string `form:"name" search:"type:contains;column:name;table:sys_dept" example:"部门名称"`    //部门名称
-	DeptId int    `form:"deptId" search:"-" swaggerignore:"true"`                                   //部门名称
+	Name   string `form:"name" search:"type:contains;column:name;table:sys_dept" example:"部门名称"`    //销售门店名称
+	DeptId int    `form:"deptId" search:"-" swaggerignore:"true"`                                   //销售门店名称
 	Type   int    `form:"type" search:"type:exact;column:type;table:sys_dept" swaggerignore:"true"` //公司类型
 	StoreOrder
 }

+ 22 - 10
app/admin/service/operation_log.go

@@ -196,7 +196,6 @@ func (e *OperationLog) Insert(c *dto.OperationLogInsertReq, p *actions.DataPermi
 
 		}
 	case "11", "12", "16", "17", "19":
-
 		// 司机端
 		for _, chipUid := range c.ChipUidList {
 			// 1、通过高频ID查询气瓶内编码
@@ -216,15 +215,15 @@ func (e *OperationLog) Insert(c *dto.OperationLogInsertReq, p *actions.DataPermi
 			}
 			operationLog := model.OperationLog{
 				ProvOperationLog: model.ProvOperationLog{
-					InnerCode:         gasCylinder.InnerCode,
-					OptType:           c.OptType,
-					OptUser:           user.ProvUserId,
-					CompanyId:         user.ProvUser.CmpCode,
-					CurrentEnterprise: user.ProvUser.CmpCode,
-					CurrentStore:      user.ProvUser.CmpCode,
-					CurrentTruck:      user.ProvUserId,
-					CurrentMotor:      truckUserCarInfo.CarNo,
-					OptTime:           time.Now().Format("2006-01-02 15:04:05"),
+					InnerCode: gasCylinder.InnerCode,
+					OptType:   c.OptType,
+					OptUser:   user.ProvUserId,
+					//CompanyId:         user.ProvUser.CmpCode,
+					//CurrentEnterprise: user.ProvUser.CmpCode,
+					//CurrentStore:      user.ProvUser.CmpCode,
+					CurrentTruck: user.ProvUserId,
+					CurrentMotor: truckUserCarInfo.CarNo,
+					OptTime:      time.Now().Format("2006-01-02 15:04:05"),
 				},
 				ControlBy: cModel.ControlBy{
 					CreateBy: p.UserId,
@@ -233,6 +232,19 @@ func (e *OperationLog) Insert(c *dto.OperationLogInsertReq, p *actions.DataPermi
 					DeptId: p.DeptId,
 				},
 			}
+
+			if c.OptType == "12" || c.OptType == "16" || c.OptType == "17" {
+				operationLog.CurrentStation = c.CurrentEnterprise
+				operationLog.CompanyId = c.CurrentEnterprise
+				operationLog.CurrentEnterprise = c.CurrentEnterprise
+			}
+
+			if c.OptType == "11" || c.OptType == "19" {
+				operationLog.CompanyId = c.CurrentEnterprise
+				operationLog.CurrentEnterprise = c.CurrentEnterprise
+				operationLog.CurrentStore = c.CurrentEnterprise
+			}
+
 			data = append(data, operationLog)
 		}
 

+ 9 - 1
app/admin/service/store.go

@@ -9,6 +9,7 @@ import (
 	"gas-cylinder-api/common/global"
 	model2 "gas-cylinder-api/common/model"
 	"gogs.baozhida.cn/zoie/OAuth-core/service"
+	"math/rand"
 	"time"
 
 	"gorm.io/gorm"
@@ -51,7 +52,14 @@ func (e *Store) Insert(c *dto.StoreInsertReq, deptId int) error {
 	}()
 
 	// TODO 上传省平台-1.1.1.4新增销售门店信息 addStore
-	// data.StoreCode = res.StoreCode
+	//storeCode = res.StoreCode
+	rand.New(rand.NewSource(time.Now().UnixNano()))
+	// 生成随机数后八位
+	randomSuffix := rand.Intn(9999999999999999)
+
+	// 组合成16位随机数
+	storeCode := fmt.Sprintf("%16d", randomSuffix)
+	data.CmpCode = storeCode
 	c.Generate(&data)
 	data.UploadTime = model2.Time(time.Now())
 	if deptId != 0 && c.ParentId == 0 {