GroupController.class.php 65 KB

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