123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870 |
- package bid
- import (
- "net/http"
- "strconv"
- "strings"
- "time"
- "zhiyuan/models"
- "zhiyuan/pkg/app"
- "zhiyuan/pkg/config"
- "zhiyuan/pkg/errcode"
- adminParam "zhiyuan/pkg/param/admin"
- "zhiyuan/pkg/param/material"
- bidParam "zhiyuan/pkg/param/material/bid"
- "zhiyuan/pkg/param/material/item"
- "zhiyuan/pkg/utils"
- "zhiyuan/services/admin"
- "zhiyuan/services/dept"
- "zhiyuan/services/form"
- "zhiyuan/services/material/bid"
- "zhiyuan/services/material/pkg"
- "zhiyuan/services/structs"
- "github.com/gin-gonic/gin"
- "github.com/tealeg/xlsx/v3"
- )
- func OrderList(c *gin.Context) {
- page := app.HandlePageNum(c)
- pkgID := utils.StrTo(c.Query("pkg_id")).MustInt()
- if pkgID <= 0 {
- app.Error(c, "套餐id有误")
- return
- }
- pkgInfo, _ := pkg.GetPkg(map[string]interface{}{"id": pkgID}, []string{"id", "room_types", "pkg_name"}, nil)
- where := map[string]string{
- "where": "`zy_mat_bid_order`.`deleted_at`=0",
- "_order_by": "`zy_mat_bid_order`.`id` desc",
- }
- if page.PageSize != 0 {
- where["_page_size"] = utils.ToStr(page.PageSize)
- where["_page_num"] = utils.ToStr(page.PageNum)
- }
- param := make(map[string]interface{})
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`pkg_id` = {{pkg_id}}"
- param["pkg_id"] = pkgID
- if keyword := c.Query("keyword"); keyword != "" {
- where["where"] = where["where"] + " AND (`zy_mat_bid_order`.`customer_name` LIKE {{keyword}} OR `zy_mat_bid_order`.`customer_phone` LIKE {{keyword}})"
- param["keyword"] = "%" + keyword + "%"
- }
- if adminId := utils.ToInt(c.Query("admin_id")); adminId > 0 {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`admin_id` = {{admin_id}}"
- param["admin_id"] = adminId
- }
- if areaMin := utils.ToFloat64(c.Query("area_min")); areaMin > 0 {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`house_area` >= {{area_min}}"
- param["area_min"] = areaMin
- }
- if areaMax := utils.ToFloat64(c.Query("area_max")); areaMax > 0 {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`house_area` <= {{area_max}}"
- param["area_max"] = areaMax
- }
- if moneyMin := utils.ToFloat64(c.Query("money_min")); moneyMin > 0 {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`total_price` >= {{money_min}}"
- param["money_min"] = moneyMin
- }
- if moneyMax := utils.ToFloat64(c.Query("money_max")); moneyMax > 0 {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`total_price` <= {{money_max}}"
- param["money_max"] = moneyMax
- }
- if address := c.Query("address"); address != "" {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`house_address` = {{address}}"
- param["address"] = "%" + address + "%"
- }
- if !admin.IsSuperAdmin(c.GetInt("adminID")) {
- var adminInfo *models.Admin
- admin.GetInfoByID(c.GetInt("adminID"), nil, &adminInfo)
- if adminInfo == nil {
- app.Response(c, http.StatusUnauthorized, errcode.TokenInvalid, nil)
- return
- }
- adminRole := false
- roleSlice := strings.Split(adminInfo.RoleIds, ",")
- for _, v := range roleSlice {
- if role, err := strconv.Atoi(v); err == nil && (role == adminParam.AdminRoleId || role == adminParam.MaterialAdminRoleId) {
- adminRole = true
- break
- }
- }
- if !adminRole {
- where["where"] = where["where"] + " AND `zy_admin`.`dept_id` IN {{dept_id}}"
- param["dept_id"] = dept.GetSubDeptIds(adminInfo.DeptID, []int{adminInfo.DeptID})
- }
- }
- total, err := bid.CountRaw(where["where"], param)
- if err != nil {
- app.Error(c, err.Error())
- return
- }
- orderList := make([]structs.MaterialBidOrderList, 0)
- if err := bid.GetOrdersRaw(where, param, &orderList); err != nil {
- app.Error(c, err.Error())
- return
- }
- roomTypeMap := material.GetRoomTypeMap(true)
- orderStateMap := bidParam.GetOrderStateMap()
- for k, v := range orderList {
- v.CreatedAt = utils.DateS(v.CreatedAt, "YYYY-MM-DD HH:mm")
- v.UpdatedAt = utils.DateS(v.UpdatedAt, "YYYY-MM-DD HH:mm")
- v.StateName = orderStateMap[v.State].Name
- v.StateColor = orderStateMap[v.State].Color
- styleName := make([]string, 0)
- var houseStyle []structs.HouseStyle
- utils.JsonDecode(v.HouseStyle).To(&houseStyle)
- for _, house := range houseStyle {
- styleName = append(styleName, utils.ToStr(house.Num)+roomTypeMap[house.Type])
- }
- v.HouseStyle = strings.Join(styleName, "")
- v.Auth = structs.MaterialBidOrderAuth{
- Finish: utils.IsContain(bidParam.OrderAllow.Finish, v.State),
- }
- orderList[k] = v
- }
- data := gin.H{
- "pkgInfo": pkgInfo,
- "list": orderList,
- "total": total,
- "limit": page.PageSize,
- }
- app.Success(c, data)
- }
- func OrderListExport(c *gin.Context) {
- pkgID := utils.StrTo(c.Query("pkg_id")).MustInt()
- if pkgID <= 0 {
- app.Error(c, "套餐id有误")
- return
- }
- where := map[string]interface{}{"pkg_id": pkgID, "_orderby": "id desc"}
- orderList := make([]structs.MaterialBidOrderList, 0)
- if _, err := bid.GetOrders(where, nil, app.Page{}, &orderList); err != nil {
- app.Error(c, err.Error())
- return
- }
- adminIds := make([]int, 0)
- for _, v := range orderList {
- adminIds = append(adminIds, v.AdminID)
- }
- adminListMap := make(map[int]string, 0)
- if len(adminIds) > 0 {
- if adminList, err := admin.GetAdmins(map[string]interface{}{"id in": adminIds}, nil, app.Page{}, nil); err == nil {
- for _, v := range adminList {
- adminListMap[v.ID] = v.Username
- }
- }
- }
- wb := xlsx.NewFile()
- time := utils.ToStr(time.Now().UnixNano())
- filename := "預算表导出-" + time + ".xlsx"
- fullPath := config.Cfg.App.ExportPath + filename
- styleBold := utils.GetCommonStyle(utils.StyleCfg{IsBold: true})
- styleCommon := utils.GetCommonStyle(utils.StyleCfg{})
- sh, err := wb.AddSheet("Sheet1")
- if err != nil {
- app.Error(c, err.Error())
- return
- }
- sh = utils.SetColWidth(sh, []float64{10, 30, 10, 10, 10, 10})
- var row *xlsx.Row
- row = utils.AddRow(sh, utils.Row{Height: 60})
- utils.AddCell(row, utils.Cell{Value: "客户名", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "楼盘", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "设计师", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "套餐内总价", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "个性化总报价", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "设计费", Style: styleBold})
- for _, v := range orderList {
- v.AdminName = adminListMap[v.AdminID]
- v.CreatedAt = utils.DateS(v.CreatedAt, "YYYY-MM-DD HH:mm")
- v.UpdatedAt = utils.DateS(v.UpdatedAt, "YYYY-MM-DD HH:mm")
- utils.JsonDecode(v.CustomizePriceDetail).To(&v.CustomizePriceDecode)
- row = utils.AddRow(sh, utils.Row{Height: 30})
- utils.AddCell(row, utils.Cell{Value: v.CustomerName, Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: v.HouseAddress, Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: v.AdminName, Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: v.PackagePrice, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: v.CustomizePrice, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: v.CustomizePriceDecode.Design, Format: "float", Style: styleCommon})
- }
- if err := wb.Save(fullPath); err != nil {
- app.Error(c, err.Error())
- return
- }
- app.Success(c, gin.H{"path": "export/" + filename, "filename": filename})
- }
- func OrderInfo(c *gin.Context) {
- id := utils.ToInt(c.Param("id"))
- if id <= 0 {
- app.Error(c, "工单 id 为空")
- }
- var orderInfo structs.MaterialBidOrderList
- if _, err := bid.GetOrder(map[string]interface{}{"id": id}, nil, &orderInfo); err != nil {
- app.Error(c, err.Error())
- }
- roomTypeMap := material.GetRoomTypeMap(true)
- var houseStyle []structs.HouseStyle
- utils.JsonDecode(orderInfo.HouseStyle).To(&houseStyle)
- styleName := make([]string, 0)
- for _, house := range houseStyle {
- styleName = append(styleName, utils.ToStr(house.Num)+roomTypeMap[house.Type])
- }
- orderInfo.HouseStyle = strings.Join(styleName, "")
- utils.JsonDecode(orderInfo.Param).To(&orderInfo.ParamDecode)
- utils.JsonDecode(orderInfo.Customize).To(&orderInfo.CustomizeDecode)
- utils.JsonDecode(orderInfo.CustomizePriceDetail).To(&orderInfo.CustomizePriceDecode)
- utils.JsonDecode(orderInfo.PackagePriceDetail).To(&orderInfo.PackagePriceDecode)
- utils.JsonDecode(orderInfo.InclusivePriceDetail).To(&orderInfo.InclusivePriceDecode)
- utils.JsonDecode(orderInfo.InclusiveCostDetail).To(&orderInfo.InclusiveCostDecode)
- utils.JsonDecode(orderInfo.PackagePriceDetail).To(&orderInfo.OutlinePriceDecode)
- utils.JsonDecode(orderInfo.ToiletPriceDetail).To(&orderInfo.ToiletPriceDecode)
- bidMap := make(map[int]*structs.MaterialBidList)
- bidList := make([]*structs.MaterialBidList, 0)
- if _, err := bid.GetBidList(map[string]interface{}{"pkg_id": orderInfo.PkgID}, nil, app.Page{}, &bidList); err == nil {
- for _, v := range bidList {
- bidMap[v.ID] = v
- }
- }
- app.Success(c, gin.H{
- "orderInfo": orderInfo,
- "bidList": bidMap,
- })
- }
- func OrderExport(c *gin.Context) {
- id := utils.ToInt(c.Param("id"))
- if id <= 0 {
- app.Error(c, "工单 id 为空")
- return
- }
- var orderInfo structs.MaterialBidOrderList
- if _, err := bid.GetOrder(map[string]interface{}{"id": id}, nil, &orderInfo); err != nil {
- app.Error(c, err.Error())
- return
- }
- roomTypeMap := material.GetRoomTypeMap(true)
- var houseStyle []structs.HouseStyle
- utils.JsonDecode(orderInfo.HouseStyle).To(&houseStyle)
- styleName := make([]string, 0)
- for _, house := range houseStyle {
- styleName = append(styleName, utils.ToStr(house.Num)+roomTypeMap[house.Type])
- }
- orderInfo.HouseStyle = strings.Join(styleName, "")
- utils.JsonDecode(orderInfo.Param).To(&orderInfo.ParamDecode)
- utils.JsonDecode(orderInfo.Customize).To(&orderInfo.CustomizeDecode)
- utils.JsonDecode(orderInfo.CustomizePriceDetail).To(&orderInfo.CustomizePriceDecode)
- utils.JsonDecode(orderInfo.PackagePriceDetail).To(&orderInfo.PackagePriceDecode)
- utils.JsonDecode(orderInfo.InclusivePriceDetail).To(&orderInfo.InclusivePriceDecode)
- bidMap := make(map[int]*structs.MaterialBidList)
- bidList := make([]*structs.MaterialBidList, 0)
- if _, err := bid.GetBidList(map[string]interface{}{"pkg_id": orderInfo.PkgID}, nil, app.Page{}, &bidList); err == nil {
- for _, v := range bidList {
- bidMap[v.ID] = v
- }
- }
- if adminInfo, err := admin.GetInfoByID(orderInfo.AdminID, nil, nil); err == nil {
- orderInfo.AdminName = adminInfo.Username
- }
- wb := xlsx.NewFile()
- time := utils.ToStr(time.Now().UnixNano())
- filename := "2021年[志远一户一价产品]工程预算书-" + orderInfo.HouseAddress + "-" + time + ".xlsx"
- fullPath := config.Cfg.App.ExportPath + filename
- styleBold := utils.GetCommonStyle(utils.StyleCfg{IsBold: true})
- styleCommon := utils.GetCommonStyle(utils.StyleCfg{})
- styleHeader := utils.GetCommonStyle(utils.StyleCfg{IsBold: true, FontSize: 17, IsBorderRight: true})
- styleHeaderFill := utils.GetCommonStyle(utils.StyleCfg{IsBold: true, IsBorderRight: true, Fill: []string{"00D9D9D9", "FF000000"}})
- styleFillLeft := utils.GetCommonStyle(utils.StyleCfg{IsBorderRight: true, Fill: []string{"00D9D9D9", "FF000000"}, Horizontal: "general"})
- styleFillBorderRight := utils.GetCommonStyle(utils.StyleCfg{IsBorderRight: true, Fill: []string{"00D9D9D9", "FF000000"}})
- styleFill := utils.GetCommonStyle(utils.StyleCfg{Fill: []string{"00D9D9D9", "FF000000"}})
- styleBlackBorderRight := utils.GetCommonStyle(utils.StyleCfg{IsBold: true, IsBorderRight: true, Fill: []string{"00808080", "FF000000"}, Horizontal: "general"})
- styleBlack := utils.GetCommonStyle(utils.StyleCfg{IsBold: true, Fill: []string{"00808080", "FF000000"}})
- styleBoldBorderRight := utils.GetCommonStyle(utils.StyleCfg{IsBold: true, IsBorderRight: true})
- styleBorderRight := utils.GetCommonStyle(utils.StyleCfg{IsBorderRight: true})
- styleBoldLeftBorderRight := utils.GetCommonStyle(utils.StyleCfg{IsBold: true, IsBorderRight: true, Horizontal: "general"})
- styleBoldBorderBottom := utils.GetCommonStyle(utils.StyleCfg{IsBold: true, IsBorderBottom: true})
- styleBoldBorderBottomRight := utils.GetCommonStyle(utils.StyleCfg{IsBold: true, IsBorderBottom: true, IsBorderRight: true})
- sh, err := wb.AddSheet("Sheet1")
- if err != nil {
- app.Error(c, err.Error())
- return
- }
- sh = utils.SetColWidth(sh, []float64{10, 5, 20, 5, 10, 15, 15, 80})
- var row *xlsx.Row
- row = utils.AddRow(sh, utils.Row{Height: 60})
- utils.AddCell(row, utils.Cell{Value: "2021年[志远一户一价产品]工程预算书", HMerge: 7, Style: styleHeader})
- row = utils.AddRow(sh, utils.Row{Height: 30})
- utils.AddCell(row, utils.Cell{Value: "工程预(决)算书 日期: 年 月 日", HMerge: 7, Style: styleHeaderFill})
- row = utils.AddRow(sh, utils.Row{Height: 30})
- utils.AddCell(row, utils.Cell{Value: "客 户:" + orderInfo.CustomerName + " 联系电话:" + orderInfo.CustomerName + " 工程地址:" + orderInfo.HouseAddress, HMerge: 7, Style: styleFillLeft})
- row = utils.AddRow(sh, utils.Row{Height: 30})
- utils.AddCell(row, utils.Cell{Value: "房 型:" + orderInfo.HouseStyle + " [套内实测面积M2]:" + utils.ToStr(orderInfo.HouseArea) + " 设计师:" + orderInfo.AdminName, HMerge: 7, Style: styleFillLeft})
- row = utils.AddRow(sh, utils.Row{Height: 30})
- utils.AddCell(row, utils.Cell{Value: "客 户 温 馨 提 示", HMerge: 7, Style: styleFillBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "一", HMerge: 1, Style: styleFill})
- utils.AddCell(row, utils.Cell{Value: "施工中如有漏项、增减项目,应将漏项及增减项目列入结算款中,以实际发生工程量和预算单上工程单价为准,并以现场签证单上双方签字认可为依据进行结算。如预算中所指定材料出现市场供应短缺,则可双方协调调换为同等价位材料;", HMerge: 5, Style: styleFillBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "二", HMerge: 1, Style: styleFill})
- utils.AddCell(row, utils.Cell{Value: "客户装修房屋的任何构件(非我方施工主体物件)如可能影响我方施工,无论是拆卸、改造或是用其他办法处理,甲方需承担费用;", HMerge: 5, Style: styleFillBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "三", HMerge: 1, Style: styleFill})
- utils.AddCell(row, utils.Cell{Value: "此预算不含物业管理处各项收费。如垃圾外运费、公共设施维护费、办理装修许可证费用等,由甲方自行负责。我公司只交纳办理工人出入证费用;", HMerge: 5, Style: styleFillBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "四", HMerge: 1, Style: styleFill})
- utils.AddCell(row, utils.Cell{Value: "不含预算单和图纸标明甲方自购的材料;", HMerge: 5, Style: styleFillBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "五", HMerge: 1, Style: styleFill})
- utils.AddCell(row, utils.Cell{Value: "公司严格按照国家安全施工规范进行施工,不承接混凝土墙、水泥现浇梁柱等拆除业务;", HMerge: 5, Style: styleFillBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "工种", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "编号", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "项目名称", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "单位", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "数量", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "单价(元)", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "总价(元)", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "材 料 及 工 艺 说 明", Style: styleBoldBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "一", HMerge: 1, Style: styleBlack})
- utils.AddCell(row, utils.Cell{Value: "一户一价产品内容", HMerge: 5, Style: styleBlackBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "1", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "一户一价工程总价", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: utils.FloatAdd(orderInfo.PackagePrice, orderInfo.InclusivePrice, 0), Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "详见《2021年一户一价产品说明表》及报价系统详细说明。", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "二", HMerge: 1, Style: styleBlack})
- utils.AddCell(row, utils.Cell{Value: "主材增加项", HMerge: 5, Style: styleBlackBorderRight})
- for k, v := range orderInfo.CustomizeDecode[4] {
- if bidMap[v.ID] == nil {
- bidMap[v.ID] = new(structs.MaterialBidList)
- }
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: v.RoomTypeName, Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: utils.ToStr(k + 1), Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: v.BidName, Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: v.UnitName, Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: v.Num, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: bidMap[v.ID].Price, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: v.Total, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: bidMap[v.ID].Description, Style: styleBorderRight})
- }
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "三", HMerge: 1, Style: styleBlack})
- utils.AddCell(row, utils.Cell{Value: "主材升级项", HMerge: 5, Style: styleBlackBorderRight})
- for k, v := range orderInfo.CustomizeDecode[6] {
- if bidMap[v.ID] == nil {
- bidMap[v.ID] = new(structs.MaterialBidList)
- }
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: v.RoomTypeName, Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: utils.ToStr(k + 1), Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: v.BidName, Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: v.UnitName, Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: v.Num, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: bidMap[v.ID].Price, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: v.Total, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: bidMap[v.ID].Description, Style: styleBorderRight})
- }
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "四", HMerge: 1, Style: styleBlack})
- utils.AddCell(row, utils.Cell{Value: "主材减项", HMerge: 5, Style: styleBlackBorderRight})
- for k, v := range orderInfo.CustomizeDecode[5] {
- if bidMap[v.ID] == nil {
- bidMap[v.ID] = new(structs.MaterialBidList)
- }
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: v.RoomTypeName, Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: utils.ToStr(k + 1), Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: v.BidName, Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: v.UnitName, Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: v.Num, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: bidMap[v.ID].Price, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: v.Total, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: bidMap[v.ID].Description, Style: styleBorderRight})
- }
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "五", HMerge: 1, Style: styleBlack})
- utils.AddCell(row, utils.Cell{Value: "施工增加项", HMerge: 5, Style: styleBlackBorderRight})
- for k, v := range orderInfo.CustomizeDecode[3] {
- if bidMap[v.ID] == nil {
- bidMap[v.ID] = new(structs.MaterialBidList)
- }
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: v.RoomTypeName, Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: utils.ToStr(k + 1), Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: v.BidName, Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: v.UnitName, Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: v.Num, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: bidMap[v.ID].Price, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: v.Total, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: bidMap[v.ID].Description, Style: styleBorderRight})
- }
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "其 它", Style: styleBold, VMerge: 13})
- utils.AddCell(row, utils.Cell{Value: "A", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "个性化施工直接费", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: orderInfo.CustomizePriceDecode.BuildPrice.Direct, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "B", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "个性化主材增项", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: orderInfo.CustomizePriceDecode.MaterialAdd, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "C", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "个性化主材升级", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: orderInfo.CustomizePriceDecode.MaterialUpgrade, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "D", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "材料搬运费D=(A+B+C)*" + utils.ToStr(orderInfo.TransportRate*100) + "%\n(如实际核算基数发生变化,计费公式必须同步)", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: orderInfo.CustomizePriceDecode.Transport, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "有电梯按工程直接费2.5%计算;无电梯二楼按2.5%计算,二楼以上以2.5%为基数每上一楼增加0.5%。(复式楼、别墅户内按无电梯计算)", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "E", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "垃圾清运费E=(A+B+C)*" + utils.ToStr(orderInfo.TransportRate*100) + "%\n(如实际核算基数发生变化,计费公式必须同步)", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: orderInfo.CustomizePriceDecode.Sanitation, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "有电梯按工程直接费2.5%(注:我方将施工过程中每天产生的装修垃圾清理到小区指定堆放点,与管理处收取的垃圾清运费无关)计算;无电梯二楼按2.5%计算,二楼以上以2.5%为基数,每上一楼增加0.5%。(复式楼、别墅户内按无电梯计算)", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "F", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "工程管理费F=(A+B+C+D+E)*10%", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: orderInfo.CustomizePriceDecode.Manage, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "G", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "设计费", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: orderInfo.CustomizePriceDecode.Design, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "H", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "个性化工程总价H=(A+B+C+D+E+F+G)", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: orderInfo.CustomizePriceDecode.Total, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "I", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "定制品赠送", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: strconv.Itoa(orderInfo.InclusiveArea), Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: 0, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "J", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "工程总造价I=一户一价工程总价+个性化工程总价+定制品总价", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: orderInfo.TotalPrice, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "K", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "稅金K=J*6%", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: 0, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "L", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "工程总造价L=J+K", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Float: orderInfo.TotalPrice, Format: "float", Style: styleCommon})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "制表: 审核: ", HMerge: 6, Style: styleBoldLeftBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBold})
- utils.AddCell(row, utils.Cell{Value: "甲方签字: 乙方签字: ", HMerge: 6, Style: styleBoldLeftBorderRight})
- row = utils.AddRow(sh, utils.Row{Height: 45})
- utils.AddCell(row, utils.Cell{Value: "", Style: styleBoldBorderBottom})
- utils.AddCell(row, utils.Cell{Value: " 年 月 日 年 月 日 ", HMerge: 6, Style: styleBoldBorderBottomRight})
- if err := wb.Save(fullPath); err != nil {
- app.Error(c, err.Error())
- return
- }
- app.Success(c, gin.H{"path": "export/" + filename, "filename": filename})
- }
- func OrderUpdate(c *gin.Context) {
- id := utils.StrTo(c.Param("id")).MustInt()
- if id <= 0 {
- app.ErrorMsg(c, "无效的订单ID", nil)
- return
- }
- if _, err := bid.UpdateOrder(id); err != nil {
- app.Error(c, err.Error())
- return
- }
- app.Success(c, nil)
- }
- func OrderRemark(c *gin.Context) {
- id := utils.StrTo(c.Param("id")).MustInt()
- if id <= 0 {
- app.ErrorMsg(c, "无效的订单ID", nil)
- return
- }
- var form form.OrderRemark
- if app.Bind(c, &form) != nil {
- return
- }
- if err := bid.RemarkOrder(form, id); err != nil {
- app.Error(c, err.Error())
- return
- }
- app.Success(c, nil)
- }
- func OrderFinish(c *gin.Context) {
- id := utils.StrTo(c.Param("id")).MustInt()
- if id <= 0 {
- app.Error(c, "工单 id 有误")
- return
- }
- err := bid.FinishOrder(id)
- if err != nil {
- app.Error(c, err.Error())
- return
- }
- app.Success(c, nil)
- }
- func OrderListApi(c *gin.Context) {
- //page := app.HandlePageNum(c)
- pkgID := utils.StrTo(c.Query("pkg_id")).MustInt()
- if pkgID <= 0 {
- app.Error(c, "套餐id有误")
- return
- }
- //pkgInfo, _ := pkg.GetPkg(map[string]interface{}{"id": pkgID}, []string{"id", "room_types", "pkg_name"}, nil)
- where := map[string]string{
- "where": "`zy_mat_bid_order`.`deleted_at`=0 AND `zy_mat_bid_order`.`type`=0",
- "_order_by": "`zy_mat_bid_order`.`id` desc",
- }
- /*if page.PageSize != 0 {
- where["_page_size"] = utils.ToStr(page.PageSize)
- where["_page_num"] = utils.ToStr(page.PageNum)
- }*/
- param := make(map[string]interface{})
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`pkg_id` = {{pkg_id}}"
- param["pkg_id"] = pkgID
- if keyword := c.Query("keyword"); keyword != "" {
- where["where"] = where["where"] + " AND (`zy_mat_bid_order`.`customer_name` LIKE {{keyword}} OR `zy_mat_bid_order`.`customer_phone` LIKE {{keyword}} OR `zy_mat_bid_order`.`house_address` LIKE {{keyword}})"
- param["keyword"] = "%" + keyword + "%"
- }
- if phone := c.Query("phone"); phone != "" {
- where["where"] = where["where"] + " AND `zy_admin`.`phone` = {{phone}}"
- param["phone"] = phone
- } else {
- where["where"] = where["where"] + " AND 1=2"
- }
- /*if adminId := utils.ToInt(c.Query("admin_id")); adminId > 0 {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`admin_id` = {{admin_id}}"
- param["admin_id"] = adminId
- }
- if areaMin := utils.ToFloat64(c.Query("area_min")); areaMin > 0 {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`house_area` >= {{area_min}}"
- param["area_min"] = areaMin
- }
- if areaMax := utils.ToFloat64(c.Query("area_max")); areaMax > 0 {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`house_area` <= {{area_max}}"
- param["area_max"] = areaMax
- }
- if moneyMin := utils.ToFloat64(c.Query("money_min")); moneyMin > 0 {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`total_price` >= {{money_min}}"
- param["money_min"] = moneyMin
- }
- if moneyMax := utils.ToFloat64(c.Query("money_max")); moneyMax > 0 {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`total_price` <= {{money_max}}"
- param["money_max"] = moneyMax
- }
- if address := c.Query("address"); address != "" {
- where["where"] = where["where"] + " AND `zy_mat_bid_order`.`house_address` = {{address}}"
- param["address"] = "%" + address + "%"
- }*/
- /*if !admin.IsSuperAdmin(c.GetInt("adminID")) {
- var adminInfo *models.Admin
- admin.GetInfoByID(c.GetInt("adminID"), nil, &adminInfo)
- if adminInfo == nil {
- app.Response(c, http.StatusUnauthorized, errcode.TokenInvalid, nil)
- return
- }
- adminRole := false
- roleSlice := strings.Split(adminInfo.RoleIds, ",")
- for _, v := range roleSlice {
- if role, err := strconv.Atoi(v); err == nil && (role == adminParam.AdminRoleId || role == adminParam.MaterialAdminRoleId) {
- adminRole = true
- break
- }
- }
- if !adminRole {
- where["where"] = where["where"] + " AND `zy_admin`.`dept_id` IN {{dept_id}}"
- param["dept_id"] = dept.GetSubDeptIds(adminInfo.DeptID, []int{adminInfo.DeptID})
- }
- }*/
- total, err := bid.CountRaw(where["where"], param)
- if err != nil {
- app.Error(c, err.Error())
- return
- }
- orderList := make([]structs.MaterialBidOrderList, 0)
- if err := bid.GetOrdersRaw(where, param, &orderList); err != nil {
- app.Error(c, err.Error())
- return
- }
- roomTypeMap := material.GetRoomTypeMap(true)
- orderStateMap := bidParam.GetOrderStateMap()
- for k, v := range orderList {
- v.CreatedAt = utils.DateS(v.CreatedAt, "YYYY-MM-DD HH:mm")
- v.UpdatedAt = utils.DateS(v.UpdatedAt, "YYYY-MM-DD HH:mm")
- v.StateName = orderStateMap[v.State].Name
- v.StateColor = orderStateMap[v.State].Color
- styleName := make([]string, 0)
- var houseStyle []structs.HouseStyle
- utils.JsonDecode(v.HouseStyle).To(&houseStyle)
- for _, house := range houseStyle {
- styleName = append(styleName, utils.ToStr(house.Num)+roomTypeMap[house.Type])
- }
- v.HouseStyle = strings.Join(styleName, "")
- v.Auth = structs.MaterialBidOrderAuth{
- Finish: utils.IsContain(bidParam.OrderAllow.Finish, v.State),
- }
- orderList[k] = v
- }
- data := gin.H{
- //"pkgInfo": pkgInfo,
- "list": orderList,
- "total": total,
- //"limit": page.PageSize,
- }
- app.Success(c, data)
- }
- func OrderInfoApi(c *gin.Context) {
- id := utils.StrTo(c.Query("id")).MustInt()
- if id <= 0 {
- app.Error(c, "工单 id 为空")
- }
- var orderInfo structs.MaterialBidOrderList
- if _, err := bid.GetOrder(map[string]interface{}{"id": id}, nil, &orderInfo); err != nil {
- app.Error(c, err.Error())
- }
- roomTypeMap := material.GetRoomTypeMap(true)
- var houseStyle []structs.HouseStyle
- utils.JsonDecode(orderInfo.HouseStyle).To(&houseStyle)
- styleName := make([]string, 0)
- for _, house := range houseStyle {
- styleName = append(styleName, utils.ToStr(house.Num)+roomTypeMap[house.Type])
- }
- orderInfo.HouseStyle = strings.Join(styleName, "")
- utils.JsonDecode(orderInfo.Param).To(&orderInfo.ParamDecode)
- utils.JsonDecode(orderInfo.Customize).To(&orderInfo.CustomizeDecode)
- utils.JsonDecode(orderInfo.CustomizePriceDetail).To(&orderInfo.CustomizePriceDecode)
- utils.JsonDecode(orderInfo.PackagePriceDetail).To(&orderInfo.PackagePriceDecode)
- utils.JsonDecode(orderInfo.InclusivePriceDetail).To(&orderInfo.InclusivePriceDecode)
- utils.JsonDecode(orderInfo.InclusiveCostDetail).To(&orderInfo.InclusiveCostDecode)
- utils.JsonDecode(orderInfo.PackagePriceDetail).To(&orderInfo.OutlinePriceDecode)
- bidMap := make(map[int]*structs.MaterialBidList)
- bidList := make([]*structs.MaterialBidList, 0)
- if _, err := bid.GetBidList(map[string]interface{}{"pkg_id": orderInfo.PkgID}, nil, app.Page{}, &bidList); err == nil {
- for _, v := range bidList {
- bidMap[v.ID] = v
- }
- }
- type List struct {
- ID int `json:"id"`
- Category int `json:"category"`
- RoomType int `json:"room_type" label:"房屋类型"`
- RoomName string `json:"room_name" label:"房屋"`
- BidName string `json:"bid_name"`
- Description string `json:"description"`
- Price float64 `json:"price"`
- Count float64 `json:"count"`
- Total float64 `json:"total"`
- Unit string `json:"unit"`
- }
- calcSetting := bid.GetCalcSetting(houseStyle)
- list := make([]List, 0)
- for _, room := range orderInfo.ParamDecode {
- for _, i := range room.Items {
- if bid, ok := bidMap[i.ID]; ok && bid.Category <= 2 {
- if bid.CalcType == 7 {
- utils.JsonDecode(bid.CalcParam).To(&bid.CalcParamDecode)
- list = append(list, List{
- ID: bid.ID,
- Category: bid.Category,
- RoomType: room.RoomType,
- RoomName: room.RoomName,
- BidName: bid.BidName,
- Description: bid.Description,
- Price: bid.CalcParamDecode.BaseMoney,
- Count: 1,
- Total: bid.CalcParamDecode.BaseMoney,
- Unit: item.GetUnitMap()[bid.Unit],
- })
- if calcSetting.RoomNum > bid.CalcParamDecode.RoomNum && bid.CalcParamDecode.AddRoomMoney != 0 {
- num := utils.ToFloat64(calcSetting.RoomNum - bid.CalcParamDecode.RoomNum)
- money := utils.FloatMul(bid.CalcParamDecode.AddRoomMoney, num, -1)
- list = append(list, List{
- ID: bid.ID,
- Category: bid.Category,
- RoomType: room.RoomType,
- RoomName: room.RoomName,
- BidName: bid.BidName + " 增加房间",
- Description: bid.Description,
- Price: bid.CalcParamDecode.AddRoomMoney,
- Count: num,
- Total: money,
- Unit: item.GetUnitMap()[bid.Unit],
- })
- }
- if calcSetting.ToiletNum > bid.CalcParamDecode.ToiletNum && bid.CalcParamDecode.AddToiletMoney != 0 {
- num := utils.ToFloat64(calcSetting.ToiletNum - bid.CalcParamDecode.ToiletNum)
- money := utils.FloatMul(bid.CalcParamDecode.AddToiletMoney, num, -1)
- list = append(list, List{
- ID: bid.ID,
- Category: bid.Category,
- RoomType: room.RoomType,
- RoomName: room.RoomName,
- BidName: bid.BidName + " 增加卫生间",
- Description: bid.Description,
- Price: bid.CalcParamDecode.AddToiletMoney,
- Count: num,
- Total: money,
- Unit: item.GetUnitMap()[bid.Unit],
- })
- }
- if calcSetting.KitchenNum > bid.CalcParamDecode.KitchenNum && bid.CalcParamDecode.AddKitchenMoney != 0 {
- num := utils.ToFloat64(calcSetting.KitchenNum - bid.CalcParamDecode.KitchenNum)
- money := utils.FloatMul(bid.CalcParamDecode.AddKitchenMoney, num, -1)
- list = append(list, List{
- ID: bid.ID,
- Category: bid.Category,
- RoomType: room.RoomType,
- RoomName: room.RoomName,
- BidName: bid.BidName + " 增加厨房",
- Description: bid.Description,
- Price: bid.CalcParamDecode.AddToiletMoney,
- Count: num,
- Total: money,
- Unit: item.GetUnitMap()[bid.Unit],
- })
- }
- if calcSetting.RestaurantNum > bid.CalcParamDecode.RestaurantNum && bid.CalcParamDecode.AddRestaurantMoney != 0 {
- num := utils.ToFloat64(calcSetting.RestaurantNum - bid.CalcParamDecode.RestaurantNum)
- money := utils.FloatMul(bid.CalcParamDecode.AddRestaurantMoney, num, -1)
- list = append(list, List{
- ID: bid.ID,
- Category: bid.Category,
- RoomType: room.RoomType,
- RoomName: room.RoomName,
- BidName: bid.BidName + " 增加客餐厅",
- Description: bid.Description,
- Price: bid.CalcParamDecode.AddToiletMoney,
- Count: num,
- Total: money,
- Unit: item.GetUnitMap()[bid.Unit],
- })
- }
- } else {
- list = append(list, List{
- ID: bid.ID,
- Category: bid.Category,
- RoomType: room.RoomType,
- RoomName: room.RoomName,
- BidName: bid.BidName,
- Description: bid.Description,
- Price: bid.Price,
- Count: utils.FloatDiv(i.Price, bid.Price, 4),
- Total: i.Price,
- Unit: item.GetUnitMap()[bid.Unit],
- })
- }
- }
- }
- }
- app.Success(c, gin.H{
- "orderInfo": orderInfo,
- "bidList": list,
- })
- }
|