@@ -0,0 +1,55 @@ | |||
package enum | |||
type FactoryIdentityState int32 | |||
const ( | |||
FactoryIdentityStateForNormal = 1 | |||
FactoryIdentityStateForFreeze = 2 | |||
) | |||
func (gt FactoryIdentityState) String() string { | |||
switch gt { | |||
case FactoryIdentityStateForNormal: | |||
return "正常" | |||
case FactoryIdentityStateForFreeze: | |||
return "冻结" | |||
default: | |||
return "未知" | |||
} | |||
} | |||
type FactoryIdentityIsSubsidy int32 | |||
const ( | |||
FactoryIdentityIsSubsidyForNo = 0 | |||
FactoryIdentityIsSubsidyForYes = 1 | |||
) | |||
func (gt FactoryIdentityIsSubsidy) String() string { | |||
switch gt { | |||
case FactoryIdentityIsSubsidyForNo: | |||
return "不开启优惠补贴" | |||
case FactoryIdentityIsSubsidyForYes: | |||
return "开启优惠补贴" | |||
default: | |||
return "未知" | |||
} | |||
} | |||
type FactoryIdentityIsLimitConsumeNum int32 | |||
const ( | |||
FactoryIdentityIsLimitConsumeNumForNo = 0 | |||
FactoryIdentityIsLimitConsumeNumForYes = 1 | |||
) | |||
func (gt FactoryIdentityIsLimitConsumeNum) String() string { | |||
switch gt { | |||
case FactoryIdentityIsSubsidyForNo: | |||
return "不限制消费次数" | |||
case FactoryIdentityIsSubsidyForYes: | |||
return "限制消费次数" | |||
default: | |||
return "未知" | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
package enum | |||
type FactorySetIsOpenNaturalCustomer int32 | |||
const ( | |||
FactorySetIsOpenNaturalCustomerForYes = 1 | |||
FactorySetIsOpenNaturalCustomerForNo = 2 | |||
) | |||
func (gt FactorySetIsOpenNaturalCustomer) String() string { | |||
switch gt { | |||
case FactorySetIsOpenNaturalCustomerForYes: | |||
return "开启自然顾客" | |||
case FactorySetIsOpenNaturalCustomerForNo: | |||
return "关闭自然顾客" | |||
default: | |||
return "未知" | |||
} | |||
} |
@@ -42,6 +42,13 @@ func EnterpriseManageInfo(c *gin.Context) { | |||
return | |||
} | |||
} | |||
if enterprise.Pvd == enum.EnterprisePvdForAllPayment && enterprise.Mode == enum.EnterpriseModeForFactory { | |||
err, resp = svc.FactoryInfo(utils.StrToInt(enterpriseId)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} | |||
if enterprise.Kind == enum.EnterpriseKindByNursingHome { | |||
err, resp = svc.NursingHomeInfo(utils.StrToInt(enterpriseId)) | |||
if err != nil { | |||
@@ -115,6 +122,13 @@ func UserIdentityList(c *gin.Context) { | |||
return | |||
} | |||
} | |||
if enterprise.Pvd == enum.EnterprisePvdForAllPayment && enterprise.Mode == enum.EnterpriseModeForFactory { | |||
resp, err = svc2.EnterpriseUserListByFactory(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
} | |||
if enterprise.Kind == enum.EnterpriseKindByNursingHome { | |||
resp, err = svc2.EnterpriseUserListByNursingHome(req) | |||
if err != nil { | |||
@@ -0,0 +1,761 @@ | |||
package hdl | |||
import ( | |||
"applet/app/admin/enum" | |||
"applet/app/admin/lib/validate" | |||
"applet/app/admin/md" | |||
"applet/app/admin/svc" | |||
svc2 "applet/app/admin/svc/enterprise_manage" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/e" | |||
enum2 "applet/app/enum" | |||
"applet/app/utils" | |||
"fmt" | |||
"github.com/360EntSecGroup-Skylar/excelize" | |||
"github.com/gin-gonic/gin" | |||
"github.com/jinzhu/copier" | |||
"strconv" | |||
"time" | |||
) | |||
func FactoryIdentityList(c *gin.Context) { | |||
enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0")) | |||
var req md.FactoryIdentityListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
factoryIdentity := db.FactoryIdentityDb{} | |||
factoryIdentity.Set(enterpriseId) | |||
factoryIdentityList, total, err := factoryIdentity.FindFactoryIdentity(req.Page, req.Limit) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
var result []*md.FactoryIdentityListResp | |||
for _, v := range *factoryIdentityList { | |||
var temp md.FactoryIdentityListResp | |||
copier.Copy(&temp, v) | |||
sql := fmt.Sprintf("SELECT count(*) as total FROM factory_identity_with_user_identity where factory_identity_id = %d", v.Id) | |||
mapArr1, err1 := db.QueryNativeString(db.Db, sql) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR, err1.Error()) | |||
return | |||
} | |||
temp.WithUserIdentitiesNum = mapArr1[0]["total"] | |||
result = append(result, &temp) | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": result, | |||
"total": total, | |||
"state": []map[string]interface{}{ | |||
{ | |||
"name": enum.FactoryIdentityState(enum.FactoryIdentityStateForNormal).String(), | |||
"value": enum.FactoryIdentityStateForNormal, | |||
}, | |||
{ | |||
"name": enum.FactoryIdentityState(enum.FactoryIdentityStateForFreeze).String(), | |||
"value": enum.FactoryIdentityStateForFreeze, | |||
}, | |||
}, | |||
"is_subsidy": []map[string]interface{}{ | |||
{ | |||
"name": enum.FactoryIdentityIsSubsidy(enum.FactoryIdentityIsSubsidyForYes).String(), | |||
"value": enum.FactoryIdentityIsSubsidyForYes, | |||
}, | |||
{ | |||
"name": enum.FactoryIdentityIsSubsidy(enum.FactoryIdentityIsSubsidyForNo).String(), | |||
"value": enum.FactoryIdentityIsSubsidyForNo, | |||
}, | |||
}, | |||
"is_limit_consume_num": []map[string]interface{}{ | |||
{ | |||
"name": enum.FactoryIdentityIsLimitConsumeNum(enum.FactoryIdentityIsLimitConsumeNumForNo).String(), | |||
"value": enum.FactoryIdentityIsLimitConsumeNumForNo, | |||
}, | |||
{ | |||
"name": enum.FactoryIdentityIsLimitConsumeNum(enum.FactoryIdentityIsLimitConsumeNumForYes).String(), | |||
"value": enum.FactoryIdentityIsLimitConsumeNumForYes, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func AddFactoryIdentity(c *gin.Context) { | |||
enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0")) | |||
var req md.AddFactoryIdentityReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
factoryIdentityDb := db.FactoryIdentityDb{} | |||
factoryIdentityDb.Set(0) | |||
now := time.Now() | |||
_, err = factoryIdentityDb.FactoryIdentityInsert(&model.FactoryIdentity{ | |||
Name: req.Name, | |||
EnterpriseId: enterpriseId, | |||
State: enum.FactoryIdentityStateForNormal, | |||
Memo: req.Memo, | |||
IsSubsidy: req.IsSubsidy, | |||
SubsidyAmount: req.SubsidyAmount, | |||
LeastPayAmount: req.LeastPayAmount, | |||
IsLimitConsumeNum: req.IsLimitConsumeNum, | |||
LimitConsumeNum: req.LimitConsumeNum, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func UpdateFactoryIdentity(c *gin.Context) { | |||
var req md.UpdateFactoryIdentityReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
factoryIdentityDb := db.FactoryIdentityDb{} | |||
factoryIdentityDb.Set(0) | |||
factoryIdentity, err := factoryIdentityDb.GetFactoryIdentity(req.Id) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if factoryIdentity == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到相应记录") | |||
return | |||
} | |||
factoryIdentity.Name = req.Name | |||
factoryIdentity.Memo = req.Memo | |||
factoryIdentity.IsSubsidy = req.IsSubsidy | |||
factoryIdentity.SubsidyAmount = req.SubsidyAmount | |||
factoryIdentity.LeastPayAmount = req.LeastPayAmount | |||
factoryIdentity.IsLimitConsumeNum = req.IsLimitConsumeNum | |||
factoryIdentity.LimitConsumeNum = req.LimitConsumeNum | |||
_, err = factoryIdentityDb.UpdateFactoryIdentity(factoryIdentity, | |||
"name", "memo", "is_subsidy", "subsidy_amount", "least_pay_amount", "is_limit_consume_num", "limit_consume_num") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func UpdateFactoryIdentityState(c *gin.Context) { | |||
var req md.UpdateFactoryIdentityStateReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
factoryIdentityDb := db.FactoryIdentityDb{} | |||
factoryIdentityDb.Set(0) | |||
factoryIdentity, err := factoryIdentityDb.GetFactoryIdentity(req.Id) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if factoryIdentity == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到相应记录") | |||
return | |||
} | |||
factoryIdentity.State = req.State | |||
_, err = factoryIdentityDb.UpdateFactoryIdentity(factoryIdentity, "state") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func DeleteFactoryIdentity(c *gin.Context) { | |||
id := c.Param("id") | |||
factoryIdentityDb := db.FactoryIdentityDb{} | |||
factoryIdentityDb.Set(0) | |||
role, err := factoryIdentityDb.GetFactoryIdentity(utils.StrToInt(id)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if role == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到相应记录") | |||
return | |||
} | |||
err = svc.DeleteFactoryIdentity(utils.StrToInt(id)) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func BindUserFactoryIdentity(c *gin.Context) { | |||
var req md.BindFactoryIdentityReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
err = svc.BindUserFactoryIdentity(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func SetBasicFactory(c *gin.Context) { | |||
enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0")) | |||
var req md.SetBasicFactoryReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
now := time.Now() | |||
//1、更新 factory_set | |||
factorySetDb := db.FactorySetDb{} | |||
factorySetDb.Set(enterpriseId) | |||
set, err := factorySetDb.GetFactorySet() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if set != nil { | |||
set.IsOpenNaturalCustomer = req.IsOpenNaturalCustomer | |||
set.NaturalCustomerServiceFee = req.NaturalCustomerServiceFee | |||
set.UpdateAt = now.Format("2006-01-02 15:04:05") | |||
_, err2 := factorySetDb.FactorySetUpdate(set, | |||
"is_open_natural_customer", "natural_customer_service_fee", "update_at") | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
return | |||
} | |||
} else { | |||
_, err2 := factorySetDb.FactorySetInsert(&model.FactorySet{ | |||
EnterpriseId: enterpriseId, | |||
IsOpenNaturalCustomer: req.IsOpenNaturalCustomer, | |||
NaturalCustomerServiceFee: req.NaturalCustomerServiceFee, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
return | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func GetBasicFactory(c *gin.Context) { | |||
enterpriseId := utils.StrToInt(c.DefaultQuery("enterprise_id", "0")) | |||
//1、获取 factory_set | |||
factorySetDb := db.FactorySetDb{} | |||
factorySetDb.Set(enterpriseId) | |||
set, err := factorySetDb.GetFactorySet() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if set == nil { | |||
set = &model.FactorySet{ | |||
EnterpriseId: enterpriseId, | |||
IsOpenNaturalCustomer: 1, | |||
NaturalCustomerServiceFee: "0.00", | |||
CreateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
} | |||
_, err2 := factorySetDb.FactorySetInsert(set) | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err2.Error()) | |||
return | |||
} | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"factory_set": set, | |||
"is_open_natural_customer": []map[string]interface{}{ | |||
{ | |||
"name": enum.FactorySetIsOpenNaturalCustomer(enum.FactorySetIsOpenNaturalCustomerForYes).String(), | |||
"value": enum.FactorySetIsOpenNaturalCustomerForYes, | |||
}, | |||
{ | |||
"name": enum.FactorySetIsOpenNaturalCustomer(enum.FactorySetIsOpenNaturalCustomerForNo).String(), | |||
"value": enum.FactorySetIsOpenNaturalCustomerForNo, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func FactoryDownloadTemplateExcel(c *gin.Context) { | |||
e.OutSuc(c, "/template/工厂(身份信息导入模板).xlsx", nil) | |||
return | |||
} | |||
func FactoryImportUserIdentity(c *gin.Context) { | |||
enterpriseIdStr := c.DefaultQuery("enterprise_id", "") | |||
enterpriseId := utils.StrToInt(enterpriseIdStr) | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(enterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
files, _ := c.FormFile("file") | |||
dst := "./static/upload/" + files.Filename | |||
err = c.SaveUploadedFile(files, dst) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
xlsx, err := excelize.OpenFile(dst) | |||
rows := xlsx.GetRows("Sheet" + "1") | |||
for key, row := range rows { | |||
if key > 0 && (row[0] != "" && row[1] != "" && row[2] != "" && row[3] != "") { | |||
var certType = 1 | |||
if row[0] == "学工号" { | |||
certType = 2 | |||
} | |||
idNo := row[1] | |||
name := row[2] | |||
//查找当前工厂身份是否存在 | |||
factoryIdentityDb := db.FactoryIdentityDb{} | |||
factoryIdentityDb.Set(enterpriseId) | |||
factoryIdentity, err := factoryIdentityDb.GetFactoryIdentityByName(row[3]) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if factoryIdentity == nil { | |||
continue | |||
} | |||
//查找当前用户身份是否已存在 | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(0) | |||
isHasUserIdentity, err := userIdentityDb.UserIdentityExist(enterpriseId, idNo, certType) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if isHasUserIdentity != nil { | |||
continue | |||
} | |||
now := time.Now() | |||
//新增身份信息 | |||
userIdentity := &model.UserIdentity{ | |||
Uid: 0, | |||
Name: name, | |||
IdNo: idNo, | |||
CertType: certType, | |||
Kind: enum2.UserIdentityKindForCommon, | |||
Identity: enum2.UserIdentityForFactory, | |||
EnterpriseId: enterpriseId, | |||
State: enum2.UserIdentityStateForNormal, | |||
Memo: "", | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
} | |||
insertAffected, err := userIdentityDb.UserIdentityInsert(userIdentity) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if insertAffected <= 0 { | |||
e.OutErr(c, e.ERR_DB_ORM, "新增身份数据失败") | |||
return | |||
} | |||
//更新 factory_identity | |||
factoryIdentityWithUserIdentityDb := db.FactoryIdentityWithUserIdentityDb{} | |||
factoryIdentityWithUserIdentityDb.Set() | |||
info, err := factoryIdentityWithUserIdentityDb.GetFactoryIdentityWithUserIdentity(insertAffected) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if info == nil { | |||
factoryIdentityWithUserIdentityDb.AddFactoryIdentityWithUserIdentity(&model.FactoryIdentityWithUserIdentity{ | |||
UserIdentityId: insertAffected, | |||
FactoryIdentityId: factoryIdentity.Id, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
} else { | |||
info.FactoryIdentityId = factoryIdentity.Id | |||
_, err1 := factoryIdentityWithUserIdentityDb.UpdateFactoryIdentityWithUserIdentity(info, "factory_identity_id") | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err1.Error()) | |||
return | |||
} | |||
} | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func FactoryUserUpdate(c *gin.Context) { | |||
var req md.FactoryUserUpdateReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
err = svc2.FactoryUserUpdate(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func FactoryUserDelete(c *gin.Context) { | |||
var req md.FactoryUserDeleteReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
err = svc2.FactoryUserDelete(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func FactoryWorkerList(c *gin.Context) { | |||
var req md.FactoryWorkerListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
resp, total, err := svc2.FactoryWorkerList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": resp, | |||
"total": total, | |||
"user_identity_cert_type_list": []map[string]interface{}{ | |||
{ | |||
"name": enum2.UserIdentityCertType.String(enum2.UserIdentityCertTypeForIdCard), | |||
"value": enum2.UserIdentityCertTypeForIdCard, | |||
}, | |||
{ | |||
"name": enum2.UserIdentityCertType.String(enum2.UserIdentityCertTypeForStudentId), | |||
"value": enum2.UserIdentityCertTypeForStudentId, | |||
}, | |||
//{ | |||
// "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForPassport), | |||
// "value": enum.UserIdentityCertTypeForPassport, | |||
//}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func FactoryWorkerUpdate(c *gin.Context) { | |||
var req md.FactoryWorkerUpdateReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
err = svc2.FactoryWorkerUpdate(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func FactoryWorkerDelete(c *gin.Context) { | |||
var req md.FactoryWorkerDeleteReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(req.EnterpriseId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if enterprise == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "未查询到对应记录") | |||
return | |||
} | |||
err = svc2.FactoryWorkerDelete(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func FactoryWorkerAdd(c *gin.Context) { | |||
var req md.FactoryWorkerAddReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
//1、查找当前身份是否已存在 | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(0) | |||
isHasUserIdentity, err := userIdentityDb.UserIdentityExist(req.EnterpriseId, req.IdNo, req.CertType) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if isHasUserIdentity != nil { | |||
e.OutErr(c, e.ERR, "当前身份已存在,直接修改身份即可!") | |||
return | |||
} | |||
now := time.Now() | |||
//2、新增身份信息 | |||
userIdentity := &model.UserIdentity{ | |||
Uid: 0, | |||
Name: req.Name, | |||
IdNo: req.IdNo, | |||
CertType: req.CertType, | |||
Kind: enum2.UserIdentityKindForCommon, | |||
Identity: enum2.UserIdentityForFactory, | |||
EnterpriseId: req.EnterpriseId, | |||
State: enum2.UserIdentityStateForNormal, | |||
Memo: "", | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
} | |||
insertAffected, err := userIdentityDb.UserIdentityInsert(userIdentity) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if insertAffected <= 0 { | |||
e.OutErr(c, e.ERR_DB_ORM, "新增身份数据失败") | |||
return | |||
} | |||
factoryIdentityWithUserIdentityDb := db.FactoryIdentityWithUserIdentityDb{} | |||
factoryIdentityWithUserIdentityDb.Set() | |||
_, err = factoryIdentityWithUserIdentityDb.AddFactoryIdentityWithUserIdentity(&model.FactoryIdentityWithUserIdentity{ | |||
UserIdentityId: userIdentity.Id, | |||
FactoryIdentityId: req.FactoryIdentityId, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, "关联工厂身份失败") | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func FactoryOrdList(c *gin.Context) { | |||
var req md.FactoryOrdListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
resp, total, err := svc2.FactoryOrdList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": resp, | |||
"total": total, | |||
"order_status_list": []map[string]interface{}{ | |||
{ | |||
"name": enum2.FactoryOrdOrderStatus.String(enum2.FactoryOrdOrderStatusForSuccess), | |||
"value": enum2.FactoryOrdOrderStatusForSuccess, | |||
}, | |||
{ | |||
"name": enum2.FactoryOrdOrderStatus.String(enum2.FactoryOrdOrderStatusForRefund), | |||
"value": enum2.FactoryOrdOrderStatusForRefund, | |||
}, | |||
{ | |||
"name": enum2.FactoryOrdOrderStatus.String(enum2.FactoryOrdOrderStatusForClose), | |||
"value": enum2.FactoryOrdOrderStatusForClose, | |||
}, | |||
}, | |||
"trade_channel_list": []map[string]interface{}{ | |||
{ | |||
"name": enum2.FactoryOrdTradeChannel.String(enum2.FactoryOrdTradeChannelForAli), | |||
"value": enum2.FactoryOrdTradeChannelForAli, | |||
}, | |||
{ | |||
"name": enum2.FactoryOrdTradeChannel.String(enum2.FactoryOrdTradeChannelForWx), | |||
"value": enum2.FactoryOrdTradeChannelForWx, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func FactoryOrdListExport(c *gin.Context) { | |||
var req md.FactoryOrdListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
resp, err := svc2.FactoryOrdListExport(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
titleList := []string{"校企名称", "用户电话", "就餐人姓名", "订单号", "交易号", "支付状态", "支付时间", "消费档口", "订单总金额", "实收金额", "买家支付金额", "补贴金额", "服务费用", "交易渠道"} | |||
xlsx := excelize.NewFile() | |||
xlsx.SetSheetRow("Sheet1", "A1", &titleList) | |||
style, err := xlsx.NewStyle(`{"fill":{"type":"pattern","color":["FFFF00"],"pattern":1}, "alignment":{"horizontal":"center"}}`) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
xlsx.SetCellStyle("Sheet1", "A1", "N1", style) | |||
xlsx.SetColWidth("Sheet1", "A", "N", 25) | |||
//xlsx.SetColWidth("Sheet1", "B", "B", 30) | |||
//xlsx.SetColWidth("Sheet1", "C", "E", 15) | |||
//xlsx.SetColWidth("Sheet1", "F", "I", 10) | |||
//xlsx.SetColWidth("Sheet1", "J", "J", 20) | |||
//xlsx.SetColWidth("Sheet1", "K", "K", 10) | |||
//xlsx.SetColWidth("Sheet1", "L", "L", 25) | |||
//xlsx.SetColWidth("Sheet1", "M", "M", 15) | |||
//表头被第一行用了,只能从第二行开始 | |||
j := 2 | |||
//var totalAmount = 0.00 | |||
for _, v := range resp { | |||
xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{v.EnterpriseName, v.Phone, v.UserIdentityName, v.OutTradeNo, v.TradeNo, enum2.FactoryOrdOrderStatus.String(enum2.FactoryOrdOrderStatus(v.OrderStatus)), | |||
v.GmtPayment, v.ShopName, v.TotalAmount, v.ReceiptAmount, v.BuyerPayAmount, v.SubsidyAmount, v.ServiceFee, v.TradeChannel}) | |||
j++ | |||
} | |||
//xlsx.SetSheetRow("Sheet1", "A"+strconv.Itoa(j), &[]interface{}{"总计:", "-", "-", "-", "-", "-", "-", totalAmount, "-", "-", "-", "-", "-"}) | |||
c.Header("Content-Type", "application/octet-stream") | |||
c.Header("Content-Disposition", "attachment; filename="+"工厂消费记录"+".xlsx") | |||
c.Header("Content-Transfer-Encoding", "binary") | |||
//回写到web 流媒体 形成下载 | |||
_ = xlsx.Write(c.Writer) | |||
return | |||
} |
@@ -158,3 +158,131 @@ func DeviceDelete(c *gin.Context) { | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func FactoryDeviceSave(c *gin.Context) { | |||
var req md.FactoryDeviceSaveReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
deviceDd := db.FactoryDevice{} | |||
deviceDd.Set(req.TerminalId) | |||
//查找 device_sn | |||
device, err := deviceDd.GetFactoryDevice() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if device == nil { | |||
insertAffected, err1 := deviceDd.FactoryDeviceInsert(&model2.FactoryDevice{ | |||
Name: req.Name, | |||
TerminalId: req.TerminalId, | |||
EnterpriseId: req.EnterpriseId, | |||
Memo: req.Memo, | |||
CreateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
}) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if insertAffected <= 0 { | |||
e.OutErr(c, e.ERR_DB_ORM, "新增数据失败") | |||
return | |||
} | |||
} else { | |||
device.EnterpriseId = req.EnterpriseId | |||
device.Name = req.Name | |||
device.Memo = req.Memo | |||
device.UpdateAt = time.Now().Format("2006-01-02 15:04:05") | |||
updateAffected, err1 := deviceDd.FactoryDeviceUpdate(device, "enterprise_id", "name", "memo", "update_at") | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if updateAffected <= 0 { | |||
e.OutErr(c, e.ERR_DB_ORM, "更新数据失败") | |||
return | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func FactoryDeviceList(c *gin.Context) { | |||
var req md.FactoryDeviceListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
if req.Limit == 0 { | |||
req.Limit = 10 | |||
} | |||
if req.Page == 0 { | |||
req.Page = 10 | |||
} | |||
sess := db.Db.Desc("factory_device.id") | |||
if req.Name != "" { | |||
sess.And("factory_device.name like ?", "%"+req.Name+"%") | |||
} | |||
if req.EnterpriseName != "" { | |||
sess.And("enterprise.name like ?", "%"+req.EnterpriseName+"%") | |||
} | |||
if req.StartDate != "" { | |||
sess.And("factory_device.create_at >=?", req.StartDate) | |||
} | |||
if req.EndDate != "" { | |||
sess.And("factory_device.create_at <=?", req.EndDate) | |||
} | |||
var m []*db.FactoryDeviceWithEnterprise | |||
total, err := sess. | |||
Join("LEFT", "enterprise", "enterprise.id = factory_device.enterprise_id").Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
var resp []interface{} | |||
for _, v := range m { | |||
resp = append(resp, map[string]interface{}{ | |||
"id": v.FactoryDevice.Id, | |||
"name": v.FactoryDevice.Name, | |||
"terminal_id": v.FactoryDevice.TerminalId, | |||
"enterprise_id": v.FactoryDevice.EnterpriseId, | |||
"memo": v.FactoryDevice.Memo, | |||
"create_at": v.FactoryDevice.CreateAt, | |||
"update_at": v.FactoryDevice.UpdateAt, | |||
"enterprise_name": v.Enterprise.Name, | |||
}) | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": resp, | |||
"total": total, | |||
}, nil) | |||
return | |||
} | |||
func FactoryDeviceDelete(c *gin.Context) { | |||
deviceSn := c.Param("terminal_id") | |||
deviceDd := db.FactoryDevice{} | |||
deviceDd.Set(deviceSn) | |||
deviceDdAffected, err := deviceDd.FactoryDeviceDelete() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if deviceDdAffected <= 0 { | |||
e.OutErr(c, e.ERR_DB_ORM, "删除数据失败") | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} |
@@ -15,3 +15,19 @@ type DeviceSaveReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required"` | |||
Memo string `json:"memo"` | |||
} | |||
type FactoryDeviceSaveReq struct { | |||
Name string `json:"name" binding:"required"` | |||
TerminalId string `json:"terminal_id" binding:"required"` | |||
EnterpriseId int `json:"enterprise_id" binding:"required"` | |||
Memo string `json:"memo"` | |||
} | |||
type FactoryDeviceListReq struct { | |||
Page int `json:"page" label:"页码"` | |||
Limit int `json:"limit" label:"每页数量"` | |||
EnterpriseName string `json:"enterprise_name" label:"校企名称"` | |||
Name string `json:"name" label:"档口名称"` | |||
StartDate string `json:"start_date" label:"起始时间"` | |||
EndDate string `json:"end_date" label:"截止时间"` | |||
} |
@@ -637,6 +637,13 @@ type EnterpriseUserListByNursingHomeResp struct { | |||
Total int64 `json:"total"` | |||
} | |||
type EnterpriseUserListByFactoryResp struct { | |||
List []EnterpriseUserListByFactoryStruct `json:"list"` | |||
Total int64 `json:"total"` | |||
UserIdentityKindList interface{} `json:"user_identity_kind_list"` | |||
UserIdentityCertTypeList interface{} `json:"user_identity_cert_type_list"` | |||
} | |||
type EnterpriseUserListByNursingHomeStruct struct { | |||
Id int `json:"id" label:"支付宝昵称"` | |||
Nickname string `json:"nickname" label:"支付宝昵称"` | |||
@@ -651,6 +658,21 @@ type EnterpriseUserListByNursingHomeStruct struct { | |||
} `json:"user_identities" label:"身份列表"` | |||
} | |||
type EnterpriseUserListByFactoryStruct struct { | |||
Id int `json:"id" label:"支付宝昵称"` | |||
Nickname string `json:"nickname" label:"支付宝昵称"` | |||
Phone string `json:"phone" label:"手机号"` | |||
Avatar string `json:"avatar" label:"头像"` | |||
CreateAt string `json:"create_at" label:"创建时间"` | |||
UserIdentities []struct { | |||
Id int `json:"id" label:"身份id"` | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
CertType int `json:"cert_type" label:"证件类型"` | |||
EnterpriseName string `json:"enterprise_name" label:"单位名"` | |||
Name string `json:"name" label:"姓名"` | |||
} `json:"user_identities" label:"身份列表"` | |||
} | |||
type NursingHomeUserUpdateReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
Uid int `json:"uid" binding:"required" label:"用户id"` | |||
@@ -0,0 +1,16 @@ | |||
package md | |||
type FactoryInfoResp struct { | |||
Name string `json:"name" label:"名称"` | |||
Memo string `json:"memo" label:"备注"` | |||
Mode string `json:"mode" label:"模式"` | |||
Pvd string `json:"pvd" label:"场景"` | |||
Kind string `json:"kind" label:"种类(1:央厨-学校 2:央厨-工厂 3:自营-学校 4:自营-工厂)"` | |||
State string `json:"state" label:"状态(1:正常 2:冻结)"` | |||
WorkerNum int64 `json:"worker_num" label:"员工数量"` | |||
//UserNum int64 `json:"user_num" label:"用户数量"` | |||
ThisMonthConsumeAmount float64 `json:"this_month_consume_amount" label:"本月消费金额"` | |||
ThisMonthOrderNum float64 `json:"this_month_order_num" label:"本月订单"` | |||
ThisMonthServiceAmount float64 `json:"this_month_service_amount" label:"本月服务费用"` | |||
ThisMonthReceiptAmount float64 `json:"this_month_receipt_amount" label:"本月实收金额"` | |||
} |
@@ -0,0 +1,159 @@ | |||
package md | |||
type FactoryIdentityListResp struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` | |||
State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` | |||
IsSubsidy int `json:"is_subsidy" xorm:"not null default 0 comment('是否优惠补贴(0:否 1:是)') TINYINT(1)"` | |||
SubsidyAmount string `json:"subsidy_amount" xorm:"not null default 0.00 comment('补贴金额') DECIMAL(8,2)"` | |||
LeastPayAmount string `json:"least_pay_amount" xorm:"not null default 0.00 comment('最少支付金额') DECIMAL(8,2)"` | |||
IsLimitConsumeNum int `json:"is_limit_consume_num" xorm:"not null default 0 comment('是否限制消费次数') TINYINT(1)"` | |||
LimitConsumeNum int `json:"limit_consume_num" xorm:"default 0 comment('限制消费次数/日') TINYINT(1)"` | |||
WithUserIdentitiesNum string `json:"with_user_identities_num"` | |||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} | |||
type UpdateFactoryIdentityStateReq struct { | |||
Id int `json:"id" binding:"required" label:"id"` | |||
State int `json:"state" binding:"required" label:"状态"` | |||
} | |||
type AddFactoryIdentityReq struct { | |||
Name string `json:"name" binding:"required" label:"名称"` | |||
Memo string `json:"memo" label:"备注"` | |||
IsSubsidy int `json:"is_subsidy" label:"是否优惠补贴(0:否 1:是)"` | |||
SubsidyAmount string `json:"subsidy_amount" label:"补贴金额"` | |||
LeastPayAmount string `json:"least_pay_amount" label:"最少支付金额"` | |||
IsLimitConsumeNum int `json:"is_limit_consume_num" label:"是否限制消费次数"` | |||
LimitConsumeNum int `json:"limit_consume_num" label:"限制消费次数/日"` | |||
} | |||
type UpdateFactoryIdentityReq struct { | |||
Id int `json:"id" binding:"required" label:"id"` | |||
Name string `json:"name" binding:"required" label:"名称"` | |||
Memo string `json:"memo" label:"备注"` | |||
IsSubsidy int `json:"is_subsidy" label:"是否优惠补贴(0:否 1:是)"` | |||
SubsidyAmount string `json:"subsidy_amount" label:"补贴金额"` | |||
LeastPayAmount string `json:"least_pay_amount" label:"最少支付金额"` | |||
IsLimitConsumeNum int `json:"is_limit_consume_num" label:"是否限制消费次数"` | |||
LimitConsumeNum int `json:"limit_consume_num" label:"限制消费次数/日"` | |||
} | |||
type FactoryIdentityListReq struct { | |||
Limit int `json:"limit"` | |||
Page int `json:"page" ` | |||
Name string `json:"name"` | |||
State int `json:"state"` | |||
StartDate string `json:"start_date" ` | |||
EndDate string `json:"end_date" ` | |||
} | |||
type BindFactoryIdentityReq struct { | |||
UserIdentitiesId int `json:"user_identities_id" binding:"required"` | |||
FactoryIdentityId int `json:"factory_identity_id" label:"角色id"` | |||
} | |||
type SetBasicFactoryReq struct { | |||
IsOpenNaturalCustomer int `json:"is_open_natural_customer" binding:"required"` | |||
NaturalCustomerServiceFee string `json:"natural_customer_service_fee" binding:"required"` | |||
} | |||
type FactoryWorkerListReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
Limit int `json:"limit" binding:"required"` | |||
Page int `json:"page" binding:"required"` | |||
Name string `json:"name" label:"姓名"` | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
Phone string `json:"phone" label:"手机号"` | |||
} | |||
type FactoryWorkerListResp struct { | |||
UserIdentityId int `json:"user_identity_id" label:"用户身份id"` | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
CertType int `json:"cert_type" label:"证件类型"` | |||
Phone string `json:"parent_phone" label:"电话"` | |||
Name string `json:"name" label:"姓名"` | |||
FactoryIdentityId int `json:"factory_identity_id" label:"工厂身份id"` | |||
FactoryIdentity string `json:"factory_identity" label:"工厂身份"` | |||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} | |||
type FactoryUserDeleteReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
Uids []int `json:"uids" binding:"required" label:"用户id"` | |||
} | |||
type FactoryUserUpdateReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
Uid int `json:"uid" binding:"required" label:"用户id"` | |||
Nickname string `json:"nickname" binding:"required" label:"支付宝昵称"` | |||
Phone string `json:"phone" binding:"required" label:"手机号"` | |||
BindUserIdentities []struct { | |||
UserIdentityId int `json:"user_identity_id" label:"用户身份id"` | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
CertType int `json:"cert_type" label:"证件类型"` | |||
Name string `json:"name" label:"姓名"` | |||
} `json:"user_identities" label:"身份列表"` | |||
} | |||
type FactoryWorkerUpdateReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
UserIdentityId int `json:"user_identity_id" binding:"required" label:"用户身份id"` | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
CertType int `json:"cert_type" label:"证件类型(1:身份证 2:学工号 3:护照)"` | |||
Name string `json:"name" label:"姓名"` | |||
FactoryIdentityId int `json:"factory_identity_id" label:"工厂身份id"` | |||
} | |||
type FactoryWorkerDeleteReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
UserIdentityIds []int `json:"user_identity_ids" binding:"required" label:"用户身份id"` | |||
} | |||
type FactoryWorkerAddReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
Name string `json:"name" label:"名称"` | |||
CertType int `json:"cert_type" label:"证件类型(1:身份证 2:学工号 3:护照)"` | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
FactoryIdentityId int `json:"factory_identity_id" label:"工厂身份id"` | |||
} | |||
type FactoryOrdListReq struct { | |||
EnterpriseId int `json:"enterprise_id" label:"企业id"` | |||
Limit int `json:"limit" binding:"required"` | |||
Page int `json:"page" binding:"required"` | |||
Name string `json:"name" label:"姓名"` | |||
Phone string `json:"phone" label:"用户电话"` | |||
OutTradeNo string `json:"out_trade_no" label:"订单号"` | |||
TradeNo string `json:"trade_no" label:"交易单号"` | |||
OrderStatus int `json:"order_status" label:"订单状态"` | |||
StartDate string `json:"start_date" label:"订单-开始时间"` | |||
EndDate string `json:"end_date" label:"订单-截止时间"` | |||
TerminalId string `json:"terminal_id" label:"设备编号"` | |||
TradeChannel string `json:"trade_channel" label:"交易渠道"` | |||
ShopName string `json:"shop_name" label:"消费档口"` | |||
} | |||
type FactoryOrdListResp struct { | |||
EnterpriseId int `json:"enterprise_id" ` | |||
EnterpriseName string `json:"enterprise_name" ` | |||
Uid int `json:"uid" ` | |||
UserIdentityId int `json:"user_identity_id" ` | |||
UserIdentityName string `json:"user_identity_name" ` | |||
OutTradeNo string `json:"out_trade_no" ` | |||
TradeNo string `json:"trade_no"` | |||
OrderStatus int `json:"order_status"` | |||
Phone string `json:"phone"` | |||
GmtPayment string `json:"gmt_payment"` | |||
TerminalId string `json:"terminal_id" label:"设备编号"` | |||
ShopName string `json:"shop_name" label:"消费档口"` | |||
TotalAmount string `json:"total_amount" label:"订单总金额"` | |||
ReceiptAmount string `json:"receipt_amount" label:"实收金额"` | |||
BuyerPayAmount string `json:"buyer_pay_amount" label:"买家支付金额"` | |||
SubsidyAmount string `json:"subsidy_amount" label:"补贴金额"` | |||
ServiceFee string `json:"service_fee" label:"服务费用"` | |||
TradeChannel string `json:"trade_channel" label:"交易渠道"` | |||
} |
@@ -378,3 +378,92 @@ func EnterpriseUserListByNursingHome(req md.EnterpriseUserListReq) (resp md.Ente | |||
} | |||
return | |||
} | |||
func EnterpriseUserListByFactory(req md.EnterpriseUserListReq) (resp md.EnterpriseUserListByFactoryResp, err error) { | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(0) | |||
userIdentities, err := userIdentityDb.FindUserIdentityForEnterprise(req.EnterpriseId) | |||
if err != nil { | |||
return | |||
} | |||
var userIdentitiesMap = map[string][]model.UserIdentity{} | |||
var uids []int | |||
for _, v := range *userIdentities { | |||
userIdentitiesMap[utils.IntToStr(v.Uid)] = append(userIdentitiesMap[utils.IntToStr(v.Uid)], v) | |||
uids = append(uids, v.Uid) | |||
} | |||
var m []model.User | |||
sess := db.Db.In("id", uids) | |||
if req.Nickname != "" { | |||
sess.And("nickname like ?", "%"+req.Nickname+"%") | |||
} | |||
if req.Phone != "" { | |||
sess.And("phone like ?", "%"+req.Phone+"%") | |||
} | |||
count, err := sess.Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) | |||
if err != nil { | |||
return | |||
} | |||
resp.Total = count | |||
for _, v := range m { | |||
temp := md.EnterpriseUserListByFactoryStruct{ | |||
Id: v.Id, | |||
Nickname: v.Nickname, | |||
Phone: v.Phone, | |||
Avatar: v.Avatar, | |||
CreateAt: v.CreateAt, | |||
} | |||
for _, v1 := range userIdentitiesMap[utils.IntToStr(v.Id)] { | |||
temp.UserIdentities = append(temp.UserIdentities, struct { | |||
Id int `json:"id" label:"身份id"` | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
CertType int `json:"cert_type" label:"证件类型"` | |||
EnterpriseName string `json:"enterprise_name" label:"单位名"` | |||
Name string `json:"name" label:"姓名"` | |||
}{Id: v1.Id, IdNo: v1.IdNo, CertType: v1.CertType, EnterpriseName: req.EnterpriseName, Name: v1.Name}) | |||
} | |||
resp.List = append(resp.List, temp) | |||
} | |||
resp.UserIdentityKindList = []map[string]interface{}{ | |||
{ | |||
"name": enum2.UserIdentity.String(enum2.UserIdentityForCentralKitchenForStudent), | |||
"value": enum2.UserIdentityForCentralKitchenForStudent, | |||
}, | |||
{ | |||
"name": enum2.UserIdentity.String(enum2.UserIdentityForCentralKitchenForTeacher), | |||
"value": enum2.UserIdentityForCentralKitchenForTeacher, | |||
}, | |||
{ | |||
"name": enum2.UserIdentity.String(enum2.UserIdentityForCentralKitchenForWorker), | |||
"value": enum2.UserIdentityForCentralKitchenForWorker, | |||
}, | |||
{ | |||
"name": enum2.UserIdentity.String(enum2.UserIdentityForSelfSupportForStudent), | |||
"value": enum2.UserIdentityForSelfSupportForStudent, | |||
}, | |||
{ | |||
"name": enum2.UserIdentity.String(enum2.UserIdentityForSelfSupportForTeacher), | |||
"value": enum2.UserIdentityForSelfSupportForTeacher, | |||
}, | |||
{ | |||
"name": enum2.UserIdentity.String(enum2.UserIdentityForSelfSupportForWorker), | |||
"value": enum2.UserIdentityForSelfSupportForWorker, | |||
}, | |||
} | |||
resp.UserIdentityCertTypeList = []map[string]interface{}{ | |||
{ | |||
"name": enum2.UserIdentityCertType.String(enum2.UserIdentityCertTypeForIdCard), | |||
"value": enum2.UserIdentityCertTypeForIdCard, | |||
}, | |||
{ | |||
"name": enum2.UserIdentityCertType.String(enum2.UserIdentityCertTypeForStudentId), | |||
"value": enum2.UserIdentityCertTypeForStudentId, | |||
}, | |||
//{ | |||
// "name": enum.UserIdentityCertType.String(enum.UserIdentityCertTypeForPassport), | |||
// "value": enum.UserIdentityCertTypeForPassport, | |||
//}, | |||
} | |||
return | |||
} |
@@ -0,0 +1,368 @@ | |||
package svc | |||
import ( | |||
"applet/app/admin/md" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
enum2 "applet/app/enum" | |||
"applet/app/utils" | |||
"errors" | |||
"time" | |||
) | |||
func FactoryUserUpdate(req md.FactoryUserUpdateReq) (err error) { | |||
var userIdentities []model.UserIdentity | |||
err = db.Db.Where("uid =? AND enterprise_id =?", req.Uid, req.EnterpriseId).Find(&userIdentities) | |||
if err != nil { | |||
return | |||
} | |||
var userIdentityIds []int | |||
for _, v := range userIdentities { | |||
userIdentityIds = append(userIdentityIds, v.Id) | |||
} | |||
session := db.Db.NewSession() | |||
defer session.Close() | |||
session.Begin() | |||
//2、新增 / 编辑 数据 | |||
now := time.Now() | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(req.Uid) | |||
var newUserIdentityIds []string | |||
for _, v := range req.BindUserIdentities { | |||
if v.UserIdentityId == 0 { | |||
// 新增 | |||
insertId, err1 := userIdentityDb.UserIdentityInsertBySession(session, &model.UserIdentity{ | |||
Uid: req.Uid, | |||
Name: v.Name, | |||
IdNo: v.IdNo, | |||
CertType: v.CertType, | |||
Kind: enum2.UserIdentityKindForCommon, | |||
Identity: enum2.UserIdentityForFactory, | |||
EnterpriseId: req.EnterpriseId, | |||
Memo: "", | |||
State: enum2.UserIdentityStateForNormal, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err1 != nil { | |||
_ = session.Rollback() | |||
return err1 | |||
} | |||
newUserIdentityIds = append(newUserIdentityIds, utils.IntToStr(insertId)) | |||
} else { | |||
//编辑 | |||
identity, err2 := userIdentityDb.GetUserIdentity(v.UserIdentityId) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return err2 | |||
} | |||
if identity == nil { | |||
_ = session.Rollback() | |||
return errors.New("未查询到对应的身份信息记录") | |||
} | |||
identity.IdNo = v.IdNo | |||
identity.CertType = v.CertType | |||
identity.Name = v.Name | |||
identity.Identity = enum2.UserIdentityForFactory | |||
_, err3 := userIdentityDb.UserIdentityUpdateBySession(session, v.UserIdentityId, identity, "id_no", "cert_type", "name", "identity") | |||
if err3 != nil { | |||
_ = session.Rollback() | |||
return err3 | |||
} | |||
newUserIdentityIds = append(newUserIdentityIds, utils.IntToStr(v.UserIdentityId)) | |||
} | |||
} | |||
//3、删除需要删除的身份信息 | |||
for _, v := range userIdentityIds { | |||
if !utils.InArr(utils.IntToStr(v), newUserIdentityIds) { | |||
_, err = session.Where("id = ?", v).Delete(model.UserIdentity{}) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return | |||
} | |||
_, err = session.Where("user_identity_id = ?", v).Delete(model.SelfSupportForUserFaceInfo{}) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return | |||
} | |||
} | |||
} | |||
return session.Commit() | |||
} | |||
func FactoryUserDelete(req md.FactoryUserDeleteReq) (err error) { | |||
//1、删除 user_identity | |||
var userIdentities []model.UserIdentity | |||
err = db.Db.Where("enterprise_id =?", req.EnterpriseId).In("uid", req.Uids).Find(&userIdentities) | |||
if err != nil { | |||
return | |||
} | |||
var userIdentityIds []int | |||
for _, v := range userIdentities { | |||
userIdentityIds = append(userIdentityIds, v.Id) | |||
} | |||
_, err = db.Db.Where("enterprise_id =?", req.EnterpriseId).In("uid", req.Uids).Delete(model.UserIdentity{}) | |||
if err != nil { | |||
return | |||
} | |||
//2、删除 factory_identity_with_user_identity | |||
_, err = db.Db.In("user_identity_id", userIdentityIds).Delete(model.FactoryIdentityWithUserIdentity{}) | |||
if err != nil { | |||
return | |||
} | |||
return | |||
} | |||
func FactoryWorkerList(req md.FactoryWorkerListReq) (resp []md.FactoryWorkerListResp, count int64, err error) { | |||
sess := db.Db.Where("user_identity.enterprise_id =?", req.EnterpriseId). | |||
And("user_identity.identity =?", enum2.UserIdentityForFactory) | |||
if req.Name != "" { | |||
sess.And("user_identity.name like ?", "%"+req.Name+"%") | |||
} | |||
if req.IdNo != "" { | |||
sess.And("user_identity.id_no like ?", "%"+req.IdNo+"%") | |||
} | |||
if req.Phone != "" { | |||
sess.And("user.phone like ?", "%"+req.Phone+"%") | |||
} | |||
var m []*db.UserIdentityWithFactoryIdentity | |||
count, err = sess. | |||
Join("LEFT", "user", "user_identity.uid = user.id"). | |||
Join("LEFT", "factory_identity_with_user_identity", "user_identity.id = factory_identity_with_user_identity.user_identity_id"). | |||
Join("LEFT", "factory_identity", "factory_identity_with_user_identity.factory_identity_id = factory_identity.id"). | |||
Limit(req.Limit, (req.Page-1)*req.Limit).FindAndCount(&m) | |||
if err != nil { | |||
return nil, 0, err | |||
} | |||
for _, v := range m { | |||
resp = append(resp, md.FactoryWorkerListResp{ | |||
UserIdentityId: v.UserIdentity.Id, | |||
IdNo: v.UserIdentity.IdNo, | |||
CertType: v.UserIdentity.CertType, | |||
Phone: v.User.Phone, | |||
Name: v.UserIdentity.Name, | |||
FactoryIdentityId: v.FactoryIdentity.Id, | |||
FactoryIdentity: v.FactoryIdentity.Name, | |||
CreateAt: v.FactoryIdentity.CreateAt, | |||
UpdateAt: v.FactoryIdentity.UpdateAt, | |||
}) | |||
} | |||
return | |||
} | |||
func FactoryWorkerUpdate(req md.FactoryWorkerUpdateReq) (err error) { | |||
//1、修改 `user_identity` | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(0) | |||
userIdentity, err := userIdentityDb.GetUserIdentity(req.UserIdentityId) | |||
if err != nil { | |||
return | |||
} | |||
if userIdentity == nil { | |||
return errors.New("未查询到对应记录") | |||
} | |||
userIdentity.IdNo = req.IdNo | |||
userIdentity.CertType = req.CertType | |||
userIdentity.Name = req.Name | |||
_, err = userIdentityDb.UserIdentityUpdate(req.UserIdentityId, userIdentity, "id_no", "name", "cert_type") | |||
if err != nil { | |||
return | |||
} | |||
//2、更新 factory_identity_with_user_identity | |||
factoryIdentityWithUserIdentityDb := db.FactoryIdentityWithUserIdentityDb{} | |||
factoryIdentityWithUserIdentityDb.Set() | |||
info, err := factoryIdentityWithUserIdentityDb.GetFactoryIdentityWithUserIdentity(req.UserIdentityId) | |||
if err != nil { | |||
return | |||
} | |||
if info != nil { | |||
info.FactoryIdentityId = req.FactoryIdentityId | |||
_, err = factoryIdentityWithUserIdentityDb.UpdateFactoryIdentityWithUserIdentity(info, "factory_identity_id") | |||
if err != nil { | |||
return | |||
} | |||
} else { | |||
_, err = factoryIdentityWithUserIdentityDb.AddFactoryIdentityWithUserIdentity(&model.FactoryIdentityWithUserIdentity{ | |||
UserIdentityId: userIdentity.Id, | |||
FactoryIdentityId: req.FactoryIdentityId, | |||
CreateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
UpdateAt: time.Now().Format("2006-01-02 15:04:05"), | |||
}) | |||
if err != nil { | |||
return | |||
} | |||
} | |||
return | |||
} | |||
func FactoryWorkerDelete(req md.FactoryWorkerDeleteReq) (err error) { | |||
//1、删除 user_identity | |||
_, err = db.Db.Where("enterprise_id =?", req.EnterpriseId).In("id", req.UserIdentityIds).Delete(model.UserIdentity{}) | |||
if err != nil { | |||
return | |||
} | |||
//2、删除 factory_identity_with_user_identity | |||
_, err = db.Db.In("user_identity_id", req.UserIdentityIds).Delete(model.FactoryIdentityWithUserIdentity{}) | |||
if err != nil { | |||
return | |||
} | |||
return | |||
} | |||
func FactoryOrdList(req md.FactoryOrdListReq) (resp []md.FactoryOrdListResp, count int64, err error) { | |||
sess := db.Db.Desc("factory_ord.id") | |||
if req.EnterpriseId != 0 { | |||
sess.And("factory_ord.enterprise_id =?", req.EnterpriseId) | |||
} | |||
if req.StartDate != "" { | |||
sess.And("factory_ord.gmt_payment >= ?", req.StartDate) | |||
} | |||
if req.EndDate != "" { | |||
sess.And("factory_ord.gmt_payment <= ?", req.EndDate) | |||
} | |||
if req.OrderStatus != 0 { | |||
sess.And("factory_ord.order_status = ?", req.OrderStatus) | |||
} | |||
if req.OutTradeNo != "" { | |||
sess.And("factory_ord.out_order_no like ?", "%"+req.OutTradeNo+"%") | |||
} | |||
if req.TerminalId != "" { | |||
sess.And("factory_ord.terminal_id like ?", "%"+req.TerminalId+"%") | |||
} | |||
if req.TradeNo != "" { | |||
sess.And("factory_ord.trade_no like ?", "%"+req.TradeNo+"%") | |||
} | |||
if req.Name != "" { | |||
sess.And("user_identity.name like ?", "%"+req.Name+"%") | |||
} | |||
if req.Phone != "" { | |||
sess.And("user.phone like ?", "%"+req.Phone+"%") | |||
} | |||
if req.ShopName != "" { | |||
sess.And("factory_device.name like ?", "%"+req.ShopName+"%") | |||
} | |||
var m []*db.FactoryOrdWithUserIdentity | |||
count, err = sess. | |||
Join("LEFT", "user_identity", "factory_ord.user_identity_id = user_identity.id"). | |||
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). | |||
Join("LEFT", "user", "user.id = user_identity.uid"). | |||
Join("LEFT", "factory_device", "factory_ord.terminal_id = factory_device.terminal_id"). | |||
Limit(req.Limit, (req.Page-1)*req.Limit).Desc("factory_ord.create_at").FindAndCount(&m) | |||
if err != nil { | |||
return nil, 0, err | |||
} | |||
for _, v := range m { | |||
resp = append(resp, md.FactoryOrdListResp{ | |||
EnterpriseId: v.Enterprise.Id, | |||
EnterpriseName: v.Enterprise.Name, | |||
Uid: v.User.Id, | |||
UserIdentityId: v.UserIdentity.Id, | |||
UserIdentityName: v.UserIdentity.Name, | |||
OutTradeNo: v.FactoryOrd.OutOrderNo, | |||
TradeNo: v.FactoryOrd.TradeNo, | |||
OrderStatus: v.FactoryOrd.OrderStatus, | |||
Phone: v.User.Phone, | |||
GmtPayment: v.FactoryOrd.GmtPayment, | |||
TerminalId: v.FactoryOrd.TerminalId, | |||
ShopName: v.FactoryDevice.Name, | |||
TotalAmount: v.FactoryOrd.TotalAmount, | |||
ReceiptAmount: v.FactoryOrd.ReceiptAmount, | |||
BuyerPayAmount: v.FactoryOrd.BuyerPayAmount, | |||
SubsidyAmount: v.FactoryOrd.SubsidyAmount, | |||
ServiceFee: v.FactoryOrd.ServiceFee, | |||
TradeChannel: v.FactoryOrd.TradeChannel, | |||
}) | |||
} | |||
return | |||
} | |||
func FactoryOrdListExport(req md.FactoryOrdListReq) (resp []md.FactoryOrdListResp, err error) { | |||
sess := db.Db.Desc("factory_ord.id") | |||
if req.EnterpriseId != 0 { | |||
sess.And("factory_ord.enterprise_id =?", req.EnterpriseId) | |||
} | |||
if req.StartDate != "" { | |||
sess.And("factory_ord.gmt_payment >= ?", req.StartDate) | |||
} | |||
if req.EndDate != "" { | |||
sess.And("factory_ord.gmt_payment <= ?", req.EndDate) | |||
} | |||
if req.OrderStatus != 0 { | |||
sess.And("factory_ord.order_status = ?", req.OrderStatus) | |||
} | |||
if req.OutTradeNo != "" { | |||
sess.And("factory_ord.out_order_no like ?", "%"+req.OutTradeNo+"%") | |||
} | |||
if req.TerminalId != "" { | |||
sess.And("factory_ord.terminal_id like ?", "%"+req.TerminalId+"%") | |||
} | |||
if req.TradeNo != "" { | |||
sess.And("factory_ord.trade_no like ?", "%"+req.TradeNo+"%") | |||
} | |||
if req.Name != "" { | |||
sess.And("user_identity.name like ?", "%"+req.Name+"%") | |||
} | |||
if req.Phone != "" { | |||
sess.And("user.phone like ?", "%"+req.Phone+"%") | |||
} | |||
if req.ShopName != "" { | |||
sess.And("factory_device.name like ?", "%"+req.ShopName+"%") | |||
} | |||
var m []*db.FactoryOrdWithUserIdentity | |||
err = sess. | |||
Join("LEFT", "user_identity", "factory_ord.user_identity_id = user_identity.id"). | |||
Join("LEFT", "enterprise", "enterprise.id = user_identity.enterprise_id"). | |||
Join("LEFT", "user", "user.id = user_identity.uid"). | |||
Join("LEFT", "factory_device", "factory_ord.terminal_id = factory_device.terminal_id"). | |||
Desc("factory_ord.create_at").Find(&m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if err != nil { | |||
return nil, err | |||
} | |||
for _, v := range m { | |||
resp = append(resp, md.FactoryOrdListResp{ | |||
EnterpriseId: v.Enterprise.Id, | |||
EnterpriseName: v.Enterprise.Name, | |||
Uid: v.User.Id, | |||
UserIdentityId: v.UserIdentity.Id, | |||
UserIdentityName: v.UserIdentity.Name, | |||
OutTradeNo: v.FactoryOrd.OutOrderNo, | |||
TradeNo: v.FactoryOrd.TradeNo, | |||
OrderStatus: v.FactoryOrd.OrderStatus, | |||
Phone: v.User.Phone, | |||
GmtPayment: v.FactoryOrd.GmtPayment, | |||
TerminalId: v.FactoryOrd.TerminalId, | |||
ShopName: v.FactoryDevice.Name, | |||
TotalAmount: v.FactoryOrd.TotalAmount, | |||
ReceiptAmount: v.FactoryOrd.ReceiptAmount, | |||
BuyerPayAmount: v.FactoryOrd.BuyerPayAmount, | |||
SubsidyAmount: v.FactoryOrd.SubsidyAmount, | |||
ServiceFee: v.FactoryOrd.ServiceFee, | |||
TradeChannel: v.FactoryOrd.TradeChannel, | |||
}) | |||
} | |||
return | |||
} |
@@ -0,0 +1,203 @@ | |||
package svc | |||
import ( | |||
"applet/app/admin/md" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/enum" | |||
"applet/app/utils" | |||
"errors" | |||
"fmt" | |||
"time" | |||
) | |||
func DeleteFactoryIdentity(id int) (err error) { | |||
session := db.Db.NewSession() | |||
defer session.Close() | |||
session.Begin() | |||
//1、删除 `role` | |||
factoryIdentityDb := db.FactoryIdentityDb{} | |||
factoryIdentityDb.Set(id) | |||
_, err = factoryIdentityDb.FactoryIdentityDeleteBySession(session, id) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return | |||
} | |||
//2、删除 `factory_identity_with_user_identity` | |||
factoryIdentityWithUserIdentityDb := db.FactoryIdentityWithUserIdentityDb{} | |||
factoryIdentityWithUserIdentityDb.Set() | |||
_, err = factoryIdentityWithUserIdentityDb.FactoryIdentityWithUserIdentityDeleteForRoleBySession(session, id) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return | |||
} | |||
return session.Commit() | |||
} | |||
//func RoleBindPermissionGroup(req md.RoleBindPermissionGroupReq) (err error) { | |||
// session := db.Db.NewSession() | |||
// defer session.Close() | |||
// session.Begin() | |||
// //1、查询 `role` | |||
// roleDb := db.RoleDb{} | |||
// roleDb.Set(req.RoleId) | |||
// role, err := roleDb.GetRole() | |||
// if err != nil { | |||
// return | |||
// } | |||
// if role == nil { | |||
// return errors.New("未查询到相应记录") | |||
// } | |||
// | |||
// //1、删除 `role_permission_group` | |||
// rolePermissionGroupDb := db.RolePermissionGroupDb{} | |||
// rolePermissionGroupDb.Set() | |||
// _, err = rolePermissionGroupDb.RolePermissionGroupDeleteForRoleBySession(session, req.RoleId) | |||
// if err != nil { | |||
// _ = session.Rollback() | |||
// return | |||
// } | |||
// | |||
// //2、新增 `role_permission_group`` | |||
// var mm []*model.RolePermissionGroup | |||
// now := time.Now() | |||
// for _, v := range req.PermissionIds { | |||
// mm = append(mm, &model.RolePermissionGroup{ | |||
// RoleId: role.Id, | |||
// GroupId: v, | |||
// CreateAt: now.Format("2006-01-02 15:04:05"), | |||
// UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
// }) | |||
// } | |||
// _, err = rolePermissionGroupDb.BatchAddRolePermissionGroupBySession(session, mm) | |||
// if err != nil { | |||
// _ = session.Rollback() | |||
// return | |||
// } | |||
// | |||
// return session.Commit() | |||
//} | |||
func BindUserFactoryIdentity(req md.BindFactoryIdentityReq) (err error) { | |||
session := db.Db.NewSession() | |||
defer session.Close() | |||
session.Begin() | |||
//1、查询 `role` | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(0) | |||
role, err := userIdentityDb.GetUserIdentity(req.UserIdentitiesId) | |||
if err != nil { | |||
return | |||
} | |||
if role == nil { | |||
return errors.New("未查询到相应记录") | |||
} | |||
//2、删除 `factory_identity_with_user_identity` | |||
factoryIdentityWithUserIdentityDb := db.FactoryIdentityWithUserIdentityDb{} | |||
factoryIdentityWithUserIdentityDb.Set() | |||
_, err = factoryIdentityWithUserIdentityDb.FactoryIdentityWithUserIdentityDeleteForRoleBySession(session, req.FactoryIdentityId) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return | |||
} | |||
//3、新增 `删除 `factory_identity_with_user_identity`` | |||
now := time.Now() | |||
_, err = factoryIdentityWithUserIdentityDb.AddFactoryIdentityWithUserIdentityBySession(session, &model.FactoryIdentityWithUserIdentity{ | |||
UserIdentityId: req.UserIdentitiesId, | |||
FactoryIdentityId: req.FactoryIdentityId, | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return | |||
} | |||
return session.Commit() | |||
} | |||
func FactoryInfo(enterpriseId int) (err error, resp md.FactoryInfoResp) { | |||
//1、查询`enterprise` | |||
enterpriseDb := db.EnterpriseDb{} | |||
enterpriseDb.Set() | |||
enterprise, err := enterpriseDb.GetEnterprise(enterpriseId) | |||
if err != nil { | |||
return | |||
} | |||
resp.Name = enterprise.Name | |||
resp.Memo = enterprise.Memo | |||
resp.Kind = enum.EnterpriseKind(enterprise.Kind).String() | |||
resp.Mode = enum.EnterpriseMode(enterprise.Mode).String() | |||
resp.Pvd = enum.EnterprisePvd(enterprise.Pvd).String() | |||
resp.State = enum.EnterpriseState(enterprise.State).String() | |||
//2、统计 "用户"、 "工人" 数量 | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(0) | |||
resp.WorkerNum, err = userIdentityDb.CountUserIdentityForEnterprise(enterpriseId, enum.UserIdentityForFactory) | |||
if err != nil { | |||
return | |||
} | |||
//userDb := db.UserDb{} | |||
//userDb.Set() | |||
//resp.UserNum, err = userDb.CountUserForEnterprise(enterpriseId) | |||
//if err != nil { | |||
// return | |||
//} | |||
//3、统计 订单数据 | |||
now := time.Now() | |||
today := now.AddDate(0, 0, +1).Format("2006-01-02") //今日 | |||
thisMonth := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location()).Format("2006-01-02") //本月 | |||
sql1 := fmt.Sprintf("SELECT SUM(total_amount) AS this_month_consume_amount FROM factory_ord where gmt_payment >= '%s' and gmt_payment <= '%s'", thisMonth, today) | |||
sql2 := fmt.Sprintf("SELECT count(*) AS this_month_order_num FROM factory_ord where gmt_payment >= '%s' and gmt_payment <= '%s'", thisMonth, today) | |||
sql3 := fmt.Sprintf("SELECT SUM(service_fee) AS this_month_service_amount FROM factory_ord where gmt_payment >= '%s' and gmt_payment <= '%s'", thisMonth, today) | |||
sql4 := fmt.Sprintf("SELECT SUM(receipt_amount) AS this_month_receipt_amount FROM factory_ord where gmt_payment >= '%s' and gmt_payment <= '%s'", thisMonth, today) | |||
mapArr1, err := db.QueryNativeString(db.Db, sql1) | |||
if err != nil { | |||
return | |||
} | |||
if mapArr1 == nil { | |||
resp.ThisMonthConsumeAmount = 0 | |||
} else { | |||
resp.ThisMonthConsumeAmount = utils.StrToFloat64(mapArr1[0]["this_month_consume_amount"]) | |||
} | |||
mapArr2, err := db.QueryNativeString(db.Db, sql2) | |||
if err != nil { | |||
return | |||
} | |||
if mapArr2 == nil { | |||
resp.ThisMonthOrderNum = 0 | |||
} else { | |||
resp.ThisMonthOrderNum = utils.StrToFloat64(mapArr2[0]["this_month_order_num"]) | |||
} | |||
mapArr3, err := db.QueryNativeString(db.Db, sql3) | |||
if err != nil { | |||
return | |||
} | |||
if mapArr3 == nil { | |||
resp.ThisMonthServiceAmount = 0 | |||
} else { | |||
resp.ThisMonthServiceAmount = utils.StrToFloat64(mapArr3[0]["this_month_service_amount"]) | |||
} | |||
mapArr4, err := db.QueryNativeString(db.Db, sql4) | |||
if err != nil { | |||
return | |||
} | |||
if mapArr4 == nil { | |||
resp.ThisMonthReceiptAmount = 0 | |||
} else { | |||
resp.ThisMonthReceiptAmount = utils.StrToFloat64(mapArr4[0]["receipt_amount"]) | |||
} | |||
return | |||
} |
@@ -11,6 +11,59 @@ import ( | |||
"github.com/gin-gonic/gin" | |||
) | |||
func FactoryOrderList(c *gin.Context) { | |||
var req md.FactoryOrderListReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
list, total, err := svc.FactoryOrderList(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
tradeAmountTotal, err := svc.FactoryOrderStatistic(req) | |||
if err != nil { | |||
e.OutErr(c, e.ERR, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, map[string]interface{}{ | |||
"list": list, | |||
"total": total, | |||
"trade_amount_total": tradeAmountTotal, | |||
"order_status_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.FactoryOrdOrderStatus.String(enum.FactoryOrdOrderStatusForSuccess), | |||
"value": enum.FactoryOrdOrderStatusForSuccess, | |||
}, | |||
{ | |||
"name": enum.FactoryOrdOrderStatus.String(enum.FactoryOrdOrderStatusForRefund), | |||
"value": enum.FactoryOrdOrderStatusForRefund, | |||
}, | |||
{ | |||
"name": enum.FactoryOrdOrderStatus.String(enum.FactoryOrdOrderStatusForClose), | |||
"value": enum.FactoryOrdOrderStatusForClose, | |||
}, | |||
}, | |||
"trade_channel_list": []map[string]interface{}{ | |||
{ | |||
"name": enum.FactoryOrdTradeChannel.String(enum.FactoryOrdTradeChannelForAli), | |||
"value": enum.FactoryOrdTradeChannelForAli, | |||
}, | |||
{ | |||
"name": enum.FactoryOrdTradeChannel.String(enum.FactoryOrdTradeChannelForWx), | |||
"value": enum.FactoryOrdTradeChannelForWx, | |||
}, | |||
}, | |||
}, nil) | |||
return | |||
} | |||
func SelfSupportForSchoolOrderList(c *gin.Context) { | |||
var req md.SelfSupportForSchoolOrderListReq | |||
err := c.ShouldBindJSON(&req) | |||
@@ -137,6 +137,25 @@ func UserInfo(c *gin.Context) { | |||
} | |||
} | |||
if v.Enterprise.Pvd == enum.EnterprisePvdForAllPayment && v.Enterprise.Mode == enum.EnterpriseModeForFactory { | |||
//TODO::工厂 | |||
sMDate := utils.GetFirstDateOfMonth(now).Format("2006-01-02 15:04:05") | |||
eMDate := utils.GetLastDateOfMonth(now).Format("2006-01-02 15:04:05") | |||
sTDate, eTDate := utils.GetDateTimeRangeStr("today") | |||
monthStatistic, err2 := svc2.FactoryUserIdentityOrderStatistic(v.UserIdentity.Id, sMDate, eMDate, "total_amount") | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR, err2.Error()) | |||
return | |||
} | |||
dayStatistic, err2 := svc2.FactoryUserIdentityOrderStatistic(v.UserIdentity.Id, sTDate, eTDate, "total_amount") | |||
if err2 != nil { | |||
e.OutErr(c, e.ERR, err2.Error()) | |||
return | |||
} | |||
tmp["month_statistic"] = monthStatistic | |||
tmp["day_statistic"] = dayStatistic | |||
} | |||
identityList = append(identityList, tmp) | |||
} | |||
@@ -287,6 +287,52 @@ func SaveSelfSupportForSchoolUserIdentity(c *gin.Context) { | |||
return | |||
} | |||
func SaveFactoryUserIdentity(c *gin.Context) { | |||
var req md.SaveFactoryUserIdentityReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
user := svc.GetUser(c) | |||
if req.CertType == 0 { | |||
req.CertType = enum.UserIdentityCertTypeForIdCard | |||
} | |||
//1、判断当前身份是否已绑定 | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(user.Id) | |||
isHasUserIdentity, err := userIdentityDb.UserIdentityExist(req.EnterpriseId, req.IdNo, req.CertType) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if isHasUserIdentity == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "当前身份信息不存在") | |||
return | |||
} else { | |||
if isHasUserIdentity.Uid != 0 && isHasUserIdentity.Uid != user.Id { | |||
e.OutErr(c, e.ERR, "当前身份信息已被绑定使用") | |||
return | |||
} | |||
//2、修改身份信息 | |||
isHasUserIdentity.Uid = user.Id | |||
isHasUserIdentity.Name = req.Name | |||
isHasUserIdentity.State = enum.UserIdentityStateForNormal | |||
_, err = userIdentityDb.UserIdentityUpdate(isHasUserIdentity.Id, isHasUserIdentity, "uid", "name", "state") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func SaveNursingHomeUserIdentity(c *gin.Context) { | |||
var req md.SaveNursingHomeUserIdentityReq | |||
err := c.ShouldBindJSON(&req) | |||
@@ -482,6 +528,42 @@ func UpdateSelfSupportForSchoolUserIdentity(c *gin.Context) { | |||
return | |||
} | |||
func UpdateFactoryUserIdentity(c *gin.Context) { | |||
var req md.UpdateFactoryUserIdentityReq | |||
err := c.ShouldBindJSON(&req) | |||
if err != nil { | |||
err = validate.HandleValidateErr(err) | |||
err1 := err.(e.E) | |||
e.OutErr(c, err1.Code, err1.Error()) | |||
return | |||
} | |||
user := svc.GetUser(c) | |||
//1、查询当前身份是否存在 | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(user.Id) | |||
userIdentity, err := userIdentityDb.GetUserIdentity(req.UserIdentityId) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if userIdentity == nil { | |||
e.OutErr(c, e.ERR_NO_DATA, "当前身份信息不存在") | |||
return | |||
} | |||
//2、修改身份信息 | |||
userIdentity.Name = req.Name | |||
userIdentity.IdNo = req.IdNo | |||
_, err = userIdentityDb.UserIdentityUpdate(userIdentity.Id, userIdentity, "id_no", "name") | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
e.OutSuc(c, "success", nil) | |||
return | |||
} | |||
func UpdateNursingHomeUserIdentity(c *gin.Context) { | |||
var req md.UpdateNursingHomeUserIdentityReq | |||
err := c.ShouldBindJSON(&req) | |||
@@ -574,6 +656,13 @@ func DeleteUserIdentity(c *gin.Context) { | |||
return | |||
} | |||
break | |||
case enum.UserIdentityForFactory: | |||
err1 := svc.DeleteUserIdentityForFactory(userIdentity.Id) | |||
if err1 != nil { | |||
e.OutErr(c, e.ERR, err1.Error()) | |||
return | |||
} | |||
break | |||
case enum.UserIdentityForNursingHome: | |||
err1 := svc.DeleteUserIdentityForNursingHome(userIdentity.Id) | |||
if err1 != nil { | |||
@@ -135,3 +135,12 @@ type NursingHomeMyReserveRespList struct { | |||
LunchTotal int `json:"lunch_total" label:"午餐-总计"` | |||
DinnerTotal int `json:"dinner_total" label:"晚餐-总计"` | |||
} | |||
type FactoryOrderListReq struct { | |||
UserIdentityId int `json:"user_identity_id" label:"用户身份id"` | |||
Limit int `json:"limit"` | |||
Page int `json:"page" ` | |||
OrderStatus int `json:"order_status" ` | |||
StartDate string `json:"start_date" ` | |||
EndDate string `json:"end_date" ` | |||
} |
@@ -28,6 +28,13 @@ type SaveSelfSupportForSchoolUserIdentityReq struct { | |||
ClassId int `json:"class_id" label:"班级id"` | |||
} | |||
type SaveFactoryUserIdentityReq struct { | |||
EnterpriseId int `json:"enterprise_id" binding:"required" label:"企业id"` | |||
Name string `json:"name" binding:"required" label:"姓名"` | |||
IdNo string `json:"id_no" binding:"required" label:"身份证号码"` | |||
CertType int `json:"cert_type" label:"证件类型(1:身份证 2:学工号 3:护照)"` | |||
} | |||
type UpdateCentralKitchenForSchoolUserIdentityReq struct { | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
Name string `json:"name" label:"姓名"` | |||
@@ -44,6 +51,12 @@ type UpdateSelfSupportForSchoolUserIdentityReq struct { | |||
UserIdentityId int `json:"user_identity_id" label:"用户身份id"` | |||
} | |||
type UpdateFactoryUserIdentityReq struct { | |||
IdNo string `json:"id_no" label:"证件号证号"` | |||
Name string `json:"name" label:"姓名"` | |||
UserIdentityId int `json:"user_identity_id" label:"用户身份id"` | |||
} | |||
type UpdateNursingHomeUserIdentityReq struct { | |||
IdNo string `json:"id_no" label:"身份证号"` | |||
Name string `json:"name" label:"姓名"` | |||
@@ -0,0 +1,61 @@ | |||
package svc | |||
import ( | |||
"applet/app/customer/md" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"fmt" | |||
) | |||
func FactoryOrderList(req md.FactoryOrderListReq) (m []model.FactoryOrd, total int64, err error) { | |||
sess := db.Db.Desc("id").Where("user_identity_id =?", req.UserIdentityId).Limit(req.Limit, (req.Page-1)*req.Limit) | |||
if req.OrderStatus != 0 { | |||
sess.And("order_status = ?", req.OrderStatus) | |||
} | |||
if req.StartDate != "" { | |||
sess.And("create_at >= ?", req.StartDate) | |||
} | |||
if req.EndDate != "" { | |||
sess.And("create_at <= ?", req.EndDate) | |||
} | |||
total, err = sess.FindAndCount(&m) | |||
if err != nil { | |||
return | |||
} | |||
return | |||
} | |||
func FactoryOrderStatistic(req md.FactoryOrderListReq) (total float64, err error) { | |||
var sql = fmt.Sprintf("SELECT SUM(total_amount) AS trade_amount_total FROM factory_ord where user_identity_id = '%d'", req.UserIdentityId) | |||
if req.OrderStatus != 0 { | |||
sql += fmt.Sprintf(" and order_status = %d", req.OrderStatus) | |||
} | |||
if req.StartDate != "" { | |||
sql += fmt.Sprintf(" and create_at >= '%s'", req.StartDate) | |||
} | |||
if req.EndDate != "" { | |||
sql += fmt.Sprintf(" and create_at <= '%s'", req.EndDate) | |||
} | |||
mapArr1, err := db.QueryNativeString(db.Db, sql) | |||
if err != nil { | |||
return | |||
} | |||
if mapArr1 != nil { | |||
total = utils.StrToFloat64(mapArr1[0]["trade_amount_total"]) | |||
} | |||
return | |||
} | |||
func FactoryUserIdentityOrderStatistic(userIdentityId int, sDate, eDate, column string) (total float64, err error) { | |||
var sql = fmt.Sprintf("SELECT SUM(%s) AS total FROM factory_ord where user_identity_id = '%d' and gmt_payment >= '%s' and gmt_payment <= '%s'", | |||
column, userIdentityId, sDate, eDate) | |||
mapArr1, err := db.QueryNativeString(db.Db, sql) | |||
if err != nil { | |||
return | |||
} | |||
if mapArr1 != nil { | |||
total = utils.StrToFloat64(mapArr1[0]["total"]) | |||
} | |||
return | |||
} |
@@ -33,10 +33,10 @@ func SupportOrderStatistic(req md.SelfSupportForSchoolOrderListReq) (total float | |||
sql += fmt.Sprintf(" and order_status = %d", req.OrderStatus) | |||
} | |||
if req.StartDate != "" { | |||
sql += fmt.Sprintf(" and create_at = %s", req.StartDate) | |||
sql += fmt.Sprintf(" and create_at >= '%s'", req.StartDate) | |||
} | |||
if req.EndDate != "" { | |||
sql += fmt.Sprintf(" and create_at <= %s", req.StartDate) | |||
sql += fmt.Sprintf(" and create_at <= '%s'", req.EndDate) | |||
} | |||
mapArr1, err := db.QueryNativeString(db.Db, sql) | |||
if err != nil { | |||
@@ -114,6 +114,25 @@ func DeleteUserIdentityForSelfSupportForWorker(userIdentityId int) (err error) { | |||
return | |||
} | |||
func DeleteUserIdentityForFactory(userIdentityId int) (err error) { | |||
//1、删除 user_identity(将`state`变成"冻结"状态) | |||
userIdentityDb := db.UserIdentityDb{} | |||
userIdentityDb.Set(0) | |||
identity, err := userIdentityDb.GetUserIdentity(userIdentityId) | |||
if err != nil { | |||
return err | |||
} | |||
identity.State = enum.UserIdentityStateForFreeze | |||
updateAffected, err := userIdentityDb.UserIdentityUpdate(userIdentityId, identity, "state") | |||
if err != nil { | |||
return err | |||
} | |||
if updateAffected <= 0 { | |||
return errors.New("删除用户信息数据失败") | |||
} | |||
return | |||
} | |||
func DeleteUserIdentityForNursingHome(userIdentityId int) (err error) { | |||
//1、删除 user_identity(将`state`变成"冻结"状态) | |||
userIdentityDb := db.UserIdentityDb{} | |||
@@ -0,0 +1,103 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"reflect" | |||
"xorm.io/xorm" | |||
) | |||
type FactoryDevice struct { | |||
Db *xorm.Engine `json:"db"` | |||
TerminalId string `json:"terminal_id"` | |||
} | |||
func (factoryDeviceDb *FactoryDevice) Set(terminalId string) { // set方法 | |||
factoryDeviceDb.Db = Db | |||
factoryDeviceDb.TerminalId = terminalId | |||
} | |||
func (factoryDeviceDb *FactoryDevice) GetFactoryDeviceById(id int) (m *model.FactoryDevice, err error) { | |||
m = new(model.FactoryDevice) | |||
has, err := factoryDeviceDb.Db.Where("id =?", id).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (factoryDeviceDb *FactoryDevice) GetFactoryDevice() (m *model.FactoryDevice, err error) { | |||
m = new(model.FactoryDevice) | |||
has, err := factoryDeviceDb.Db.Where("terminal_id =?", factoryDeviceDb.TerminalId).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (factoryDeviceDb *FactoryDevice) FactoryDeviceInsert(m *model.FactoryDevice) (int, error) { | |||
_, err := factoryDeviceDb.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (factoryDeviceDb *FactoryDevice) FactoryDeviceInsertBySession(session *xorm.Session, m *model.FactoryDevice) (int, error) { | |||
_, err := session.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (factoryDeviceDb *FactoryDevice) BatchAddFactoryDevices(mm []*model.FactoryDevice) (int64, error) { | |||
affected, err := factoryDeviceDb.Db.Insert(mm) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
func (factoryDeviceDb *FactoryDevice) FactoryDeviceDeleteById(id interface{}) (int64, error) { | |||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||
return Db.In("id", id).Delete(model.FactoryDevice{}) | |||
} else { | |||
return Db.Where("id = ?", id).Delete(model.FactoryDevice{}) | |||
} | |||
} | |||
func (factoryDeviceDb *FactoryDevice) FactoryDeviceDelete() (int64, error) { | |||
return Db.Where("terminal_id = ?", factoryDeviceDb.TerminalId).Delete(model.FactoryDevice{}) | |||
} | |||
func (factoryDeviceDb *FactoryDevice) FactoryDeviceUpdate(m *model.FactoryDevice, forceColums ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceColums != nil { | |||
affected, err = factoryDeviceDb.Db.Where("terminal_id=?", factoryDeviceDb.TerminalId).Cols(forceColums...).Update(m) | |||
} else { | |||
affected, err = factoryDeviceDb.Db.Where("terminal_id=?", factoryDeviceDb.TerminalId).Update(m) | |||
} | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
type FactoryDeviceWithEnterprise struct { | |||
model.FactoryDevice `xorm:"extends"` | |||
model.Enterprise `xorm:"extends"` | |||
} | |||
func (FactoryDeviceWithEnterprise) TableName() string { | |||
return "factory_device" | |||
} |
@@ -0,0 +1,111 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"reflect" | |||
"xorm.io/xorm" | |||
) | |||
type FactoryIdentityDb struct { | |||
Db *xorm.Engine `json:"db"` | |||
EnterpriseId int `json:"enterprise_id"` | |||
} | |||
func (factoryIdentityDb *FactoryIdentityDb) Set(enterpriseId int) { // set方法 | |||
factoryIdentityDb.Db = Db | |||
factoryIdentityDb.EnterpriseId = enterpriseId | |||
} | |||
func (factoryIdentityDb *FactoryIdentityDb) FindFactoryIdentity(page, limit int) (list *[]model.FactoryIdentity, count int64, err error) { | |||
var m []model.FactoryIdentity | |||
if count, err = factoryIdentityDb.Db.Where("enterprise_id = ?", factoryIdentityDb.EnterpriseId).Desc("id").Limit(limit, (page-1)*limit).FindAndCount(&m); err != nil { | |||
return nil, 0, logx.Error(err) | |||
} | |||
return &m, count, nil | |||
} | |||
func (factoryIdentityDb *FactoryIdentityDb) GetFactoryIdentity(id int) (m *model.FactoryIdentity, err error) { | |||
m = new(model.FactoryIdentity) | |||
has, err := factoryIdentityDb.Db.Where("id = ?", id).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (factoryIdentityDb *FactoryIdentityDb) GetFactoryIdentityByName(name string) (m *model.FactoryIdentity, err error) { | |||
m = new(model.FactoryIdentity) | |||
has, err := factoryIdentityDb.Db.Where("name = ?", name).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (factoryIdentityDb *FactoryIdentityDb) UpdateFactoryIdentity(m *model.FactoryIdentity, columns ...string) (int64, error) { | |||
affected, err := factoryIdentityDb.Db.Where("id =?", m.Id).Cols(columns...).Update(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
func (factoryIdentityDb *FactoryIdentityDb) FactoryIdentityDeleteBySession(session *xorm.Session, id interface{}) (int64, error) { | |||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||
return session.In("id", id).Delete(model.FactoryIdentity{}) | |||
} else { | |||
return session.Where("id = ?", id).Delete(model.FactoryIdentity{}) | |||
} | |||
} | |||
func (factoryIdentityDb *FactoryIdentityDb) FactoryIdentityInsert(m *model.FactoryIdentity) (int, error) { | |||
_, err := factoryIdentityDb.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (factoryIdentityDb *FactoryIdentityDb) FindUserIdentityWithFactoryIdentity(userIdentityId int) (list []*UserIdentityWithFactoryIdentity, total int64, err error) { | |||
total, err = factoryIdentityDb.Db.Where("user_identity.id =?", userIdentityId). | |||
Join("LEFT", "factory_identity_with_user_identity", "factory_identity_with_user_identity.user_identity_id = user_identity.id"). | |||
Join("LEFT", "factory_identity", "factory_identity.id = factory_identity_with_user_identity.factory_identity_id"). | |||
FindAndCount(&list) | |||
return | |||
} | |||
type UserIdentityWithFactoryIdentity struct { | |||
model.UserIdentity `xorm:"extends"` | |||
model.User `xorm:"extends"` | |||
model.FactoryIdentityWithUserIdentity `xorm:"extends"` | |||
model.FactoryIdentity `xorm:"extends"` | |||
} | |||
func (UserIdentityWithFactoryIdentity) TableName() string { | |||
return "user_identity" | |||
} | |||
func (factoryIdentityDb *FactoryIdentityDb) FindFactoryIdentityWithUserIdentity(factoryIdentityId int) (list []*FactoryIdentityWithUserIdentity, total int64, err error) { | |||
total, err = factoryIdentityDb.Db.Where("factory_identity.id =?", factoryIdentityId). | |||
Join("LEFT", "factory_identity_with_user_identity", "factory_identity_with_user_identity.factory_identity_id = factory_identity.id"). | |||
Join("LEFT", "user_identity", "user_identity.id = factory_identity_with_user_identity.user_identity_id"). | |||
FindAndCount(&list) | |||
return | |||
} | |||
type FactoryIdentityWithUserIdentity struct { | |||
model.FactoryIdentity `xorm:"extends"` | |||
model.UserIdentity `xorm:"extends"` | |||
model.FactoryIdentityWithUserIdentity `xorm:"extends"` | |||
} | |||
func (FactoryIdentityWithUserIdentity) TableName() string { | |||
return "factory_identity" | |||
} |
@@ -0,0 +1,68 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"reflect" | |||
"xorm.io/xorm" | |||
) | |||
type FactoryIdentityWithUserIdentityDb struct { | |||
Db *xorm.Engine `json:"db"` | |||
} | |||
func (factoryIdentityWithUserIdentityDb *FactoryIdentityWithUserIdentityDb) Set() { // set方法 | |||
factoryIdentityWithUserIdentityDb.Db = Db | |||
} | |||
func (factoryIdentityWithUserIdentityDb *FactoryIdentityWithUserIdentityDb) FactoryIdentityWithUserIdentityDeleteForRoleBySession(session *xorm.Session, factoryIdentityId interface{}) (int64, error) { | |||
if reflect.TypeOf(factoryIdentityId).Kind() == reflect.Slice { | |||
return session.In("factory_identity_id", factoryIdentityId).Delete(model.FactoryIdentityWithUserIdentity{}) | |||
} else { | |||
return session.Where("factory_identity_id = ?", factoryIdentityId).Delete(model.FactoryIdentityWithUserIdentity{}) | |||
} | |||
} | |||
func (factoryIdentityWithUserIdentityDb *FactoryIdentityWithUserIdentityDb) BatchAddFactoryIdentityWithUserIdentityBySession(session *xorm.Session, mm []*model.FactoryIdentityWithUserIdentity) (int64, error) { | |||
affected, err := session.Insert(mm) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
func (factoryIdentityWithUserIdentityDb *FactoryIdentityWithUserIdentityDb) AddFactoryIdentityWithUserIdentityBySession(session *xorm.Session, m *model.FactoryIdentityWithUserIdentity) (int, error) { | |||
_, err := session.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (factoryIdentityWithUserIdentityDb *FactoryIdentityWithUserIdentityDb) AddFactoryIdentityWithUserIdentity(m *model.FactoryIdentityWithUserIdentity) (int, error) { | |||
_, err := factoryIdentityWithUserIdentityDb.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (factoryIdentityWithUserIdentityDb *FactoryIdentityWithUserIdentityDb) GetFactoryIdentityWithUserIdentity(userIdentityId int) (m *model.FactoryIdentityWithUserIdentity, err error) { | |||
m = new(model.FactoryIdentityWithUserIdentity) | |||
has, err := factoryIdentityWithUserIdentityDb.Db.Where("user_identity_id = ?", userIdentityId).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (factoryIdentityWithUserIdentityDb *FactoryIdentityWithUserIdentityDb) UpdateFactoryIdentityWithUserIdentity(m *model.FactoryIdentityWithUserIdentity, columns ...string) (int64, error) { | |||
affected, err := factoryIdentityWithUserIdentityDb.Db.Where("id =?", m.Id).Cols(columns...).Update(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} |
@@ -0,0 +1,115 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"reflect" | |||
"xorm.io/xorm" | |||
) | |||
type FactoryOrd struct { | |||
Db *xorm.Engine `json:"db"` | |||
OutOrderNo string `json:"user_identity_id"` | |||
} | |||
func (factoryOrdOrdDb *FactoryOrd) Set(outOrderNo string) { // set方法 | |||
factoryOrdOrdDb.Db = Db | |||
factoryOrdOrdDb.OutOrderNo = outOrderNo | |||
} | |||
func (factoryOrdOrdDb *FactoryOrd) GetFactoryOrdById(id int) (m *model.FactoryOrd, err error) { | |||
m = new(model.FactoryOrd) | |||
has, err := factoryOrdOrdDb.Db.Where("id =?", id).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (factoryOrdOrdDb *FactoryOrd) GetFactoryOrd() (m *model.FactoryOrd, err error) { | |||
m = new(model.FactoryOrd) | |||
has, err := factoryOrdOrdDb.Db.Where("out_order_no =?", factoryOrdOrdDb.OutOrderNo).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (factoryOrdOrdDb *FactoryOrd) FactoryOrdInsert(m *model.FactoryOrd) (int, error) { | |||
_, err := factoryOrdOrdDb.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (factoryOrdOrdDb *FactoryOrd) FactoryOrdInsertBySession(session *xorm.Session, m *model.FactoryOrd) (int, error) { | |||
_, err := session.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (factoryOrdOrdDb *FactoryOrd) BatchAddFactoryOrds(mm []*model.FactoryOrd) (int64, error) { | |||
affected, err := factoryOrdOrdDb.Db.Insert(mm) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
func (factoryOrdOrdDb *FactoryOrd) FactoryOrdDeleteById(id interface{}) (int64, error) { | |||
if reflect.TypeOf(id).Kind() == reflect.Slice { | |||
return Db.In("id", id).Delete(model.FactoryOrd{}) | |||
} else { | |||
return Db.Where("id = ?", id).Delete(model.FactoryOrd{}) | |||
} | |||
} | |||
func (factoryOrdOrdDb *FactoryOrd) FactoryOrdDelete() (int64, error) { | |||
return Db.Where("out_order_no = ?", factoryOrdOrdDb.OutOrderNo).Delete(model.FactoryOrd{}) | |||
} | |||
func (factoryOrdOrdDb *FactoryOrd) FactoryOrdUpdate(m *model.FactoryOrd, forceColums ...string) (int64, error) { | |||
var ( | |||
affected int64 | |||
err error | |||
) | |||
if forceColums != nil { | |||
affected, err = factoryOrdOrdDb.Db.Where("out_order_no=?", factoryOrdOrdDb.OutOrderNo).Cols(forceColums...).Update(m) | |||
} else { | |||
affected, err = factoryOrdOrdDb.Db.Where("out_order_no=?", factoryOrdOrdDb.OutOrderNo).Update(m) | |||
} | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} | |||
type FactoryOrdWithUserIdentity struct { | |||
model.FactoryOrd `xorm:"extends"` | |||
model.UserIdentity `xorm:"extends"` | |||
model.Enterprise `xorm:"extends"` | |||
model.User `xorm:"extends"` | |||
model.FactoryDevice `xorm:"extends"` | |||
} | |||
func (FactoryOrdWithUserIdentity) TableName() string { | |||
return "factory_ord" | |||
} | |||
type FactoryOrdWithUserIdentityV2 struct { | |||
model.FactoryOrd `xorm:"extends"` | |||
model.Enterprise `xorm:"extends"` | |||
} | |||
func (FactoryOrdWithUserIdentityV2) TableName() string { | |||
return "factory_ord" | |||
} |
@@ -0,0 +1,45 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
type FactorySetDb struct { | |||
Db *xorm.Engine `json:"db"` | |||
EnterpriseId int `json:"enterprise_id"` | |||
} | |||
func (factorySetDb *FactorySetDb) Set(enterpriseId int) { // set方法 | |||
factorySetDb.Db = Db | |||
factorySetDb.EnterpriseId = enterpriseId | |||
} | |||
func (factorySetDb *FactorySetDb) GetFactorySet() (m *model.FactorySet, err error) { | |||
m = new(model.FactorySet) | |||
has, err := factorySetDb.Db.Where("enterprise_id =?", factorySetDb.EnterpriseId).Get(m) | |||
if err != nil { | |||
return nil, logx.Error(err) | |||
} | |||
if has == false { | |||
return nil, nil | |||
} | |||
return m, nil | |||
} | |||
func (factorySetDb *FactorySetDb) FactorySetInsert(m *model.FactorySet) (int, error) { | |||
_, err := factorySetDb.Db.InsertOne(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return m.Id, nil | |||
} | |||
func (factorySetDb *FactorySetDb) FactorySetUpdate(m *model.FactorySet, columns ...string) (int64, error) { | |||
affected, err := factorySetDb.Db.Where("enterprise_id =?", factorySetDb.EnterpriseId).Cols(columns...).Update(m) | |||
if err != nil { | |||
return 0, err | |||
} | |||
return affected, nil | |||
} |
@@ -102,6 +102,15 @@ func (userDb *UserDb) DeleteUser(id interface{}) (int64, error) { | |||
} | |||
} | |||
//func (userDb *UserDb) CountUserForEnterprise(enterpriseId int) (total int64, err error) { | |||
// var m model.User | |||
// total, err = userDb.Db.Where("enterprise_id =? ", enterpriseId).Count(&m) | |||
// if err != nil { | |||
// return | |||
// } | |||
// return | |||
//} | |||
type UserWithUserIdentity struct { | |||
model.User `xorm:"extends"` | |||
model.UserIdentity `xorm:"extends"` | |||
@@ -0,0 +1,11 @@ | |||
package model | |||
type FactoryDevice struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' comment('档口名称') VARCHAR(255)"` | |||
TerminalId string `json:"terminal_id" xorm:"not null default '' comment('设备编号') unique VARCHAR(255)"` | |||
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('校企id') INT(11)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(255)"` | |||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} |
@@ -0,0 +1,16 @@ | |||
package model | |||
type FactoryIdentity struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('所属单位id') INT(11)"` | |||
Name string `json:"name" xorm:"not null default '' comment('名称') VARCHAR(255)"` | |||
State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"` | |||
IsSubsidy int `json:"is_subsidy" xorm:"not null default 0 comment('是否优惠补贴(0:否 1:是)') TINYINT(1)"` | |||
SubsidyAmount string `json:"subsidy_amount" xorm:"not null default 0.00 comment('补贴金额') DECIMAL(8,2)"` | |||
LeastPayAmount string `json:"least_pay_amount" xorm:"not null default 0.00 comment('最少支付金额') DECIMAL(8,2)"` | |||
IsLimitConsumeNum int `json:"is_limit_consume_num" xorm:"not null default 0 comment('是否限制消费次数') TINYINT(1)"` | |||
LimitConsumeNum int `json:"'limit_consume_num'" xorm:"default 0 comment('限制消费次数/日') TINYINT(1)"` | |||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} |
@@ -0,0 +1,9 @@ | |||
package model | |||
type FactoryIdentityWithUserIdentity struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
UserIdentityId int `json:"user_identity_id" xorm:"not null default 0 comment('用户身份id') INT(11)"` | |||
FactoryIdentityId int `json:"factory_identity_id" xorm:"not null default 0 comment('工厂身份id') INT(11)"` | |||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} |
@@ -0,0 +1,27 @@ | |||
package model | |||
type FactoryOrd struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('所属单位id') INT(11)"` | |||
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"` | |||
UserIdentityId int `json:"user_identity_id" xorm:"not null default 0 comment('用户身份id') INT(11)"` | |||
OutOrderNo string `json:"out_order_no" xorm:"not null default '' comment('外部订单号,设备端产生') VARCHAR(255)"` | |||
TradeNo string `json:"trade_no" xorm:"not null default '' comment('第三方交易号,支付宝,微信,ISV渠道等') VARCHAR(255)"` | |||
BuyerId string `json:"buyer_id" xorm:"not null default '' comment('渠道买家标识') CHAR(100)"` | |||
TerminalId string `json:"terminal_id" xorm:"not null default '' comment('设备编号') CHAR(100)"` | |||
TradeChannel string `json:"trade_channel" xorm:"not null default '' comment('交易渠道') CHAR(100)"` | |||
StoreId string `json:"store_id" xorm:"not null default '' comment('门店编号') CHAR(100)"` | |||
MerchantId string `json:"merchant_id" xorm:"not null default '' comment('商户编码') CHAR(100)"` | |||
GmtPayment string `json:"gmt_payment" xorm:"not null default '' comment('支付成功时间') CHAR(100)"` | |||
OrderStatus int `json:"order_status" xorm:"not null default 1 comment('交易状态 (1:支付成功 2:已退款 3:已关闭)') TINYINT(1)"` | |||
Subject string `json:"subject" xorm:"not null default '' comment('订单主题') CHAR(50)"` | |||
TotalAmount string `json:"total_amount" xorm:"not null default 0.00 comment('订单总金额') DECIMAL(8,2)"` | |||
DiscountAmount string `json:"discount_amount" xorm:"not null default 0.00 comment('支付宝平台优惠金额') DECIMAL(8,2)"` | |||
MdiscountAmount string `json:"mdiscount_amount" xorm:"not null default 0.00 comment('支付宝商家优惠金额') DECIMAL(8,2)"` | |||
ReceiptAmount string `json:"receipt_amount" xorm:"not null default 0.00 comment('实收金额') DECIMAL(8,2)"` | |||
BuyerPayAmount string `json:"buyer_pay_amount" xorm:"not null default 0.00 comment('买家支付金额') DECIMAL(8,2)"` | |||
SubsidyAmount string `json:"subsidy_amount" xorm:"not null default 0.00 comment('补贴金额') DECIMAL(8,2)"` | |||
ServiceFee string `json:"service_fee" xorm:"not null default 0.00 comment('服务费用') DECIMAL(8,2)"` | |||
CreateAt string `json:"create_at" xorm:"not null pk default 'CURRENT_TIMESTAMP' DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} |
@@ -0,0 +1,10 @@ | |||
package model | |||
type FactorySet struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
EnterpriseId int `json:"enterprise_id" xorm:"not null default 0 comment('所属单位id') INT(11)"` | |||
IsOpenNaturalCustomer int `json:"is_open_natural_customer" xorm:"not null default 0 comment('开启自然顾客(1:开启 2:关闭)') TINYINT(1)"` | |||
NaturalCustomerServiceFee string `json:"natural_customer_service_fee" xorm:"not null default 0.00 comment('自然顾客服务费') DECIMAL(8,2)"` | |||
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` | |||
} |
@@ -50,6 +50,7 @@ type EnterprisePvd int32 | |||
const ( | |||
EnterprisePvdForOnlinePayment = 1 | |||
EnterprisePvdForFaceScanPayment = 2 | |||
EnterprisePvdForAllPayment = 3 | |||
) | |||
func (gt EnterprisePvd) String() string { | |||
@@ -58,6 +59,8 @@ func (gt EnterprisePvd) String() string { | |||
return "在线支付" | |||
case EnterprisePvdForFaceScanPayment: | |||
return "刷脸支付" | |||
case EnterprisePvdForAllPayment: | |||
return "刷脸/刷码/扫码支付" | |||
default: | |||
return "未知" | |||
} | |||
@@ -0,0 +1,40 @@ | |||
package enum | |||
type FactoryOrdOrderStatus int32 | |||
const ( | |||
FactoryOrdOrderStatusForSuccess = 1 | |||
FactoryOrdOrderStatusForRefund = 2 | |||
FactoryOrdOrderStatusForClose = 3 | |||
) | |||
func (gt FactoryOrdOrderStatus) String() string { | |||
switch gt { | |||
case FactoryOrdOrderStatusForSuccess: | |||
return "支付成功" | |||
case FactoryOrdOrderStatusForRefund: | |||
return "已退款" | |||
case FactoryOrdOrderStatusForClose: | |||
return "已关闭" | |||
default: | |||
return "未知" | |||
} | |||
} | |||
type FactoryOrdTradeChannel string | |||
const ( | |||
FactoryOrdTradeChannelForAli = "alipay" | |||
FactoryOrdTradeChannelForWx = "wechat" | |||
) | |||
func (gt FactoryOrdTradeChannel) String() string { | |||
switch gt { | |||
case FactoryOrdTradeChannelForAli: | |||
return "支付宝" | |||
case FactoryOrdTradeChannelForWx: | |||
return "微信" | |||
default: | |||
return "未知" | |||
} | |||
} |
@@ -10,6 +10,7 @@ const ( | |||
UserIdentityForSelfSupportForTeacher = 5 | |||
UserIdentityForSelfSupportForWorker = 6 | |||
UserIdentityForNursingHome = 7 | |||
UserIdentityForFactory = 8 | |||
) | |||
func (gt UserIdentity) String() string { | |||
@@ -28,6 +29,8 @@ func (gt UserIdentity) String() string { | |||
return "自营-工作人员" | |||
case UserIdentityForNursingHome: | |||
return "养老院-普通用户" | |||
case UserIdentityForFactory: | |||
return "工厂-普通用户" | |||
default: | |||
return "未知" | |||
} | |||
@@ -104,9 +104,12 @@ func rFinanceManage(r *gin.RouterGroup) { | |||
} | |||
func rDeviceManage(r *gin.RouterGroup) { | |||
r.POST("/save", hdl2.DeviceSave) //设备管理-编辑/新增 | |||
r.POST("/list", hdl2.DeviceList) //设备管理-列表 | |||
r.DELETE("/delete/:device_sn", hdl2.DeviceDelete) //设备管理-删除 | |||
r.POST("/save", hdl2.DeviceSave) //设备管理-编辑/新增 | |||
r.POST("/list", hdl2.DeviceList) //设备管理-列表 | |||
r.DELETE("/delete/:device_sn", hdl2.DeviceDelete) //设备管理-删除 | |||
r.POST("/factory/save", hdl2.FactoryDeviceSave) //工厂设备管理-编辑/新增 | |||
r.POST("/factory/list", hdl2.FactoryDeviceList) //工厂设备管理-列表 | |||
r.DELETE("/factory/delete/:terminal_id", hdl2.FactoryDeviceDelete) //工厂设备管理-删除 | |||
} | |||
func rDataStatistics(r *gin.RouterGroup) { | |||
@@ -253,6 +256,31 @@ func rEnterpriseManage(r *gin.RouterGroup) { | |||
//r.POST("/nursingHome/statisticsExport", hdl2.NursingHomeDataStatisticsExport) //"养老院-数据统计"-导出 | |||
//r.POST("/nursingHome/statisticsList", hdl2.NursingHomeDataStatisticsList) //"养老院-数据统计"-列表 | |||
//r.DELETE("/nursingHome/statisticsDelete/:id", hdl2.NursingHomeDataStatisticsDelete) //"养老院-数据统计"-删除 | |||
rFactory := r.Group("/factory") //工厂 | |||
{ | |||
rFactory.POST("/factoryIdentityList", hdl.FactoryIdentityList) //身份列表 | |||
rFactory.POST("/addFactoryIdentity", hdl.AddFactoryIdentity) //添加身份 | |||
rFactory.POST("/updateFactoryIdentityState", hdl.UpdateFactoryIdentityState) //修改身份状态 | |||
rFactory.POST("/updateFactoryIdentity", hdl.UpdateFactoryIdentity) //修改身份 | |||
rFactory.DELETE("/deleteFactoryIdentity/:id", hdl.DeleteFactoryIdentity) //删除身份 | |||
rFactory.POST("/bindFactoryIdentity", hdl.BindUserFactoryIdentity) //绑定身份 | |||
rFactory.GET("/getBasic", hdl.GetBasicFactory) //获取基础设置 | |||
rFactory.POST("/setBasic", hdl.SetBasicFactory) //设置基础设置 | |||
rFactory.POST("/userUpdate", hdl.FactoryUserUpdate) //用户编辑 | |||
rFactory.POST("/userDelete", hdl.FactoryUserDelete) //用户删除 | |||
rFactory.POST("/downloadTemplateExcel", hdl.FactoryDownloadTemplateExcel) //下载表格模板 | |||
rFactory.POST("/importUserIdentity", hdl.FactoryImportUserIdentity) //导入员工 | |||
rFactory.POST("/workersList", hdl.FactoryWorkerList) //员工列表 | |||
rFactory.POST("/workerUpdate", hdl.FactoryWorkerUpdate) //员工编辑 | |||
rFactory.POST("/workerDelete", hdl.FactoryWorkerDelete) //员工删除 | |||
rFactory.POST("/workerAdd", hdl.FactoryWorkerAdd) //员工新增 | |||
rFactory.POST("/ordList", hdl.FactoryOrdList) //订单列表 | |||
rFactory.Any("/ordListExport", hdl.FactoryOrdListExport) //订单列表-导出 | |||
} | |||
} | |||
func rRole(r *gin.RouterGroup) { | |||
@@ -13,6 +13,7 @@ func CustomerInit(r *gin.RouterGroup) { | |||
rCentralKitchenForSchoolOrder(r.Group("/order/centralKitchenForSchool")) | |||
rNursingHomeOrder(r.Group("/order/nursingHome")) | |||
rSelfSupportForSchoolOrder(r.Group("/order/selfSupportForSchool")) | |||
rFactoryOrder(r.Group("/order/factory")) | |||
rSelfSupportForSchool(r.Group("/selfSupportForSchool")) | |||
rUserIdentity(r.Group("/userIdentity")) | |||
rTest(r.Group("/test")) | |||
@@ -52,6 +53,8 @@ func CustomerInit(r *gin.RouterGroup) { | |||
r.POST("enterprise/selfSupportForSchool/saveUserIdentity", hdl.SaveSelfSupportForSchoolUserIdentity) //"自营-学校"新增身份信息 | |||
r.POST("enterprise/factory/saveUserIdentity", hdl.SaveFactoryUserIdentity) //"工厂"新增身份信息 | |||
r.POST("enterprise/nursingHome/saveUserIdentity", hdl.SaveNursingHomeUserIdentity) //"养老院"新增身份信息 | |||
r.GET("enterprise/nursingHome/package", hdl.NursingHomePackage) //"养老院"获取套餐 | |||
r.GET("enterprise/nursingHome/myReserve", hdl.NursingHomeMyReserve) //"养老院"我的预定 | |||
@@ -107,6 +110,11 @@ func rSelfSupportForSchoolOrder(r *gin.RouterGroup) { | |||
r.POST("/debtRepay", hdl.SelfSupportForSchoolOrderDebtRepay) // 自营学校-支付欠款订单 | |||
} | |||
func rFactoryOrder(r *gin.RouterGroup) { | |||
r.Use(mw.Auth) //检测登录状态 | |||
r.POST("/list", hdl.FactoryOrderList) // 自营学校-订单列表 | |||
} | |||
func rSelfSupportForSchool(r *gin.RouterGroup) { //自营学校 | |||
r.Use(mw.Auth) //检测登录状态 | |||
r.GET("/educateSceneTokenQuery", selfSupportForSchoolhdl.EducateSceneTokenQuery) // 自营学校-查询刷脸用户开通详细信息 | |||
@@ -122,5 +130,6 @@ func rUserIdentity(r *gin.RouterGroup) { //用户身份 | |||
r.DELETE("/deleteUserIdentity/:id", hdl.DeleteUserIdentity) // 删除身份信息 | |||
r.POST("/updateCentralKitchenForSchoolUserIdentity", hdl.UpdateCentralKitchenForSchoolUserIdentity) // 修改"央厨-学校"学生身份信息 | |||
r.POST("/updateSelfSupportForSchoolUserIdentity", hdl.UpdateSelfSupportForSchoolUserIdentity) // 修改"自营-学校"学生身份信息 | |||
r.POST("/updateFactoryUserIdentity", hdl.UpdateFactoryUserIdentity) // 修改"工厂"身份信息 | |||
r.POST("/updateNursingHomeUserIdentity", hdl.UpdateNursingHomeUserIdentity) // 修改"养老院"身份信息 | |||
} |
@@ -40,6 +40,7 @@ require ( | |||
github.com/golang/protobuf v1.5.2 // indirect | |||
github.com/golang/snappy v0.0.4 // indirect | |||
github.com/gookit/color v1.3.6 // indirect | |||
github.com/jinzhu/copier v0.4.0 // indirect | |||
github.com/josharian/intern v1.0.0 // indirect | |||
github.com/json-iterator/go v1.1.12 // indirect | |||
github.com/kr/text v0.2.0 // indirect | |||