IntegralmallController.class.php 22 KB

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