GroupController.class.php 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. class GroupController extends CommonController{
  16. protected function _initialize(){
  17. parent::_initialize();
  18. $this->breadcrumb1='拼团管理';
  19. $this->breadcrumb2='商品信息';
  20. $this->sellerid = SELLERUID;
  21. }
  22. public function goods()
  23. {
  24. $pindex = I('get.page', 1);
  25. $psize = 20;
  26. $starttime_arr = I('get.time');
  27. $starttime = isset($starttime_arr['start']) ? strtotime($starttime_arr['start']) : strtotime(date('Y-m-d'.' 00:00:00'));
  28. $endtime = isset($starttime_arr['end']) ? strtotime($starttime_arr['end']) : strtotime(date('Y-m-d'.' 23:59:59'));
  29. $this->starttime = $starttime;
  30. $this->endtime = $endtime;
  31. $searchtime = I('get.searchtime','');
  32. $this->searchtime = $searchtime;
  33. $shop_data = array();
  34. $type = I('get.type','all');
  35. //---begin
  36. $count_common_where ="";
  37. if (defined('ROLE') && ROLE == 'agenter' ) {
  38. $supper_info = get_agent_logininfo();
  39. $supper_goods_list = M('lionfish_comshop_good_common')->field('goods_id')->where( array('supply_id' =>$supper_info['id'] ) )->select();
  40. $gids_list = array();
  41. foreach($supper_goods_list as $vv)
  42. {
  43. $gids_list[] = $vv['goods_id'];
  44. }
  45. if( !empty($gids_list) )
  46. {
  47. $count_common_where = " and id in ( ".implode(',', $gids_list )." )";
  48. }else{
  49. $count_common_where = " and id in (0)";
  50. }
  51. }
  52. $all_count = D('Seller/Goods')->get_goods_count(" and type = 'pin' {$count_common_where}");//全部商品数量
  53. $onsale_count = D('Seller/Goods')->get_goods_count(" and grounding = 1 and type = 'pin' {$count_common_where}");//出售中商品数量
  54. $getdown_count = D('Seller/Goods')->get_goods_count(" and grounding = 0 and type = 'pin' {$count_common_where}");//已下架商品数量
  55. $warehouse_count = D('Seller/Goods')->get_goods_count(" and grounding = 2 and type = 'pin' {$count_common_where}");//仓库商品数量
  56. $recycle_count = D('Seller/Goods')->get_goods_count(" and grounding = 3 and type = 'pin' {$count_common_where}");//回收站商品数量
  57. $waishen_count = D('Seller/Goods')->get_goods_count(" and grounding = 4 and type = 'pin' {$count_common_where}");//审核商品数量
  58. $unsuccshen_count = D('Seller/Goods')->get_goods_count(" and grounding = 5 and type = 'pin' {$count_common_where}");//拒绝审核商品数量
  59. $this->assign('waishen_count',$waishen_count);
  60. $this->assign('unsuccshen_count',$unsuccshen_count);
  61. //recycle 仓库
  62. //--end
  63. //recycle 仓库 get_config_by_name($name)
  64. $goods_stock_notice = D('Home/Front')->get_config_by_name('goods_stock_notice');
  65. $goods_stock_notice = intval($goods_stock_notice);
  66. if( empty($goods_stock_notice) )
  67. {
  68. $goods_stock_notice = 0;
  69. }
  70. $stock_notice_count = D('Admin/Goods')->get_goods_count(" and grounding = 1 and total<= {$goods_stock_notice} and type = 'normal' {$count_common_where} ");//回收站商品数量
  71. //goods_stock_notice
  72. //grounding 1
  73. //type all 全部
  74. //saleon 1 出售中
  75. //getdown 0 已下架
  76. //warehouse 2 仓库中
  77. //recycle 3 回收站
  78. $psize = 20;
  79. $condition = ' WHERE g.type = "pin" ';
  80. $sqlcondition = "";
  81. if( !empty($type) && $type != 'all')
  82. {
  83. switch($type)
  84. {
  85. case 'saleon':
  86. $condition .= " and g.grounding = 1";
  87. break;
  88. case 'getdown':
  89. $condition .= " and g.grounding = 0";
  90. break;
  91. case 'warehouse':
  92. $condition .= " and g.grounding = 2";
  93. break;
  94. case 'wait_shen':
  95. $condition .= " and g.grounding = 4";
  96. break;
  97. case 'refuse':
  98. $condition .= " and g.grounding = 5";
  99. break;
  100. case 'recycle':
  101. $condition .= " and g.grounding = 3";
  102. break;
  103. case 'stock_notice':
  104. $condition .= " and g.grounding = 1 and g.total<= {$goods_stock_notice} ";
  105. break;
  106. }
  107. }else{
  108. $condition .= " and g.grounding != 3 ";
  109. }
  110. $keyword = I('get.keyword','');
  111. $this->keyword = $keyword;
  112. if (!(empty($keyword))) {
  113. $condition .= " AND (g.`id` = '{$keyword}' or g.`goodsname` LIKE '%{$keyword}%' or g.`codes` LIKE '%{$keyword}%' ) ";
  114. }
  115. if (defined('ROLE') && ROLE == 'agenter' )
  116. {
  117. $supper_info = get_agent_logininfo();
  118. $sqlcondition .= ' , ' . C('DB_PREFIX'). 'lionfish_comshop_good_common as gm ';
  119. $condition .= ' and gm.goods_id =g.id AND gm.supply_id ='.$supper_info['id'].' ';
  120. }
  121. if( !empty($searchtime) )
  122. {
  123. switch( $searchtime )
  124. {
  125. case 'create':
  126. $condition .= ' AND (gm.begin_time >='.$starttime.' and gm.end_time < '.$endtime.' )';
  127. if (!defined('ROLE') && ROLE != 'agenter' )
  128. {
  129. $sqlcondition .= ' left join ' . C('DB_PREFIX'). 'lionfish_comshop_good_common as gm on gm.goods_id = g.id ';
  130. }
  131. break;
  132. }
  133. }
  134. $cate = I('get.cate', '');
  135. $this->cate = $cate;
  136. if( !empty($cate) )
  137. {
  138. $cate_list = M('lionfish_comshop_goods_to_category')->field('goods_id')->where(array('cate_id' => $cate))->select();
  139. $catids_arr = array();
  140. foreach($cate_list as $val)
  141. {
  142. $catids_arr[] = $val['goods_id'];
  143. }
  144. if( !empty($catids_arr) )
  145. {
  146. $catids_str = implode(',', $catids_arr);
  147. $condition .= ' and g.id in ('.$catids_str.')';
  148. }else{
  149. $condition .= " and 1=0 ";
  150. }
  151. }
  152. $sql = 'SELECT COUNT(g.id) as count FROM ' .C('DB_PREFIX'). 'lionfish_comshop_goods g ' .$sqlcondition. $condition ;
  153. $total_arr = M()->query($sql);
  154. $total = $total_arr[0]['count'];
  155. $pager = pagination2($total, $pindex, $psize);
  156. if (!(empty($total))) {
  157. $sql = 'SELECT g.* FROM ' .C('DB_PREFIX'). 'lionfish_comshop_goods g ' .$sqlcondition . $condition . '
  158. ORDER BY g.istop DESC, g.settoptime DESC, g.`id` DESC ';
  159. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  160. $list = M()->query($sql);
  161. foreach ($list as $key => &$value ) {
  162. $price_arr = D('Home/Pingoods')->get_goods_price($value['id']);
  163. $value['price_arr'] = $price_arr;
  164. $thumb = M('lionfish_comshop_goods_images')->where( array('goods_id' => $value['id']) )->order('id asc')->find();
  165. if( empty($thumb['thumb']) )
  166. {
  167. $value['thumb'] = $thumb['image'];
  168. }else{
  169. $value['thumb'] = $thumb['thumb'];
  170. }
  171. //is_take_fullreduction
  172. $gd_common = M('lionfish_comshop_good_common')->field('is_take_fullreduction,supply_id')->where( array('goods_id' => $value['id']) )->find();
  173. $value['is_take_fullreduction'] = $gd_common['is_take_fullreduction'];
  174. $value['supply_name'] = '';
  175. if( empty($gd_common['supply_id']) || $gd_common['supply_id'] ==0 )
  176. {
  177. $value['supply_id'] = 0;
  178. }else{
  179. $value['supply_id'] = $gd_common['supply_id'];
  180. $sub_info = M('lionfish_comshop_supply')->field('name')->where( array('id' => $gd_common['supply_id'] ) )->find();
  181. $value['supply_name'] = $sub_info['name'];
  182. }
  183. $categorys = M('lionfish_comshop_goods_to_category')->where( array('goods_id' => $value['id']) )->order('id asc')->select();
  184. $value['cate'] = $categorys;
  185. $time_info = D('home/front')->get_goods_common_field($value['id'] , 'begin_time,end_time');
  186. $value['begin_time'] = $time_info['begin_time'];
  187. $value['end_time'] = $time_info['end_time'];
  188. //团长数量
  189. $head_count = 0;
  190. if( $value['is_all_sale'] == 1 )
  191. {
  192. $head_count = M('lionfish_community_head')->count();
  193. }else{
  194. $head_count = M('lionfish_community_head_goods')->where( array('goods_id' => $value['id'] ) )->count();
  195. }
  196. $value['head_count'] = $head_count;
  197. }
  198. }
  199. $categorys = D('Seller/GoodsCategory')->getFullCategory(true,false,'pintuan');
  200. $category = array();
  201. foreach ($categorys as $cate ) {
  202. $category[$cate['id']] = $cate;
  203. }
  204. $this->category =$category;
  205. $this->type = $type;
  206. $this->all_count = $all_count;
  207. $this->onsale_count = $onsale_count;
  208. $this->getdown_count = $getdown_count;
  209. $this->warehouse_count = $warehouse_count;
  210. $this->recycle_count = $recycle_count;
  211. $this->stock_notice_count = $stock_notice_count;
  212. $this->assign('list',$list);// 赋值数据集
  213. $this->assign('pager',$pager);// 赋值分页输出
  214. $is_open_fullreduction = 0;
  215. $this->assign('is_open_fullreduction',$is_open_fullreduction);
  216. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  217. if( empty($index_sort_method) || $index_sort_method == 0 )
  218. {
  219. $index_sort_method = 0;
  220. }
  221. $this->index_sort_method = $index_sort_method;
  222. //---
  223. $supply_add_goods_shenhe = D('Home/Front')->get_config_by_name('supply_add_goods_shenhe');
  224. $supply_edit_goods_shenhe = D('Home/Front')->get_config_by_name('supply_edit_goods_shenhe');
  225. $supply_add_goods_shenhe = 0;
  226. $supply_edit_goods_shenhe = 0;
  227. $is_open_shenhe = 0;
  228. $this->supply_add_goods_shenhe = $supply_add_goods_shenhe;
  229. $this->supply_edit_goods_shenhe = $supply_edit_goods_shenhe;
  230. $this->assign('is_open_shenhe',$is_open_shenhe);
  231. //--
  232. //团长分组
  233. $group_default_list = array(
  234. array('id' => 'default', 'groupname' => '默认分组')
  235. );
  236. $this->group_list = array();
  237. $config_data = D('Seller/Config')->get_all_config();
  238. $pintuan_model_buy = isset($config_data['pintuan_model_buy']) ? intval( $config_data['pintuan_model_buy'] ) : 0;
  239. $this->pintuan_model_buy = $pintuan_model_buy;
  240. //团长分组
  241. $group_default_list = array(
  242. array('id' => 'default', 'groupname' => '默认分组')
  243. );
  244. $group_list = M('lionfish_community_head_group')->field('id,groupname')->order('id asc')->select();
  245. $group_list = array_merge($group_default_list, $group_list);
  246. $this->group_list = $group_list;
  247. $is_index = true;
  248. $is_top = true;
  249. $is_updown = true;
  250. $is_fullreduce = true;
  251. $is_vir_count = true;
  252. $is_newbuy = true;
  253. $is_goodsspike = true;
  254. $this->config_data = $config_data;
  255. $this->is_index = $is_index;
  256. $this->is_top = $is_top;
  257. $this->is_updown = $is_updown;
  258. $this->is_fullreduce = $is_fullreduce;
  259. $this->is_vir_count = $is_vir_count;
  260. $this->is_newbuy = $is_newbuy;
  261. $this->is_goodsspike = $is_goodsspike;
  262. $this->display();
  263. }
  264. public function editgoods()
  265. {
  266. $id = I('get.id');
  267. if (IS_POST) {
  268. $_GPC = I('post.');
  269. if( !isset($_GPC['thumbs']) || empty($_GPC['thumbs']) )
  270. {
  271. show_json(0, array('message' => '商品图片必须上传' ,'url' => $_SERVER['HTTP_REFERER']) );
  272. die();
  273. }
  274. D('Seller/Goods')->modify_goods('pin');
  275. $http_refer = S('HTTP_REFERER');
  276. $http_refer = empty($http_refer) ? $_SERVER['HTTP_REFERER'] : $http_refer;
  277. show_json(1, array('message'=>'修改商品成功!','url' => $http_refer ));
  278. }
  279. //sss
  280. S('HTTP_REFERER', $_SERVER['HTTP_REFERER']);
  281. $this->id = $id;
  282. $item = D('Seller/Goods')->get_edit_goods_info($id,1);
  283. //-------------------------以上是获取资料
  284. $limit_goods = array();
  285. $this->limit_goods = $limit_goods;
  286. $category = D('Seller/GoodsCategory')->getFullCategory(true, true,'pintuan');
  287. $this->category = $category;
  288. $spec_list = D('Seller/Spec')->get_all_spec('pintuan');
  289. $this->spec_list = $spec_list;
  290. $dispatch_data = M('lionfish_comshop_shipping')->where( array('enabled' => 1, 'isdefault' => 1) )->order('sort_order desc')->select();
  291. $this->dispatch_data = $dispatch_data;
  292. $set = D('Seller/Config')->get_all_config();
  293. $this->set = $set;
  294. $commission_level = array();
  295. $config_data = $set;
  296. $this->config_data = $config_data;
  297. $default = array('id' => 'default', 'levelname' => empty($config_data['commission_levelname']) ? '默认等级' : $config_data['commission_levelname'], 'commission1' => $config_data['commission1'], 'commission2' => $config_data['commission2'], 'commission3' => $config_data['commission3']);
  298. //$others = pdo_fetchall('SELECT * FROM ' . tablename('lionfish_comshop_commission_level') . ' WHERE uniacid = \'' . $_W['uniacid'] . '\' ORDER BY commission1 asc');
  299. //$commission_level = array_merge(array($default), $others);
  300. $commission_level = array();
  301. //$level['key']
  302. foreach($commission_level as $key => $val)
  303. {
  304. $val['key'] = $val['id'];
  305. $commission_level[$key] = $val;
  306. }
  307. $shopset_level = empty($set['commiss_level']) ? 0: $set['commiss_level'];
  308. $this->shopset_level = $shopset_level;
  309. $open_buy_send_score = empty($set['open_buy_send_score']) ? 0: $set['open_buy_send_score'];
  310. $this->open_buy_send_score = $open_buy_send_score;
  311. $delivery_type_express = $config_data['delivery_type_express'];
  312. if( empty($delivery_type_express) )
  313. {
  314. $delivery_type_express = 2;
  315. }
  316. $this->delivery_type_express = $delivery_type_express;
  317. $is_open_fullreduction = $config_data['is_open_fullreduction'];
  318. $this->is_open_fullreduction = $is_open_fullreduction;
  319. $community_head_level = M('lionfish_comshop_community_head_level')->order('id asc')->select();
  320. $head_commission_levelname = $config_data['head_commission_levelname'];
  321. $default_comunity_money = $config_data['default_comunity_money'];
  322. $list_default = array(
  323. array('id' => '0','level'=>0,'levelname' => empty($head_commission_levelname) ? '默认等级' : $head_commission_levelname, 'commission' => $default_comunity_money, )
  324. );
  325. $community_head_level = array_merge($list_default, $community_head_level);
  326. $community_head_commission_info = D('Seller/Communityhead')->get_goods_head_level_bili( $id );
  327. $mb_level = M('lionfish_comshop_member_level')->count();
  328. $this->mb_level = $mb_level;
  329. if( !empty($community_head_commission_info) )
  330. {
  331. foreach( $community_head_commission_info as $kk => $vv)
  332. {
  333. $item[$kk] = $vv;
  334. }
  335. }
  336. $this->community_head_commission_info = $community_head_commission_info;
  337. $this->item = $item;
  338. $this->community_head_level = $community_head_level;
  339. //end
  340. $community_money_type = $config_data['community_money_type'];
  341. $this->community_money_type = $community_money_type;
  342. $index_sort_method = D('Home/Front')->get_config_by_name('index_sort_method');
  343. if( empty($index_sort_method) || $index_sort_method == 0 )
  344. {
  345. $index_sort_method = 0;
  346. }
  347. $this->index_sort_method = $index_sort_method;
  348. $is_open_only_express = $config_data['is_open_only_express'];
  349. $this->is_open_only_express = $is_open_only_express;
  350. $is_open_goods_relative_goods = $config_data['is_open_goods_relative_goods'];
  351. $this->is_open_goods_relative_goods = $is_open_goods_relative_goods;
  352. //供应商权限begin
  353. $is_index = true;
  354. $is_top = true;
  355. $is_updown = true;
  356. $is_fullreduce = true;
  357. $is_vir_count = true;
  358. $is_newbuy = true;
  359. $is_goodsspike = true;
  360. //供应商权限end
  361. $this->is_index = $is_index;
  362. $this->is_top = $is_top;
  363. $this->is_updown = $is_updown;
  364. $this->is_fullreduce = $is_fullreduce;
  365. $this->is_vir_count = $is_vir_count;
  366. $this->is_newbuy = $is_newbuy;
  367. $this->is_goodsspike = $is_goodsspike;
  368. $pintuan_model_buy = isset($config_data['pintuan_model_buy']) ? intval( $config_data['pintuan_model_buy'] ) : 0;
  369. //供应商权限begin community_head_level
  370. $this->pintuan_model_buy = $pintuan_model_buy;
  371. include $this->display('Group/addgoods');
  372. }
  373. public function addgoods()
  374. {
  375. if (IS_POST) {
  376. $_GPC = I('request.');
  377. if( !isset($_GPC['thumbs']) || empty($_GPC['thumbs']) )
  378. {
  379. show_json(0, array('message' => '商品图片必须上传' ,'url' => $_SERVER['HTTP_REFERER']) );
  380. die();
  381. }
  382. D('Seller/Goods')->addgoods('pin');
  383. $http_refer = S('HTTP_REFERER');
  384. $http_refer = empty($http_refer) ? $_SERVER['HTTP_REFERER'] : $http_refer;
  385. show_json(1, array('message' => '添加商品成功!','url' => $http_refer ));
  386. }
  387. S('HTTP_REFERER', $_SERVER['HTTP_REFERER']);
  388. $category = D('Seller/GoodsCategory')->getFullCategory(true, true,'pintuan');
  389. $this->category = $category;
  390. $spec_list = D('Seller/Spec')->get_all_spec('pintuan');
  391. $this->spec_list = $spec_list;
  392. $dispatch_data = M('lionfish_comshop_shipping')->where( array('enabled' => 1,'isdefault' =>1) )->order('sort_order desc')->select();
  393. $this->dispatch_data = $dispatch_data;
  394. $set = D('Seller/Config')->get_all_config();
  395. $commission_level = array();
  396. $config_data = $set;
  397. $this->config_data = $config_data;
  398. $default = array('id' => 'default', 'levelname' => empty($config_data['commission_levelname']) ? '默认等级' : $config_data['commission_levelname'], 'commission1' => $config_data['commission1'], 'commission2' => $config_data['commission2'], 'commission3' => $config_data['commission3']);
  399. $others = M('lionfish_comshop_commission_level')->order('commission1 asc')->select();
  400. $commission_level = array_merge(array($default), $others);
  401. $communityhead_commission = $config_data['default_comunity_money'];
  402. $this->communityhead_commission = $communityhead_commission;
  403. //$level['key']
  404. foreach($commission_level as $key => $val)
  405. {
  406. $val['key'] = $val['id'];
  407. $commission_level[$key] = $val;
  408. }
  409. $this->commission_level = $commission_level;
  410. $shopset_level = empty($set['commiss_level']) ? 0: $set['commiss_level'];
  411. $this->shopset_level = $shopset_level;
  412. $open_buy_send_score = empty($set['open_buy_send_score']) ? 0: $set['open_buy_send_score'];
  413. $this->open_buy_send_score = $open_buy_send_score;
  414. $item = array();
  415. $item['begin_time'] = time();
  416. $item['community_head_commission'] = $communityhead_commission;
  417. $item['end_time'] = time() + 86400;
  418. $item['pin_count'] = 2;
  419. $delivery_type_express = $config_data['delivery_type_express'];
  420. if( empty($delivery_type_express) )
  421. {
  422. $delivery_type_express = 2;
  423. }
  424. $this->delivery_type_express = $delivery_type_express;
  425. $is_open_fullreduction = $config_data['is_open_fullreduction'];
  426. $this->is_open_fullreduction = $is_open_fullreduction;
  427. $community_head_level = M('lionfish_comshop_community_head_level')->order('id asc')->select();
  428. $head_commission_levelname = $config_data['head_commission_levelname'];
  429. $default_comunity_money = $config_data['default_comunity_money'];
  430. $list_default = array(
  431. array('id' => '0','level'=>0,'levelname' => empty($head_commission_levelname) ? '默认等级' : $head_commission_levelname, 'commission' => $default_comunity_money, )
  432. );
  433. $community_head_level = array_merge($list_default, $community_head_level);
  434. if( !empty($community_head_level) )
  435. {
  436. foreach( $community_head_level as $head_level)
  437. {
  438. $item['head_level'.$head_level['id']] = $head_level['commission'];
  439. }
  440. }
  441. $this->item = $item;
  442. $this->community_head_level = $community_head_level;
  443. $community_money_type = $config_data['community_money_type'];
  444. $this->community_money_type = $community_money_type;
  445. $mb_level = M('lionfish_comshop_member_level')->count();
  446. $this->mb_level = $mb_level;
  447. $is_open_only_express = $config_data['is_open_only_express'];
  448. $this->is_open_only_express = $is_open_only_express;
  449. $is_open_goods_relative_goods = $config_data['is_open_goods_relative_goods'];
  450. $this->is_open_goods_relative_goods = $is_open_goods_relative_goods;
  451. //供应商权限begin
  452. $is_index = true;
  453. $is_top = true;
  454. $is_updown = true;
  455. $is_fullreduce = true;
  456. $is_vir_count = true;
  457. $is_newbuy = true;
  458. $is_goodsspike = true;
  459. //供应商权限end
  460. $this->is_index = $is_index;
  461. $this->is_top = $is_top;
  462. $this->is_updown = $is_updown;
  463. $this->is_fullreduce = $is_fullreduce;
  464. $this->is_vir_count = $is_vir_count;
  465. $this->is_newbuy = $is_newbuy;
  466. $this->is_goodsspike = $is_goodsspike;
  467. $pintuan_model_buy = isset($config_data['pintuan_model_buy']) ? intval( $config_data['pintuan_model_buy'] ) : 0;
  468. $this->pintuan_model_buy = $pintuan_model_buy;
  469. $this->display();
  470. }
  471. public function config()
  472. {
  473. if (IS_POST) {
  474. $data = I('post.parameter', array());
  475. $data['pintuan_stranger_zero'] = isset($data['pintuan_stranger_zero']) ? $data['pintuan_stranger_zero'] : 0;
  476. D('Seller/Config')->update($data);
  477. show_json(1, array('url'=> U('group/config')));
  478. }
  479. $data = D('Seller/Config')->get_all_config();
  480. $this->data = $data;
  481. $this->display();
  482. }
  483. public function slider ()
  484. {
  485. $_GPC = I('request.');
  486. $condition = ' and type="pintuan" ';
  487. $pindex = max(1, intval($_GPC['page']));
  488. $psize = 20;
  489. if (!empty($_GPC['keyword'])) {
  490. $_GPC['keyword'] = trim($_GPC['keyword']);
  491. $condition .= ' and advname like "%'.$_GPC['keyword'].'%"';
  492. }
  493. if (isset($_GPC['enabled']) && $_GPC['enabled'] >= 0) {
  494. $_GPC['enabled'] = trim($_GPC['enabled']);
  495. $condition .= ' and enabled = ' . $_GPC['enabled'];
  496. } else {
  497. $_GPC['enabled'] = -1;
  498. }
  499. $list = M()->query('SELECT id,advname,thumb,link,type,displayorder,enabled FROM ' . C('DB_PREFIX') . "lionfish_comshop_adv
  500. WHERE 1 " . $condition . ' order by displayorder desc, id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  501. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX'). 'lionfish_comshop_adv WHERE 1 ' . $condition );
  502. $total = $total_arr[0]['count'];
  503. $pager = pagination2($total, $pindex, $psize);
  504. $this->list = $list;
  505. $this->pager = $pager;
  506. $this->_GPC = $_GPC;
  507. include $this->display();
  508. }
  509. public function pintuan()
  510. {
  511. $_GPC = I('request.');
  512. $state = $_GPC['state'];
  513. $pindex = max(1, intval($_GPC['page']));
  514. $psize = 20;
  515. $where = "";
  516. if( isset($state) && $state >=0 )
  517. {
  518. if($state == 0) {
  519. $where = " and p.state=0 and p.end_time > ".time();
  520. } else if($state == 1) {
  521. $where = " and p.state=1 ";
  522. } else if($state == 2) {
  523. $where = " and (p.state=2 or (p.state = 0 and p.end_time <".time()." ) )";
  524. }
  525. }
  526. $sql = "select p.pin_id,p.is_jiqi,og.goods_id,og.name,p.state,p.need_count,p.end_time,p.begin_time from ".
  527. C('DB_PREFIX')."lionfish_comshop_pin as p,".C('DB_PREFIX')."lionfish_comshop_pin_order as o,".C('DB_PREFIX')."lionfish_comshop_order_goods as og
  528. where p.order_id= o.order_id {$where} and p.order_id = og.order_id ".' order by p.pin_id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  529. $list = M()->query( $sql );
  530. $sql_count = "select count(1) as count from ".
  531. C('DB_PREFIX')."lionfish_comshop_pin as p,".C('DB_PREFIX')."lionfish_comshop_pin_order as o,".C('DB_PREFIX')."lionfish_comshop_order_goods as og
  532. where p.order_id= o.order_id {$where} and p.order_id = og.order_id ";
  533. $total_arr = M()->query( $sql_count );
  534. $total = $total_arr[0]['count'];
  535. foreach($list as $key => $val)
  536. {
  537. $sql = "select count(o.order_id) as count from ".C('DB_PREFIX')."lionfish_comshop_pin_order as po,".C('DB_PREFIX')."lionfish_comshop_order as o
  538. where po.order_id= o.order_id and po.pin_id = ".$val['pin_id']." and o.order_status_id in(1,2,4,6,7,8,9,10) ";
  539. $count_arr = M()->query($sql);
  540. $pin_buy_count = $count_arr[0]['count'];
  541. $val['real_state'] = $val['state'];
  542. if($val['state'] == 0 && $val['end_time'] <time()) {
  543. $val['state'] = 2;
  544. }
  545. $val['buy_count'] = $pin_buy_count;
  546. $list[$key] = $val;
  547. }
  548. $pager = pagination2($total, $pindex, $psize);
  549. $this->pager = $pager;
  550. $this->list = $list;
  551. $this->_GPC = $_GPC;
  552. $this->display();
  553. }
  554. public function pintuan_detail()
  555. {
  556. $_GPC = I('request.');
  557. $pin_id = $_GPC['pin_id'];
  558. $pin_info = M('lionfish_comshop_pin')->where( array('pin_id' => $pin_id ) )->find();
  559. if($pin_info['state'] == 0 && $pin_info['end_time'] <time()) {
  560. $pin_info['state'] = 2;
  561. }
  562. if( empty($pin_info['qrcode']) )
  563. {
  564. $weqrcode = D('Home/Pingoods')->_get_commmon_wxqrcode('lionfish_comshop/moduleA/pin/share', $pin_info['order_id'] );
  565. M('lionfish_comshop_pin')->where( array('pin_id' => $pin_id ) )->save( array('qrcode' => $weqrcode ) );
  566. $qrcode = tomedia( $weqrcode );
  567. }else{
  568. $qrcode = tomedia( $pin_info['qrcode'] );
  569. }
  570. $jiapinorder = array();
  571. if($pin_info['is_jiqi'] == 1)
  572. {
  573. $jiapinorder = M('lionfish_comshop_jiapinorder')->where( array('pin_id' => $pin_id) )->order('id asc')->select();
  574. }
  575. $this->pin_info = $pin_info;
  576. $this->pin_id = $pin_id;
  577. $this->jiapinorder = $jiapinorder;
  578. $sql = "select o.order_num_alias,o.total,o.order_id,o.payment_code,o.name,o.telephone,o.shipping_name,o.shipping_tel,o.shipping_city_id,
  579. o.shipping_country_id,o.shipping_province_id,o.shipping_address,o.date_added,o.order_status_id,
  580. 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
  581. from ".C('DB_PREFIX')."lionfish_comshop_order as o,".C('DB_PREFIX')."lionfish_comshop_order_goods as og,".C('DB_PREFIX')."lionfish_comshop_pin_order as p
  582. 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} ";
  583. $sql.=' ORDER BY o.order_id desc ';
  584. $list = M()->query($sql);
  585. foreach($list as $key => $val)
  586. {
  587. /**
  588. $province_info = M('area')->where( array('area_id' =>$val['shipping_province_id'] ) )->find();
  589. $city_info = M('area')->where( array('area_id' =>$val['shipping_city_id'] ) )->find();
  590. $country_info = M('area')->where( array('area_id' =>$val['shipping_country_id'] ) )->find();
  591. $val['province_name'] = $province_info['area_name'];
  592. $val['city_name'] = $city_info['area_name'];
  593. $val['area_name'] = $country_info['area_name'];
  594. **/
  595. $list[$key] = $val;
  596. }
  597. $this->list = $list;
  598. $pin_buy_sql = "select count(o.order_id) as count from ".C('DB_PREFIX')."lionfish_comshop_pin_order as p,".C('DB_PREFIX')."lionfish_comshop_order as o,".C('DB_PREFIX')."lionfish_comshop_order_goods as og
  599. 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)
  600. ";
  601. $pin_buy_count_arr = M()->query($pin_buy_sql );
  602. $pin_buy_count = $pin_buy_count_arr[0]['count'];
  603. $this->pin_buy_count = $pin_buy_count;
  604. $pin_jia_count = 0;
  605. $order = current($list);
  606. $this->order = $order;
  607. $goods_images = tomedia($order['goods_images']);
  608. $this->goods_images = $goods_images;
  609. $order_status_list = M('lionfish_comshop_order_status')->select();
  610. $order_status_arr = array();
  611. foreach($order_status_list as $val)
  612. {
  613. $order_status_arr[$val['order_status_id']] = $val['name'];
  614. }
  615. $this->order_status_arr = $order_status_arr;
  616. include $this->display();
  617. }
  618. public function addslider()
  619. {
  620. $id = I('request.id');
  621. if (!empty($id)) {
  622. $item = M('lionfish_comshop_adv')->where( array('id' => $id) )->find();
  623. $this->item = $item;
  624. }
  625. if (IS_POST) {
  626. $data = I('request.data');
  627. D('Seller/Adv')->update($data ,'pintuan');
  628. show_json(1, array('url' => U('group.slider') ));
  629. }
  630. $this->display();
  631. }
  632. public function changeslider()
  633. {
  634. $id = I('request.id');
  635. //ids
  636. if (empty($id)) {
  637. $ids = I('request.ids');
  638. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  639. }
  640. if (empty($id)) {
  641. show_json(0, array('message' => '参数错误'));
  642. }
  643. $type = I('request.type');
  644. $value = I('request.value');
  645. if (!(in_array($type, array('enabled', 'displayorder')))) {
  646. show_json(0, array('message' => '参数错误'));
  647. }
  648. $items = M('lionfish_comshop_adv')->where( array('id' => array('in', $id)) )->select();
  649. foreach ($items as $item) {
  650. M('lionfish_comshop_adv')->where( array('id' => $item['id']) )->save( array($type => $value) );
  651. }
  652. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  653. }
  654. public function deleteslider()
  655. {
  656. $id = I('request.id');
  657. //ids
  658. if (empty($id)) {
  659. $ids = I('request.ids');
  660. $id = ((is_array($ids) ? implode(',', $ids) : 0));
  661. }
  662. if (empty($id)) {
  663. show_json(0, array('message' => '参数错误'));
  664. }
  665. $items = M('lionfish_comshop_adv')->where( array('id' => array('in', $id)) )->select();
  666. foreach ($items as $item) {
  667. M('lionfish_comshop_adv')->where( array('id' => $item['id']) )->delete();
  668. }
  669. show_json(1 , array('url' => $_SERVER['HTTP_REFERER']));
  670. }
  671. public function goodstag()
  672. {
  673. $_GPC = I('request.');
  674. $this->gpc = $_GPC;
  675. $condition = ' 1 and tag_type="pintuan" ';
  676. $pindex = max(1, intval($_GPC['page']));
  677. $psize = 20;
  678. if ($_GPC['enabled'] != '') {
  679. $condition .= ' and state=' . intval($_GPC['enabled']);
  680. }
  681. if (!empty($_GPC['keyword'])) {
  682. $_GPC['keyword'] = trim($_GPC['keyword']);
  683. $condition .= ' and tagname like "%'.$_GPC['keyword'].'%" ';
  684. }
  685. $label = M('lionfish_comshop_goods_tags')->where( $condition )->order(' id asc ')->limit( (($pindex - 1) * $psize) . ',' . $psize )->select();
  686. $total = M('lionfish_comshop_goods_tags')->where( $condition )->count();
  687. $pager = pagination2($total, $pindex, $psize);
  688. $this->label = $label;
  689. $this->pager = $pager;
  690. $this->display();
  691. }
  692. public function addtags()
  693. {
  694. $_GPC = I('request.');
  695. if (IS_POST) {
  696. $data = $_GPC['data'];
  697. D('Seller/Tags')->update($data,'pintuan');
  698. show_json(1, array('url' => U('group/goodstag')));
  699. }
  700. $this->display();
  701. }
  702. public function edittags()
  703. {
  704. $_GPC = I('request.');
  705. $id = intval($_GPC['id']);
  706. if (!empty($id)) {
  707. $item = M('lionfish_comshop_goods_tags')->field('id,tagname,tagcontent,state,sort_order,type')->where( array('id' =>$id ) )->find();
  708. if (json_decode($item['tagcontent'], true)) {
  709. $labelname = json_decode($item['tagcontent'], true);
  710. }
  711. else {
  712. $labelname = unserialize($item['tagcontent']);
  713. }
  714. $this->item = $item;
  715. $this->labelname = $labelname;
  716. }
  717. if (IS_POST) {
  718. $data = $_GPC['data'];
  719. D('Seller/Tags')->update($data,'pintuan');
  720. show_json(1, array('url' => U('group/goodstag') ));
  721. }
  722. $this->display('Group/addtags');
  723. }
  724. public function deletetags()
  725. {
  726. $_GPC = I('request.');
  727. $id = intval($_GPC['id']);
  728. if (empty($id)) {
  729. $id = $_GPC['ids'];
  730. }
  731. if( is_array($id) )
  732. {
  733. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' => array('in', $id)) )->select();
  734. }else{
  735. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' =>$id ) )->select();
  736. }
  737. //$items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' => array('in', $id )) )->select();
  738. if (empty($item)) {
  739. $item = array();
  740. }
  741. foreach ($items as $item) {
  742. M('lionfish_comshop_goods_tags')->where( array('id' => $item['id']) )->delete();
  743. }
  744. show_json(1, array('url' => U('group/goodstag')));
  745. }
  746. public function tagsstate()
  747. {
  748. $_GPC = I('request.');
  749. $id = intval($_GPC['id']);
  750. if (empty($id)) {
  751. $id = $_GPC['ids'];
  752. }
  753. if( is_array($id) )
  754. {
  755. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' => array('in', $id)) )->select();
  756. }else{
  757. $items = M('lionfish_comshop_goods_tags')->field('id,tagname')->where( array('id' =>$id ) )->select();
  758. }
  759. if (empty($item)) {
  760. $item = array();
  761. }
  762. foreach ($items as $item) {
  763. M('lionfish_comshop_goods_tags')->where( array('id' => $item['id']) )->save( array('state' => intval($_GPC['value'])) );
  764. }
  765. show_json(1, array('url' => U('group/goodstag')));
  766. }
  767. public function labelquery()
  768. {
  769. $_GPC = I('request.');
  770. $kwd = trim($_GPC['keyword']);
  771. $type = isset($_GPC['type']) ? $_GPC['type'] : 'pintuan';
  772. $condition = ' and state = 1 and tag_type="'.$type.'" ';
  773. if (!empty($kwd)) {
  774. $condition .= ' AND tagname LIKE "%'.$kwd.'%" ';
  775. }
  776. $labels = M('lionfish_comshop_goods_tags')->field('id,tagname,tagcontent')->where( '1 '. $condition )->order('id desc')->select();
  777. if (empty($labels)) {
  778. $labels = array();
  779. }
  780. $html = '';
  781. foreach ($labels as $key => $value) {
  782. if (json_decode($value['tagcontent'], true)) {
  783. $labels[$key]['tagcontent'] = json_decode($value['tagcontent'], true);
  784. }
  785. else {
  786. $labels[$key]['tagcontent'] = unserialize($value['tagcontent']);
  787. }
  788. $html .= '<nav class="btn btn-default btn-sm choose_dan_link" data-id="'.$value['id'].'" data-json=\''.json_encode(array("id"=>$value["id"],"tagname"=>$value["tagname"])).'\'>';
  789. $html .= $value['tagname'];
  790. $html .= '</nav>';
  791. }
  792. if( isset($_GPC['is_ajax']) )
  793. {
  794. echo json_encode( array('code' => 0, 'html' => $html) );
  795. die();
  796. }
  797. $this->labels = $labels;
  798. $this->display();
  799. }
  800. public function editspec()
  801. {
  802. $id = I('request.id');
  803. if (!empty($id)) {
  804. $item = M('lionfish_comshop_spec')->where( array('id' => $id) )->find();
  805. if (json_decode($item['value'], true)) {
  806. $labelname = json_decode($item['value'], true);
  807. }
  808. else {
  809. $labelname = unserialize($item['value']);
  810. }
  811. }
  812. if (IS_POST) {
  813. $data = I('post.data');
  814. D('Seller/Spec')->update($data,'pintuan');
  815. show_json(1, array('url' => U('group/goodsspec')));
  816. }
  817. $this->item = $item;
  818. $this->labelname = $labelname;
  819. $this->display('Group/addspec');
  820. }
  821. public function addspec()
  822. {
  823. global $_W;
  824. global $_GPC;
  825. if (IS_POST) {
  826. $data = I('post.data');
  827. D('Seller/Spec')->update($data,'pintuan');
  828. show_json(1, array('url' => U('group/goodsspec')));
  829. }
  830. $this->display();
  831. }
  832. public function deletespec()
  833. {
  834. $id = I('get.id');
  835. if (empty($id)) {
  836. $ids = I('post.ids');
  837. $id = (is_array($ids) ? implode(',', $ids) : 0);
  838. }
  839. $items = M('lionfish_comshop_spec')->field('id,name')->where( array('id' => array('in', $id)) )->select();
  840. if (empty($item)) {
  841. $item = array();
  842. }
  843. foreach ($items as $item) {
  844. M('lionfish_comshop_spec')->where( array('id' => $item['id']) )->delete();
  845. }
  846. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  847. }
  848. public function goodsspec()
  849. {
  850. $condition = ' 1=1 and spec_type="pintuan" ';
  851. $pindex = I('get.page',1);
  852. $psize = 20;
  853. $enabled = I('get.enabled');
  854. if ($enabled != '') {
  855. $condition .= ' and state=' . intval($enabled);
  856. }
  857. $keyword = I('get.keyword','','trim');
  858. if (!empty($keyword)) {
  859. $condition .= ' and name like "%'.$keyword.'%" ';
  860. }
  861. $offset = ($pindex - 1) * $psize;
  862. $label = M('lionfish_comshop_spec')->field('id,name,value')->where($condition)->order(' id desc ')->limit($offset, $psize)->select();
  863. $total = M('lionfish_comshop_spec')->where( $condition )->count();
  864. $cur_url = U('goods/goodsspec', array('enabled' => $enabled,'keyword' => $keyword));
  865. $pager = pagination2($total, $pindex, $psize);
  866. foreach( $label as &$val )
  867. {
  868. $val['value'] = unserialize($val['value']);
  869. $val['value_str'] = !empty($val['value']) ? implode(',', $val['value']) : '';
  870. }
  871. $this->keyword = $keyword;
  872. $this->label = $label;
  873. $this->total = $total;
  874. $this->pager = $pager;
  875. include $this->display();
  876. }
  877. public function category_enabled()
  878. {
  879. $id = I('request.id');
  880. if (empty($id)) {
  881. $ids = I('request.ids');
  882. $id = (is_array($ids) ? implode(',', $ids) : 0);
  883. }
  884. $items = M('lionfish_comshop_goods_category')->field('id,name')->where( 'id in( ' . $id . ' )' )->select();
  885. $enabled = I('request.enabled');
  886. foreach ($items as $item) {
  887. M('lionfish_comshop_goods_category')->where( array('id' => $item['id']) )->save( array('is_show' => intval($enabled)) );
  888. }
  889. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  890. }
  891. public function goodscategory()
  892. {
  893. if (IS_POST) {
  894. $datas = I('post.datas');
  895. if (!empty($datas)) {
  896. D('Seller/GoodsCategory')->goodscategory_modify($datas);
  897. show_json(1 , array('url' => U('group/goodscategory') ));
  898. }
  899. }
  900. $children = array();
  901. $category = M('lionfish_comshop_goods_category')->where(' cate_type="pintuan" ')->order('pid ASC, sort_order DESC')->select();
  902. foreach ($category as $index => $row) {
  903. if (!empty($row['pid'])) {
  904. $children[$row['pid']][] = $row;
  905. unset($category[$index]);
  906. }
  907. }
  908. $this->children = $children;
  909. $this->category = $category;
  910. include $this->display();
  911. }
  912. public function addcategory()
  913. {
  914. $data = array();
  915. $pid = I('get.pid', 0);
  916. $id = I('get.id', 0);
  917. if (IS_POST) {
  918. $data = I('post.data');
  919. D('Seller/GoodsCategory')->update($data,'pintuan');
  920. show_json(1, array('url' => U('group/goodscategory')));
  921. }
  922. if($id >0 )
  923. {
  924. $data = M('lionfish_comshop_goods_category')->where( array('id' => $id) )->find();
  925. $this->data = $data;
  926. }
  927. $this->pid = $pid;
  928. $this->id = $id;
  929. $this->display();
  930. }
  931. public function category_delete()
  932. {
  933. $id = I('get.id');
  934. $item = M('lionfish_comshop_goods_category')->field('id, name, pid')->where( array('id' => $id) )->find();
  935. M('lionfish_comshop_goods_category')->where( "id={$id} or pid={$id}" )->delete();
  936. show_json(1, array('url' => U('group/goodscategory')));
  937. }
  938. public function goodsvircomment()
  939. {
  940. $_GPC = I('request.');
  941. $condition = ' and type = 1 and gd_type="pintuan" ';
  942. $pindex = max(1, intval($_GPC['page']));
  943. $psize = 20;
  944. if (!empty($_GPC['keyword'])) {
  945. $_GPC['keyword'] = trim($_GPC['keyword']);
  946. $condition .= ' and content like "%'.$_GPC['keyword'].'%"';
  947. }
  948. $label = M()->query('SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_order_comment
  949. WHERE 1 " . $condition . ' order by comment_id desc limit ' . (($pindex - 1) * $psize) . ',' . $psize);
  950. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX'). 'lionfish_comshop_order_comment WHERE 1 ' . $condition);
  951. $total = $total_arr[0]['count'];
  952. $pager = pagination2($total, $pindex, $psize);
  953. $this->pager = $pager;
  954. $this->label = $label;
  955. include $this->display();
  956. }
  957. public function addvircomment()
  958. {
  959. $_GPC = I('request.');
  960. if (IS_POST) {
  961. $data = $_GPC['data'];
  962. $jia_id = $_GPC['jiaid'];
  963. $goods_id = $_GPC['goods_id'];
  964. if( empty($goods_id) )
  965. {
  966. show_json(0, array('message' => '请选择评价商品!'));
  967. }
  968. if( empty($jia_id) )
  969. {
  970. show_json(0, array('message' => '请选择机器人!'));
  971. }
  972. $goods_info = M('lionfish_comshop_goods')->field('goodsname')->where( array('id' => $goods_id) )->find();
  973. $goods_image = isset($_GPC['goods_image']) && !empty($_GPC['goods_image']) ? $_GPC['goods_image'] : array();
  974. $time = empty($_GPC['time']) ? time() : $_GPC['time'];
  975. $jia_info = M('lionfish_comshop_jiauser')->where( array('id' => $jia_id ) )->find();
  976. $commen_data = array();
  977. $commen_data['order_id'] = 0;
  978. $commen_data['state'] = 1;
  979. $commen_data['type'] = 1;
  980. $commen_data['gd_type'] = "pintuan";
  981. $commen_data['member_id'] = $jia_id;
  982. $commen_data['avatar'] = $jia_info['avatar'];
  983. $commen_data['user_name'] = $jia_info['username'];
  984. $commen_data['order_num_alias'] = 1;
  985. $commen_data['star'] = $data['star'];
  986. $commen_data['star3'] = $data['star3'];
  987. $commen_data['star2'] = $data['star2'];
  988. $commen_data['is_picture'] = !empty($goods_image) ? 1: 0;
  989. $commen_data['content'] = $data['content'];
  990. $commen_data['images'] = serialize(implode(',', $goods_image));
  991. $image = D('Home/Pingoods')->get_goods_images($goods_id);
  992. $seller_id = 1;
  993. if(!empty($image))
  994. {
  995. $commen_data['goods_image'] = $image['image'];
  996. }else{
  997. $commen_data['goods_image'] = '';
  998. }
  999. $commen_data['goods_id'] = $goods_id;
  1000. $commen_data['goods_name'] = $goods_info['goodsname'];
  1001. $commen_data['add_time'] = strtotime($time);
  1002. M('lionfish_comshop_order_comment')->add($commen_data);
  1003. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  1004. }
  1005. $this->display();
  1006. }
  1007. public function orderlist()
  1008. {
  1009. $time = I('request.time');
  1010. $starttime = isset($time['start']) ? strtotime($time['start']) : strtotime(date('Y-m-d'.' 00:00:00'));
  1011. $endtime = isset($time['end']) ? strtotime($time['end']) : strtotime(date('Y-m-d'.' 23:59:59'));
  1012. $this->searchfield = I('request.searchfield','');
  1013. $this->keyword = I('request.keyword','');
  1014. $this->searchtime = I('request.searchtime','');
  1015. $this->delivery = I('request.delivery','');
  1016. $this->starttime = $starttime;
  1017. $this->endtime = $endtime;
  1018. $this->time = $time;
  1019. $order_status_id = I('request.order_status_id',0);
  1020. $order_status_arr = D('Seller/Order')->get_order_status_name();
  1021. $this->order_status_arr = $order_status_arr;
  1022. $need_data = D('Seller/Order')->load_order_list(0,0,1);
  1023. $cur_controller = 'group/orderlist';
  1024. $total = $need_data['total'];
  1025. $total_money = $need_data['total_money'];
  1026. $list = $need_data['list'];
  1027. $pager = $need_data['pager'];
  1028. $all_count = $need_data['all_count'];
  1029. $count_status_1 = $need_data['count_status_1'];
  1030. $count_status_3 = $need_data['count_status_3'];
  1031. $count_status_4 = $need_data['count_status_4'];
  1032. $count_status_5 = $need_data['count_status_5'];
  1033. $count_status_7 = $need_data['count_status_7'];
  1034. $count_status_11 = $need_data['count_status_11'];
  1035. $count_status_14 = $need_data['count_status_14'];
  1036. $this->cur_controller = $cur_controller;
  1037. $this->total = $total;
  1038. $this->total_money = $total_money;
  1039. $this->list = $list;
  1040. $this->pager = $pager;
  1041. $this->all_count = $all_count;
  1042. $this->count_status_1 = $count_status_1;
  1043. $this->count_status_3 = $count_status_3;
  1044. $this->count_status_4 = $count_status_4;
  1045. $this->count_status_5 = $count_status_5;
  1046. $this->count_status_7 = $count_status_7;
  1047. $this->count_status_11 = $count_status_11;
  1048. $this->count_status_14 = $count_status_14;
  1049. $this->order_status_id = $order_status_id;
  1050. $this->is_community = I('request.is_community', 0);
  1051. $this->headid = I('request.headid', 0);
  1052. $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print');
  1053. if( empty($open_feier_print) )
  1054. {
  1055. $open_feier_print = 0;
  1056. }
  1057. $this->open_feier_print = $open_feier_print;
  1058. $is_can_look_headinfo = true;
  1059. $is_can_nowrfund_order = true;
  1060. $this->is_can_look_headinfo = $is_can_look_headinfo;
  1061. $this->is_can_nowrfund_order = $is_can_nowrfund_order;
  1062. include $this->display();
  1063. }
  1064. public function ordersendall()
  1065. {
  1066. $_GPC = I('request.');
  1067. $express_list = D('Seller/Express')->load_all_express();
  1068. if( IS_POST )
  1069. {
  1070. $type = isset($_GPC['type']) && !empty($_GPC['type']) ? $_GPC['type']:'normal';
  1071. $fext = substr($_FILES['excelfile']['name'], strrpos($_FILES['excelfile']['name'], '.') + 1);
  1072. $express = trim($_GPC['express']);
  1073. $expresscom = trim($_GPC['expresscom']);
  1074. if( $fext == 'csv' )
  1075. {
  1076. $file_name = $_FILES['excelfile']['tmp_name'];
  1077. $file = fopen($file_name,'r');
  1078. $rows = array();
  1079. $i =0;
  1080. while ($data = fgetcsv($file)) {
  1081. $rows[] = eval('return '.iconv('gbk','utf-8',var_export($data,true)).';');
  1082. }
  1083. //var_dump( $rows );
  1084. //die();
  1085. }else{
  1086. $rows = D('Seller/Excel')->import('excelfile');
  1087. }
  1088. $num = count($rows);
  1089. $time = time();
  1090. $express_arr = array();
  1091. foreach($express_list as $val)
  1092. {
  1093. $express_arr[ $val['id'] ] = $val['name'];
  1094. }
  1095. $i = 0;
  1096. $err_array = array();
  1097. $quene_order_list = array();
  1098. $cache_key = md5(time().count($rows));
  1099. $j =0;
  1100. foreach ($rows as $rownum => $col)
  1101. {
  1102. $order_id = trim($col[0]);
  1103. if (empty($order_id)) {
  1104. $err_array[] = $order_id;
  1105. continue;
  1106. }
  1107. if($j == 0)
  1108. {
  1109. $j++;
  1110. continue;
  1111. }
  1112. $quene_order_list[] = array('order_num_alias' => $order_id , 'shipping_no' => $col[1], 'express' => $express,'expresscom' => $expresscom );
  1113. }
  1114. S('_orderquene_'.$cache_key, $quene_order_list);
  1115. $this->cache_key = $cache_key;
  1116. $this->type = $type;
  1117. $this->display('Order/oploadexcelorder');
  1118. die();
  1119. }
  1120. $this->express_list = $express_list;
  1121. $this->type = I('request.type');
  1122. $this->display();
  1123. }
  1124. public function orderaftersales()
  1125. {
  1126. //$_GPC['order_status_id'] = 12;
  1127. $gpc = I('request.');
  1128. $this->gpc = $gpc;
  1129. $this->_GPC = $gpc;
  1130. $time = I('request.time');
  1131. $starttime = isset($time['start']) ? strtotime($time['start']) : strtotime(date('Y-m-d'.' 00:00:00'));
  1132. $endtime = isset($time['end']) ? strtotime($time['end']) : strtotime(date('Y-m-d'.' 23:59:59'));
  1133. $this->searchfield = I('request.searchfield','');
  1134. $this->keyword = I('request.keyword','');
  1135. $this->searchtime = I('request.searchtime','');
  1136. $this->delivery = I('request.delivery','');
  1137. $this->starttime = $starttime;
  1138. $this->endtime = $endtime;
  1139. $this->time = $time;
  1140. $order_status_arr = D('Seller/Order')->get_order_status_name();
  1141. $this->order_status_arr = $order_status_arr;
  1142. $need_data = D('Seller/Order')->load_afterorder_list(1);//改造原来的加载方法
  1143. $this->need_data = $need_data;
  1144. $cur_controller = 'order/order';
  1145. $total = $need_data['total'];
  1146. $total_money = $need_data['total_money'];
  1147. $list = $need_data['list'];
  1148. $pager = $need_data['pager'];
  1149. $all_count = $need_data['all_count'];
  1150. $count_status_1 = $need_data['count_status_1'];
  1151. $count_status_3 = $need_data['count_status_3'];
  1152. $count_status_4 = $need_data['count_status_4'];
  1153. $count_status_5 = $need_data['count_status_5'];
  1154. $count_status_7 = $need_data['count_status_7'];
  1155. $count_status_11 = $need_data['count_status_11'];
  1156. $count_status_14 = $need_data['count_status_14'];
  1157. $this->cur_controller = $cur_controller;
  1158. $this->total = $total;
  1159. $this->total_money = $total_money;
  1160. $this->list = $list;
  1161. $this->pager = $pager;
  1162. $this->all_count = $all_count;
  1163. $this->count_status_1 = $count_status_1;
  1164. $this->count_status_3 = $count_status_3;
  1165. $this->count_status_4 = $count_status_4;
  1166. $this->count_status_5 = $count_status_5;
  1167. $this->count_status_7 = $count_status_7;
  1168. $this->count_status_11 = $count_status_11;
  1169. $this->count_status_14 = $count_status_14;
  1170. $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print');
  1171. if( empty($open_feier_print) )
  1172. {
  1173. $open_feier_print = 0;
  1174. }
  1175. $this->open_feier_print = $open_feier_print;
  1176. //退款状态:0申请中,1商家拒绝,2平台介入,3退款成功,4退款失败,5:撤销申请
  1177. $order_refund_state = array(0=>'申请中',1=>'商家拒绝', 2=>'平台介入',3=>'退款成功',4=>'退款失败',5=>'撤销申请');
  1178. $this->order_refund_state = $order_refund_state;
  1179. $is_can_look_headinfo = true;
  1180. $is_can_nowrfund_order = true;
  1181. $supply_can_look_headinfo = D('Home/Front')->get_config_by_name('supply_can_look_headinfo');
  1182. $supply_can_nowrfund_order = D('Home/Front')->get_config_by_name('supply_can_nowrfund_order');
  1183. if (defined('ROLE') && ROLE == 'agenter' )
  1184. {
  1185. if( isset($supply_can_look_headinfo) && $supply_can_look_headinfo == 2 )
  1186. {
  1187. $is_can_look_headinfo = false;
  1188. }
  1189. if( isset($supply_can_nowrfund_order) && $supply_can_nowrfund_order == 2 )
  1190. {
  1191. $is_can_nowrfund_order = false;
  1192. }
  1193. }
  1194. $this->is_can_look_headinfo = $is_can_look_headinfo;
  1195. $this->is_can_nowrfund_order = $is_can_nowrfund_order;
  1196. $this->display();
  1197. }
  1198. public function pincommiss()
  1199. {
  1200. $_GPC = I('request.');
  1201. $condition = ' ';
  1202. $pindex = max(1, intval($_GPC['page']));
  1203. $psize = 20;
  1204. if (!empty($_GPC['keyword'])) {
  1205. $_GPC['keyword'] = trim($_GPC['keyword']);
  1206. $condition .= ' and ( m.username like %"'.$_GPC['keyword'].'"% ) ';
  1207. }
  1208. $sql = 'SELECT m.*,pc.money as pcmoney,pc.dongmoney,pc.getmoney FROM ' . C('DB_PREFIX') . "lionfish_comshop_pintuan_commiss as pc left join ".C('DB_PREFIX')."lionfish_comshop_member as m on pc.member_id=m.member_id
  1209. WHERE 1 " . $condition . ' order by pc.id asc ';
  1210. $sql_count = 'SELECT count(1) as count FROM ' . C('DB_PREFIX'). "lionfish_comshop_pintuan_commiss as pc left join ".C('DB_PREFIX')."lionfish_comshop_member as m on pc.member_id=m.member_id
  1211. WHERE 1 " . $condition . ' order by pc.id asc ';
  1212. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  1213. $list = M()->query($sql);
  1214. $total_arr = M()->query($sql_count);
  1215. $total = $total_arr[0]['count'];
  1216. foreach( $list as $key => $val )
  1217. {
  1218. //普通等级
  1219. //ims_ lionfish_comshop_order 1 2 4 6 11
  1220. $list[$key] = $val;
  1221. }
  1222. $pager = pagination2($total, $pindex, $psize);
  1223. $this->list = $list;
  1224. $this->pager = $pager;
  1225. $this->_GPC = $_GPC;
  1226. $this->display();
  1227. }
  1228. public function pincommiss_list()
  1229. {
  1230. $_GPC = I('request.');
  1231. $member_id = $_GPC['id'];
  1232. $this->member_id = $member_id;
  1233. $pindex = max(1, intval($_GPC['page']));
  1234. $psize = 20;
  1235. $where = " and co.member_id = {$member_id} ";
  1236. $starttime = strtotime( date('Y-m-d')." 00:00:00" );
  1237. $endtime = $starttime + 86400;
  1238. if( isset($_GPC['searchtime']) && $_GPC['searchtime'] == 'create_time' )
  1239. {
  1240. if (!empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) {
  1241. $starttime = strtotime($_GPC['time']['start']);
  1242. $endtime = strtotime($_GPC['time']['end']);
  1243. $where .= ' AND co.addtime >= '.$starttime.' AND co.addtime <= '.$endtime;
  1244. }
  1245. }
  1246. $this->starttime = $starttime;
  1247. $this->endtime = $endtime;
  1248. $order_status = isset($_GPC['order_status']) ? $_GPC['order_status'] : -1;
  1249. if($order_status == 1)
  1250. {
  1251. $where .= " and co.state = 1 ";
  1252. } else if($order_status == 2){
  1253. $where .= " and co.state = 2 ";
  1254. } else if($order_status == 0){
  1255. $where .= " and co.state = 0 ";
  1256. }
  1257. $sql = "select co.order_id,co.state,co.money,co.addtime ,og.total,og.name,og.total
  1258. from ".C('DB_PREFIX')."lionfish_comshop_pintuan_commiss_order as co ,
  1259. ".C('DB_PREFIX')."lionfish_comshop_order_goods as og
  1260. where co.order_goods_id = og.order_goods_id {$where}
  1261. order by co.id desc ".' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  1262. $list = M()->query($sql);
  1263. if( !empty($list) )
  1264. {
  1265. foreach($list as $key => $val)
  1266. {
  1267. $val['total'] = sprintf("%.2f",$val['total']);
  1268. $val['money'] = sprintf("%.2f",$val['money']);
  1269. $val['addtime'] = date('Y-m-d H:i:s',$val['addtime']);
  1270. $order_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array('order_id' => $val['order_id'] ) )->find();
  1271. $val['order_num_alias'] = $order_info['order_num_alias'];
  1272. $list[$key] = $val;
  1273. }
  1274. }
  1275. $sql_count = "select count(1) as count
  1276. from ".C('DB_PREFIX')."lionfish_comshop_pintuan_commiss_order as co ,
  1277. ".C('DB_PREFIX')."lionfish_comshop_order_goods as og
  1278. where co.order_goods_id = og.order_goods_id {$where} ";
  1279. $total_arr = M()->query($sql_count);
  1280. $total = $total_arr[0]['count'];
  1281. $pager = pagination($total, $pindex, $psize);
  1282. $this->list = $list;
  1283. $this->pager = $pager;
  1284. $this->_GPC = $_GPC;
  1285. $this->display();
  1286. }
  1287. public function withdrawallist()
  1288. {
  1289. $_GPC = I('request.');
  1290. $condition = ' ';
  1291. $pindex = max(1, intval($_GPC['page']));
  1292. $psize = 20;
  1293. if (!empty($_GPC['keyword'])) {
  1294. $_GPC['keyword'] = trim($_GPC['keyword']);
  1295. $condition .= ' and ( id = '.intval($_GPC['keyword']).') ';
  1296. }
  1297. $starttime = strtotime( date('Y-m-d')." 00:00:00" );
  1298. $endtime = $starttime + 86400;
  1299. if (!empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) {
  1300. $starttime = strtotime($_GPC['time']['start']);
  1301. $endtime = strtotime($_GPC['time']['end']);
  1302. $condition .= ' AND addtime >= '.$starttime.' AND addtime <= '.$endtime.' ';
  1303. }
  1304. $this->starttime = $starttime;
  1305. $this->endtime = $endtime;
  1306. if ($_GPC['comsiss_state'] != '') {
  1307. $condition .= ' and state=' . intval($_GPC['comsiss_state']);
  1308. }
  1309. $sql = 'SELECT * FROM ' . C('DB_PREFIX') . "lionfish_comshop_pintuan_tixian_order
  1310. WHERE 1 " . $condition . ' order by id desc ';
  1311. if (empty($_GPC['export'])) {
  1312. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  1313. }
  1314. $community_tixian_fee = D('Home/Front')->get_config_by_name('pintuan_tixian_fee', $_W['uniacid']);
  1315. $list = M()->query($sql);
  1316. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX') . 'lionfish_comshop_pintuan_tixian_order WHERE 1 ' . $condition );
  1317. $total = $total_arr[0]['count'];
  1318. foreach( $list as $key => $val )
  1319. {
  1320. //普通等级
  1321. $member_info = M('lionfish_comshop_member')->field('username,avatar,we_openid,telephone')->where( array('member_id' => $val['member_id'] ) )->find();
  1322. $val['member_info'] = $member_info;
  1323. $list[$key] = $val;
  1324. }
  1325. if ($_GPC['export'] == '1') {
  1326. foreach($list as $key =>&$row)
  1327. {
  1328. $row['username'] = $row['member_info']['username'];
  1329. $row['telephone'] = $row['member_info']['telephone'];
  1330. $row['bankname'] = $row['bankname'];
  1331. if( $row['type'] == 1 )
  1332. {
  1333. $row['bankname'] = '余额';
  1334. }elseif( $row['type'] == 2 ){
  1335. $row['bankname'] = '微信零钱';
  1336. }elseif($row['type'] == 3){
  1337. $row['bankname'] = '支付宝';
  1338. }
  1339. $row['bankaccount'] = "\t".$row['bankaccount'];
  1340. $row['bankusername'] = $row['bankusername'];
  1341. $row['get_money'] = $row['money']-$row['service_charge_money'];
  1342. $row['addtime'] = date('Y-m-d H:i:s', $row['addtime']);
  1343. if(!empty($row['shentime']))
  1344. {
  1345. $row['shentime'] = date('Y-m-d H:i:s', $row['shentime']);
  1346. }
  1347. if($row['state'] ==0)
  1348. {
  1349. $row['state'] = '待审核';
  1350. }else if($row[state] ==1)
  1351. {
  1352. $row['state'] = '已审核,打款';
  1353. }else if($row[state] ==2){
  1354. $row['state'] = '已拒绝';
  1355. }
  1356. }
  1357. unset($row);
  1358. $columns = array(
  1359. array('title' => 'ID', 'field' => 'id', 'width' => 12),
  1360. array('title' => '用户名', 'field' => 'username', 'width' => 12),
  1361. array('title' => '联系方式', 'field' => 'telephone', 'width' => 12),
  1362. array('title' => '打款银行', 'field' => 'bankname', 'width' => 24),
  1363. array('title' => '打款账户', 'field' => 'bankaccount', 'width' => 24),
  1364. array('title' => '真实姓名', 'field' => 'bankusername', 'width' => 24),
  1365. array('title' => '申请提现金额', 'field' => 'money', 'width' => 24),
  1366. array('title' => '手续费', 'field' => 'service_charge_money', 'width' => 24),
  1367. array('title' => '到账金额', 'field' => 'get_money', 'width' => 24),
  1368. array('title' => '申请时间', 'field' => 'addtime', 'width' => 24),
  1369. array('title' => '审核时间', 'field' => 'shentime', 'width' => 24),
  1370. array('title' => '状态', 'field' => 'state', 'width' => 24)
  1371. );
  1372. D('Seller/Excel')->export($list, array('title' => '拼团佣金提现数据-' . date('Y-m-d-H-i', time()), 'columns' => $columns));
  1373. }
  1374. $pager = pagination2($total, $pindex, $psize);
  1375. $this->list = $list;
  1376. $this->pager = $pager;
  1377. $this->_GPC = $_GPC;
  1378. $this->display();
  1379. }
  1380. public function withdraw_config()
  1381. {
  1382. $_GPC = I('request.');
  1383. if (IS_POST) {
  1384. $data = ((is_array($_GPC['data']) ? $_GPC['data'] : array()));
  1385. $data['pintuan_tixianway_yuer'] = isset($data['pintuan_tixianway_yuer']) ? $data['pintuan_tixianway_yuer']:1;
  1386. $data['pintuan_tixianway_weixin'] = isset($data['pintuan_tixianway_weixin']) ? $data['pintuan_tixianway_weixin']:1;
  1387. $data['pintuan_tixianway_alipay'] = isset($data['pintuan_tixianway_alipay']) ? $data['pintuan_tixianway_alipay']:1;
  1388. $data['pintuan_tixianway_bank'] = isset($data['pintuan_tixianway_bank']) ? $data['pintuan_tixianway_bank']:1;
  1389. $data['pintuan_tixian_publish'] = isset($data['pintuan_tixian_publish']) ? $data['pintuan_tixian_publish']:'';
  1390. D('Seller/Config')->update($data);
  1391. show_json(1, array('url' => $_SERVER['HTTP_REFERER']) );
  1392. die();
  1393. }
  1394. $data = D('Seller/Config')->get_all_config();
  1395. $this->data = $data;
  1396. $this->display();
  1397. }
  1398. public function jia_over_order()
  1399. {
  1400. $_GPC = I('request.');
  1401. $pin_id = $_GPC['pin_id'];
  1402. $res = D('Home/Pin')->jia_over_order( $pin_id );
  1403. if( $res )
  1404. {
  1405. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ) );
  1406. }else{
  1407. show_json(0, array('url' => $_SERVER['HTTP_REFERER'] ) );
  1408. }
  1409. }
  1410. public function agent_check_apply()
  1411. {
  1412. $_GPC = I('request.');
  1413. $commission_model = D('Home/Pin');
  1414. $id = intval($_GPC['id']);
  1415. if (empty($id)) {
  1416. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  1417. }
  1418. $comsiss_state = intval($_GPC['state']);
  1419. $apply_list = M('lionfish_comshop_pintuan_tixian_order')->where('id in( ' . $id . ' )')->select();
  1420. $time = time();
  1421. //var_dump($members,$comsiss_state);die();
  1422. foreach ($apply_list as $apply) {
  1423. if ($apply['state'] == $comsiss_state || $apply['state'] == 1 || $apply['state'] == 2) {
  1424. continue;
  1425. }
  1426. $money = $apply['money'];
  1427. if ($comsiss_state == 1) {
  1428. switch( $apply['type'] )
  1429. {
  1430. case 1:
  1431. $result = $commission_model->send_apply_yuer( $apply['id'] );
  1432. break;
  1433. case 2:
  1434. $result = $commission_model->send_apply_weixin_yuer( $apply['id'] );
  1435. break;
  1436. case 3:
  1437. $result = $commission_model->send_apply_alipay_bank( $apply['id'] );
  1438. break;
  1439. case 4:
  1440. $result = $commission_model->send_apply_alipay_bank( $apply['id'] );
  1441. break;
  1442. }
  1443. if( $result['code'] == 1)
  1444. {
  1445. show_json(0, array('url' => $_SERVER['HTTP_REFERER'] ,'message'=>$result['msg'] ) );
  1446. die();
  1447. }
  1448. //检测是否存在账户,没有就新建
  1449. //TODO....检测是否微信提现到零钱,如果是,那么就准备打款吧
  1450. $commission_model->send_apply_success_msg($apply['id']);
  1451. }
  1452. else if ($comsiss_state == 2) {
  1453. M('lionfish_comshop_pintuan_tixian_order')->where( array('id' => $apply['id'] ) )->save( array('state' => 2, 'shentime' => $time) );
  1454. //退回冻结的货款
  1455. M('lionfish_comshop_pintuan_commiss')->where( array('member_id' => $apply['member_id'] ) )->setInc('money',$money);
  1456. M('lionfish_comshop_pintuan_commiss')->where( array('member_id' => $apply['member_id'] ) )->setInc('dongmoney',-$money);
  1457. }
  1458. else {
  1459. M('lionfish_comshop_pintuan_tixian_order')->where( array('id' => $apply['id']) )->save( array('state' => 0, 'shentime' => 0) );
  1460. }
  1461. }
  1462. show_json(1, array('url' => $_SERVER['HTTP_REFERER'] ));
  1463. }
  1464. }
  1465. ?>