PinController.class.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  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 PinController 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_pingoods_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('pin_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');
  171. echo json_encode($result);
  172. die();
  173. }
  174. public function del_goods()
  175. {
  176. $id = I('get.id');
  177. $pin_goods_info = M('pin_goods')->field('type,goods_id')->where( array('id' => $id) )->find();
  178. //type goods_id
  179. //pin C('DB_PREFIX')
  180. //p.order_id p.state=0,p.end_time , po. pin_order
  181. $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
  182. 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'];
  183. $pin_list = M()->query($sql);
  184. $id_arr = array();
  185. foreach($pin_list as $val)
  186. {
  187. $id_arr[] = $val['pin_id'];
  188. }
  189. if( !empty($id_arr) )
  190. {
  191. M('pin')->where( array( 'pin_id' => array('in', $id_arr) ) )->save( array('end_time' => time() ) );
  192. }
  193. if( $pin_goods_info['type'] == 'lottery' )
  194. {
  195. //抽奖
  196. M('lottery_goods')->where( array('goods_id' => $pin_goods_info['goods_id'] ) )->delete();
  197. }
  198. M('goods')->where( array('goods_id' => $pin_goods_info['goods_id']) )->save( array('type' => 'normal','lock_type' => 'normal') );
  199. M('pin_goods')->where( array('id' => $id) )->delete();
  200. echo json_encode( array('code' => 1) );
  201. die();
  202. }
  203. public function addGoods()
  204. {
  205. $this->display();
  206. }
  207. public function modify_pin()
  208. {
  209. $data = I('post.');
  210. /**
  211. array(1) {
  212. ["goods_ids_arr"]=>
  213. array(1) {
  214. [0]=>
  215. string(173) "73,0.01,2,69_pin_price:0.01@@70_pin_price:0.08,69_price:0.05@@70_price:0.04,69_quantity:80@@70_quantity:110,normal,2018/03/13 0:00:00,2018/03/16 0:00:00,10.00,
  216. 100_100_100_0_"
  217. }
  218. }
  219. **/
  220. if(empty($data))
  221. {
  222. $result = array('code' =>0,'msg' =>'请选择商品');
  223. echo json_encode($result);
  224. die();
  225. }
  226. //var goods_str = goods_id+','+pin_price+','+pin_count+','+option_pin_price+','+option_price+','+option_quanty;
  227. foreach($data['goods_ids_arr'] as $goods_data)
  228. {
  229. $goods_info = explode(',', $goods_data);
  230. //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"
  231. $pin_goods = array();
  232. $pin_goods['pin_price'] = $goods_info[1];
  233. $pin_goods['pin_count'] = $goods_info[2];
  234. $pin_goods['type'] = $goods_info[6];
  235. //+begin_time+','+end_time
  236. $pin_goods['begin_time'] = strtotime( $goods_info[7]);
  237. $pin_goods['end_time'] = strtotime( $goods_info[8]) ;
  238. $pin_goods['pin_hour'] = floatval( $goods_info[9]) ;
  239. $commiss_money_arr = explode('_', $goods_info[10]);
  240. $pin_goods['commiss_one_pin_disc'] = $commiss_money_arr[0];
  241. $pin_goods['commiss_two_pin_disc'] = $commiss_money_arr[1];
  242. $pin_goods['commiss_three_pin_disc'] = $commiss_money_arr[2];
  243. //lottery
  244. $pin_goods_info = M('pin_goods')->where( array('goods_id' => $goods_info[0]) )->find();
  245. if( $pin_goods_info['type'] == 'lottery' )
  246. {
  247. unset($pin_goods['type']);
  248. M('lottery_goods')->where( array('goods_id' => $goods_info[0] ) )->save( array('begin_time' => $pin_goods['begin_time'] , 'end_time' => $pin_goods['end_time']) );
  249. }else{
  250. M('goods')->where( array('goods_id' => $goods_info[0]) )->save( array('type' => 'pintuan') );
  251. }
  252. M('pin_goods')->where( array('goods_id' => $goods_info[0]) )->save($pin_goods);
  253. $price_arr = array('pin_price' =>$goods_info[1],'pin_count' => $goods_info[2]);
  254. S($this->customer_id.'goods_price_cache'.$goods_info[0], $price_arr);
  255. $quantity = 0;
  256. if( !empty($goods_info[3]) )
  257. {
  258. $option_pin_price_arr = explode('@@',$goods_info[3]);
  259. foreach($option_pin_price_arr as $pin_price_val)
  260. {
  261. $price_val = explode(':', $pin_price_val);
  262. $option_mult_id_arr = explode('_pin',$price_val[0]);
  263. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  264. $option_pin_price = $price_val[1];
  265. M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $goods_info[0]) )
  266. ->save( array('pin_price' => $option_pin_price) );
  267. }
  268. }
  269. if( !empty($goods_info[4]) )
  270. {
  271. $option_price_arr = explode('@@',$goods_info[4]);
  272. foreach($option_price_arr as $price_val)
  273. {
  274. $price_val = explode(':', $price_val);
  275. $option_mult_id_arr = explode('_price',$price_val[0]);
  276. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  277. $option_price = $price_val[1];
  278. $c = M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $goods_info[0]) )
  279. ->save( array('dan_price' => $option_price) );
  280. }
  281. }
  282. if( !empty($goods_info[5]) )
  283. {
  284. $option_quantity_arr = explode('@@',$goods_info[5]);
  285. foreach($option_quantity_arr as $quantity_val)
  286. {
  287. $quantity_val = explode(':', $quantity_val);
  288. $option_mult_id_arr = explode('_quantity',$quantity_val[0]);
  289. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  290. $option_quantity = $quantity_val[1];
  291. $quantity = $quantity+$option_quantity;
  292. M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $goods_info[0]) )
  293. ->save( array('quantity' => $option_quantity) );
  294. }
  295. }
  296. if($quantity > 0)
  297. {
  298. M('goods')->where( array('goods_id' => $goods_info[0]) )->save( array('quantity' => $quantity) );
  299. }
  300. }
  301. echo json_encode(array('code'=>1));
  302. die();
  303. }
  304. public function sub_pin()
  305. {
  306. $data = I('post.');
  307. $begin_time = $data['begin_time'];
  308. $end_time = $data['end_time'];
  309. if(empty($data))
  310. {
  311. $result = array('code' =>0,'msg' =>'请选择商品');
  312. echo json_encode($result);
  313. die();
  314. }
  315. //var goods_str = goods_id+','+pin_price+','+pin_count+','+option_pin_price+','+option_price+','+option_quanty;
  316. //','+rel_pin_hour+','+rel_type
  317. foreach($data['goods_ids_arr'] as $goods_data)
  318. {
  319. $goods_info = explode(',', $goods_data);
  320. //避免二次开团
  321. M('pin_goods')->where( array('goods_id' => $goods_info[0]) )->delete();
  322. $pin_goods = array();
  323. $pin_goods['goods_id'] = $goods_info[0];
  324. $pin_goods['customer_id'] = SELLERUID;
  325. $pin_goods['pin_price'] = $goods_info[1];
  326. $pin_goods['pin_count'] = $goods_info[2];
  327. $pin_goods['pin_hour'] = $goods_info[6];
  328. $pin_goods['type'] = $goods_info[7];
  329. $pin_goods['begin_time'] = strtotime($begin_time);
  330. $pin_goods['end_time'] = strtotime($end_time);
  331. //begin_time end_time
  332. $pin_goods['addtime'] = time();
  333. M('pin_goods')->add($pin_goods);
  334. $price_arr = array('pin_price' =>$goods_info[1],'pin_count' => $goods_info[2]);
  335. S($this->customer_id.'goods_price_cache'.$goods_info[0], $price_arr);
  336. M('goods')->where( array('goods_id' => $pin_goods['goods_id']) )->save( array('type' => 'pintuan') );
  337. //if($pin_goods['type'] == 'newman')
  338. //{
  339. // M('goods')->where( array('goods_id' => $pin_goods['goods_id']) )->save( array('type' => 'newman') );
  340. //}
  341. if( !empty($goods_info[3]) )
  342. {
  343. $option_pin_price_arr = explode('@@',$goods_info[3]);
  344. foreach($option_pin_price_arr as $pin_price_val)
  345. {
  346. $price_val = explode(':', $pin_price_val);
  347. $option_mult_id_arr = explode('_pin',$price_val[0]);
  348. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  349. $option_pin_price = $price_val[1];
  350. M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $pin_goods['goods_id']) )
  351. ->save( array('pin_price' => $option_pin_price) );
  352. }
  353. }
  354. if( !empty($goods_info[4]) )
  355. {
  356. $option_price_arr = explode('@@',$goods_info[4]);
  357. foreach($option_price_arr as $price_val)
  358. {
  359. $price_val = explode(':', $price_val);
  360. $option_mult_id_arr = explode('_price',$price_val[0]);
  361. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  362. $option_price = $price_val[1];
  363. M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $pin_goods['goods_id']) )
  364. ->save( array('dan_price' => $option_price) );
  365. }
  366. }
  367. $quantity = 0;
  368. if( !empty($goods_info[5]) )
  369. {
  370. $option_quantity_arr = explode('@@',$goods_info[5]);
  371. foreach($option_quantity_arr as $quantity_val)
  372. {
  373. $quantity_val = explode(':', $quantity_val);
  374. $option_mult_id_arr = explode('_quantity',$quantity_val[0]);
  375. $rela_goodsoption_valueid = $option_mult_id_arr[0];
  376. $option_quantity = $quantity_val[1];
  377. $quantity = $quantity + $option_quantity;
  378. M('goods_option_mult_value')->where( array('rela_goodsoption_valueid' => $rela_goodsoption_valueid,'goods_id' => $pin_goods['goods_id']) )
  379. ->save( array('quantity' => $option_quantity) );
  380. }
  381. }
  382. if($quantity > 0)
  383. {
  384. M('goods')->where( array('goods_id' => $pin_goods['goods_id']) )->save( array('quantity' => $quantity) );
  385. }
  386. }
  387. echo json_encode(array('code'=>1));
  388. die();
  389. }
  390. public function jia_over_order()
  391. {
  392. $pin_id = I('get.pin_id');
  393. $pin_model = D('Home/Pin');
  394. $pin_info = M('pin')->where( array('pin_id' => $pin_id) )->find();
  395. $buy_count = $pin_model->get_tuan_buy_count($pin_id);
  396. $del_count = $pin_info['need_count'] - $buy_count;
  397. if($del_count > 0)
  398. {
  399. $jia_list = M('jiauser')->order(' rand() desc ')->limit($del_count)->select();
  400. foreach($jia_list as $jia_member)
  401. {
  402. $tmp_arr = array();
  403. //jiapinorder
  404. $tmp_arr['pin_id'] = $pin_id;
  405. $tmp_arr['uname'] = $jia_member['username'];
  406. $tmp_arr['avatar'] = $jia_member['avatar'];
  407. $tmp_arr['order_sn'] = build_order_no($pin_id);;
  408. $tmp_arr['mobile'] = $jia_member['mobile'];
  409. $tmp_arr['addtime'] = time() + mt_rand(60,120);
  410. M('jiapinorder')->add($tmp_arr);
  411. }
  412. }
  413. //need_count
  414. $pin_model->updatePintuanSuccess($pin_id);
  415. //
  416. M('pin')->where( array('pin_id' => $pin_id) )->save( array('is_jiqi' => 1) );
  417. $return = array(
  418. 'status'=>'success',
  419. 'message'=>'操作成功',
  420. 'jump'=>U('Pin/pinlist', array('state' => 1) )
  421. );
  422. $this->osc_alert($return);
  423. }
  424. public function buy()
  425. {
  426. if($this->has_plugin)
  427. {
  428. $return = array(
  429. 'status'=>'success',
  430. 'message'=>'操作成功',
  431. 'jump'=>U('Pin/index')
  432. );
  433. $this->osc_alert($return);
  434. }else {
  435. $pin_plugin = M('plugin_list')->where( array('plugin_uname' => 'pin') )->find();
  436. //money
  437. if($pin_plugin['money'] <= 0)
  438. {
  439. //free
  440. $order_data = array();
  441. $order_data['plugin_uname'] = 'pin';
  442. $order_data['customer_id'] = UID;
  443. $order_data['state'] = 0;
  444. $order_data['money'] = $pin_plugin['money'];
  445. $order_data['val_end_time'] = time() + (86400*36500);
  446. $order_data['addtime'] = time();
  447. //val_end_time
  448. M('plugin_order')->add($order_data);
  449. $order_id = M('plugin_order')->getLastInsID();
  450. $plugin_model = D('Website/PluginsSlider');
  451. $plugin_model->modify_plugin_order_state($order_id);
  452. $return = array(
  453. 'status'=>'success',
  454. 'message'=>'操作成功',
  455. 'jump'=>U('Pin/index')
  456. );
  457. $this->osc_alert($return);
  458. }else {
  459. //TODO load pay js ....
  460. }
  461. }
  462. }
  463. public function guobie()
  464. {
  465. $model=new GoodsModel();
  466. $data=$model->show_guobie_page();
  467. $this->breadcrumb2='海淘国别';
  468. $this->assign('empty',$data['empty']);// 赋值数据集
  469. $this->assign('list',$data['list']);// 赋值数据集
  470. $this->assign('page',$data['page']);// 赋值分页输出
  471. $this->display();
  472. }
  473. public function editguobie()
  474. {
  475. $id = I('get.id');
  476. $guobie = M('guobie')->where( array('id' =>$id) )->find();
  477. $this->guobie = $guobie;
  478. $this->breadcrumb2='海淘国别';
  479. $this->display('addguobie');
  480. }
  481. public function get_json_category_tree($pid,$is_ajax=0)
  482. {
  483. // {pid:pid,is_ajax:1}
  484. $pid = empty($_GET['pid']) ? 0: intval($_GET['pid']);
  485. $is_ajax = empty($_GET['is_ajax']) ? 0:intval($_GET['is_ajax']);
  486. $list = M('goods_category')->field('id,pid,name')->where( array('pid'=>$pid,'customer_id'=>UID) )->order('sort_order asc')->select();
  487. $result = array();
  488. if($is_ajax ==0)
  489. {
  490. return $list;
  491. } else {
  492. if(empty($list)){
  493. $result['code'] = 0;
  494. } else {
  495. $result['code'] = 1;
  496. $result['list'] = $list;
  497. }
  498. echo json_encode($result);
  499. die();
  500. }
  501. }
  502. function del(){
  503. $model=new GoodsModel();
  504. $return=$model->del_goods(I('get.id'));
  505. $this->osc_alert($return);
  506. }
  507. }
  508. ?>