From cdfe5abc484d264a5c08eecc855959f6b2661ecb Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Fri, 17 Nov 2023 21:05:07 +0800 Subject: [PATCH] update --- app/admin/enum/enum_factory_identity.go | 55 ++ app/admin/enum/enum_factory_set.go | 19 + .../hdl/enterprise_manage/hdl_enterprise.go | 14 + .../enterprise_manage/hdl_factory_identity.go | 761 ++++++++++++++++++ app/admin/hdl/hdl_device.go | 128 +++ app/admin/md/md_device.go | 16 + app/admin/md/md_enterprise_manage.go | 22 + app/admin/md/md_factory.go | 16 + app/admin/md/md_factory_identity.go | 159 ++++ .../svc_enterprise_manage.go | 89 ++ .../svc/enterprise_manage/svc_factory.go | 368 +++++++++ app/admin/svc/svc_factory_identity.go | 203 +++++ .../hdl/hdl_self_support_for_school_order.go | 53 ++ app/customer/hdl/hdl_user.go | 19 + app/customer/hdl/hdl_user_identity.go | 89 ++ app/customer/md/md_order.go | 9 + app/customer/md/md_user_identity.go | 13 + app/customer/svc/order/svc_factory_ord.go | 61 ++ .../svc_self_support_for_school_order.go | 4 +- app/customer/svc/svc_user_identity.go | 19 + app/db/db_factory_device.go | 103 +++ app/db/db_factory_identity.go | 111 +++ .../db_factory_identity_with_user_identity.go | 68 ++ app/db/db_factory_ord.go | 115 +++ app/db/db_factory_set.go | 45 ++ app/db/db_user.go | 9 + app/db/model/factory_device.go | 11 + app/db/model/factory_identity.go | 3 +- app/db/model/factory_set.go | 15 +- app/enum/enum_factory_ord.go | 40 + app/enum/enum_user_identity.go | 3 + app/router/admin_router.go | 34 +- app/router/customer_router.go | 9 + go.mod | 1 + .../工厂(身份信息导入模板).xlsx | Bin 0 -> 8890 bytes 35 files changed, 2669 insertions(+), 15 deletions(-) create mode 100644 app/admin/enum/enum_factory_identity.go create mode 100644 app/admin/enum/enum_factory_set.go create mode 100644 app/admin/hdl/enterprise_manage/hdl_factory_identity.go create mode 100644 app/admin/md/md_factory.go create mode 100644 app/admin/md/md_factory_identity.go create mode 100644 app/admin/svc/enterprise_manage/svc_factory.go create mode 100644 app/admin/svc/svc_factory_identity.go create mode 100644 app/customer/svc/order/svc_factory_ord.go create mode 100644 app/db/db_factory_device.go create mode 100644 app/db/db_factory_identity.go create mode 100644 app/db/db_factory_identity_with_user_identity.go create mode 100644 app/db/db_factory_ord.go create mode 100644 app/db/db_factory_set.go create mode 100644 app/db/model/factory_device.go create mode 100644 app/enum/enum_factory_ord.go create mode 100644 static/template/工厂(身份信息导入模板).xlsx diff --git a/app/admin/enum/enum_factory_identity.go b/app/admin/enum/enum_factory_identity.go new file mode 100644 index 0000000..4c53177 --- /dev/null +++ b/app/admin/enum/enum_factory_identity.go @@ -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 "未知" + } +} diff --git a/app/admin/enum/enum_factory_set.go b/app/admin/enum/enum_factory_set.go new file mode 100644 index 0000000..57b7673 --- /dev/null +++ b/app/admin/enum/enum_factory_set.go @@ -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 "未知" + } +} diff --git a/app/admin/hdl/enterprise_manage/hdl_enterprise.go b/app/admin/hdl/enterprise_manage/hdl_enterprise.go index d9da738..23ff052 100644 --- a/app/admin/hdl/enterprise_manage/hdl_enterprise.go +++ b/app/admin/hdl/enterprise_manage/hdl_enterprise.go @@ -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 { diff --git a/app/admin/hdl/enterprise_manage/hdl_factory_identity.go b/app/admin/hdl/enterprise_manage/hdl_factory_identity.go new file mode 100644 index 0000000..661d77f --- /dev/null +++ b/app/admin/hdl/enterprise_manage/hdl_factory_identity.go @@ -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 +} diff --git a/app/admin/hdl/hdl_device.go b/app/admin/hdl/hdl_device.go index 31eeeb8..32f0e42 100644 --- a/app/admin/hdl/hdl_device.go +++ b/app/admin/hdl/hdl_device.go @@ -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 +} diff --git a/app/admin/md/md_device.go b/app/admin/md/md_device.go index 14e14ac..dffbf58 100644 --- a/app/admin/md/md_device.go +++ b/app/admin/md/md_device.go @@ -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:"截止时间"` +} diff --git a/app/admin/md/md_enterprise_manage.go b/app/admin/md/md_enterprise_manage.go index 69c82c9..32b0a82 100644 --- a/app/admin/md/md_enterprise_manage.go +++ b/app/admin/md/md_enterprise_manage.go @@ -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"` diff --git a/app/admin/md/md_factory.go b/app/admin/md/md_factory.go new file mode 100644 index 0000000..942a682 --- /dev/null +++ b/app/admin/md/md_factory.go @@ -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:"本月实收金额"` +} diff --git a/app/admin/md/md_factory_identity.go b/app/admin/md/md_factory_identity.go new file mode 100644 index 0000000..94e18c3 --- /dev/null +++ b/app/admin/md/md_factory_identity.go @@ -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:"交易渠道"` +} diff --git a/app/admin/svc/enterprise_manage/svc_enterprise_manage.go b/app/admin/svc/enterprise_manage/svc_enterprise_manage.go index 5c06938..233827c 100644 --- a/app/admin/svc/enterprise_manage/svc_enterprise_manage.go +++ b/app/admin/svc/enterprise_manage/svc_enterprise_manage.go @@ -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 +} diff --git a/app/admin/svc/enterprise_manage/svc_factory.go b/app/admin/svc/enterprise_manage/svc_factory.go new file mode 100644 index 0000000..d4542d6 --- /dev/null +++ b/app/admin/svc/enterprise_manage/svc_factory.go @@ -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 +} diff --git a/app/admin/svc/svc_factory_identity.go b/app/admin/svc/svc_factory_identity.go new file mode 100644 index 0000000..4d38472 --- /dev/null +++ b/app/admin/svc/svc_factory_identity.go @@ -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 +} diff --git a/app/customer/hdl/hdl_self_support_for_school_order.go b/app/customer/hdl/hdl_self_support_for_school_order.go index cfb78e0..7d43c2b 100644 --- a/app/customer/hdl/hdl_self_support_for_school_order.go +++ b/app/customer/hdl/hdl_self_support_for_school_order.go @@ -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) diff --git a/app/customer/hdl/hdl_user.go b/app/customer/hdl/hdl_user.go index 8216f17..93e1d47 100644 --- a/app/customer/hdl/hdl_user.go +++ b/app/customer/hdl/hdl_user.go @@ -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) } diff --git a/app/customer/hdl/hdl_user_identity.go b/app/customer/hdl/hdl_user_identity.go index 541a0a3..998811f 100644 --- a/app/customer/hdl/hdl_user_identity.go +++ b/app/customer/hdl/hdl_user_identity.go @@ -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 { diff --git a/app/customer/md/md_order.go b/app/customer/md/md_order.go index 984a11b..7847db2 100644 --- a/app/customer/md/md_order.go +++ b/app/customer/md/md_order.go @@ -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" ` +} diff --git a/app/customer/md/md_user_identity.go b/app/customer/md/md_user_identity.go index 658892e..088f5fe 100644 --- a/app/customer/md/md_user_identity.go +++ b/app/customer/md/md_user_identity.go @@ -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:"姓名"` diff --git a/app/customer/svc/order/svc_factory_ord.go b/app/customer/svc/order/svc_factory_ord.go new file mode 100644 index 0000000..0ebec57 --- /dev/null +++ b/app/customer/svc/order/svc_factory_ord.go @@ -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 +} diff --git a/app/customer/svc/order/svc_self_support_for_school_order.go b/app/customer/svc/order/svc_self_support_for_school_order.go index e2a0423..847665b 100644 --- a/app/customer/svc/order/svc_self_support_for_school_order.go +++ b/app/customer/svc/order/svc_self_support_for_school_order.go @@ -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 { diff --git a/app/customer/svc/svc_user_identity.go b/app/customer/svc/svc_user_identity.go index dce8a78..7c37e47 100644 --- a/app/customer/svc/svc_user_identity.go +++ b/app/customer/svc/svc_user_identity.go @@ -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{} diff --git a/app/db/db_factory_device.go b/app/db/db_factory_device.go new file mode 100644 index 0000000..3a2afca --- /dev/null +++ b/app/db/db_factory_device.go @@ -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" +} diff --git a/app/db/db_factory_identity.go b/app/db/db_factory_identity.go new file mode 100644 index 0000000..f90e507 --- /dev/null +++ b/app/db/db_factory_identity.go @@ -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" +} diff --git a/app/db/db_factory_identity_with_user_identity.go b/app/db/db_factory_identity_with_user_identity.go new file mode 100644 index 0000000..fe80560 --- /dev/null +++ b/app/db/db_factory_identity_with_user_identity.go @@ -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 +} diff --git a/app/db/db_factory_ord.go b/app/db/db_factory_ord.go new file mode 100644 index 0000000..1e6bc8c --- /dev/null +++ b/app/db/db_factory_ord.go @@ -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" +} diff --git a/app/db/db_factory_set.go b/app/db/db_factory_set.go new file mode 100644 index 0000000..5ee49eb --- /dev/null +++ b/app/db/db_factory_set.go @@ -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 +} diff --git a/app/db/db_user.go b/app/db/db_user.go index 9f9fcf8..fdf2646 100644 --- a/app/db/db_user.go +++ b/app/db/db_user.go @@ -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"` diff --git a/app/db/model/factory_device.go b/app/db/model/factory_device.go new file mode 100644 index 0000000..2b26cf5 --- /dev/null +++ b/app/db/model/factory_device.go @@ -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"` +} diff --git a/app/db/model/factory_identity.go b/app/db/model/factory_identity.go index 6fe4ef9..f1a9ee4 100644 --- a/app/db/model/factory_identity.go +++ b/app/db/model/factory_identity.go @@ -2,6 +2,7 @@ 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)"` @@ -9,7 +10,7 @@ type FactoryIdentity struct { 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)"` + 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"` } diff --git a/app/db/model/factory_set.go b/app/db/model/factory_set.go index 9ba1bf2..f564117 100644 --- a/app/db/model/factory_set.go +++ b/app/db/model/factory_set.go @@ -1,13 +1,10 @@ package model -import ( - "time" -) - type FactorySet struct { - Id int `json:"id" xorm:"not null pk autoincr 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 time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + 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"` } diff --git a/app/enum/enum_factory_ord.go b/app/enum/enum_factory_ord.go new file mode 100644 index 0000000..c1a35a4 --- /dev/null +++ b/app/enum/enum_factory_ord.go @@ -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 "未知" + } +} diff --git a/app/enum/enum_user_identity.go b/app/enum/enum_user_identity.go index a0758e7..2dbb84f 100644 --- a/app/enum/enum_user_identity.go +++ b/app/enum/enum_user_identity.go @@ -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 "未知" } diff --git a/app/router/admin_router.go b/app/router/admin_router.go index 76d0de3..fa3c117 100644 --- a/app/router/admin_router.go +++ b/app/router/admin_router.go @@ -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) { diff --git a/app/router/customer_router.go b/app/router/customer_router.go index 9be78a8..1299f6c 100644 --- a/app/router/customer_router.go +++ b/app/router/customer_router.go @@ -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) // 修改"养老院"身份信息 } diff --git a/go.mod b/go.mod index 7e37f2b..5cc7372 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/static/template/工厂(身份信息导入模板).xlsx b/static/template/工厂(身份信息导入模板).xlsx new file mode 100644 index 0000000000000000000000000000000000000000..f543f0f918d9c3f38584bc188a9cb5c50523a346 GIT binary patch literal 8890 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
    j4%uNX^ugvPD&}PSG+(#7Ggiw9ongG(?Ss) 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