Model_logic_zhlp.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <?php
  2. /**
  3. * 此类就是为了针对erp的料品组合,以后都用这个类进行组合排序 将来后边需要转化erp的sku相关信息的时候 都调用这个类 到时间方便统一管理
  4. * 前边已有的代码都不动了 稳定压倒一切!!!
  5. * 目前erp有两种排序的方案 1 按照名称排序 2 按照规格的classid
  6. * 此类仅用于排序 后续的u9编写等 请到logic_u9tools中找对应的方法
  7. * 其实如果真要搞成erp的那种插入长度排序的话 就记住 长度跟在等级后边
  8. */
  9. class Model_logic_zhlp extends Lin_Model {
  10. function __construct(){
  11. parent::__construct();
  12. }
  13. public function sortByName($arr){
  14. return $this->doAction(1,$arr);
  15. }
  16. public function sortByClass($arr){
  17. return $this->doAction(2,$arr);
  18. }
  19. //根据已有的规格id 获取到对应主类id 转化为需要的规格序列
  20. public function transferSku($arr){
  21. $sku_list = $this->db->select('id,classid,classtitle,title')->from('typeclass')->where_in('id ',$arr)->get()->result_array();
  22. $ret_final_list = [];
  23. foreach ($sku_list as $k => $v){
  24. $ret_final_list[$v['classid']] = $v['id'];
  25. }
  26. return $ret_final_list;
  27. }
  28. //几种处理 排序的各种要求
  29. private function doAction($type,$arr){
  30. //1 除去真人发类型中的
  31. if($type == 1){
  32. if(isset($arr['hairtype']) && in_array($arr['hairtype'],[163,164,165,166])){
  33. $arr['hairtype'] = 0;
  34. }
  35. }else{
  36. if(isset($arr[22]) && in_array($arr[22],[163,164,165,166])){
  37. $arr[22] = 0;
  38. }
  39. }
  40. $ret_list = $this->chooseCate($type,$arr);
  41. if(empty($ret_list)){
  42. return [
  43. 'code'=>-1,
  44. "msg"=>'没有找到对应的料品分类,请通知技术设置',
  45. ];
  46. }
  47. $final_list = [];
  48. foreach ($ret_list as $k => $v){
  49. if(empty($v)){
  50. continue;
  51. }
  52. $final_list[$k] = $v;
  53. }
  54. return [
  55. 'code'=>1,
  56. "msg"=>'ok',
  57. 'data'=>$final_list
  58. ];
  59. }
  60. private function chooseCate($type,$arr){
  61. if($type == 1){
  62. $cate = $arr['category'];
  63. }else{
  64. $cate = $arr[16];
  65. }
  66. //发条
  67. if($cate == 126){
  68. return $this->fatiao($type,$arr);
  69. }
  70. //发块前头
  71. if($cate == 127){
  72. return $this->fakuai($type,$arr);
  73. }
  74. //头套
  75. if($cate == 128){
  76. return $this->toutao($type,$arr);
  77. }
  78. //Hair Extension - 接发
  79. if($cate == 130){
  80. return $this->jiefa($type,$arr);
  81. }
  82. //Gift - 礼物
  83. if($cate == 131){
  84. return $this->liwu($type,$arr);
  85. }
  86. //Accessories - 配件
  87. if($cate == 133){
  88. return $this->peijian($type,$arr);
  89. }
  90. //Synthetic Wig - 化纤头套
  91. if($cate == 1297){
  92. return $this->huaqiantoutao($type,$arr);
  93. }
  94. //Synthetic Hair - 化纤其它
  95. if($cate == 1702){
  96. return $this->huaqianqita($type,$arr);
  97. }
  98. return [];
  99. }
  100. /*******************$type 1 代表名称 2 代表classid**************************/
  101. //发条
  102. private function fatiao($type,$arr){
  103. if($type == 1){
  104. return [
  105. "category"=>empty($arr['category'])?0:$arr['category'],
  106. "hairtype"=>empty($arr['hairtype'])?0:$arr['hairtype'],
  107. "grade"=>empty($arr['grade'])?0:$arr['grade'],
  108. "color"=>empty($arr['color'])?0:$arr['color'],
  109. "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
  110. "size"=>empty($arr['size'])?0:$arr['size'],
  111. ];
  112. }else{
  113. return [
  114. 16=>empty($arr[16])?0:$arr[16],//类目
  115. 22=>empty($arr[22])?0:$arr[22],//真人发类型
  116. 13=>empty($arr[13])?0:$arr[13],//等 级
  117. 8=>empty($arr[8])?0:$arr[8],//头发颜色
  118. 15=>empty($arr[15])?0:$arr[15],//曲 度
  119. 14=>empty($arr[14])?0:$arr[14],//长 度
  120. ];
  121. }
  122. }
  123. //发块
  124. private function fakuai($type,$arr){
  125. //类型27 如果是195 Lace Closure - 发块 则类似尺寸 需要对应25 如果是197 Lace Frontal - 蕾丝前头 需要对应26
  126. //都对应25 26 到时间过滤空
  127. if($type == 1){
  128. return [
  129. "category"=>empty($arr['category'])?0:$arr['category'],
  130. "hairtype"=>empty($arr['hairtype'])?0:$arr['hairtype'],
  131. "grade"=>empty($arr['grade'])?0:$arr['grade'],
  132. "color"=>empty($arr['color'])?0:$arr['color'],
  133. "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
  134. "type"=>empty($arr['type'])?0:$arr['type'],
  135. "headroad"=>empty($arr['headroad'])?0:$arr['headroad'],
  136. "density"=>empty($arr['density'])?0:$arr['density'],
  137. 'lacesize'=>empty($arr['lacesize'])?0:$arr['lacesize'],
  138. 'lacecolor'=>empty($arr['lacecolor'])?0:$arr['lacecolor'],
  139. "lacetypes"=>empty($arr['lacetypes'])?0:$arr['lacetypes'],
  140. "size"=>empty($arr['size'])?0:$arr['size'],
  141. ];
  142. }else{
  143. return [
  144. 16=>empty($arr[16])?0:$arr[16],//类目
  145. 22=>empty($arr[22])?0:$arr[22],//真人发类型
  146. 13=>empty($arr[13])?0:$arr[13],//等 级
  147. 8=>empty($arr[8])?0:$arr[8],//头发颜色
  148. 15=>empty($arr[15])?0:$arr[15],//曲 度
  149. 27=>empty($arr[27])?0:$arr[27],//类 型
  150. 12=>empty($arr[12])?0:$arr[12],//头路设计
  151. 10=>empty($arr[10])?0:$arr[10],//密 度
  152. //到时间会去重处理
  153. 25=>empty($arr[25])?0:$arr[25],//蕾丝尺寸
  154. 26=>empty($arr[26])?0:$arr[26],//蕾丝尺寸
  155. 9=>empty($arr[9])?0:$arr[9],//蕾丝颜色
  156. 44=>empty($arr[44])?0:$arr[44],//蕾丝类型
  157. 14=>empty($arr[14])?0:$arr[14],//长 度
  158. ];
  159. }
  160. }
  161. //头套
  162. private function toutao($type,$arr){
  163. if($type == 1){
  164. return [
  165. "category"=>empty($arr['category'])?0:$arr['category'],
  166. "hairtype"=>empty($arr['hairtype'])?0:$arr['hairtype'],
  167. "grade"=>empty($arr['grade'])?0:$arr['grade'],
  168. "hairnumber"=>empty($arr['hairnumber'])?0:$arr['hairnumber'],
  169. "color"=>empty($arr['color'])?0:$arr['color'],
  170. "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
  171. "lacetype"=>empty($arr['lacetype'])?0:$arr['lacetype'],
  172. "haircap"=>empty($arr['haircap'])?0:$arr['haircap'],
  173. "density"=>empty($arr['density'])?0:$arr['density'],
  174. "lacecolor"=>empty($arr['lacecolor'])?0:$arr['lacecolor'],
  175. "lacetypes"=>empty($arr['lacetypes'])?0:$arr['lacetypes'],
  176. "wigother"=>empty($arr['wigother'])?0:$arr['wigother'],
  177. "wigother1"=>empty($arr['wigother1'])?0:$arr['wigother1'],
  178. "wigother2"=>empty($arr['wigother2'])?0:$arr['wigother2'],
  179. "size"=>empty($arr['size'])?0:$arr['size'],
  180. ];
  181. }else{
  182. return [
  183. 16=>empty($arr[16])?0:$arr[16],//类目
  184. 22=>empty($arr[22])?0:$arr[22],//真人发类型
  185. 13=>empty($arr[13])?0:$arr[13],//等 级
  186. 43=>empty($arr[43])?0:$arr[43],//人发头套编号
  187. 8=>empty($arr[8])?0:$arr[8],//头发颜色
  188. 15=>empty($arr[15])?0:$arr[15],//曲 度
  189. 18=>empty($arr[18])?0:$arr[18],//头套种类
  190. 6=>empty($arr[6])?0:$arr[6],//发帽大小
  191. 10=>empty($arr[10])?0:$arr[10],//密 度
  192. 9=>empty($arr[9])?0:$arr[9],//蕾丝颜色
  193. 44=>empty($arr[44])?0:$arr[44],//蕾丝类型
  194. 39=>empty($arr[39])?0:$arr[39],//分缝及刘海
  195. 50=>empty($arr[50])?0:$arr[50],//头套其它1
  196. 51=>empty($arr[51])?0:$arr[51],//头套其它2
  197. 14=>empty($arr[14])?0:$arr[14],//长 度
  198. ];
  199. }
  200. }
  201. //接发
  202. private function jiefa($type,$arr){
  203. if($type == 1){
  204. return [
  205. "category"=>empty($arr['category'])?0:$arr['category'],
  206. "hairtype"=>empty($arr['hairtype'])?0:$arr['hairtype'],
  207. "grade"=>empty($arr['grade'])?0:$arr['grade'],
  208. "extension"=>empty($arr['extension'])?0:$arr['extension'],
  209. "color"=>empty($arr['color'])?0:$arr['color'],
  210. "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
  211. "items"=>empty($arr['items'])?0:$arr['items'],
  212. "weight"=>empty($arr['weight'])?0:$arr['weight'],
  213. "size"=>empty($arr['size'])?0:$arr['size'],
  214. ];
  215. }else{
  216. return [
  217. 16=>empty($arr[16])?0:$arr[16],//类目
  218. 22=>empty($arr[22])?0:$arr[22],//真人发类型
  219. 13=>empty($arr[13])?0:$arr[13],//等 级
  220. 33=>empty($arr[33])?0:$arr[33],//Extension类型
  221. 8=>empty($arr[8])?0:$arr[8],//头发颜色
  222. 15=>empty($arr[15])?0:$arr[15],//曲 度
  223. 38=>empty($arr[38])?0:$arr[38],//单片片数
  224. 7=>empty($arr[7])?0:$arr[7],//重量
  225. 14=>empty($arr[14])?0:$arr[14],//长 度
  226. ];
  227. }
  228. }
  229. //礼物
  230. private function liwu($type,$arr){
  231. if($type == 1){
  232. return [
  233. "category"=>empty($arr['category'])?0:$arr['category'],
  234. "gifttype"=>empty($arr['gifttype'])?0:$arr['gifttype'],
  235. "giftother"=>empty($arr['giftother'])?0:$arr['giftother'],
  236. ];
  237. }else{
  238. return [
  239. 16=>empty($arr[16])?0:$arr[16],//类目
  240. 34=>empty($arr[34])?0:$arr[34],//礼物类型
  241. 49=>empty($arr[49])?0:$arr[49],//礼物其它
  242. ];
  243. }
  244. }
  245. //配件
  246. private function peijian($type,$arr){
  247. if($type == 1){
  248. return [
  249. "category"=>empty($arr['category'])?0:$arr['category'],
  250. "grade"=>empty($arr['grade'])?0:$arr['grade'],
  251. "fittype"=>empty($arr['fittype'])?0:$arr['fittype'],
  252. "acother"=>empty($arr['acother'])?0:$arr['acother'],
  253. "color"=>empty($arr['color'])?0:$arr['color'],
  254. "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
  255. "items"=>empty($arr['items'])?0:$arr['items'],
  256. "weight"=>empty($arr['weight'])?0:$arr['weight'],
  257. 'size'=>empty($arr['size'])?0:$arr['size'],
  258. ];
  259. }else{
  260. return [
  261. 16=>empty($arr[16])?0:$arr[16],//类目
  262. 13=>empty($arr[13])?0:$arr[13],//等 级
  263. 35=>empty($arr[35])?0:$arr[35],//配件类型
  264. 45=>empty($arr[45])?0:$arr[45],//配件其它
  265. 8=>empty($arr[8])?0:$arr[8],//头发颜色
  266. 15=>empty($arr[15])?0:$arr[15],//曲 度
  267. 38=>empty($arr[38])?0:$arr[38],//单片片数
  268. 7=>empty($arr[7])?0:$arr[7],//重量
  269. 14=>empty($arr[14])?0:$arr[14],//长 度
  270. ];
  271. }
  272. }
  273. //化纤头套
  274. private function huaqiantoutao($type,$arr){
  275. if($type == 1){
  276. return [
  277. "category"=>empty($arr['category'])?0:$arr['category'],
  278. "grade"=>empty($arr['grade'])?0:$arr['grade'],
  279. "sywignumber"=>empty($arr['sywignumber'])?0:$arr['sywignumber'],
  280. "color"=>empty($arr['color'])?0:$arr['color'],
  281. "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
  282. "synthetictype"=>empty($arr['synthetictype'])?0:$arr['synthetictype'],
  283. "sywigother"=>empty($arr['sywigother'])?0:$arr['sywigother'],
  284. "size"=>empty($arr['size'])?0:$arr['size'],
  285. ];
  286. }else{
  287. return [
  288. 16=>empty($arr[16])?0:$arr[16],//类目
  289. 13=>empty($arr[13])?0:$arr[13],//等 级
  290. 40=>empty($arr[40])?0:$arr[40],//化纤头套编号
  291. 8=>empty($arr[8])?0:$arr[8],//头发颜色
  292. 15=>empty($arr[15])?0:$arr[15],//曲 度
  293. 41=>empty($arr[41])?0:$arr[41],//化纤头套类型
  294. 42=>empty($arr[42])?0:$arr[42],//化纤头套其它
  295. 14=>empty($arr[14])?0:$arr[14],//长 度
  296. ];
  297. }
  298. }
  299. //化纤其它
  300. private function huaqianqita($type,$arr){
  301. if($type == 1){
  302. return [
  303. "category"=>empty($arr['category'])?0:$arr['category'],
  304. "grade"=>empty($arr['grade'])?0:$arr['grade'],
  305. "sywignumber"=>empty($arr['sywignumber'])?0:$arr['sywignumber'],
  306. "syother"=>empty($arr['syother'])?0:$arr['syother'],
  307. "color"=>empty($arr['color'])?0:$arr['color'],
  308. "lowe"=>empty($arr['lowe'])?0:$arr['lowe'],
  309. "items"=>empty($arr['items'])?0:$arr['items'],
  310. "syother"=>empty($arr['syother'])?0:$arr['syother'],
  311. "size"=>empty($arr['size'])?0:$arr['size'],
  312. ];
  313. }else{
  314. return [
  315. 16=>empty($arr[16])?0:$arr[16],//类目
  316. 13=>empty($arr[13])?0:$arr[13],//等 级
  317. 47=>empty($arr[47])?0:$arr[47],//化纤发编号
  318. 46=>empty($arr[46])?0:$arr[46],//化纤其它分类
  319. 8=>empty($arr[8])?0:$arr[8],//头发颜色
  320. 15=>empty($arr[15])?0:$arr[15],//曲 度
  321. 38=>empty($arr[38])?0:$arr[38],//单包片数
  322. 48=>empty($arr[48])?0:$arr[48],//化纤发其它
  323. 14=>empty($arr[14])?0:$arr[14],//长 度
  324. ];
  325. }
  326. }
  327. }