Sku.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. <?php
  2. namespace Goods\Lib;
  3. use Dever;
  4. class Sku
  5. {
  6. # 设置sku特殊字段
  7. private $col = array
  8. (
  9. 's_price' => '市场价',
  10. 'f_price' => '采购价',
  11. 'price' => '销售价',
  12. 'min' => '起购数',
  13. );
  14. # 主要价格字段
  15. private $main = 'price';
  16. public function __construct()
  17. {
  18. # 设置权限
  19. Dever::load('manage/auth.init');
  20. }
  21. public function config()
  22. {
  23. $data['action'] = Dever::url('goods/lib/sku.update');
  24. $data['goods_id'] = Dever::input('goods_id');
  25. $data['other'] = Dever::input('other');
  26. $data['other_id'] = Dever::input('other_id');
  27. if ($data['other']) {
  28. $data['other_col'] = $data['other'] . '_id';
  29. }
  30. $data['attr'] = Dever::input('attr');
  31. $data['key'] = Dever::input('key');
  32. $data['single_attr'] = Dever::input('single_attr');
  33. $data['single_key'] = Dever::input('single_key');
  34. $data['input_attr'] = Dever::input('input_attr');
  35. $data['input_key'] = Dever::input('input_key');
  36. $data['hook'] = Dever::input('hook');
  37. $data['set'] = $this->getSet($data['other']);
  38. return $data;
  39. }
  40. private function getSet($other)
  41. {
  42. if ($other) {
  43. if (Dever::project($other)) {
  44. $set = Dever::load($other . '/lib/sku')->set;
  45. if (!isset($set['price_type'])) {
  46. $set['price_type'] = false;
  47. }
  48. } else {
  49. Dever::alert($other . '不存在');
  50. }
  51. } else {
  52. $set = array('col' => $this->col, 'price_type' => false);
  53. }
  54. return $set;
  55. }
  56. public function show()
  57. {
  58. $config = Dever::load('goods/lib/sku')->config();
  59. return $this->table($config['goods_id'], $config['other'], $config['other_id'], $config['set'], true);
  60. }
  61. public function update_api()
  62. {
  63. $config = Dever::load('goods/lib/sku')->config();
  64. $where = array();
  65. if ($config['other']) {
  66. $where[$config['other_col']] = $config['other_id'];
  67. $where['goods_id'] = $config['goods_id'];
  68. $key = 'sku_id';
  69. $table = $config['other'] . '/goods';
  70. } else {
  71. $where['info_id'] = $config['goods_id'];
  72. $key = 'key';
  73. $table = 'goods/info';
  74. }
  75. $sku_table = $table . '_sku';
  76. $w['option_info_id'] = $config['goods_id'];
  77. $w['set_state'] = 2;
  78. Dever::db('goods/info_sku')->update($w);
  79. if ($config['key'] == -1) {
  80. if ($config['other']) {
  81. $info = Dever::db($table)->one($where);
  82. } else {
  83. $info = Dever::db($table)->one($config['goods_id']);
  84. }
  85. $update = $where;
  86. foreach ($config['set']['col'] as $k => $v) {
  87. $update[$k] = Dever::input($k);
  88. }
  89. if ($info && $update) {
  90. $update['where_id'] = $info['id'];
  91. Dever::db($table)->update($update);
  92. unset($update['where_id']);
  93. }
  94. $where[$key] = -1;
  95. $info = Dever::db($sku_table)->one($where);
  96. $update[$key] = $where[$key];
  97. Dever::config('base')->hook = false;
  98. if (!$info) {
  99. $state = Dever::db($sku_table)->insert($update);
  100. } else {
  101. $update['where_id'] = $info['id'];
  102. $state = Dever::db($sku_table)->update($update);
  103. }
  104. } elseif ($config['key']) {
  105. if (!is_array($config['key'])) {
  106. $config['key'] = explode(',', $config['key']);
  107. }
  108. $min = array();
  109. $cur_sku = false;
  110. $sku_id = false;
  111. foreach ($config['key'] as $k => $v) {
  112. $type = 1;
  113. if (strstr($v, '||')) {
  114. $temp = explode('||', $v);
  115. $v = $temp[0];
  116. $type = $temp[1];
  117. }
  118. if (isset($config['attr'][$k])) {
  119. $data = $where;
  120. if ($config['other']) {
  121. $sku = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  122. if (!$sku) {
  123. continue;
  124. }
  125. $data[$key] = $sku['id'];
  126. $info = Dever::db($sku_table)->one($data);
  127. } else {
  128. $info = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  129. $data['attr'] = $config['attr'][$k];
  130. $data[$key] = $v;
  131. }
  132. $data['type'] = $type;
  133. foreach ($config['set']['col'] as $k1 => $v1) {
  134. $value = Dever::input($k1);
  135. $cur_sku = false;
  136. if (isset($value[$k])) {
  137. $data[$k1] = $value[$k];
  138. if ($k1 == $this->main) {
  139. if (!isset($min[$k1])) {
  140. $min = $data;
  141. $cur_sku = true;
  142. } elseif ($min[$k1] > $data[$k1]) {
  143. $min = $data;
  144. $cur_sku = true;
  145. }
  146. }
  147. }
  148. }
  149. Dever::config('base')->hook = false;
  150. if (!$info) {
  151. $temp = Dever::db($sku_table)->insert($data);
  152. if ($cur_sku) {
  153. $sku_id = $temp;
  154. }
  155. } else {
  156. $data['where_id'] = $info['id'];
  157. if ($cur_sku) {
  158. $sku_id = $data['where_id'];
  159. }
  160. Dever::db($sku_table)->update($data);
  161. }
  162. }
  163. }
  164. if (!$config['other'] && $min) {
  165. $update = array();
  166. if ($sku_id) {
  167. $update['sku_id'] = $sku_id;
  168. }
  169. foreach ($config['set']['col'] as $k => $v) {
  170. if (isset($min[$k])) {
  171. $update[$k] = $min[$k];
  172. }
  173. }
  174. $update['where_id'] = $config['goods_id'];
  175. Dever::db($table)->update($update);
  176. }
  177. }
  178. if ($config['single_key']) {
  179. if (!is_array($config['single_key'])) {
  180. $config['single_key'] = explode(',', $config['single_key']);
  181. }
  182. foreach ($config['single_key'] as $k => $v) {
  183. $type = 2;
  184. if (strstr($v, '||')) {
  185. $temp = explode('||', $v);
  186. $v = $temp[0];
  187. $type = $temp[1];
  188. }
  189. if (isset($config['single_attr'][$k])) {
  190. $data = $where;
  191. if ($config['other']) {
  192. $sku = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  193. if (!$sku) {
  194. continue;
  195. }
  196. $data[$key] = $sku['id'];
  197. $info = Dever::db($sku_table)->one($data);
  198. } else {
  199. $info = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  200. $data['attr'] = $config['single_attr'][$k];
  201. $data[$key] = $v;
  202. }
  203. $data['type'] = $type;
  204. foreach ($config['set']['col'] as $k1 => $v1) {
  205. $value = Dever::input('single_' . $k1);
  206. if (isset($value[$k])) {
  207. $data[$k1] = $value[$k];
  208. }
  209. }
  210. Dever::config('base')->hook = false;
  211. if (!$info) {
  212. $temp = Dever::db($sku_table)->insert($data);
  213. } else {
  214. $data['where_id'] = $info['id'];
  215. Dever::db($sku_table)->update($data);
  216. }
  217. }
  218. }
  219. }
  220. if ($config['input_key']) {
  221. if (!is_array($config['input_key'])) {
  222. $config['input_key'] = explode(',', $config['input_key']);
  223. }
  224. foreach ($config['input_key'] as $k => $v) {
  225. $type = 3;
  226. if (strstr($v, '||')) {
  227. $temp = explode('||', $v);
  228. $v = $temp[0];
  229. $type = $temp[1];
  230. }
  231. if (isset($config['input_attr'][$k])) {
  232. $data = $where;
  233. if ($config['other']) {
  234. $sku = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  235. if (!$sku) {
  236. continue;
  237. }
  238. $data[$key] = $sku['id'];
  239. $info = Dever::db($sku_table)->one($data);
  240. } else {
  241. $info = Dever::db('goods/info_sku')->one(array('key' => $v, 'info_id' => $config['goods_id']));
  242. $data['attr'] = $config['input_attr'][$k];
  243. $data[$key] = $v;
  244. }
  245. $data['type'] = $type;
  246. foreach ($config['set']['col'] as $k1 => $v1) {
  247. $value = Dever::input('input_' . $k1);
  248. if (isset($value[$k])) {
  249. $data[$k1] = $value[$k];
  250. }
  251. }
  252. Dever::config('base')->hook = false;
  253. if (!$info) {
  254. $temp = Dever::db($sku_table)->insert($data);
  255. } else {
  256. $data['where_id'] = $info['id'];
  257. Dever::db($sku_table)->update($data);
  258. }
  259. }
  260. }
  261. }
  262. Dever::config('base')->hook = true;
  263. Dever::out('yes');
  264. }
  265. public function table($goods, $other = false, $other_id = false, $set = false, $update = true, $parent_goods = false)
  266. {
  267. if (!$set) {
  268. $set = $this->getSet($other);
  269. }
  270. $info = is_array($goods) ? $goods : Dever::db('goods/info')->one($goods);
  271. $info = Info::init(-1)->info($info, 'view_reorder');
  272. if ($info && $other && isset($set['price_type']) && $set['price_type']) {
  273. $price_type = explode(',', $set['price_type']);
  274. if (in_array($info['price_type'], $price_type)) {
  275. if ($update) {
  276. return '组合商品无法设置库存';
  277. }
  278. if ($info['goods'] && is_array($info['goods'])) {
  279. $html = '';
  280. foreach ($info['goods'] as $k => $v) {
  281. $html .= $this->table($v['id'], $other, $other_id, $set, $update, $v) . '<br />';
  282. }
  283. $html .= '*组合商品的库存为以上商品中的最低库存为准';
  284. return $html;
  285. } else {
  286. return '';
  287. }
  288. }
  289. }
  290. $input = '';
  291. $sku_value = array();
  292. if ($other) {
  293. $other_col = $other . '_id';
  294. $sku_value = Dever::db($other . '/goods_sku')->getData(array('goods_id' => $info['id'], $other_col => $other_id, 'state_1' => 1));
  295. $input = '<input type="hidden" name="goods_id" value="'.$info['id'].'"/><input type="hidden" name="'.$other_col.'" value="'.$other_id.'"/>';
  296. }
  297. $sku = Dever::db('goods/info_sku')->getDataByKeys(array('info_id' => $info['id']));
  298. $group_attr = $single_attr = $input_attr = array();
  299. $head = $single_head = $input_head = '<thead><tr>';
  300. $html = '请先选择属性';
  301. if ($parent_goods) {
  302. $head .= '<th>商品名称</th>';
  303. $single_head .= '<th>商品名称</th>';
  304. $input_head .= '<th>商品名称</th>';
  305. }
  306. if (isset($info['group_attr']) && $info['group_attr']) {
  307. foreach ($info['group_attr'] as $k => $v) {
  308. if (isset($info['attr'][$v]['option'])) {
  309. $group_attr[$k] = $info['attr'][$v]['option'];
  310. $head .= '<th>'.$info['attr'][$v]['name'].'</th>';
  311. }
  312. }
  313. }
  314. if (isset($info['single_attr']) && $info['single_attr']) {
  315. $single_head .= '<th>属性名称</th>';
  316. foreach ($info['single_attr'] as $k => $v) {
  317. if (isset($info['attr'][$v]['option'])) {
  318. $single_attr = array_merge($single_attr, $info['attr'][$v]['option']);
  319. }
  320. }
  321. }
  322. if (isset($info['input_attr']) && $info['input_attr']) {
  323. $input_head .= '<th>属性名称</th>';
  324. $input_head .= '<th>起算</th>';
  325. foreach ($info['input_attr'] as $k => $v) {
  326. if (isset($info['attr'][$v]['option'])) {
  327. $input_attr[$k] = $info['attr'][$v];
  328. }
  329. }
  330. }
  331. $col_num = 0;
  332. foreach ($set['col'] as $k => $v) {
  333. if (!$update && strstr($v, '^')) {
  334. continue;
  335. }
  336. $col_num++;
  337. if (strstr($v, '^')) {
  338. $v = str_replace('^', '', $v);
  339. }
  340. if (strstr($v, '|')) {
  341. $v = str_replace('|', '', $v);
  342. }
  343. $head .= '<th>'.$v.'</th>';
  344. $single_head .= '<th>'.$v.'</th>';
  345. $input_head .= '<th>'.$v.'</th>';
  346. }
  347. $head .= '</tr></thead>';
  348. $single_head .= '</tr></thead>';
  349. $input_head .= '</tr></thead>';
  350. $body = '<tbody>';
  351. $single_body = '<tbody>';
  352. $input_body = '<tbody>';
  353. if (!$group_attr) {
  354. $prefix = '[总价]:';
  355. if (!$update && $col_num <= 1) {
  356. $head = '';
  357. }
  358. if ($update) {
  359. $input .= '<input type="hidden" name="key" value="-1"/>';
  360. }
  361. $body .= '<tr>';
  362. if ($parent_goods) {
  363. $body .= '<td width="10">'.$parent_goods['name'].'</td>';
  364. }
  365. foreach ($set['col'] as $k1 => $v1) {
  366. if (!$update && strstr($v1, '^')) {
  367. continue;
  368. }
  369. $value = $this->getValue($k1, -1, $sku_value, $sku);
  370. if ($update) {
  371. if (strstr($v1, '|')) {
  372. $v1 = str_replace('|', '', $v1);
  373. $body .= '<td width="30">'.$value.'</td>';
  374. } else {
  375. $body .= '<td width="30"><input type="text" class="layui-input" name="'.$k1.'" value="'.$value.'"/></td>';
  376. }
  377. } elseif ($col_num > 1) {
  378. $body .= '<td width="30">'.$value.'</td>';
  379. } else {
  380. $body .= $value;
  381. }
  382. }
  383. $body .= '</tr>';
  384. } else {
  385. $prefix = '[组合价格]:';
  386. $group_attr = Dever::cartesian($group_attr);
  387. if ($sku_value) {
  388. foreach ($group_attr as $k => $v) {
  389. $key = array();
  390. foreach ($v['name'] as $k1 => $v1) {
  391. $key[] = $v['info_id'][$k1] . '-' . $v['id'][$k1];
  392. }
  393. $key = implode('_', $key);
  394. if (!isset($sku[$key])) {
  395. unset($group_attr[$k]);
  396. } elseif (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
  397. unset($group_attr[$k]);
  398. }
  399. }
  400. }
  401. $show = false;
  402. if ($group_attr) {
  403. foreach ($group_attr as $k => $v) {
  404. $body .= '<tr data-row="' .($k+1). '">';
  405. if ($parent_goods) {
  406. $body .= '<td>'.$parent_goods['name'].'</td>';
  407. }
  408. $key = $id = array();
  409. foreach ($v['name'] as $k1 => $v1) {
  410. $rows = 1;
  411. $body .= '<td width="50" rowspan="'.$rows.'">'.$v1.'</td>';
  412. $id[] = array
  413. (
  414. 'id' => $v['id'][$k1],
  415. 'attr_id' => $v['info_id'][$k1],
  416. );
  417. $key[] = $v['info_id'][$k1] . '-' . $v['id'][$k1];
  418. }
  419. $key = implode('_', $key);
  420. foreach ($set['col'] as $k1 => $v1) {
  421. if (!$update && strstr($v1, '^')) {
  422. continue;
  423. }
  424. $value = $this->getValue($k1, $key, $sku_value, $sku);
  425. if ($update) {
  426. if (strstr($v1, '|')) {
  427. $v1 = str_replace('|', '', $v1);
  428. $body .= '<td width="30">'.$value.'</td>';
  429. } else {
  430. $body .= '<td width="30"><input type="text" class="layui-input" name="'.$k1.'['.$k.']" value="'.$value.'"/></td>';
  431. }
  432. } else {
  433. $body .= '<td width="30">'.$value.'</td>';
  434. }
  435. }
  436. if ($update) {
  437. $body .= '<input type="hidden" name="key['.$k.']" value="'.$key.'"/><textarea style="display:none;" name="attr['.$k.']">'.json_encode($id).'</textarea>';
  438. }
  439. $body .= '</tr>';
  440. }
  441. } else {
  442. $prefix = $head = $body = '';
  443. }
  444. }
  445. $body .= $input;
  446. $html = $prefix . $head . $body;
  447. if ($update) {
  448. $html = '<table class="layui-table">' . $html . '</table>';
  449. } else {
  450. $html = '<table class="layui-table">' . $html . '</table>';
  451. }
  452. if ($single_attr && $sku_value) {
  453. foreach ($single_attr as $k => $v) {
  454. $key = $v['info_id'] . '-' . $v['id'];
  455. if (!isset($sku[$key])) {
  456. unset($single_attr[$k]);
  457. } elseif (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
  458. unset($single_attr[$k]);
  459. }
  460. }
  461. }
  462. if ($single_attr) {
  463. $html = $html;
  464. foreach ($single_attr as $k => $v) {
  465. $id = array();
  466. $single_body .= '<tr data-row="' .($k+1). '">';
  467. if ($parent_goods) {
  468. $single_body .= '<td>'.$parent_goods['name'].'</td>';
  469. }
  470. $rows = 1;
  471. $single_body .= '<td width="100" rowspan="'.$rows.'">'. $v['parent_name'].'->'. $v['name'].'</td>';
  472. $id[] = array
  473. (
  474. 'id' => $v['id'],
  475. 'attr_id' => $v['info_id'],
  476. );
  477. $key = $v['info_id'] . '-' . $v['id'];
  478. foreach ($set['col'] as $k1 => $v1) {
  479. if (!$update && strstr($v1, '^')) {
  480. continue;
  481. }
  482. $value = $this->getValue($k1, $key, $sku_value, $sku);
  483. if ($update) {
  484. if (strstr($v1, '|')) {
  485. $v1 = str_replace('|', '', $v1);
  486. $single_body .= '<td width="30">'.$value.'</td>';
  487. } else {
  488. $single_body .= '<td width="30"><input type="text" class="layui-input" name="single_'.$k1.'['.$k.']" value="'.$value.'"/></td>';
  489. }
  490. } else {
  491. $single_body .= '<td width="30">'.$value.'</td>';
  492. }
  493. }
  494. if ($update) {
  495. $single_body .= '<input type="hidden" name="single_key['.$k.']" value="'.$key.'"/><textarea style="display:none;" name="single_attr['.$k.']">'.json_encode($id).'</textarea>';
  496. }
  497. $single_body .= '</tr>';
  498. }
  499. $html = $html . '[单选价格]:<table class="layui-table">' . $single_head . $single_body . '</table>';
  500. }
  501. if ($input_attr && $sku_value) {
  502. foreach ($input_attr as $k => $v) {
  503. $key = array();
  504. foreach ($v['option'] as $k1 => $v1) {
  505. $key[] = $v1['price_key'];
  506. }
  507. $key = implode('_', $key);
  508. if (!isset($sku[$key])) {
  509. unset($input_attr[$k]);
  510. } elseif (isset($sku[$key]) && !isset($sku_value[$sku[$key]['id']])) {
  511. unset($input_attr[$k]);
  512. }
  513. }
  514. }
  515. if ($input_attr) {
  516. foreach ($input_attr as $k => $v) {
  517. if ($v['sell_compute'] == 2) {
  518. $v['sell_compute_type'] = '+';
  519. } elseif ($v['sell_compute'] == 3) {
  520. $v['sell_compute_type'] = '-';
  521. } else {
  522. $v['sell_compute_type'] = '*';
  523. }
  524. $id = array();
  525. $input_body .= '<tr data-row="' .($k+1). '">';
  526. if ($parent_goods) {
  527. $input_body .= '<td>'.$parent_goods['name'].'</td>';
  528. }
  529. $rows = 1;
  530. $key = $id = $name = array();
  531. foreach ($v['option'] as $k1 => $v1) {
  532. $id[] = array
  533. (
  534. 'id' => $v1['id'],
  535. 'attr_id' => $v1['info_id'],
  536. );
  537. $key[] = $v1['price_key'];
  538. $name[] = $v1['name'];
  539. }
  540. $key = implode('_', $key);
  541. $input_body .= '<td width="100" rowspan="'.$rows.'">'. $v['name'].'->'. implode($v['sell_compute_type'], $name).'</td>';
  542. $input_body .= '<td width="5"> >='.$v['sell_value'].'</td>';
  543. foreach ($set['col'] as $k1 => $v1) {
  544. if (!$update && strstr($v1, '^')) {
  545. continue;
  546. }
  547. $value = $this->getValue($k1, $key, $sku_value, $sku);
  548. if ($update) {
  549. if (strstr($v1, '|')) {
  550. $v1 = str_replace('|', '', $v1);
  551. $input_body .= '<td width="30">'.$value.'</td>';
  552. } else {
  553. $input_body .= '<td width="30"><input type="text" class="layui-input" name="input_'.$k1.'['.$k.']" value="'.$value.'"/></td>';
  554. }
  555. } else {
  556. $input_body .= '<td width="30">'.$value.'</td>';
  557. }
  558. }
  559. if ($update) {
  560. $input_body .= '<input type="hidden" name="input_key['.$k.']" value="'.$key.'"/><textarea style="display:none;" name="input_attr['.$k.']">'.json_encode($id).'</textarea>';
  561. }
  562. $input_body .= '</tr>';
  563. }
  564. $html = $html . '[计算价]:<table class="layui-table">' . $input_head . $input_body . '</table>';
  565. }
  566. return $html;
  567. }
  568. private function create_table($head, $body)
  569. {
  570. $html = '<table class="layui-table">';
  571. }
  572. private function getValue($k1, $key, $sku_value, $sku)
  573. {
  574. $value = '';
  575. if ($k1 == 'min') {
  576. $value = 0;
  577. } else {
  578. $value = 0;
  579. }
  580. if ($key == -1) {
  581. if (isset($sku_value[-1]) && isset($sku_value[-1][$k1])) {
  582. $value = $sku_value[-1][$k1];
  583. } elseif (isset($sku[-1]) && isset($sku[-1][$k1])) {
  584. $value = $sku[-1][$k1];
  585. }
  586. } else {
  587. if (isset($sku[$key])) {
  588. if (isset($sku_value[$sku[$key]['id']][$k1])) {
  589. $value = $sku_value[$sku[$key]['id']][$k1];
  590. } elseif (isset($sku[$key][$k1])) {
  591. $value = $sku[$key][$k1];
  592. }
  593. }
  594. }
  595. return $value;
  596. }
  597. }