BargainController.class.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. use Seller\Model\PinModel;
  16. use Admin\Model\GoodsModel;
  17. class BargainController extends CommonController{
  18. protected function _initialize(){
  19. parent::_initialize();
  20. $this->breadcrumb1='砍价管理';
  21. $this->breadcrumb2='砍价商品管理';
  22. }
  23. public function index(){
  24. $model=new GoodsModel();
  25. $filter=I('get.');
  26. $search=array( 'customer_id' => SELLERUID );
  27. if(isset($filter['name'])){
  28. $search['name']=$filter['name'];
  29. }
  30. $data=$model->show_bargain_page($search);
  31. $this->assign('empty',$data['empty']);// 赋值数据集
  32. $this->assign('list',$data['list']);// 赋值数据集
  33. $this->assign('page',$data['page']);// 赋值分页输出
  34. $this->display();
  35. }
  36. public function newman_activity()
  37. {
  38. $id = I('post.pin_goods_id');
  39. M('pin_goods')->where( array('id' => $id) )->save( array('type' => 'newman') );
  40. echo json_encode( array('code' => 1) );
  41. die();
  42. }
  43. public function pinlist(){
  44. $model=new PinModel();
  45. $filter=I('get.');
  46. $state = I('get.state', -1);
  47. $name = I('get.name', '');
  48. $search=array('store_id' => SELLERUID,'state' => $state,'name' => $name);
  49. $data=$model->show_order_page($search);
  50. $this->state = $state;
  51. $this->assign('empty',$data['empty']);// 赋值数据集
  52. $this->assign('list',$data['list']);// 赋值数据集
  53. $this->assign('page',$data['page']);// 赋值分页输出
  54. $this->display();
  55. }
  56. public function show_order(){
  57. $this->crumbs='拼团详情';
  58. $pin_id = I('get.pin_id');
  59. $pin_info = M('pin')->where( array('pin_id' => $pin_id) )->find();
  60. if($pin_info['state'] == 0 && $pin_info['end_time'] <time()) {
  61. $pin_info['state'] = 2;
  62. }
  63. //
  64. if( empty($pin_info['qrcode']) )
  65. {
  66. //qrcode
  67. $jssdk = new \Lib\Weixin\Jssdk( C('weprogram_appid'), C('weprogram_appscret') );
  68. //$weqrcode = $jssdk->getAllWeQrcode('pages/store/index','5');
  69. $weqrcode = $jssdk->getAllWeQrcode('pages/share/index',$pin_info['order_id'] );
  70. //保存图片
  71. $image_dir = ROOT_PATH.'Uploads/image/goods';
  72. $image_dir .= '/'.date('Y-m-d').'/';
  73. $file_path = C('SITE_URL').'Uploads/image/goods/'.date('Y-m-d').'/';
  74. $kufile_path = $dir.'/'.date('Y-m-d').'/';
  75. RecursiveMkdir($image_dir);
  76. $file_name = md5('qrcode_'.$pick_order_info['pick_sn'].time()).'.png';
  77. //qrcode
  78. file_put_contents($image_dir.$file_name, $weqrcode);
  79. M('pin')->where( array('pin_id' => $pin_id) )->save( array('qrcode' => $file_path.$file_name) );
  80. $this->qrcode = $file_path.$file_name;
  81. }else{
  82. $this->qrcode = $pin_info['qrcode'];
  83. }
  84. $this->pin_info = $pin_info;
  85. $jiapinorder = array();
  86. if($pin_info['is_jiqi'] == 1)
  87. {
  88. $jiapinorder = M('jiapinorder')->where( array('pin_id' => $pin_id) )->select();
  89. }
  90. $this->jiapinorder = $jiapinorder;
  91. $sql = "select o.order_num_alias,o.total,o.order_id,o.name,o.telephone,o.shipping_name,o.shipping_tel,o.shipping_city_id,
  92. o.shipping_country_id,o.shipping_province_id,o.shipping_address,o.date_added,o.order_status_id,
  93. og.goods_id,og.name as goods_name,og.goods_images,og.name as goods_name,og.quantity,og.price,og.total as atotal,o.shipping_fare
  94. from ".C('DB_PREFIX')."order as o,".C('DB_PREFIX')."order_goods as og,".C('DB_PREFIX')."pin_order as p
  95. where o.order_status_id !=3 and o.order_id = og.order_id and o.order_id = p.order_id and p.pin_id ={$pin_id}";
  96. $sql.=' ORDER BY o.order_id desc ';
  97. $list = M()->query($sql);
  98. foreach($list as $key => $val)
  99. {
  100. $province_info = M('area')->where( array('area_id' =>$val['shipping_province_id'] ) )->find();
  101. $city_info = M('area')->where( array('area_id' =>$val['shipping_city_id'] ) )->find();
  102. $country_info = M('area')->where( array('area_id' =>$val['shipping_country_id'] ) )->find();
  103. $val['province_name'] = $province_info['area_name'];
  104. $val['city_name'] = $city_info['area_name'];
  105. $val['area_name'] = $country_info['area_name'];
  106. $list[$key] = $val;
  107. }
  108. $pin_buy_sql = "select count(o.order_id) as count from ".C('DB_PREFIX')."pin_order as p,".C('DB_PREFIX')."order as o,".C('DB_PREFIX')."order_goods as og
  109. where p.order_id= o.order_id and p.order_id = og.order_id and p.pin_id = {$pin_id} and o.order_status_id in(1,2,4,6,7,8,9,10)
  110. ";
  111. $pin_buy_count_arr = M()->query($pin_buy_sql);
  112. $pin_buy_count = $pin_buy_count_arr[0]['count'];
  113. $pin_jia_count = M('jiapinorder')->where( array('pin_id' => $pin_id) )->count();
  114. $order = current($list);
  115. //$goods_info = M('goods')->where( array('goods_id' => $order['goods_id']) )->find();
  116. $goods_images=resize($order['goods_images'], 50,50);
  117. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  118. $order_id = $hashids->encode($order['order_id']);
  119. $config_info = M('config')->where( array('name' => 'SITE_URL') )->find();
  120. $pin_url = $config_info['value'].'/index.php?s=/group/info/group_order_id/'.$order_id.'.html';
  121. $this->pin_url = $pin_url;
  122. $order_status_list = M('order_status')->select();
  123. $order_status_arr = array();
  124. foreach($order_status_list as $val)
  125. {
  126. $order_status_arr[$val['order_status_id']] = $val['name'];
  127. }
  128. $this->order_status_arr = $order_status_arr;
  129. $this->list = $list;
  130. $this->pin_buy_count = $pin_buy_count + $pin_jia_count;
  131. $this->goods_images = $goods_images;
  132. $this->order = $order;
  133. $this->display('show');
  134. }
  135. public function edit_goods()
  136. {
  137. $id = I('get.id');
  138. $pin_goods = M('bargain_goods')->where( array('id' => $id) )->find();
  139. //goods_id
  140. $goods_id = $pin_goods['goods_id'];
  141. $this->pin_goods = $pin_goods;
  142. $goods_info = M('goods')->field('name,goods_id,price,danprice')->where( array('goods_id' => $goods_id) )->find();
  143. $model=new GoodsModel();
  144. $this->goods_options=$model->get_goods_options($goods_id, SELLERUID);
  145. $goods_option_mult_value = M('goods_option_mult_value')->where( array('goods_id' => $goods_id ) )->select();
  146. $goods_option_mult_str = '';
  147. if( !empty($goods_option_mult_value) )
  148. {
  149. $goods_option_mult_arr = array();
  150. foreach($goods_option_mult_value as $key => $val)
  151. {
  152. $goods_option_mult_arr[] = 'mult_id:'.$val['rela_goodsoption_valueid'].'@@mult_qu:'.$val['quantity'].'@@mult_image:'.$val['image'];
  153. //option_value option_value_id value_name
  154. $option_name_arr = explode('_', $val['rela_goodsoption_valueid']);
  155. $option_name_list = array();
  156. foreach($option_name_arr as $option_value_id_tp)
  157. {
  158. $tp_op_val_info =M('option_value')->where( array('option_value_id' => $option_value_id_tp) )->find();
  159. $option_name_list[] = $tp_op_val_info['value_name'];
  160. }
  161. $val['option_name_list'] = $option_name_list;
  162. $goods_option_mult_value[$key] = $val;
  163. }
  164. $goods_option_mult_str = implode(',', $goods_option_mult_arr);
  165. }
  166. $this->goods_option_mult_value = $goods_option_mult_value;
  167. $this->goods_option_mult_str = $goods_option_mult_str;
  168. $this->goods_info = $goods_info;
  169. $result = array();
  170. $result['html'] = $this->fetch('Goods:goods_option_fetch_bargain');
  171. echo json_encode($result);
  172. die();
  173. }
  174. public function del_goods()
  175. {
  176. $id = I('get.id');
  177. $pin_goods_info = M('bargain_goods')->field('goods_id')->where( array('id' => $id) )->find();
  178. $sql ="select p.pin_id ,p.state,og.goods_id from ".C('DB_PREFIX')."pin as p left join ".C('DB_PREFIX')."pin_order as po on p.order_id = po.order_id
  179. left join ".C('DB_PREFIX')."order_goods as og on og.order_id = po.order_id where p.state =0 and og.goods_id = ".$pin_goods_info['goods_id'];
  180. $pin_list = M()->query($sql);
  181. $id_arr = array();
  182. foreach($pin_list as $val)
  183. {
  184. $id_arr[] = $val['pin_id'];
  185. }
  186. if( !empty($id_arr) )
  187. {
  188. M('pin')->where( array( 'pin_id' => array('in', $id_arr) ) )->save( array('end_time' => time() ) );
  189. }
  190. M('goods')->where( array('goods_id' => $pin_goods_info['goods_id']) )->save( array('type' => 'normal','lock_type' => 'normal') );
  191. M('bargain_goods')->where( array('id' => $id) )->delete();
  192. echo json_encode( array('code' => 1) );
  193. die();
  194. }
  195. public function addGoods()
  196. {
  197. $this->display();
  198. }
  199. public function modify_pin()
  200. {
  201. $data = I('post.');
  202. if(empty($data))
  203. {
  204. $result = array('code' =>0,'msg' =>'请选择商品');
  205. echo json_encode($result);
  206. die();
  207. }
  208. //var goods_str = goods_id+','+pin_price+','+pin_count+','+option_pin_price+','+option_price+','+option_quanty;
  209. foreach($data['goods_ids_arr'] as $goods_data)
  210. {
  211. $goods_info = explode(',', $goods_data);
  212. //string(172) "18,18.00,0, 36_33_pin_price:2@@37_33_pin_price:2@@38_33_pin_price:2, 36_33_price:1.00@@37_33_price:2.00@@38_33_price:3.00,36_33_quantity:2@@37_33_quantity:2@@38_33_quantity:2"
  213. $pin_goods = array();
  214. $pin_goods['bargain_price'] = $goods_info[1];
  215. $pin_goods['bargain_count'] = $goods_info[2];
  216. $pin_goods['begin_time'] = strtotime( $goods_info[7]);
  217. $pin_goods['end_time'] = strtotime( $goods_info[8]) ;
  218. $pin_goods['hour'] = floatval( $goods_info[9]) ;
  219. $pin_goods_info = M('bargain_goods')->where( array('goods_id' => $goods_info[0]) )->find();
  220. M('bargain_goods')->where( array('goods_id' => $goods_info[0]) )->save($pin_goods);
  221. $price_arr = array('pin_price' =>$goods_info[1],'pin_count' => $goods_info[2]);
  222. S($this->customer_id.'goods_price_cache'.$goods_info[0], $price_arr);
  223. $quantity = 0;
  224. if( !empty($goods_info[3]) )
  225. {
  226. $option_pin_price_arr = explode('@@',$goods_info[3]);
  227. foreach($option_pin_price_arr as $pin_price_val)
  228. {
  229. $price_val = explode(':', $pin_price_val);
  230. $option_mult_id_arr = explode('_pin',$price_val[0]);
  231. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  232. $option_pin_price = $price_val[1];
  233. M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $goods_info[0]) )
  234. ->save( array('pin_price' => $option_pin_price) );
  235. }
  236. }
  237. if( !empty($goods_info[4]) )
  238. {
  239. $option_price_arr = explode('@@',$goods_info[4]);
  240. foreach($option_price_arr as $price_val)
  241. {
  242. $price_val = explode(':', $price_val);
  243. $option_mult_id_arr = explode('_price',$price_val[0]);
  244. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  245. $option_price = $price_val[1];
  246. $c = M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $goods_info[0]) )
  247. ->save( array('dan_price' => $option_price) );
  248. }
  249. }
  250. if( !empty($goods_info[5]) )
  251. {
  252. $option_quantity_arr = explode('@@',$goods_info[5]);
  253. foreach($option_quantity_arr as $quantity_val)
  254. {
  255. $quantity_val = explode(':', $quantity_val);
  256. $option_mult_id_arr = explode('_quantity',$quantity_val[0]);
  257. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  258. $option_quantity = $quantity_val[1];
  259. $quantity = $quantity+$option_quantity;
  260. M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $goods_info[0]) )
  261. ->save( array('quantity' => $option_quantity) );
  262. }
  263. }
  264. if($quantity > 0)
  265. {
  266. M('goods')->where( array('goods_id' => $goods_info[0]) )->save( array('quantity' => $quantity) );
  267. }
  268. }
  269. echo json_encode(array('code'=>1));
  270. die();
  271. }
  272. public function sub_pin()
  273. {
  274. $data = I('post.');
  275. $begin_time = $data['begin_time'];
  276. $end_time = $data['end_time'];
  277. /**
  278. array(3) {
  279. ["goods_ids_arr"]=>
  280. array(1) {
  281. [0]=>
  282. string(171) "88,1,2,100_pin_price:2@@101_pin_price:3@@102_pin_price:0.00@@103_pin_price:0.00,,100_quantity:11109@@101_quantity:11111@@102_quantity:11111@@103_quantity:11111,1,undefined"
  283. }
  284. ["begin_time"]=>
  285. string(18) "2018/06/01 0:00:00"
  286. ["end_time"]=>
  287. string(18) "2018/06/02 0:00:00"
  288. }
  289. string(18) "2018/06/01 0:00:00"
  290. string(18) "2018/06/02 0:00:00"
  291. **/
  292. if(empty($data))
  293. {
  294. $result = array('code' =>0,'msg' =>'请选择商品');
  295. echo json_encode($result);
  296. die();
  297. }
  298. //var goods_str = goods_id+','+pin_price+','+pin_count+','+option_pin_price+','+option_price+','+option_quanty;
  299. //','+rel_pin_hour+','+rel_type
  300. foreach($data['goods_ids_arr'] as $goods_data)
  301. {
  302. $goods_info = explode(',', $goods_data);
  303. //避免二次开团
  304. M('bargain_goods')->where( array('goods_id' => $goods_info[0]) )->delete();
  305. /**
  306. goods_id
  307. customer_id
  308. begin_time
  309. end_time
  310. bargain_count
  311. hour
  312. addtime
  313. bargain_price
  314. **/
  315. $pin_goods = array();
  316. $pin_goods['goods_id'] = $goods_info[0];
  317. $pin_goods['customer_id'] = SELLERUID;
  318. $pin_goods['bargain_price'] = $goods_info[1];
  319. $pin_goods['bargain_count'] = $goods_info[2];
  320. $pin_goods['hour'] = $goods_info[6];
  321. $pin_goods['begin_time'] = strtotime($begin_time);
  322. $pin_goods['end_time'] = strtotime($end_time);
  323. $pin_goods['addtime'] = time();
  324. M('bargain_goods')->add($pin_goods);
  325. $price_arr = array('pin_price' =>$goods_info[1],'pin_count' => $goods_info[2]);
  326. S($this->customer_id.'goods_price_cache'.$goods_info[0], $price_arr);
  327. M('goods')->where( array('goods_id' => $pin_goods['goods_id']) )->save( array('type' => 'bargain') );
  328. //if($pin_goods['type'] == 'newman')
  329. //{
  330. // M('goods')->where( array('goods_id' => $pin_goods['goods_id']) )->save( array('type' => 'newman') );
  331. //}
  332. if( !empty($goods_info[3]) )
  333. {
  334. $option_pin_price_arr = explode('@@',$goods_info[3]);
  335. foreach($option_pin_price_arr as $pin_price_val)
  336. {
  337. $price_val = explode(':', $pin_price_val);
  338. $option_mult_id_arr = explode('_pin',$price_val[0]);
  339. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  340. $option_pin_price = $price_val[1];
  341. M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $pin_goods['goods_id']) )
  342. ->save( array('pin_price' => $option_pin_price) );
  343. }
  344. }
  345. if( !empty($goods_info[4]) )
  346. {
  347. $option_price_arr = explode('@@',$goods_info[4]);
  348. foreach($option_price_arr as $price_val)
  349. {
  350. $price_val = explode(':', $price_val);
  351. $option_mult_id_arr = explode('_price',$price_val[0]);
  352. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  353. $option_price = $price_val[1];
  354. M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $pin_goods['goods_id']) )
  355. ->save( array('dan_price' => $option_price) );
  356. }
  357. }
  358. $quantity = 0;
  359. if( !empty($goods_info[5]) )
  360. {
  361. $option_quantity_arr = explode('@@',$goods_info[5]);
  362. foreach($option_quantity_arr as $quantity_val)
  363. {
  364. $quantity_val = explode(':', $quantity_val);
  365. $option_mult_id_arr = explode('_quantity',$quantity_val[0]);
  366. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  367. $option_quantity = $quantity_val[1];
  368. $quantity = $quantity + $option_quantity;
  369. M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $pin_goods['goods_id']) )
  370. ->save( array('quantity' => $option_quantity) );
  371. }
  372. }
  373. if($quantity > 0)
  374. {
  375. M('goods')->where( array('goods_id' => $pin_goods['goods_id']) )->save( array('quantity' => $quantity) );
  376. }
  377. }
  378. echo json_encode(array('code'=>1));
  379. die();
  380. }
  381. public function jia_over_order()
  382. {
  383. $pin_id = I('get.pin_id');
  384. $pin_model = D('Home/Pin');
  385. $pin_info = M('pin')->where( array('pin_id' => $pin_id) )->find();
  386. $buy_count = $pin_model->get_tuan_buy_count($pin_id);
  387. $del_count = $pin_info['need_count'] - $buy_count;
  388. if($del_count > 0)
  389. {
  390. $jia_list = M('jiauser')->order(' rand() desc ')->limit($del_count)->select();
  391. foreach($jia_list as $jia_member)
  392. {
  393. $tmp_arr = array();
  394. //jiapinorder
  395. $tmp_arr['pin_id'] = $pin_id;
  396. $tmp_arr['uname'] = $jia_member['username'];
  397. $tmp_arr['avatar'] = $jia_member['avatar'];
  398. $tmp_arr['order_sn'] = build_order_no($pin_id);;
  399. $tmp_arr['mobile'] = $jia_member['mobile'];
  400. $tmp_arr['addtime'] = time() + mt_rand(60,120);
  401. M('jiapinorder')->add($tmp_arr);
  402. }
  403. }
  404. //need_count
  405. $pin_model->updatePintuanSuccess($pin_id);
  406. //
  407. M('pin')->where( array('pin_id' => $pin_id) )->save( array('is_jiqi' => 1) );
  408. $return = array(
  409. 'status'=>'success',
  410. 'message'=>'操作成功',
  411. 'jump'=>U('Pin/pinlist', array('state' => 1) )
  412. );
  413. $this->osc_alert($return);
  414. }
  415. public function buy()
  416. {
  417. if($this->has_plugin)
  418. {
  419. $return = array(
  420. 'status'=>'success',
  421. 'message'=>'操作成功',
  422. 'jump'=>U('Pin/index')
  423. );
  424. $this->osc_alert($return);
  425. }else {
  426. $pin_plugin = M('plugin_list')->where( array('plugin_uname' => 'pin') )->find();
  427. //money
  428. if($pin_plugin['money'] <= 0)
  429. {
  430. //free
  431. $order_data = array();
  432. $order_data['plugin_uname'] = 'pin';
  433. $order_data['customer_id'] = UID;
  434. $order_data['state'] = 0;
  435. $order_data['money'] = $pin_plugin['money'];
  436. $order_data['val_end_time'] = time() + (86400*36500);
  437. $order_data['addtime'] = time();
  438. //val_end_time
  439. M('plugin_order')->add($order_data);
  440. $order_id = M('plugin_order')->getLastInsID();
  441. $plugin_model = D('Website/PluginsSlider');
  442. $plugin_model->modify_plugin_order_state($order_id);
  443. $return = array(
  444. 'status'=>'success',
  445. 'message'=>'操作成功',
  446. 'jump'=>U('Pin/index')
  447. );
  448. $this->osc_alert($return);
  449. }else {
  450. //TODO load pay js ....
  451. }
  452. }
  453. }
  454. public function guobie()
  455. {
  456. $model=new GoodsModel();
  457. $data=$model->show_guobie_page();
  458. $this->breadcrumb2='海淘国别';
  459. $this->assign('empty',$data['empty']);// 赋值数据集
  460. $this->assign('list',$data['list']);// 赋值数据集
  461. $this->assign('page',$data['page']);// 赋值分页输出
  462. $this->display();
  463. }
  464. public function editguobie()
  465. {
  466. $id = I('get.id');
  467. $guobie = M('guobie')->where( array('id' =>$id) )->find();
  468. $this->guobie = $guobie;
  469. $this->breadcrumb2='海淘国别';
  470. $this->display('addguobie');
  471. }
  472. public function get_json_category_tree($pid,$is_ajax=0)
  473. {
  474. // {pid:pid,is_ajax:1}
  475. $pid = empty($_GET['pid']) ? 0: intval($_GET['pid']);
  476. $is_ajax = empty($_GET['is_ajax']) ? 0:intval($_GET['is_ajax']);
  477. $list = M('goods_category')->field('id,pid,name')->where( array('pid'=>$pid,'customer_id'=>UID) )->order('sort_order asc')->select();
  478. $result = array();
  479. if($is_ajax ==0)
  480. {
  481. return $list;
  482. } else {
  483. if(empty($list)){
  484. $result['code'] = 0;
  485. } else {
  486. $result['code'] = 1;
  487. $result['list'] = $list;
  488. }
  489. echo json_encode($result);
  490. die();
  491. }
  492. }
  493. function del(){
  494. $model=new GoodsModel();
  495. $return=$model->del_goods(I('get.id'));
  496. $this->osc_alert($return);
  497. }
  498. }
  499. ?>