GroupController.class.php 65 KB

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