pkgitem.go 77 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477
  1. package pkg2024
  2. import (
  3. "errors"
  4. "math"
  5. "zhiyuan/models/final"
  6. "zhiyuan/pkg/db"
  7. "zhiyuan/pkg/utils"
  8. )
  9. var PkgItems = map[int][]PkgItemObject{
  10. -1: {
  11. {
  12. Item: "水电基础",
  13. NumberCalc: func(context *ItemContext) (float64, error) {
  14. return context.Pkg.RoomData.Pkg.Area, nil
  15. },
  16. },
  17. {
  18. Item: "水电安装", Number: 1,
  19. },
  20. {
  21. Item: "粉线槽",
  22. NumberCalc: func(context *ItemContext) (float64, error) {
  23. return context.Pkg.RoomData.Pkg.Area, nil
  24. },
  25. },
  26. {
  27. Item: "天棚、墙面批嵌",
  28. NumberCalc: func(context *ItemContext) (float64, error) {
  29. return utils.FloatMul(context.Pkg.RoomData.Pkg.Area, 2.5, 2), nil
  30. },
  31. },
  32. {
  33. Item: "天棚、墙面乳胶漆",
  34. NumberCalc: func(context *ItemContext) (float64, error) {
  35. return utils.FloatMul(context.Pkg.RoomData.Pkg.Area, 2.5, 2), nil
  36. },
  37. },
  38. {
  39. Item: "封包管道(单管或双管)",
  40. NumberCalc: func(context *ItemContext) (float64, error) {
  41. return float64(context.Pkg.RoomData.Pkg.Layout[2] + context.Pkg.RoomData.Pkg.Layout[3] + context.Pkg.RoomData.Pkg.Layout[4]), nil
  42. },
  43. },
  44. {
  45. Region: "地漏",
  46. NumberCalc: func(context *ItemContext) (float64, error) {
  47. num := context.Pkg.RoomData.Pkg.Layout[3] * 2
  48. if context.Pkg.RoomData.Pkg.Layout[4] > 0 {
  49. num += 1
  50. }
  51. return float64(num), nil
  52. },
  53. Unit: "个",
  54. ControlPrice: map[int]float64{A10: 21, A8: 28, A5: 21, ZZ1_0: 28},
  55. DeductionPrice: map[int]float64{A10: 20, A8: 20, A5: 20, ZZ1_0: 20},
  56. },
  57. {
  58. Region: "角阀",
  59. NumberCalc: func(context *ItemContext) (float64, error) {
  60. return float64(context.Pkg.RoomData.Pkg.Layout[2]*4 + context.Pkg.RoomData.Pkg.Layout[3]*3 + context.Pkg.RoomData.Pkg.Layout[4]*2), nil
  61. },
  62. Unit: "个",
  63. ControlPrice: map[int]float64{A10: 17, A8: 17, A5: 17, ZZ1_0: 17},
  64. DeductionPrice: map[int]float64{A10: 16, A8: 16, A5: 16, ZZ1_0: 16},
  65. },
  66. {
  67. Item: "开关面板控额",
  68. Region: "开关面板",
  69. NumberCalc: func(context *ItemContext) (float64, error) {
  70. return 1, nil
  71. },
  72. ControlPriceCalc: func(context *ItemContext) (float64, error) {
  73. prices := map[int]float64{A10: 9.8, A8: 8, A5: 5.5, ZZ1_0: 8}
  74. num := 65
  75. if context.Pkg.RoomData.Pkg.Layout[0] > 2 {
  76. num += (context.Pkg.RoomData.Pkg.Layout[0] - 2) * 13
  77. }
  78. if context.Pkg.RoomData.Pkg.Layout[3] > 1 {
  79. num += (context.Pkg.RoomData.Pkg.Layout[3] - 1) * 4
  80. }
  81. if context.Pkg.RoomData.Pkg.Layout[4] > 1 {
  82. num += (context.Pkg.RoomData.Pkg.Layout[4] - 1) * 3
  83. }
  84. return utils.FloatMul(prices[context.Pkg.RoomData.Pkg.Type], float64(num), -1), nil
  85. },
  86. DeductionPriceCalc: func(context *ItemContext) (float64, error) {
  87. deductions := map[int]float64{A10: 700, A8: 550, A5: 400, ZZ1_0: 550}
  88. add := map[int]float64{A10: 150, A8: 110, A5: 100, ZZ1_0: 110}
  89. price := deductions[context.Pkg.RoomData.Pkg.Type]
  90. if context.Pkg.RoomData.Pkg.Layout[0] > 2 {
  91. price += float64(context.Pkg.RoomData.Pkg.Layout[0]-2) * add[context.Pkg.RoomData.Pkg.Type]
  92. }
  93. return price, nil
  94. },
  95. },
  96. },
  97. 0: {
  98. {
  99. Region: "木门",
  100. Number: 1,
  101. Unit: "樘",
  102. ControlPrice: map[int]float64{A10: 1300, A8: 850, A5: 700, ZZ1_0: 850},
  103. DeductionPrice: map[int]float64{A10: 1050, A8: 820, A5: 700, ZZ1_0: 820},
  104. MaterialAdditionalItemCalc: func(context *ItemContext) ([]PersonalItem, error) {
  105. items := make([]PersonalItem, 0)
  106. mat := context.GetMat(context.Region.Material)
  107. if mat != nil {
  108. if context.Space.DoorwayHeight > 2.2 {
  109. number := math.Ceil(utils.FloatMul(utils.FloatSub(context.Space.DoorwayHeight, 2.2, -1), 100, -1))
  110. total := math.Round(utils.FloatMul(15, number, 3))
  111. items = append(items, PersonalItem{
  112. Name: context.GetSpaceName() + " 木门(" + mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color + ") 超高度",
  113. Unit: "cm",
  114. Number: number,
  115. Price: 15,
  116. Total: total,
  117. Index: -1,
  118. })
  119. }
  120. if context.Space.DoorwayWidth > 0.9 {
  121. number := math.Ceil(utils.FloatMul(utils.FloatSub(context.Space.DoorwayWidth, 0.9, -1), 100, -1))
  122. total := math.Round(utils.FloatMul(15, number, 3))
  123. items = append(items, PersonalItem{
  124. Name: context.GetSpaceName() + " 木门(" + mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color + ") 超宽度",
  125. Unit: "cm",
  126. Number: number,
  127. Price: 15,
  128. Total: total,
  129. Index: -1,
  130. })
  131. }
  132. if context.Space.DoorwayWallThickness > 0.28 {
  133. number := math.Ceil(utils.FloatMul(utils.FloatSub(context.Space.DoorwayWallThickness, 0.28, -1), 100, -1))
  134. total := math.Round(utils.FloatMul(25, number, 3))
  135. items = append(items, PersonalItem{
  136. Name: context.GetSpaceName() + " 木门(" + mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color + ") 超墙厚",
  137. Unit: "cm",
  138. Number: number,
  139. Price: 25,
  140. Total: total,
  141. Index: -1,
  142. })
  143. }
  144. }
  145. return items, nil
  146. },
  147. },
  148. {
  149. Item: "安装门槛石",
  150. NumberCalc: func(context *ItemContext) (float64, error) {
  151. return context.Space.DoorwayWidth, nil
  152. },
  153. },
  154. {
  155. Region: "门槛石",
  156. NumberCalc: func(context *ItemContext) (float64, error) {
  157. return context.Space.DoorwayWidth, nil
  158. },
  159. ConvertCalc: func(context *ItemContext) (float64, error) {
  160. return float64(context.Space.DoorwayWallThickness), nil
  161. },
  162. Unit: "m",
  163. ControlPrice: map[int]float64{A10: 89, A8: 89, A5: 0, ZZ1_0: 89},
  164. AdditionalMaterialCalc: func(context *ItemContext) ([]MaterialItem, error) {
  165. mat := context.GetMat(1610)
  166. if mat == nil {
  167. return nil, errors.New("找不到材料: " + db.ToString(1610))
  168. }
  169. typ, ok := context.MatTypeCache[mat.TypeId]
  170. if !ok {
  171. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  172. }
  173. total := utils.FloatMul(mat.Price, context.Space.DoorwayWidth, 3)
  174. materials := []MaterialItem{{
  175. Material: 1610,
  176. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  177. Type: "门槛石",
  178. Unit: typ.Unit,
  179. Number: context.Space.DoorwayWidth,
  180. Price: mat.Price,
  181. Total: total,
  182. CostNumber: context.Space.DoorwayWidth,
  183. CostTotal: total,
  184. Index: -1,
  185. }}
  186. if context.Region.Material == 52 || context.Region.Material == 53 || context.Region.Material == 54 {
  187. mat := context.GetMat(55)
  188. if mat == nil {
  189. return nil, errors.New("找不到材料: " + db.ToString(55))
  190. }
  191. typ, ok := context.MatTypeCache[mat.TypeId]
  192. if !ok {
  193. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  194. }
  195. number := utils.FloatMul(8, context.Space.DoorwayWidth, 3)
  196. total := utils.FloatMul(mat.Price, number, 3)
  197. materials = append(materials, MaterialItem{
  198. Material: 55,
  199. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  200. Type: "钢筋成本",
  201. Unit: typ.Unit,
  202. Number: number,
  203. Price: mat.Price,
  204. Total: total,
  205. CostNumber: number,
  206. CostTotal: total,
  207. Index: -1,
  208. })
  209. }
  210. return materials, nil
  211. },
  212. NoUpgrade: true,
  213. },
  214. {
  215. Item: "小窗台大理石安装",
  216. NumberCalc: func(context *ItemContext) (float64, error) {
  217. num := float64(0)
  218. if context.Space.Windows != nil {
  219. for _, window := range context.Space.Windows {
  220. if window.Width <= 0.2 {
  221. num = utils.FloatAdd(num, window.Length, -1)
  222. }
  223. }
  224. }
  225. return num, nil
  226. },
  227. },
  228. {
  229. Item: "窗台大理石安装 宽度>200MM<700MM",
  230. NumberCalc: func(context *ItemContext) (float64, error) {
  231. num := float64(0)
  232. if context.Space.Windows != nil {
  233. for _, window := range context.Space.Windows {
  234. if window.Width > 0.2 && window.Width < 0.7 {
  235. num = utils.FloatAdd(num, window.Length, -1)
  236. }
  237. }
  238. }
  239. return num, nil
  240. },
  241. },
  242. {
  243. Item: "窗台大理石安装 宽度≥700MM",
  244. NumberCalc: func(context *ItemContext) (float64, error) {
  245. num := float64(0)
  246. if context.Space.Windows != nil {
  247. for _, window := range context.Space.Windows {
  248. if window.Width >= 0.7 {
  249. num = utils.FloatAdd(num, window.Length, -1)
  250. }
  251. }
  252. }
  253. return num, nil
  254. },
  255. },
  256. {
  257. Region: "窗台石",
  258. NumberCalc: func(context *ItemContext) (float64, error) {
  259. num := float64(0)
  260. if context.Space.Windows != nil {
  261. for _, window := range context.Space.Windows {
  262. if window.Width > 0 {
  263. num = utils.FloatAdd(num, utils.FloatAdd(window.Length, 0.1, -1), -1)
  264. }
  265. }
  266. }
  267. return num, nil
  268. },
  269. ConvertCalc: func(context *ItemContext) (float64, error) {
  270. num := float64(0)
  271. if context.Space.Windows != nil {
  272. for _, window := range context.Space.Windows {
  273. if window.Width > 0 {
  274. num = utils.FloatAdd(num, utils.FloatAdd(window.Length, 0.1, -1), -1)
  275. }
  276. }
  277. }
  278. mnum := float64(0)
  279. if context.Space.Windows != nil {
  280. for _, window := range context.Space.Windows {
  281. if window.Width > 0 {
  282. mnum = utils.FloatAdd(num, utils.FloatMul(utils.FloatAdd(window.Length, 0.1, -1), window.Width, -1), -1)
  283. }
  284. }
  285. }
  286. return utils.FloatDiv(num, mnum, -1), nil
  287. },
  288. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  289. num := float64(0)
  290. if context.Space.Windows != nil {
  291. for _, window := range context.Space.Windows {
  292. if window.Length > 0 {
  293. num = utils.FloatAdd(num, utils.FloatMul(utils.FloatAdd(window.Length, 0.1, -1), window.Width, -1), -1)
  294. }
  295. }
  296. }
  297. return num, nil
  298. },
  299. Unit: "m",
  300. ControlPrice: map[int]float64{A10: 143, A8: 143, A5: 143, ZZ1_0: 143},
  301. AdditionalMaterialCalc: func(context *ItemContext) ([]MaterialItem, error) {
  302. num := float64(0)
  303. if context.Space.Windows != nil {
  304. for _, window := range context.Space.Windows {
  305. if window.Width > 0 {
  306. num = utils.FloatAdd(num, utils.FloatAdd(window.Length, 0.1, -1), -1)
  307. }
  308. }
  309. }
  310. mat := context.GetMat(1609)
  311. if mat == nil {
  312. return nil, errors.New("找不到材料: " + db.ToString(1609))
  313. }
  314. typ, ok := context.MatTypeCache[mat.TypeId]
  315. if !ok {
  316. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  317. }
  318. total := utils.FloatMul(mat.Price, num, 3)
  319. return []MaterialItem{{
  320. Material: 1609,
  321. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  322. Type: "窗台石",
  323. Unit: typ.Unit,
  324. Number: num,
  325. Price: mat.Price,
  326. Total: total,
  327. CostNumber: num,
  328. CostTotal: total,
  329. Index: -1,
  330. }}, nil
  331. },
  332. NoUpgrade: true,
  333. },
  334. {
  335. ItemSelect: func(context *ItemContext) (string, error) {
  336. mat := context.GetMat(context.Region.Material)
  337. if mat == nil {
  338. return "", nil
  339. }
  340. if mat.TypeId == 110 {
  341. return "地面找平", nil
  342. }
  343. if mat.TypeId == 6 {
  344. return "地面贴砖(600*1200mm)", nil
  345. }
  346. if mat.TypeId == 7 {
  347. return "地面贴砖(750*1500mm)", nil
  348. }
  349. return "地面贴砖(300*300mm-800*800mm)", nil
  350. },
  351. Region: "地面",
  352. NumberCalc: func(context *ItemContext) (float64, error) {
  353. return context.Space.Area, nil
  354. },
  355. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  356. return 0, nil
  357. },
  358. DiffPriceCalc: func(context *ItemContext) (float64, error) {
  359. price, err := context.Item.GetPrice(context)
  360. if err != nil {
  361. return 0, err
  362. }
  363. if price < 38 {
  364. return 0, nil
  365. }
  366. return utils.FloatSub(price, 38, -1), nil
  367. },
  368. },
  369. {
  370. Region: "地面",
  371. NumberCalc: func(context *ItemContext) (float64, error) {
  372. return context.Space.Area, nil
  373. },
  374. LossCalc: func(context *ItemContext) (float64, error) {
  375. mat := context.GetMat(context.Region.Material)
  376. if mat == nil {
  377. return 1, nil
  378. }
  379. loss := map[int64]float64{
  380. 110: 1, 10: 1.08, 9: 1.08, 7: 1.1, 6: 1.1, 5: 1.1, 4: 1.08, 3: 1.08,
  381. }
  382. return loss[mat.TypeId], nil
  383. },
  384. ConvertCalc: func(context *ItemContext) (float64, error) {
  385. mat := context.GetMat(context.Region.Material)
  386. if mat == nil {
  387. return 1, nil
  388. }
  389. area := map[int64]float64{
  390. 110: 1, 10: 0.09, 9: 0.18, 7: 1.125, 6: 0.72, 5: 0.64, 4: 0.16, 3: 0.32,
  391. }
  392. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  393. },
  394. CostLossCalc: func(context *ItemContext) (float64, error) {
  395. mat := context.GetMat(context.Region.Material)
  396. if mat == nil {
  397. return 1, nil
  398. }
  399. loss := map[int64]float64{
  400. 110: 1.1, 10: 1.2, 9: 1.2, 7: 1.2, 6: 1.2, 5: 1.2, 4: 1.2, 3: 1.2,
  401. }
  402. return loss[mat.TypeId], nil
  403. },
  404. Unit: "m²",
  405. MaterialRound: true,
  406. ControlPrice: map[int]float64{A10: 92, A8: 84, A5: 70, ZZ1_0: 84},
  407. DeductionPrice: map[int]float64{A10: 85, A8: 70, A5: 55, ZZ1_0: 70},
  408. },
  409. },
  410. 1: {
  411. {
  412. Region: "入户门套",
  413. NumberCalc: func(context *ItemContext) (float64, error) {
  414. if context.Pkg.RoomData.Pkg.Type == A5 {
  415. return 0, nil
  416. }
  417. return utils.FloatAdd(context.Space.DoorwayWidth, utils.FloatMul(context.Space.DoorwayHeight, 2, -1), -1), nil
  418. },
  419. PkgNumber: 6,
  420. Unit: "m",
  421. ControlPrice: map[int]float64{A10: 90, A8: 90, A5: 0, ZZ1_0: 90},
  422. DeductionPrice: map[int]float64{A10: 85, A8: 70, A5: 0, ZZ1_0: 75},
  423. },
  424. {
  425. Item: "安装门槛石",
  426. NumberCalc: func(context *ItemContext) (float64, error) {
  427. return context.Space.DoorwayWidth, nil
  428. },
  429. },
  430. {
  431. Region: "门槛石",
  432. NumberCalc: func(context *ItemContext) (float64, error) {
  433. return context.Space.DoorwayWidth, nil
  434. },
  435. ConvertCalc: func(context *ItemContext) (float64, error) {
  436. return float64(context.Space.DoorwayWallThickness), nil
  437. },
  438. Unit: "m",
  439. ControlPrice: map[int]float64{A10: 89, A8: 89, A5: 0, ZZ1_0: 89},
  440. AdditionalMaterialCalc: func(context *ItemContext) ([]MaterialItem, error) {
  441. mat := context.GetMat(1610)
  442. if mat == nil {
  443. return nil, errors.New("找不到材料: " + db.ToString(1610))
  444. }
  445. typ, ok := context.MatTypeCache[mat.TypeId]
  446. if !ok {
  447. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  448. }
  449. total := utils.FloatMul(mat.Price, context.Space.DoorwayWidth, 3)
  450. materials := []MaterialItem{{
  451. Material: 1610,
  452. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  453. Type: "门槛石",
  454. Unit: typ.Unit,
  455. Number: context.Space.DoorwayWidth,
  456. Price: mat.Price,
  457. Total: total,
  458. CostNumber: context.Space.DoorwayWidth,
  459. CostTotal: total,
  460. Index: -1,
  461. }}
  462. if context.Region.Material == 52 || context.Region.Material == 53 || context.Region.Material == 54 {
  463. mat := context.GetMat(55)
  464. if mat == nil {
  465. return nil, errors.New("找不到材料: " + db.ToString(55))
  466. }
  467. typ, ok := context.MatTypeCache[mat.TypeId]
  468. if !ok {
  469. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  470. }
  471. number := utils.FloatMul(8, context.Space.DoorwayWidth, 3)
  472. total := utils.FloatMul(mat.Price, number, 3)
  473. materials = append(materials, MaterialItem{
  474. Material: 55,
  475. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  476. Type: "钢筋成本",
  477. Unit: typ.Unit,
  478. Number: number,
  479. Price: mat.Price,
  480. Total: total,
  481. CostNumber: number,
  482. CostTotal: total,
  483. Index: -1,
  484. })
  485. }
  486. return materials, nil
  487. },
  488. NoUpgrade: true,
  489. },
  490. {
  491. Item: "小窗台大理石安装",
  492. NumberCalc: func(context *ItemContext) (float64, error) {
  493. num := float64(0)
  494. if context.Space.Windows != nil {
  495. for _, window := range context.Space.Windows {
  496. if window.Width <= 0.2 {
  497. num = utils.FloatAdd(num, window.Length, -1)
  498. }
  499. }
  500. }
  501. return num, nil
  502. },
  503. },
  504. {
  505. Item: "窗台大理石安装 宽度>200MM<700MM",
  506. NumberCalc: func(context *ItemContext) (float64, error) {
  507. num := float64(0)
  508. if context.Space.Windows != nil {
  509. for _, window := range context.Space.Windows {
  510. if window.Width > 0.2 && window.Width < 0.7 {
  511. num = utils.FloatAdd(num, window.Length, -1)
  512. }
  513. }
  514. }
  515. return num, nil
  516. },
  517. },
  518. {
  519. Item: "窗台大理石安装 宽度≥700MM",
  520. NumberCalc: func(context *ItemContext) (float64, error) {
  521. num := float64(0)
  522. if context.Space.Windows != nil {
  523. for _, window := range context.Space.Windows {
  524. if window.Width >= 0.7 {
  525. num = utils.FloatAdd(num, window.Length, -1)
  526. }
  527. }
  528. }
  529. return num, nil
  530. },
  531. },
  532. {
  533. Region: "窗台石",
  534. NumberCalc: func(context *ItemContext) (float64, error) {
  535. num := float64(0)
  536. if context.Space.Windows != nil {
  537. for _, window := range context.Space.Windows {
  538. if window.Width > 0 {
  539. num = utils.FloatAdd(num, utils.FloatAdd(window.Length, 0.1, -1), -1)
  540. }
  541. }
  542. }
  543. return num, nil
  544. },
  545. ConvertCalc: func(context *ItemContext) (float64, error) {
  546. num := float64(0)
  547. if context.Space.Windows != nil {
  548. for _, window := range context.Space.Windows {
  549. if window.Width > 0 {
  550. num = utils.FloatAdd(num, utils.FloatAdd(window.Length, 0.1, -1), -1)
  551. }
  552. }
  553. }
  554. mnum := float64(0)
  555. if context.Space.Windows != nil {
  556. for _, window := range context.Space.Windows {
  557. if window.Width > 0 {
  558. mnum = utils.FloatAdd(num, utils.FloatMul(utils.FloatAdd(window.Length, 0.1, -1), window.Width, -1), -1)
  559. }
  560. }
  561. }
  562. return utils.FloatDiv(mnum, num, -1), nil
  563. },
  564. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  565. num := float64(0)
  566. if context.Space.Windows != nil {
  567. for _, window := range context.Space.Windows {
  568. if window.Length > 0 {
  569. num = utils.FloatAdd(num, utils.FloatMul(utils.FloatAdd(window.Length, 0.1, -1), window.Width, -1), -1)
  570. }
  571. }
  572. }
  573. return num, nil
  574. },
  575. Unit: "m",
  576. ControlPrice: map[int]float64{A10: 143, A8: 143, A5: 143, ZZ1_0: 143},
  577. AdditionalMaterialCalc: func(context *ItemContext) ([]MaterialItem, error) {
  578. num := float64(0)
  579. if context.Space.Windows != nil {
  580. for _, window := range context.Space.Windows {
  581. if window.Width > 0 {
  582. num = utils.FloatAdd(num, utils.FloatAdd(window.Length, 0.1, -1), -1)
  583. }
  584. }
  585. }
  586. mat := context.GetMat(1609)
  587. if mat == nil {
  588. return nil, errors.New("找不到材料: " + db.ToString(1609))
  589. }
  590. typ, ok := context.MatTypeCache[mat.TypeId]
  591. if !ok {
  592. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  593. }
  594. total := utils.FloatMul(mat.Price, num, 3)
  595. return []MaterialItem{{
  596. Material: 1609,
  597. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  598. Type: "窗台石",
  599. Unit: typ.Unit,
  600. Number: num,
  601. Price: mat.Price,
  602. Total: total,
  603. CostNumber: num,
  604. CostTotal: total,
  605. Index: -1,
  606. }}, nil
  607. },
  608. NoUpgrade: true,
  609. },
  610. {
  611. ItemSelect: func(context *ItemContext) (string, error) {
  612. mat := context.GetMat(context.Region.Material)
  613. if mat == nil {
  614. return "", nil
  615. }
  616. if mat.TypeId == 110 {
  617. return "地面找平", nil
  618. }
  619. if mat.TypeId == 6 {
  620. return "地面贴砖(600*1200mm)", nil
  621. }
  622. if mat.TypeId == 7 {
  623. return "地面贴砖(750*1500mm)", nil
  624. }
  625. return "地面贴砖(300*300mm-800*800mm)", nil
  626. },
  627. Region: "地面",
  628. NumberCalc: func(context *ItemContext) (float64, error) {
  629. return context.Space.Area, nil
  630. },
  631. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  632. return 0, nil
  633. },
  634. DiffPriceCalc: func(context *ItemContext) (float64, error) {
  635. price, err := context.Item.GetPrice(context)
  636. if err != nil {
  637. return 0, err
  638. }
  639. if price < 68 {
  640. return 0, nil
  641. }
  642. return utils.FloatSub(price, 68, -1), nil
  643. },
  644. },
  645. {
  646. Region: "地面",
  647. MaterialType: "地面",
  648. NumberCalc: func(context *ItemContext) (float64, error) {
  649. return context.Space.Area, nil
  650. },
  651. LossCalc: func(context *ItemContext) (float64, error) {
  652. mat := context.GetMat(context.Region.Material)
  653. if mat == nil {
  654. return 1, nil
  655. }
  656. loss := map[int64]float64{
  657. 110: 1, 10: 1.08, 9: 1.08, 7: 1.1, 6: 1.1, 5: 1.1, 4: 1.08, 3: 1.08,
  658. }
  659. return loss[mat.TypeId], nil
  660. },
  661. ConvertCalc: func(context *ItemContext) (float64, error) {
  662. mat := context.GetMat(context.Region.Material)
  663. if mat == nil {
  664. return 1, nil
  665. }
  666. area := map[int64]float64{
  667. 110: 1, 10: 0.09, 9: 0.18, 7: 1.125, 6: 0.72, 5: 0.64, 4: 0.16, 3: 0.32,
  668. }
  669. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  670. },
  671. CostLossCalc: func(context *ItemContext) (float64, error) {
  672. mat := context.GetMat(context.Region.Material)
  673. if mat == nil {
  674. return 1, nil
  675. }
  676. loss := map[int64]float64{
  677. 110: 1.1, 10: 1.2, 9: 1.2, 7: 1.2, 6: 1.2, 5: 1.2, 4: 1.2, 3: 1.2,
  678. }
  679. return loss[mat.TypeId], nil
  680. },
  681. Unit: "m²",
  682. MaterialRound: true,
  683. ControlPrice: map[int]float64{A10: 81, A8: 56, A5: 36, ZZ1_0: 56},
  684. DeductionPrice: map[int]float64{A10: 55, A8: 40, A5: 30, ZZ1_0: 40},
  685. },
  686. {
  687. Item: "地砖铺贴后成品保护",
  688. NumberCalc: func(context *ItemContext) (float64, error) {
  689. mat := context.GetMat(context.Region.Material)
  690. if mat == nil {
  691. return 0, nil
  692. }
  693. if mat.TypeId == 110 {
  694. return 0, nil
  695. }
  696. return context.Space.Area, nil
  697. },
  698. },
  699. {
  700. Item: "踢脚线铺贴(明贴)",
  701. Region: "地面",
  702. NumberCalc: func(context *ItemContext) (float64, error) {
  703. mat := context.GetMat(context.Region.Material)
  704. if mat == nil {
  705. return 0, nil
  706. }
  707. if mat.TypeId == 110 {
  708. return 0, nil
  709. }
  710. KitchenHole := context.Pkg.RoomData.Space[2][0].DoorwayWidth
  711. BalconyHole := float64(0)
  712. if len(context.Pkg.RoomData.Space[4]) != 0 {
  713. BalconyHole = context.Pkg.RoomData.Space[4][0].DoorwayWidth
  714. }
  715. RoomHole := float64(0)
  716. for _, space := range context.Pkg.RoomData.Space[0] {
  717. RoomHole = utils.FloatAdd(RoomHole, space.DoorwayWidth, -1)
  718. }
  719. number := utils.FloatSubSlice([]float64{context.Space.Perimeter, context.Space.DoorwayWidth, KitchenHole, BalconyHole, RoomHole}, -1)
  720. if number < 0 {
  721. return 0, nil
  722. }
  723. return number, nil
  724. },
  725. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  726. return 0, nil
  727. },
  728. },
  729. {
  730. Region: "地面",
  731. MaterialType: "瓷砖地脚线",
  732. NumberCalc: func(context *ItemContext) (float64, error) {
  733. mat := context.GetMat(context.Region.Material)
  734. if mat == nil {
  735. return 0, nil
  736. }
  737. if mat.TypeId == 110 {
  738. return 0, nil
  739. }
  740. KitchenHole := context.Pkg.RoomData.Space[2][0].DoorwayWidth
  741. BalconyHole := float64(0)
  742. if len(context.Pkg.RoomData.Space[4]) != 0 {
  743. BalconyHole = context.Pkg.RoomData.Space[4][0].DoorwayWidth
  744. }
  745. RoomHole := float64(0)
  746. for _, space := range context.Pkg.RoomData.Space[0] {
  747. RoomHole = utils.FloatAdd(RoomHole, space.DoorwayWidth, -1)
  748. }
  749. number := utils.FloatSubSlice([]float64{context.Space.Perimeter, context.Space.DoorwayWidth, KitchenHole, BalconyHole, RoomHole}, -1)
  750. if number < 0 {
  751. return 0, nil
  752. }
  753. return number, nil
  754. },
  755. ConvertCalc: func(context *ItemContext) (float64, error) {
  756. mat := context.GetMat(context.Region.Material)
  757. if mat == nil {
  758. return 1, nil
  759. }
  760. lineArea := map[int64]float64{
  761. 10: 0.6, 9: 1.2, 7: 11.25, 6: 7.2, 5: 6.4, 4: 0.8, 3: 1.6,
  762. }
  763. return utils.FloatDiv(1, lineArea[mat.TypeId], -1), nil
  764. },
  765. Unit: "m",
  766. MaterialRound: true,
  767. ControlPrice: map[int]float64{A10: 16, A8: 12, A5: 8, ZZ1_0: 12},
  768. DeductionPrice: map[int]float64{A10: 12, A8: 8, A5: 6, ZZ1_0: 8},
  769. AdditionalMaterialCalc: func(context *ItemContext) ([]MaterialItem, error) {
  770. KitchenHole := context.Pkg.RoomData.Space[2][0].DoorwayWidth
  771. BalconyHole := float64(0)
  772. if len(context.Pkg.RoomData.Space[4]) != 0 {
  773. BalconyHole = context.Pkg.RoomData.Space[4][0].DoorwayWidth
  774. }
  775. number := utils.FloatSubSlice([]float64{context.Space.Perimeter, context.Space.DoorwayWidth, KitchenHole, BalconyHole}, -1)
  776. if number < 0 {
  777. number = 0
  778. }
  779. number = utils.FloatMul(number, 2, 3)
  780. ymat := context.GetMat(context.Region.Material)
  781. if ymat == nil {
  782. return nil, errors.New("找不到材料: " + db.ToString(context.Region.Material))
  783. }
  784. var mat final.FinalMat
  785. db.GetModel(map[string]interface{}{
  786. "supplier_id": ymat.SupplierId,
  787. "model": "其他费用",
  788. "deleted_at": 0,
  789. }, &mat)
  790. if mat.ID == 0 {
  791. return []MaterialItem{}, nil
  792. }
  793. typ, ok := context.MatTypeCache[mat.TypeId]
  794. if !ok {
  795. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  796. }
  797. total := utils.FloatMul(mat.Price, number, 3)
  798. return []MaterialItem{{
  799. Material: mat.ID,
  800. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  801. Type: "瓷砖地脚线",
  802. Unit: typ.Unit,
  803. Number: number,
  804. Price: mat.Price,
  805. Total: total,
  806. CostNumber: number,
  807. CostTotal: total,
  808. Index: -1,
  809. }}, nil
  810. },
  811. },
  812. {
  813. Region: "筒灯或灯带",
  814. NumberCalc: func(context *ItemContext) (float64, error) {
  815. if context.Pkg.RoomData.Pkg.Type != ZZ1_0 {
  816. return 0, nil
  817. }
  818. return 15, nil
  819. },
  820. Unit: "套",
  821. ControlPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 8},
  822. DeductionPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 8},
  823. },
  824. {
  825. Item: "直线造型吊顶(二级)",
  826. NumberCalc: func(context *ItemContext) (float64, error) {
  827. if context.Pkg.RoomData.Pkg.Type != ZZ1_0 {
  828. return 0, nil
  829. }
  830. return utils.FloatMul(context.Space.Area, 0.8, -1), nil
  831. },
  832. },
  833. },
  834. 2: {
  835. {
  836. Region: "铝合金门",
  837. NumberCalc: func(context *ItemContext) (float64, error) {
  838. mat := context.GetMat(context.Region.Material)
  839. if mat == nil {
  840. return 0, nil
  841. }
  842. if mat.TypeId == 105 {
  843. return 1, nil
  844. }
  845. return utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayHeight, -1), nil
  846. },
  847. PkgNumberCalc: func(context *ItemContext) (float64, error) {
  848. mat := context.GetMat(context.Region.Material)
  849. if mat == nil {
  850. return 0, nil
  851. }
  852. if mat.TypeId == 105 {
  853. return 1, nil
  854. }
  855. return 3.52, nil
  856. },
  857. Unit: "m",
  858. UnitCalc: func(context *ItemContext) (string, error) {
  859. mat := context.GetMat(context.Region.Material)
  860. if mat != nil && mat.TypeId == 105 {
  861. return "樘", nil
  862. }
  863. return "m", nil
  864. },
  865. ControlPriceCalc: func(context *ItemContext) (float64, error) {
  866. mat := context.GetMat(context.Region.Material)
  867. controls := map[int]float64{A10: 430, A8: 403, A5: 700, ZZ1_0: 403}
  868. if mat != nil && mat.TypeId == 105 {
  869. if context.Pkg.RoomData.Pkg.Type == A5 {
  870. return controls[context.Pkg.RoomData.Pkg.Type], nil
  871. }
  872. return utils.FloatMul(controls[context.Pkg.RoomData.Pkg.Type], 3.52, -1), nil
  873. }
  874. if context.Pkg.RoomData.Pkg.Type == A5 {
  875. return utils.FloatDiv(controls[context.Pkg.RoomData.Pkg.Type], 3.52, -1), nil
  876. }
  877. return controls[context.Pkg.RoomData.Pkg.Type], nil
  878. },
  879. DeductionPriceCalc: func(context *ItemContext) (float64, error) {
  880. mat := context.GetMat(context.Region.Material)
  881. deductions := map[int]float64{A10: 410, A8: 360, A5: 500, ZZ1_0: 360}
  882. if mat != nil && mat.TypeId == 105 {
  883. if context.Pkg.RoomData.Pkg.Type == A5 {
  884. return deductions[context.Pkg.RoomData.Pkg.Type], nil
  885. }
  886. return utils.FloatMul(deductions[context.Pkg.RoomData.Pkg.Type], 3.52, -1), nil
  887. }
  888. if context.Pkg.RoomData.Pkg.Type == A5 {
  889. return utils.FloatDiv(deductions[context.Pkg.RoomData.Pkg.Type], 3.52, -1), nil
  890. }
  891. return deductions[context.Pkg.RoomData.Pkg.Type], nil
  892. },
  893. MaterialAdditionalItemCalc: func(context *ItemContext) ([]PersonalItem, error) {
  894. items := make([]PersonalItem, 0)
  895. mat := context.GetMat(context.Region.Material)
  896. if mat != nil && mat.TypeId == 105 && context.Pkg.RoomData.Pkg.Type == A5 {
  897. if context.Space.DoorwayHeight > 2 {
  898. //number := math.Ceil(utils.FloatMul(utils.FloatSub(context.Space.DoorwayHeight, 2, -1), 100, -1))
  899. //total := math.Round(utils.FloatMul(15, number, 3))
  900. items = append(items, PersonalItem{
  901. Name: context.GetSpaceName() + " 铝合金门(" + mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color + ") 超高度",
  902. Unit: "套",
  903. Number: 1,
  904. Price: 60,
  905. Total: 60,
  906. Index: -1,
  907. })
  908. }
  909. if context.Space.DoorwayWidth > 0.8 {
  910. //number := math.Ceil(utils.FloatMul(utils.FloatSub(context.Space.DoorwayWidth, 0.8, -1), 100, -1))
  911. //total := math.Round(utils.FloatMul(15, number, 3))
  912. items = append(items, PersonalItem{
  913. Name: context.GetSpaceName() + " 铝合金门(" + mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color + ") 超宽度",
  914. Unit: "套",
  915. Number: 1,
  916. Price: 60,
  917. Total: 60,
  918. Index: -1,
  919. })
  920. }
  921. if context.Space.DoorwayWallThickness > 0.28 {
  922. //number := math.Ceil(utils.FloatMul(utils.FloatSub(context.Space.DoorwayWallThickness, 0.28, -1), 100, -1))
  923. //total := math.Round(utils.FloatMul(25, number, 3))
  924. items = append(items, PersonalItem{
  925. Name: context.GetSpaceName() + " 铝合金门(" + mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color + ") 超墙厚",
  926. Unit: "套",
  927. Number: 1,
  928. Price: 60,
  929. Total: 60,
  930. Index: -1,
  931. })
  932. }
  933. }
  934. return items, nil
  935. },
  936. },
  937. {
  938. Region: "门套",
  939. NumberCalc: func(context *ItemContext) (float64, error) {
  940. if context.Pkg.RoomData.Pkg.Type == A5 {
  941. return 0, nil
  942. }
  943. return utils.FloatAdd(context.Space.DoorwayWidth, utils.FloatMul(context.Space.DoorwayHeight, 2, -1), -1), nil
  944. },
  945. PkgNumber: 6,
  946. Unit: "m",
  947. ControlPrice: map[int]float64{A10: 90, A8: 90, A5: 0, ZZ1_0: 90},
  948. DeductionPrice: map[int]float64{A10: 90, A8: 90, A5: 0, ZZ1_0: 90},
  949. },
  950. {
  951. Item: "安装门槛石",
  952. NumberCalc: func(context *ItemContext) (float64, error) {
  953. if context.Space.WideBed {
  954. return 0, nil
  955. }
  956. return context.Space.DoorwayWidth, nil
  957. },
  958. },
  959. {
  960. Region: "门槛石",
  961. NumberCalc: func(context *ItemContext) (float64, error) {
  962. if context.Space.WideBed {
  963. return 0, nil
  964. }
  965. return context.Space.DoorwayWidth, nil
  966. },
  967. ConvertCalc: func(context *ItemContext) (float64, error) {
  968. return float64(context.Space.DoorwayWallThickness), nil
  969. },
  970. Unit: "m",
  971. ControlPrice: map[int]float64{A10: 89, A8: 89, A5: 0, ZZ1_0: 89},
  972. AdditionalMaterialCalc: func(context *ItemContext) ([]MaterialItem, error) {
  973. mat := context.GetMat(1610)
  974. if mat == nil {
  975. return nil, errors.New("找不到材料: " + db.ToString(1610))
  976. }
  977. typ, ok := context.MatTypeCache[mat.TypeId]
  978. if !ok {
  979. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  980. }
  981. total := utils.FloatMul(mat.Price, context.Space.DoorwayWidth, 3)
  982. materials := []MaterialItem{{
  983. Material: 1610,
  984. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  985. Type: "门槛石",
  986. Unit: typ.Unit,
  987. Number: context.Space.DoorwayWidth,
  988. Price: mat.Price,
  989. Total: total,
  990. CostNumber: context.Space.DoorwayWidth,
  991. CostTotal: total,
  992. Index: -1,
  993. }}
  994. if context.Region.Material == 52 || context.Region.Material == 53 || context.Region.Material == 54 {
  995. mat := context.GetMat(55)
  996. if mat == nil {
  997. return nil, errors.New("找不到材料: " + db.ToString(55))
  998. }
  999. typ, ok := context.MatTypeCache[mat.TypeId]
  1000. if !ok {
  1001. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  1002. }
  1003. number := utils.FloatMul(8, context.Space.DoorwayWidth, 3)
  1004. total := utils.FloatMul(mat.Price, number, 3)
  1005. materials = append(materials, MaterialItem{
  1006. Material: 55,
  1007. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  1008. Type: "钢筋成本",
  1009. Unit: typ.Unit,
  1010. Number: number,
  1011. Price: mat.Price,
  1012. Total: total,
  1013. CostNumber: number,
  1014. CostTotal: total,
  1015. Index: -1,
  1016. })
  1017. }
  1018. return materials, nil
  1019. },
  1020. NoUpgrade: true,
  1021. },
  1022. {
  1023. ItemSelect: func(context *ItemContext) (string, error) {
  1024. mat := context.GetMat(context.Region.Material)
  1025. if mat == nil {
  1026. return "", nil
  1027. }
  1028. if mat.TypeId == 6 {
  1029. return "地面贴砖(600*1200mm)", nil
  1030. }
  1031. if mat.TypeId == 7 {
  1032. return "地面贴砖(750*1500mm)", nil
  1033. }
  1034. return "地面贴砖(300*300mm-800*800mm)", nil
  1035. },
  1036. Region: "地砖",
  1037. NumberCalc: func(context *ItemContext) (float64, error) {
  1038. number := context.Space.Area
  1039. if context.Space.WideBed {
  1040. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  1041. }
  1042. return number, nil
  1043. },
  1044. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  1045. return 0, nil
  1046. },
  1047. DiffPriceCalc: func(context *ItemContext) (float64, error) {
  1048. price, err := context.Item.GetPrice(context)
  1049. if err != nil {
  1050. return 0, err
  1051. }
  1052. if price < 68 {
  1053. return 0, nil
  1054. }
  1055. return utils.FloatSub(price, 68, -1), nil
  1056. },
  1057. },
  1058. {
  1059. Region: "地砖",
  1060. NumberCalc: func(context *ItemContext) (float64, error) {
  1061. number := context.Space.Area
  1062. if context.Space.WideBed {
  1063. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  1064. }
  1065. return number, nil
  1066. },
  1067. LossCalc: func(context *ItemContext) (float64, error) {
  1068. mat := context.GetMat(context.Region.Material)
  1069. if mat == nil {
  1070. return 1, nil
  1071. }
  1072. loss := map[int64]float64{
  1073. 10: 1.08, 9: 1.08, 7: 1.1, 6: 1.1, 5: 1.1, 4: 1.08, 3: 1.08,
  1074. }
  1075. return loss[mat.TypeId], nil
  1076. },
  1077. ConvertCalc: func(context *ItemContext) (float64, error) {
  1078. mat := context.GetMat(context.Region.Material)
  1079. if mat == nil {
  1080. return 1, nil
  1081. }
  1082. area := map[int64]float64{
  1083. 10: 0.09, 9: 0.18, 7: 1.125, 6: 0.72, 5: 0.64, 4: 0.16, 3: 0.32,
  1084. }
  1085. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  1086. },
  1087. CostLossCalc: func(context *ItemContext) (float64, error) {
  1088. mat := context.GetMat(context.Region.Material)
  1089. if mat == nil {
  1090. return 1, nil
  1091. }
  1092. loss := map[int64]float64{
  1093. 110: 1.1, 10: 1.2, 9: 1.2, 7: 1.2, 6: 1.2, 5: 1.2, 4: 1.2, 3: 1.2,
  1094. }
  1095. return loss[mat.TypeId], nil
  1096. },
  1097. Unit: "m²",
  1098. MaterialRound: true,
  1099. ControlPrice: map[int]float64{A10: 81, A8: 56, A5: 36, ZZ1_0: 56},
  1100. DeductionPrice: map[int]float64{A10: 55, A8: 40, A5: 30, ZZ1_0: 40},
  1101. },
  1102. {
  1103. Item: "地砖铺贴后成品保护",
  1104. NumberCalc: func(context *ItemContext) (float64, error) {
  1105. number := context.Space.Area
  1106. if context.Space.WideBed {
  1107. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  1108. }
  1109. return number, nil
  1110. },
  1111. },
  1112. {
  1113. ItemSelect: func(context *ItemContext) (string, error) {
  1114. mat := context.GetMat(context.Region.Material)
  1115. if mat == nil {
  1116. return "", nil
  1117. }
  1118. if mat.TypeId == 6 {
  1119. return "墙面贴砖(600*1200mm)", nil
  1120. }
  1121. if mat.TypeId == 7 {
  1122. return "墙面贴砖(750*1500mm)", nil
  1123. }
  1124. if mat.TypeId == 4 || mat.TypeId == 3 {
  1125. return "墙面贴砖(400*800mm)", nil
  1126. }
  1127. return "墙面贴砖(300*300mm-300*600mm)", nil
  1128. },
  1129. Region: "墙砖",
  1130. NumberCalc: func(context *ItemContext) (float64, error) {
  1131. number := utils.FloatSub(utils.FloatMul(context.Space.Perimeter, 2.4, -1), utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayHeight, -1), -1)
  1132. if context.Space.Windows != nil {
  1133. for _, window := range context.Space.Windows {
  1134. number = utils.FloatSub(number, utils.FloatMul(window.Length, window.Height, -1), -1)
  1135. number = utils.FloatAdd(number, utils.FloatMul(utils.FloatMul(utils.FloatAdd(window.Length, window.Height, -1), 2, -1), window.Width, -1), -1)
  1136. }
  1137. }
  1138. return number, nil
  1139. },
  1140. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  1141. return 0, nil
  1142. },
  1143. },
  1144. {
  1145. Region: "墙砖",
  1146. NumberCalc: func(context *ItemContext) (float64, error) {
  1147. number := utils.FloatSub(utils.FloatMul(context.Space.Perimeter, 2.4, -1), utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayHeight, -1), -1)
  1148. if context.Space.Windows != nil {
  1149. for _, window := range context.Space.Windows {
  1150. number = utils.FloatSub(number, utils.FloatMul(window.Length, window.Height, -1), -1)
  1151. number = utils.FloatAdd(number, utils.FloatMul(utils.FloatMul(utils.FloatAdd(window.Length, window.Height, -1), 2, -1), window.Width, -1), -1)
  1152. }
  1153. }
  1154. return number, nil
  1155. },
  1156. LossCalc: func(context *ItemContext) (float64, error) {
  1157. mat := context.GetMat(context.Region.Material)
  1158. if mat == nil {
  1159. return 1, nil
  1160. }
  1161. loss := map[int64]float64{
  1162. 10: 1.08, 9: 1.08, 7: 1.1, 6: 1.1, 5: 1.1, 4: 1.08, 3: 1.08,
  1163. }
  1164. return loss[mat.TypeId], nil
  1165. },
  1166. ConvertCalc: func(context *ItemContext) (float64, error) {
  1167. mat := context.GetMat(context.Region.Material)
  1168. if mat == nil {
  1169. return 1, nil
  1170. }
  1171. area := map[int64]float64{
  1172. 10: 0.09, 9: 0.18, 7: 1.125, 6: 0.72, 5: 0.64, 4: 0.16, 3: 0.32,
  1173. }
  1174. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  1175. },
  1176. CostLossCalc: func(context *ItemContext) (float64, error) {
  1177. mat := context.GetMat(context.Region.Material)
  1178. if mat == nil {
  1179. return 1, nil
  1180. }
  1181. loss := map[int64]float64{
  1182. 110: 1.1, 10: 1.2, 9: 1.2, 7: 1.2, 6: 1.2, 5: 1.2, 4: 1.2, 3: 1.2,
  1183. }
  1184. return loss[mat.TypeId], nil
  1185. },
  1186. Unit: "m²",
  1187. MaterialRound: true,
  1188. ControlPrice: map[int]float64{A10: 81, A8: 56, A5: 31, ZZ1_0: 56},
  1189. DeductionPrice: map[int]float64{A10: 55, A8: 40, A5: 30, ZZ1_0: 40},
  1190. },
  1191. {
  1192. Region: "橱柜地柜",
  1193. NumberCalc: func(context *ItemContext) (float64, error) {
  1194. number := utils.FloatSub(utils.FloatDiv(context.Space.Perimeter, 2, -1), 0.6, -1)
  1195. if number < 4.5 {
  1196. number = 4.5
  1197. }
  1198. return number, nil
  1199. },
  1200. Unit: "m",
  1201. ControlPrice: map[int]float64{A10: 592, A8: 460, A5: 306, ZZ1_0: 460},
  1202. DeductionPrice: map[int]float64{A10: 450, A8: 410, A5: 410, ZZ1_0: 410},
  1203. },
  1204. {
  1205. Region: "橱柜吊柜",
  1206. NumberCalc: func(context *ItemContext) (float64, error) {
  1207. number := utils.FloatSub(utils.FloatDiv(context.Space.Perimeter, 2, -1), 1.6, -1)
  1208. if number < 3.5 {
  1209. number = 3.5
  1210. }
  1211. return number, nil
  1212. },
  1213. Unit: "m",
  1214. ControlPrice: map[int]float64{A10: 343, A8: 170, A5: 294, ZZ1_0: 170},
  1215. DeductionPrice: map[int]float64{A10: 320, A8: 170, A5: 170, ZZ1_0: 170},
  1216. },
  1217. {
  1218. Region: "橱柜台面",
  1219. NumberCalc: func(context *ItemContext) (float64, error) {
  1220. number := utils.FloatSub(utils.FloatDiv(context.Space.Perimeter, 2, -1), 0.6, -1)
  1221. if number < 4.5 {
  1222. number = 4.5
  1223. }
  1224. return number, nil
  1225. },
  1226. Unit: "m",
  1227. ControlPrice: map[int]float64{A10: 515, A8: 450, A5: 380, ZZ1_0: 450},
  1228. DeductionPrice: map[int]float64{A10: 420, A8: 392, A5: 320, ZZ1_0: 390},
  1229. },
  1230. {
  1231. Region: "燃气包管",
  1232. Number: 1,
  1233. Unit: "根",
  1234. ControlPrice: map[int]float64{A10: 120, A8: 120, A5: 120, ZZ1_0: 120},
  1235. DeductionPrice: map[int]float64{A10: 120, A8: 120, A5: 120, ZZ1_0: 120},
  1236. },
  1237. {
  1238. Region: "洗菜盆及龙头",
  1239. Number: 1,
  1240. Unit: "套",
  1241. ControlPrice: map[int]float64{A10: 468, A8: 468, A5: 468, ZZ1_0: 468},
  1242. DeductionPrice: map[int]float64{A10: 420, A8: 420, A5: 420, ZZ1_0: 420},
  1243. },
  1244. {
  1245. Region: "集成吊顶",
  1246. NumberCalc: func(context *ItemContext) (float64, error) {
  1247. return context.Space.Area, nil
  1248. },
  1249. Loss: 1.08,
  1250. ConvertCalc: func(context *ItemContext) (float64, error) {
  1251. mat := context.GetMat(context.Region.Material)
  1252. if mat == nil {
  1253. return 1, nil
  1254. }
  1255. area := map[int64]float64{
  1256. 128: 1, 188: 0.18, 187: 0.09,
  1257. }
  1258. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  1259. },
  1260. Unit: "m²",
  1261. MaterialRound: true,
  1262. ControlPrice: map[int]float64{A10: 90, A8: 90, A5: 75, ZZ1_0: 90},
  1263. DeductionPrice: map[int]float64{A10: 80, A8: 80, A5: 70, ZZ1_0: 80},
  1264. },
  1265. {
  1266. Region: "吊顶灯",
  1267. Number: 1,
  1268. Unit: "个",
  1269. ControlPrice: map[int]float64{A10: 38, A8: 38, A5: 38, ZZ1_0: 38},
  1270. DeductionPrice: map[int]float64{A10: 40, A8: 40, A5: 40, ZZ1_0: 40},
  1271. },
  1272. {
  1273. Item: "烟道挂网加固",
  1274. Number: 1,
  1275. },
  1276. },
  1277. 3: {
  1278. {
  1279. Region: "平开门",
  1280. NumberCalc: func(context *ItemContext) (float64, error) {
  1281. return 1, nil
  1282. },
  1283. Unit: "樘",
  1284. ControlPrice: map[int]float64{A10: 865, A8: 780, A5: 780, ZZ1_0: 900},
  1285. DeductionPrice: map[int]float64{A10: 850, A8: 750, A5: 700, ZZ1_0: 750},
  1286. MaterialAdditionalItemCalc: func(context *ItemContext) ([]PersonalItem, error) {
  1287. items := make([]PersonalItem, 0)
  1288. mat := context.GetMat(context.Region.Material)
  1289. if mat != nil && mat.TypeId == 105 {
  1290. if context.Space.DoorwayHeight > 2 {
  1291. //number := math.Ceil(utils.FloatMul(utils.FloatSub(context.Space.DoorwayHeight, 2, -1), 100, -1))
  1292. //total := math.Round(utils.FloatMul(15, number, 3))
  1293. items = append(items, PersonalItem{
  1294. Name: context.GetSpaceName() + " 平开门(" + mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color + ") 超高度",
  1295. Unit: "套",
  1296. Number: 1,
  1297. Price: 60,
  1298. Total: 60,
  1299. Index: -1,
  1300. })
  1301. }
  1302. if context.Space.DoorwayWidth > 0.8 {
  1303. //number := math.Ceil(utils.FloatMul(utils.FloatSub(context.Space.DoorwayWidth, 0.8, -1), 100, -1))
  1304. //total := math.Round(utils.FloatMul(15, number, 3))
  1305. items = append(items, PersonalItem{
  1306. Name: context.GetSpaceName() + " 平开门(" + mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color + ") 超宽度",
  1307. Unit: "套",
  1308. Number: 1,
  1309. Price: 60,
  1310. Total: 60,
  1311. Index: -1,
  1312. })
  1313. }
  1314. if context.Space.DoorwayWallThickness > 0.28 {
  1315. //number := math.Ceil(utils.FloatMul(utils.FloatSub(context.Space.DoorwayWallThickness, 0.28, -1), 100, -1))
  1316. //total := math.Round(utils.FloatMul(25, number, 3))
  1317. items = append(items, PersonalItem{
  1318. Name: context.GetSpaceName() + " 平开门(" + mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color + ") 超墙厚",
  1319. Unit: "套",
  1320. Number: 1,
  1321. Price: 60,
  1322. Total: 60,
  1323. Index: -1,
  1324. })
  1325. }
  1326. }
  1327. return items, nil
  1328. },
  1329. },
  1330. {
  1331. Item: "安装门槛石",
  1332. NumberCalc: func(context *ItemContext) (float64, error) {
  1333. if context.Space.WideBed {
  1334. return 0, nil
  1335. }
  1336. return context.Space.DoorwayWidth, nil
  1337. },
  1338. },
  1339. {
  1340. Region: "门槛石",
  1341. NumberCalc: func(context *ItemContext) (float64, error) {
  1342. if context.Space.WideBed {
  1343. return 0, nil
  1344. }
  1345. return context.Space.DoorwayWidth, nil
  1346. },
  1347. ConvertCalc: func(context *ItemContext) (float64, error) {
  1348. return float64(context.Space.DoorwayWallThickness), nil
  1349. },
  1350. Unit: "m",
  1351. ControlPrice: map[int]float64{A10: 89, A8: 89, A5: 0, ZZ1_0: 89},
  1352. AdditionalMaterialCalc: func(context *ItemContext) ([]MaterialItem, error) {
  1353. mat := context.GetMat(1610)
  1354. if mat == nil {
  1355. return nil, errors.New("找不到材料: " + db.ToString(1610))
  1356. }
  1357. typ, ok := context.MatTypeCache[mat.TypeId]
  1358. if !ok {
  1359. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  1360. }
  1361. total := utils.FloatMul(mat.Price, context.Space.DoorwayWidth, 3)
  1362. materials := []MaterialItem{{
  1363. Material: 1610,
  1364. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  1365. Type: "门槛石",
  1366. Unit: typ.Unit,
  1367. Number: context.Space.DoorwayWidth,
  1368. Price: mat.Price,
  1369. Total: total,
  1370. CostNumber: context.Space.DoorwayWidth,
  1371. CostTotal: total,
  1372. Index: -1,
  1373. }}
  1374. if context.Region.Material == 52 || context.Region.Material == 53 || context.Region.Material == 54 {
  1375. mat := context.GetMat(55)
  1376. if mat == nil {
  1377. return nil, errors.New("找不到材料: " + db.ToString(55))
  1378. }
  1379. typ, ok := context.MatTypeCache[mat.TypeId]
  1380. if !ok {
  1381. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  1382. }
  1383. number := utils.FloatMul(8, context.Space.DoorwayWidth, 3)
  1384. total := utils.FloatMul(mat.Price, number, 3)
  1385. materials = append(materials, MaterialItem{
  1386. Material: 55,
  1387. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  1388. Type: "钢筋成本",
  1389. Unit: typ.Unit,
  1390. Number: number,
  1391. Price: mat.Price,
  1392. Total: total,
  1393. CostNumber: number,
  1394. CostTotal: total,
  1395. Index: -1,
  1396. })
  1397. }
  1398. return materials, nil
  1399. },
  1400. NoUpgrade: true,
  1401. },
  1402. {
  1403. ItemSelect: func(context *ItemContext) (string, error) {
  1404. mat := context.GetMat(context.Region.Material)
  1405. if mat == nil {
  1406. return "", nil
  1407. }
  1408. if mat.TypeId == 6 {
  1409. return "地面贴砖(600*1200mm)", nil
  1410. }
  1411. if mat.TypeId == 7 {
  1412. return "地面贴砖(750*1500mm)", nil
  1413. }
  1414. return "地面贴砖(300*300mm-800*800mm)", nil
  1415. },
  1416. Region: "地砖",
  1417. NumberCalc: func(context *ItemContext) (float64, error) {
  1418. if context.Space.DryWetSeparation {
  1419. return 0, nil
  1420. }
  1421. number := context.Space.Area
  1422. if context.Space.WideBed {
  1423. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  1424. }
  1425. return number, nil
  1426. },
  1427. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  1428. return 0, nil
  1429. },
  1430. DiffPriceCalc: func(context *ItemContext) (float64, error) {
  1431. price, err := context.Item.GetPrice(context)
  1432. if err != nil {
  1433. return 0, err
  1434. }
  1435. if price < 68 {
  1436. return 0, nil
  1437. }
  1438. return utils.FloatSub(price, 68, -1), nil
  1439. },
  1440. },
  1441. {
  1442. ItemSelect: func(context *ItemContext) (string, error) {
  1443. mat := context.GetMat(context.Region.Material)
  1444. if mat == nil {
  1445. return "", nil
  1446. }
  1447. if mat.TypeId == 6 {
  1448. return "地面贴砖(600*1200mm)", nil
  1449. }
  1450. if mat.TypeId == 7 {
  1451. return "地面贴砖(750*1500mm)", nil
  1452. }
  1453. return "地面贴砖(300*300mm-800*800mm)", nil
  1454. },
  1455. Region: "干区地砖",
  1456. NumberCalc: func(context *ItemContext) (float64, error) {
  1457. if context.Space.DryWetSeparation {
  1458. return context.Space.Area, nil
  1459. }
  1460. return 0, nil
  1461. },
  1462. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  1463. return 0, nil
  1464. },
  1465. DiffPriceCalc: func(context *ItemContext) (float64, error) {
  1466. price, err := context.Item.GetPrice(context)
  1467. if err != nil {
  1468. return 0, err
  1469. }
  1470. if price < 68 {
  1471. return 0, nil
  1472. }
  1473. return utils.FloatSub(price, 68, -1), nil
  1474. },
  1475. },
  1476. {
  1477. ItemSelect: func(context *ItemContext) (string, error) {
  1478. mat := context.GetMat(context.Region.Material)
  1479. if mat == nil {
  1480. return "", nil
  1481. }
  1482. if mat.TypeId == 6 {
  1483. return "地面贴砖(600*1200mm)", nil
  1484. }
  1485. if mat.TypeId == 7 {
  1486. return "地面贴砖(750*1500mm)", nil
  1487. }
  1488. return "地面贴砖(300*300mm-800*800mm)", nil
  1489. },
  1490. Region: "湿区地砖",
  1491. NumberCalc: func(context *ItemContext) (float64, error) {
  1492. if context.Space.DryWetSeparation {
  1493. return context.Space.WetArea, nil
  1494. }
  1495. return 0, nil
  1496. },
  1497. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  1498. return 0, nil
  1499. },
  1500. DiffPriceCalc: func(context *ItemContext) (float64, error) {
  1501. price, err := context.Item.GetPrice(context)
  1502. if err != nil {
  1503. return 0, err
  1504. }
  1505. if price < 68 {
  1506. return 0, nil
  1507. }
  1508. return utils.FloatSub(price, 68, -1), nil
  1509. },
  1510. },
  1511. {
  1512. Region: "地砖",
  1513. NumberCalc: func(context *ItemContext) (float64, error) {
  1514. if context.Space.DryWetSeparation {
  1515. return 0, nil
  1516. }
  1517. number := context.Space.Area
  1518. if context.Space.WideBed {
  1519. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  1520. }
  1521. return number, nil
  1522. },
  1523. LossCalc: func(context *ItemContext) (float64, error) {
  1524. mat := context.GetMat(context.Region.Material)
  1525. if mat == nil {
  1526. return 1, nil
  1527. }
  1528. loss := map[int64]float64{
  1529. 10: 1.08, 9: 1.08, 7: 1.1, 6: 1.1, 5: 1.1, 4: 1.08, 3: 1.08,
  1530. }
  1531. return loss[mat.TypeId], nil
  1532. },
  1533. ConvertCalc: func(context *ItemContext) (float64, error) {
  1534. mat := context.GetMat(context.Region.Material)
  1535. if mat == nil {
  1536. return 1, nil
  1537. }
  1538. area := map[int64]float64{
  1539. 10: 0.09, 9: 0.18, 7: 1.125, 6: 0.72, 5: 0.64, 4: 0.16, 3: 0.32,
  1540. }
  1541. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  1542. },
  1543. CostLossCalc: func(context *ItemContext) (float64, error) {
  1544. mat := context.GetMat(context.Region.Material)
  1545. if mat == nil {
  1546. return 1, nil
  1547. }
  1548. loss := map[int64]float64{
  1549. 110: 1.1, 10: 1.2, 9: 1.2, 7: 1.2, 6: 1.2, 5: 1.2, 4: 1.2, 3: 1.2,
  1550. }
  1551. return loss[mat.TypeId], nil
  1552. },
  1553. Unit: "m²",
  1554. MaterialRound: true,
  1555. ControlPrice: map[int]float64{A10: 81, A8: 56, A5: 36, ZZ1_0: 56},
  1556. DeductionPrice: map[int]float64{A10: 55, A8: 40, A5: 30, ZZ1_0: 40},
  1557. },
  1558. {
  1559. Region: "干区地砖",
  1560. NumberCalc: func(context *ItemContext) (float64, error) {
  1561. if context.Space.DryWetSeparation {
  1562. return context.Space.Area, nil
  1563. }
  1564. return 0, nil
  1565. },
  1566. LossCalc: func(context *ItemContext) (float64, error) {
  1567. mat := context.GetMat(context.Region.Material)
  1568. if mat == nil {
  1569. return 1, nil
  1570. }
  1571. loss := map[int64]float64{
  1572. 10: 1.08, 9: 1.08, 7: 1.1, 6: 1.1, 5: 1.1, 4: 1.08, 3: 1.08,
  1573. }
  1574. return loss[mat.TypeId], nil
  1575. },
  1576. ConvertCalc: func(context *ItemContext) (float64, error) {
  1577. mat := context.GetMat(context.Region.Material)
  1578. if mat == nil {
  1579. return 1, nil
  1580. }
  1581. area := map[int64]float64{
  1582. 10: 0.09, 9: 0.18, 7: 1.125, 6: 0.72, 5: 0.64, 4: 0.16, 3: 0.32,
  1583. }
  1584. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  1585. },
  1586. CostLossCalc: func(context *ItemContext) (float64, error) {
  1587. mat := context.GetMat(context.Region.Material)
  1588. if mat == nil {
  1589. return 1, nil
  1590. }
  1591. loss := map[int64]float64{
  1592. 110: 1.1, 10: 1.2, 9: 1.2, 7: 1.2, 6: 1.2, 5: 1.2, 4: 1.2, 3: 1.2,
  1593. }
  1594. return loss[mat.TypeId], nil
  1595. },
  1596. Unit: "m²",
  1597. MaterialRound: true,
  1598. ControlPrice: map[int]float64{A10: 81, A8: 56, A5: 36, ZZ1_0: 56},
  1599. DeductionPrice: map[int]float64{A10: 55, A8: 40, A5: 30, ZZ1_0: 40},
  1600. },
  1601. {
  1602. Region: "湿区地砖",
  1603. NumberCalc: func(context *ItemContext) (float64, error) {
  1604. if context.Space.DryWetSeparation {
  1605. return context.Space.WetArea, nil
  1606. }
  1607. return 0, nil
  1608. },
  1609. LossCalc: func(context *ItemContext) (float64, error) {
  1610. mat := context.GetMat(context.Region.Material)
  1611. if mat == nil {
  1612. return 1, nil
  1613. }
  1614. loss := map[int64]float64{
  1615. 10: 1.08, 9: 1.08, 7: 1.1, 6: 1.1, 5: 1.1, 4: 1.08, 3: 1.08,
  1616. }
  1617. return loss[mat.TypeId], nil
  1618. },
  1619. ConvertCalc: func(context *ItemContext) (float64, error) {
  1620. mat := context.GetMat(context.Region.Material)
  1621. if mat == nil {
  1622. return 1, nil
  1623. }
  1624. area := map[int64]float64{
  1625. 10: 0.09, 9: 0.18, 7: 1.125, 6: 0.72, 5: 0.64, 4: 0.16, 3: 0.32,
  1626. }
  1627. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  1628. },
  1629. CostLossCalc: func(context *ItemContext) (float64, error) {
  1630. mat := context.GetMat(context.Region.Material)
  1631. if mat == nil {
  1632. return 1, nil
  1633. }
  1634. loss := map[int64]float64{
  1635. 110: 1.1, 10: 1.2, 9: 1.2, 7: 1.2, 6: 1.2, 5: 1.2, 4: 1.2, 3: 1.2,
  1636. }
  1637. return loss[mat.TypeId], nil
  1638. },
  1639. Unit: "m²",
  1640. MaterialRound: true,
  1641. ControlPrice: map[int]float64{A10: 81, A8: 56, A5: 36, ZZ1_0: 56},
  1642. DeductionPrice: map[int]float64{A10: 55, A8: 40, A5: 30, ZZ1_0: 40},
  1643. },
  1644. {
  1645. Item: "地面找平",
  1646. NumberCalc: func(context *ItemContext) (float64, error) {
  1647. number := context.Space.Area
  1648. if context.Space.DryWetSeparation {
  1649. number = utils.FloatAdd(number, context.Space.WetArea, -1)
  1650. }
  1651. if context.Space.WideBed {
  1652. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  1653. }
  1654. return number, nil
  1655. },
  1656. },
  1657. {
  1658. Item: "地砖铺贴后成品保护",
  1659. NumberCalc: func(context *ItemContext) (float64, error) {
  1660. number := context.Space.Area
  1661. if context.Space.DryWetSeparation {
  1662. number = utils.FloatAdd(number, context.Space.WetArea, -1)
  1663. }
  1664. if context.Space.WideBed {
  1665. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  1666. }
  1667. return number, nil
  1668. },
  1669. },
  1670. {
  1671. Item: "卫生间地面防水",
  1672. NumberCalc: func(context *ItemContext) (float64, error) {
  1673. number := context.Space.Area
  1674. if context.Space.DryWetSeparation {
  1675. number = utils.FloatAdd(number, context.Space.WetArea, -1)
  1676. }
  1677. if context.Space.WideBed {
  1678. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  1679. }
  1680. return number, nil
  1681. },
  1682. },
  1683. {
  1684. ItemSelect: func(context *ItemContext) (string, error) {
  1685. mat := context.GetMat(context.Region.Material)
  1686. if mat == nil {
  1687. return "", nil
  1688. }
  1689. if mat.TypeId == 6 {
  1690. return "墙面贴砖(600*1200mm)", nil
  1691. }
  1692. if mat.TypeId == 7 {
  1693. return "墙面贴砖(750*1500mm)", nil
  1694. }
  1695. if mat.TypeId == 4 || mat.TypeId == 3 {
  1696. return "墙面贴砖(400*800mm)", nil
  1697. }
  1698. return "墙面贴砖(300*300mm-300*600mm)", nil
  1699. },
  1700. Region: "墙砖",
  1701. NumberCalc: func(context *ItemContext) (float64, error) {
  1702. number := utils.FloatSub(utils.FloatMul(context.Space.Perimeter, 2.4, -1), utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayHeight, -1), -1)
  1703. if context.Space.Windows != nil {
  1704. for _, window := range context.Space.Windows {
  1705. number = utils.FloatSub(number, utils.FloatMul(window.Length, window.Height, -1), -1)
  1706. number = utils.FloatAdd(number, utils.FloatMul(utils.FloatMul(utils.FloatAdd(window.Length, window.Height, -1), 2, -1), window.Width, -1), -1)
  1707. }
  1708. }
  1709. return number, nil
  1710. },
  1711. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  1712. return 0, nil
  1713. },
  1714. },
  1715. {
  1716. Region: "墙砖",
  1717. NumberCalc: func(context *ItemContext) (float64, error) {
  1718. number := utils.FloatSub(utils.FloatMul(context.Space.Perimeter, 2.4, -1), utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayHeight, -1), -1)
  1719. if context.Space.Windows != nil {
  1720. for _, window := range context.Space.Windows {
  1721. number = utils.FloatSub(number, utils.FloatMul(window.Length, window.Height, -1), -1)
  1722. number = utils.FloatAdd(number, utils.FloatMul(utils.FloatMul(utils.FloatAdd(window.Length, window.Height, -1), 2, -1), window.Width, -1), -1)
  1723. }
  1724. }
  1725. return number, nil
  1726. },
  1727. LossCalc: func(context *ItemContext) (float64, error) {
  1728. mat := context.GetMat(context.Region.Material)
  1729. if mat == nil {
  1730. return 1, nil
  1731. }
  1732. loss := map[int64]float64{
  1733. 10: 1.08, 9: 1.08, 7: 1.1, 6: 1.1, 5: 1.1, 4: 1.08, 3: 1.08,
  1734. }
  1735. return loss[mat.TypeId], nil
  1736. },
  1737. ConvertCalc: func(context *ItemContext) (float64, error) {
  1738. mat := context.GetMat(context.Region.Material)
  1739. if mat == nil {
  1740. return 1, nil
  1741. }
  1742. area := map[int64]float64{
  1743. 10: 0.09, 9: 0.18, 7: 1.125, 6: 0.72, 5: 0.64, 4: 0.16, 3: 0.32,
  1744. }
  1745. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  1746. },
  1747. CostLossCalc: func(context *ItemContext) (float64, error) {
  1748. mat := context.GetMat(context.Region.Material)
  1749. if mat == nil {
  1750. return 1, nil
  1751. }
  1752. loss := map[int64]float64{
  1753. 110: 1.1, 10: 1.2, 9: 1.2, 7: 1.2, 6: 1.2, 5: 1.2, 4: 1.2, 3: 1.2,
  1754. }
  1755. return loss[mat.TypeId], nil
  1756. },
  1757. Unit: "m²",
  1758. MaterialRound: true,
  1759. ControlPrice: map[int]float64{A10: 81, A8: 56, A5: 31, ZZ1_0: 56},
  1760. DeductionPrice: map[int]float64{A10: 55, A8: 40, A5: 30, ZZ1_0: 40},
  1761. },
  1762. {
  1763. Item: "卫生间墙面防水",
  1764. NumberCalc: func(context *ItemContext) (float64, error) {
  1765. return context.Space.Perimeter * 1.5, nil
  1766. },
  1767. },
  1768. {
  1769. Region: "浴室柜(含龙头)",
  1770. Number: 1,
  1771. Unit: "套",
  1772. ControlPrice: map[int]float64{A10: 1630, A8: 1000, A5: 960, ZZ1_0: 1000},
  1773. DeductionPrice: map[int]float64{A10: 1500, A8: 1000, A5: 900, ZZ1_0: 1000},
  1774. },
  1775. {
  1776. Region: "淋浴花洒",
  1777. Number: 1,
  1778. Unit: "套",
  1779. ControlPrice: map[int]float64{A10: 650, A8: 390, A5: 400, ZZ1_0: 400},
  1780. DeductionPrice: map[int]float64{A10: 600, A8: 390, A5: 350, ZZ1_0: 390},
  1781. },
  1782. {
  1783. Region: "马桶蹲坑",
  1784. Number: 1,
  1785. Unit: "套",
  1786. ControlPrice: map[int]float64{A10: 720, A8: 450, A5: 500, ZZ1_0: 460},
  1787. DeductionPrice: map[int]float64{A10: 650, A8: 450, A5: 420, ZZ1_0: 450},
  1788. },
  1789. {
  1790. Region: "集成吊顶",
  1791. NumberCalc: func(context *ItemContext) (float64, error) {
  1792. number := context.Space.Area
  1793. if context.Space.DryWetSeparation {
  1794. number = utils.FloatAdd(number, context.Space.WetArea, -1)
  1795. }
  1796. return number, nil
  1797. },
  1798. Loss: 1.08,
  1799. ConvertCalc: func(context *ItemContext) (float64, error) {
  1800. mat := context.GetMat(context.Region.Material)
  1801. if mat == nil {
  1802. return 1, nil
  1803. }
  1804. area := map[int64]float64{
  1805. 128: 1, 188: 0.18, 187: 0.09,
  1806. }
  1807. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  1808. },
  1809. Unit: "m²",
  1810. MaterialRound: true,
  1811. ControlPrice: map[int]float64{A10: 90, A8: 90, A5: 75, ZZ1_0: 90},
  1812. DeductionPrice: map[int]float64{A10: 80, A8: 80, A5: 70, ZZ1_0: 80},
  1813. },
  1814. /*{
  1815. Region: "吊顶灯",
  1816. Number: 1,
  1817. Unit: "个",
  1818. ControlPrice: map[int]float64{A10: 38, A8: 38, A5: 38},
  1819. DeductionPrice: map[int]float64{A10: 40, A8: 40, A5: 40},
  1820. },*/
  1821. {
  1822. Region: "浴霸",
  1823. NumberCalc: func(context *ItemContext) (float64, error) {
  1824. if context.Pkg.RoomData.Pkg.Type == ZZ1_0 {
  1825. return 1, nil
  1826. }
  1827. return 0, nil
  1828. },
  1829. Unit: "个",
  1830. ControlPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 242},
  1831. DeductionPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 235},
  1832. },
  1833. {
  1834. Region: "淋浴隔断",
  1835. NumberCalc: func(context *ItemContext) (float64, error) {
  1836. if context.Pkg.RoomData.Pkg.Type == ZZ1_0 {
  1837. return 3.2, nil
  1838. }
  1839. return 0, nil
  1840. },
  1841. Unit: "m²",
  1842. ControlPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 285},
  1843. DeductionPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 850 / 3.2},
  1844. },
  1845. {
  1846. Item: "安装石基",
  1847. Region: "石基",
  1848. NumberCalc: func(context *ItemContext) (float64, error) {
  1849. if context.Pkg.RoomData.Pkg.Type == ZZ1_0 {
  1850. return 1.6, nil
  1851. }
  1852. return 0, nil
  1853. },
  1854. Unit: "m",
  1855. ControlPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 35},
  1856. DeductionPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 50 / 1.6},
  1857. },
  1858. {
  1859. Region: "五金挂件",
  1860. NumberCalc: func(context *ItemContext) (float64, error) {
  1861. return 1, nil
  1862. },
  1863. Unit: "套",
  1864. ControlPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 238},
  1865. DeductionPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 190},
  1866. },
  1867. },
  1868. 4: {
  1869. {
  1870. Item: "安装门槛石",
  1871. NumberCalc: func(context *ItemContext) (float64, error) {
  1872. if context.Space.WideBed {
  1873. return 0, nil
  1874. }
  1875. return context.Space.DoorwayWidth, nil
  1876. },
  1877. },
  1878. {
  1879. Region: "门槛石",
  1880. NumberCalc: func(context *ItemContext) (float64, error) {
  1881. if context.Space.WideBed {
  1882. return 0, nil
  1883. }
  1884. return context.Space.DoorwayWidth, nil
  1885. },
  1886. ConvertCalc: func(context *ItemContext) (float64, error) {
  1887. return float64(context.Space.DoorwayWallThickness), nil
  1888. },
  1889. Unit: "m",
  1890. ControlPrice: map[int]float64{A10: 89, A8: 89, A5: 0, ZZ1_0: 89},
  1891. AdditionalMaterialCalc: func(context *ItemContext) ([]MaterialItem, error) {
  1892. mat := context.GetMat(1610)
  1893. if mat == nil {
  1894. return nil, errors.New("找不到材料: " + db.ToString(1610))
  1895. }
  1896. typ, ok := context.MatTypeCache[mat.TypeId]
  1897. if !ok {
  1898. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  1899. }
  1900. total := utils.FloatMul(mat.Price, context.Space.DoorwayWidth, 3)
  1901. materials := []MaterialItem{{
  1902. Material: 1610,
  1903. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  1904. Type: "门槛石",
  1905. Unit: typ.Unit,
  1906. Number: context.Space.DoorwayWidth,
  1907. Price: mat.Price,
  1908. Total: total,
  1909. CostNumber: context.Space.DoorwayWidth,
  1910. CostTotal: total,
  1911. Index: -1,
  1912. }}
  1913. if context.Region.Material == 52 || context.Region.Material == 53 || context.Region.Material == 54 {
  1914. mat := context.GetMat(55)
  1915. if mat == nil {
  1916. return nil, errors.New("找不到材料: " + db.ToString(55))
  1917. }
  1918. typ, ok := context.MatTypeCache[mat.TypeId]
  1919. if !ok {
  1920. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  1921. }
  1922. number := utils.FloatMul(8, context.Space.DoorwayWidth, 3)
  1923. total := utils.FloatMul(mat.Price, number, 3)
  1924. materials = append(materials, MaterialItem{
  1925. Material: 55,
  1926. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  1927. Type: "钢筋成本",
  1928. Unit: typ.Unit,
  1929. Number: number,
  1930. Price: mat.Price,
  1931. Total: total,
  1932. CostNumber: number,
  1933. CostTotal: total,
  1934. Index: -1,
  1935. })
  1936. }
  1937. return materials, nil
  1938. },
  1939. NoUpgrade: true,
  1940. },
  1941. {
  1942. ItemSelect: func(context *ItemContext) (string, error) {
  1943. mat := context.GetMat(context.Region.Material)
  1944. if mat == nil {
  1945. return "", nil
  1946. }
  1947. if mat.TypeId == 6 {
  1948. return "墙面贴砖(600*1200mm)", nil
  1949. }
  1950. if mat.TypeId == 7 {
  1951. return "墙面贴砖(750*1500mm)", nil
  1952. }
  1953. if mat.TypeId == 4 || mat.TypeId == 3 {
  1954. return "墙面贴砖(400*800mm)", nil
  1955. }
  1956. return "墙面贴砖(300*300mm-300*600mm)", nil
  1957. },
  1958. Region: "墙砖",
  1959. NumberCalc: func(context *ItemContext) (float64, error) {
  1960. if context.Pkg.RoomData.Pkg.Type != ZZ1_0 {
  1961. return 0, nil
  1962. }
  1963. number := utils.FloatSub(utils.FloatMul(context.Space.Perimeter, 2.4, -1), utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayHeight, -1), -1)
  1964. if context.Space.Windows != nil {
  1965. for _, window := range context.Space.Windows {
  1966. number = utils.FloatSub(number, utils.FloatMul(window.Length, window.Height, -1), -1)
  1967. number = utils.FloatAdd(number, utils.FloatMul(utils.FloatMul(utils.FloatAdd(window.Length, window.Height, -1), 2, -1), window.Width, -1), -1)
  1968. }
  1969. }
  1970. return number, nil
  1971. },
  1972. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  1973. return 0, nil
  1974. },
  1975. },
  1976. {
  1977. Region: "墙砖",
  1978. NumberCalc: func(context *ItemContext) (float64, error) {
  1979. if context.Pkg.RoomData.Pkg.Type != ZZ1_0 {
  1980. return 0, nil
  1981. }
  1982. number := utils.FloatSub(utils.FloatMul(context.Space.Perimeter, 2.4, -1), utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayHeight, -1), -1)
  1983. if context.Space.Windows != nil {
  1984. for _, window := range context.Space.Windows {
  1985. number = utils.FloatSub(number, utils.FloatMul(window.Length, window.Height, -1), -1)
  1986. number = utils.FloatAdd(number, utils.FloatMul(utils.FloatMul(utils.FloatAdd(window.Length, window.Height, -1), 2, -1), window.Width, -1), -1)
  1987. }
  1988. }
  1989. return number, nil
  1990. },
  1991. LossCalc: func(context *ItemContext) (float64, error) {
  1992. mat := context.GetMat(context.Region.Material)
  1993. if mat == nil {
  1994. return 1, nil
  1995. }
  1996. loss := map[int64]float64{
  1997. 10: 1.08, 9: 1.08, 7: 1.1, 6: 1.1, 5: 1.1, 4: 1.08, 3: 1.08,
  1998. }
  1999. return loss[mat.TypeId], nil
  2000. },
  2001. ConvertCalc: func(context *ItemContext) (float64, error) {
  2002. mat := context.GetMat(context.Region.Material)
  2003. if mat == nil {
  2004. return 1, nil
  2005. }
  2006. area := map[int64]float64{
  2007. 10: 0.09, 9: 0.18, 7: 1.125, 6: 0.72, 5: 0.64, 4: 0.16, 3: 0.32,
  2008. }
  2009. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  2010. },
  2011. CostLossCalc: func(context *ItemContext) (float64, error) {
  2012. mat := context.GetMat(context.Region.Material)
  2013. if mat == nil {
  2014. return 1, nil
  2015. }
  2016. loss := map[int64]float64{
  2017. 110: 1.1, 10: 1.2, 9: 1.2, 7: 1.2, 6: 1.2, 5: 1.2, 4: 1.2, 3: 1.2,
  2018. }
  2019. return loss[mat.TypeId], nil
  2020. },
  2021. Unit: "m²",
  2022. MaterialRound: true,
  2023. ControlPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 56},
  2024. DeductionPrice: map[int]float64{A10: 0, A8: 0, A5: 0, ZZ1_0: 40},
  2025. },
  2026. {
  2027. ItemSelect: func(context *ItemContext) (string, error) {
  2028. mat := context.GetMat(context.Region.Material)
  2029. if mat == nil {
  2030. return "", nil
  2031. }
  2032. if mat.TypeId == 6 {
  2033. return "地面贴砖(600*1200mm)", nil
  2034. }
  2035. if mat.TypeId == 7 {
  2036. return "地面贴砖(750*1500mm)", nil
  2037. }
  2038. return "地面贴砖(300*300mm-800*800mm)", nil
  2039. },
  2040. Region: "地砖",
  2041. NumberCalc: func(context *ItemContext) (float64, error) {
  2042. number := context.Space.Area
  2043. if context.Space.WideBed {
  2044. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  2045. }
  2046. return number, nil
  2047. },
  2048. MaterialNumberCalc: func(context *ItemContext) (float64, error) {
  2049. return 0, nil
  2050. },
  2051. DiffPriceCalc: func(context *ItemContext) (float64, error) {
  2052. price, err := context.Item.GetPrice(context)
  2053. if err != nil {
  2054. return 0, err
  2055. }
  2056. if price < 68 {
  2057. return 0, nil
  2058. }
  2059. return utils.FloatSub(price, 68, -1), nil
  2060. },
  2061. },
  2062. {
  2063. Region: "地砖",
  2064. MaterialType: "地砖",
  2065. NumberCalc: func(context *ItemContext) (float64, error) {
  2066. number := context.Space.Area
  2067. if context.Space.WideBed {
  2068. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  2069. }
  2070. return number, nil
  2071. },
  2072. LossCalc: func(context *ItemContext) (float64, error) {
  2073. mat := context.GetMat(context.Region.Material)
  2074. if mat == nil {
  2075. return 1, nil
  2076. }
  2077. loss := map[int64]float64{
  2078. 10: 1.08, 9: 1.08, 7: 1.1, 6: 1.1, 5: 1.1, 4: 1.08, 3: 1.08,
  2079. }
  2080. return loss[mat.TypeId], nil
  2081. },
  2082. ConvertCalc: func(context *ItemContext) (float64, error) {
  2083. mat := context.GetMat(context.Region.Material)
  2084. if mat == nil {
  2085. return 1, nil
  2086. }
  2087. area := map[int64]float64{
  2088. 10: 0.09, 9: 0.18, 7: 1.125, 6: 0.72, 5: 0.64, 4: 0.16, 3: 0.32,
  2089. }
  2090. return utils.FloatDiv(1, area[mat.TypeId], -1), nil
  2091. },
  2092. CostLossCalc: func(context *ItemContext) (float64, error) {
  2093. mat := context.GetMat(context.Region.Material)
  2094. if mat == nil {
  2095. return 1, nil
  2096. }
  2097. loss := map[int64]float64{
  2098. 110: 1.1, 10: 1.2, 9: 1.2, 7: 1.2, 6: 1.2, 5: 1.2, 4: 1.2, 3: 1.2,
  2099. }
  2100. return loss[mat.TypeId], nil
  2101. },
  2102. Unit: "m²",
  2103. MaterialRound: true,
  2104. ControlPrice: map[int]float64{A10: 81, A8: 56, A5: 36, ZZ1_0: 56},
  2105. DeductionPrice: map[int]float64{A10: 55, A8: 40, A5: 30, ZZ1_0: 40},
  2106. },
  2107. {
  2108. Item: "地砖铺贴后成品保护",
  2109. NumberCalc: func(context *ItemContext) (float64, error) {
  2110. number := context.Space.Area
  2111. if context.Space.WideBed {
  2112. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  2113. }
  2114. return number, nil
  2115. },
  2116. },
  2117. {
  2118. Item: "阳台地面防水",
  2119. NumberCalc: func(context *ItemContext) (float64, error) {
  2120. if context.Pkg.RoomData.Pkg.Type != ZZ1_0 {
  2121. return 0, nil
  2122. }
  2123. number := utils.FloatAdd(context.Space.Area, utils.FloatMul(context.Space.Perimeter, 0.3, -1), -1)
  2124. if context.Space.WideBed {
  2125. number = utils.FloatAdd(number, utils.FloatMul(context.Space.DoorwayWidth, context.Space.DoorwayWallThickness, -1), -1)
  2126. }
  2127. return number, nil
  2128. },
  2129. },
  2130. /*{
  2131. Item: "踢脚线铺贴(明贴)",
  2132. NumberCalc: func(context *ItemContext) (float64, error) {
  2133. number := utils.FloatSubSlice([]float64{context.Space.Perimeter, context.Space.DoorwayWidth}, -1)
  2134. if number < 0 {
  2135. return 0, nil
  2136. }
  2137. return number, nil
  2138. },
  2139. },
  2140. {
  2141. Region: "地砖",
  2142. MaterialType: "瓷砖地脚线",
  2143. NumberCalc: func(context *ItemContext) (float64, error) {
  2144. number := utils.FloatSubSlice([]float64{context.Space.Perimeter, context.Space.DoorwayWidth}, -1)
  2145. if number < 0 {
  2146. return 0, nil
  2147. }
  2148. return number, nil
  2149. },
  2150. ConvertCalc: func(context *ItemContext) (float64, error) {
  2151. mat := context.GetMat(context.Region.Material)
  2152. if mat == nil {
  2153. return 1, nil
  2154. }
  2155. lineArea := map[int64]float64{
  2156. 10: 0.6, 9: 1.2, 7: 11.25, 6: 7.2, 5: 6.4, 4: 0.8, 3: 1.6,
  2157. }
  2158. return utils.FloatDiv(1, lineArea[mat.TypeId], -1), nil
  2159. },
  2160. Unit: "m",
  2161. MaterialRound: true,
  2162. ControlPrice: map[int]float64{A10: 16, A8: 12, A5: 8},
  2163. DeductionPrice: map[int]float64{A10: 12, A8: 8, A5: 6},
  2164. AdditionalMaterialCalc: func(context *ItemContext) ([]MaterialItem, error) {
  2165. number := utils.FloatSubSlice([]float64{context.Space.Perimeter, context.Space.DoorwayWidth}, -1)
  2166. if number < 0 {
  2167. number = 0
  2168. }
  2169. number = utils.FloatMul(number, 2, 3)
  2170. ymat := context.GetMat(context.Region.Material)
  2171. if ymat == nil {
  2172. return nil, errors.New("找不到材料: " + db.ToString(context.Region.Material))
  2173. }
  2174. var mat final.FinalMat
  2175. db.GetModel(map[string]interface{}{
  2176. "supplier_id": ymat.SupplierId,
  2177. "model": "其他费用",
  2178. "deleted_at": 0,
  2179. }, &mat)
  2180. if mat.ID == 0 {
  2181. return []MaterialItem{}, nil
  2182. }
  2183. typ, ok := context.MatTypeCache[mat.TypeId]
  2184. if !ok {
  2185. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  2186. }
  2187. total := utils.FloatMul(mat.Price, number, 3)
  2188. return []MaterialItem{{
  2189. Material: mat.ID,
  2190. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  2191. Type: "瓷砖地脚线",
  2192. Unit: typ.Unit,
  2193. Number: number,
  2194. Price: mat.Price,
  2195. Total: total,
  2196. CostNumber: number,
  2197. CostTotal: total,
  2198. Index: -1,
  2199. }}, nil
  2200. },
  2201. },*/
  2202. {
  2203. Region: "洗衣机龙头",
  2204. NumberCalc: func(context *ItemContext) (float64, error) {
  2205. if context.SpaceIndex == 0 {
  2206. return 1, nil
  2207. }
  2208. return 0, nil
  2209. },
  2210. Unit: "套",
  2211. ControlPrice: map[int]float64{A10: 30, A8: 30, A5: 30, ZZ1_0: 30},
  2212. DeductionPrice: map[int]float64{A10: 30, A8: 30, A5: 30, ZZ1_0: 30},
  2213. },
  2214. },
  2215. }
  2216. var SubsidyItems = []SubsidyItemObject{
  2217. {
  2218. Name: "主材配合费",
  2219. Unit: "项",
  2220. Number: 1,
  2221. Price: 500,
  2222. },
  2223. {
  2224. Name: "人工、材料补差费",
  2225. Unit: "项",
  2226. Number: 1,
  2227. Price: 2000,
  2228. },
  2229. {
  2230. Name: "23年增加补贴",
  2231. Unit: "m²",
  2232. NumberCalc: func(context *ItemContext) (float64, error) {
  2233. return context.Pkg.RoomData.Pkg.Area, nil
  2234. },
  2235. Price: 12,
  2236. },
  2237. {
  2238. Name: "2024年增加大砖铺贴补贴费",
  2239. Unit: "m²",
  2240. NumberCalc: func(context *ItemContext) (float64, error) {
  2241. if context.Pkg.RoomData.Pkg.Type == A5 || context.Pkg.RoomData.Pkg.Type == ZZ1_0 {
  2242. return 0, nil
  2243. }
  2244. number := float64(0)
  2245. for _, typ := range []int{2, 3} {
  2246. for _, space := range context.Pkg.RoomData.Space[typ] {
  2247. numbers := utils.FloatSub(utils.FloatMul(space.Perimeter, 2.4, -1), utils.FloatMul(space.DoorwayWidth, space.DoorwayHeight, -1), -1)
  2248. if numbers > 0 {
  2249. number = utils.FloatAdd(number, numbers, -1)
  2250. }
  2251. }
  2252. }
  2253. return number, nil
  2254. },
  2255. Price: 25,
  2256. },
  2257. {
  2258. Name: "截止阀",
  2259. Unit: "个",
  2260. Number: 1,
  2261. Price: 39,
  2262. },
  2263. {
  2264. Name: "排气、空调打孔费",
  2265. Unit: "项",
  2266. Number: 1,
  2267. PriceCalc: func(context *ItemContext) (float64, error) {
  2268. price := 170
  2269. if context.Pkg.RoomData.Pkg.Layout[0] > 2 {
  2270. price += 30 * (context.Pkg.RoomData.Pkg.Layout[0] - 2)
  2271. }
  2272. if context.Pkg.RoomData.Pkg.Layout[3] > 1 {
  2273. price += 30 * (context.Pkg.RoomData.Pkg.Layout[3] - 1)
  2274. }
  2275. return float64(price), nil
  2276. },
  2277. },
  2278. {
  2279. Name: "水电卫生间走顶管工艺",
  2280. Unit: "间",
  2281. NumberCalc: func(context *ItemContext) (float64, error) {
  2282. return float64(context.Pkg.RoomData.Pkg.Layout[3]), nil
  2283. },
  2284. Price: 200,
  2285. },
  2286. {
  2287. Name: "厨房洗菜盆下水管",
  2288. Unit: "个",
  2289. NumberCalc: func(context *ItemContext) (float64, error) {
  2290. return float64(context.Pkg.RoomData.Pkg.Layout[2]), nil
  2291. },
  2292. Price: 100,
  2293. },
  2294. {
  2295. Name: "下沉式卫生间排水管",
  2296. Unit: "个",
  2297. NumberCalc: func(context *ItemContext) (float64, error) {
  2298. number := 0
  2299. for _, space := range context.Pkg.RoomData.Space[3] {
  2300. if space.SinkBackfill {
  2301. number++
  2302. }
  2303. }
  2304. return float64(number), nil
  2305. },
  2306. Price: 50,
  2307. },
  2308. }
  2309. func 瓷砖材料限选品牌(context *ItemContext) ([]PersonalItem, error) {
  2310. items := make([]PersonalItem, 0)
  2311. nums := map[int]int{A10: 2, A8: 1, A5: 1, ZZ1_0: 1}
  2312. supplierMap := make(map[int64]int)
  2313. for _, materialss := range context.Pkg.BuildBudget.Materials {
  2314. for _, materials := range materialss {
  2315. for _, material := range materials {
  2316. mat := context.GetMat(material.Material)
  2317. if mat != nil {
  2318. typ := context.GetMatTopType(mat.TypeId)
  2319. if typ != nil {
  2320. if typ.ID == 2 {
  2321. supplierMap[mat.SupplierId] = 1
  2322. }
  2323. }
  2324. }
  2325. }
  2326. }
  2327. }
  2328. if len(supplierMap) > nums[context.Pkg.RoomData.Pkg.Type] {
  2329. number := float64(len(supplierMap) - nums[context.Pkg.RoomData.Pkg.Type])
  2330. total := utils.FloatMul(number, 200, 3)
  2331. items = append(items, PersonalItem{
  2332. Name: "瓷砖材料增加品牌",
  2333. Unit: "套",
  2334. Number: number,
  2335. Price: 200,
  2336. Total: total,
  2337. Index: -1,
  2338. })
  2339. }
  2340. return items, nil
  2341. }
  2342. func 地板材料限选品牌(context *ItemContext) ([]PersonalItem, error) {
  2343. items := make([]PersonalItem, 0)
  2344. supplierMap := make(map[int64]int)
  2345. for _, materialss := range context.Pkg.BuildBudget.Materials {
  2346. for _, materials := range materialss {
  2347. for _, material := range materials {
  2348. mat := context.GetMat(material.Material)
  2349. if mat != nil {
  2350. typ := context.GetMatTopType(mat.TypeId)
  2351. if typ != nil {
  2352. if typ.ID == 11 {
  2353. supplierMap[mat.SupplierId] = 1
  2354. }
  2355. }
  2356. }
  2357. }
  2358. }
  2359. }
  2360. if len(supplierMap) > 1 {
  2361. number := float64(len(supplierMap) - 1)
  2362. total := utils.FloatMul(number, 200, 3)
  2363. items = append(items, PersonalItem{
  2364. Name: "地板材料增加品牌",
  2365. Unit: "套",
  2366. Number: number,
  2367. Price: 200,
  2368. Total: total,
  2369. Index: -1,
  2370. })
  2371. }
  2372. return items, nil
  2373. }
  2374. func 卫浴材料限选品牌(context *ItemContext) ([]PersonalItem, error) {
  2375. items := make([]PersonalItem, 0)
  2376. supplierMap := make(map[int64]map[int]int)
  2377. number := 0
  2378. for _, materialss := range context.Pkg.BuildBudget.Materials {
  2379. for _, materials := range materialss {
  2380. spaceSupplierMap := make(map[int64]int)
  2381. for _, material := range materials {
  2382. mat := context.GetMat(material.Material)
  2383. if mat != nil {
  2384. if _, ok := supplierMap[mat.SupplierId]; !ok {
  2385. supplierMap[mat.SupplierId] = make(map[int]int)
  2386. }
  2387. if mat.TypeId == 97 {
  2388. spaceSupplierMap[mat.SupplierId] = 1
  2389. supplierMap[mat.SupplierId][0] = 1
  2390. }
  2391. if mat.TypeId == 98 || mat.TypeId == 99 {
  2392. spaceSupplierMap[mat.SupplierId] = 1
  2393. supplierMap[mat.SupplierId][1] = 1
  2394. }
  2395. if mat.TypeId == 100 || mat.TypeId == 101 || mat.TypeId == 102 || mat.TypeId == 103 {
  2396. spaceSupplierMap[mat.SupplierId] = 1
  2397. supplierMap[mat.SupplierId][2] = 1
  2398. }
  2399. }
  2400. }
  2401. if len(spaceSupplierMap) > 1 {
  2402. number += len(spaceSupplierMap) - 1
  2403. }
  2404. }
  2405. }
  2406. supplierNumber := 0
  2407. for _, ss := range supplierMap {
  2408. if len(ss) < 3 {
  2409. supplierNumber++
  2410. }
  2411. }
  2412. if number > supplierNumber {
  2413. number = supplierNumber
  2414. }
  2415. if number > 0 {
  2416. total := utils.FloatMul(float64(number), 200, 3)
  2417. items = append(items, PersonalItem{
  2418. Name: "卫浴材料增加品牌",
  2419. Unit: "套",
  2420. Number: float64(number),
  2421. Price: 200,
  2422. Total: total,
  2423. Index: -1,
  2424. })
  2425. }
  2426. return items, nil
  2427. }
  2428. var MaterialAdditionalItems = []ItemPersonalFunction{瓷砖材料限选品牌, 地板材料限选品牌, 卫浴材料限选品牌}
  2429. func 石材运费(context *ItemContext) ([]MaterialItem, error) {
  2430. for _, materialss := range context.Pkg.BuildBudget.Materials {
  2431. for _, materials := range materialss {
  2432. for _, material := range materials {
  2433. mat := context.GetMat(material.Material)
  2434. if mat != nil {
  2435. if mat.SupplierId == 23 {
  2436. mat := context.GetMat(55)
  2437. if mat == nil {
  2438. return nil, errors.New("找不到材料: " + db.ToString(material.Material))
  2439. }
  2440. typ, ok := context.MatTypeCache[mat.TypeId]
  2441. if !ok {
  2442. return nil, errors.New("找不到材料类型: " + db.ToString(mat.TypeId))
  2443. }
  2444. total := utils.FloatMul(mat.Price, 100, 3)
  2445. return []MaterialItem{{
  2446. Material: 55,
  2447. Name: mat.Brand + " " + mat.Series + " " + mat.Model + " " + mat.Specs + " " + mat.Color,
  2448. Type: "石材运费",
  2449. Unit: typ.Unit,
  2450. Number: 100,
  2451. Price: mat.Price,
  2452. Total: total,
  2453. CostNumber: 100,
  2454. CostTotal: total,
  2455. Index: -1,
  2456. }}, nil
  2457. }
  2458. }
  2459. }
  2460. }
  2461. }
  2462. return []MaterialItem{}, nil
  2463. }
  2464. var AdditionalMaterials = []ItemMaterialFunction{石材运费}