DistributionController.class.php 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  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 DistributionController extends CommonController {
  16. protected function _initialize(){
  17. parent::_initialize();
  18. }
  19. public function distributionpostal()
  20. {
  21. if (IS_POST) {
  22. $data = I('request.data');
  23. D('Seller/Config')->update($data);
  24. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  25. }
  26. $data = D('Seller/Config')->get_all_config();
  27. $this->data = $data;
  28. $this->display();
  29. }
  30. public function changename()
  31. {
  32. $_GPC = I('request.');
  33. $id = intval($_GPC['id']);
  34. //ids
  35. if (empty($id)) {
  36. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  37. }
  38. if (empty($id)) {
  39. show_json(0, array('message' => '参数错误'));
  40. }
  41. $type = trim($_GPC['type']);
  42. $value = trim($_GPC['value']);
  43. $items = M('lionfish_community_head_tixian_order')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  44. foreach ($items as $item ) {
  45. M('lionfish_community_head_tixian_order')->where( array('id' => $item['id']) )->save( array('bankusername' => $value) );
  46. }
  47. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  48. }
  49. public function clear_user_member_qrcode()
  50. {
  51. M('lionfish_comshop_member')->where( "member_id > 0" )->save( array('wepro_qrcode' => '') );
  52. echo json_encode( array('code' => 0) );
  53. die();
  54. }
  55. public function config()
  56. {
  57. if (IS_POST) {
  58. $data = I('request.data');
  59. D('Seller/Config')->update($data);
  60. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  61. }
  62. $data = D('Seller/Config')->get_all_config();
  63. $this->data = $data;
  64. $this->display();
  65. }
  66. public function qrcodeconfig()
  67. {
  68. if (IS_POST) {
  69. $_GPC = I('request.');
  70. $data = array();
  71. $data['distribution_avatar_left'] = $_GPC['avatar_left'];
  72. $data['distribution_avatar_top'] = $_GPC['avatar_top'];
  73. $data['distribution_qrcodes_left'] = $_GPC['qrcodes_left'];
  74. $data['distribution_qrcodes_top'] = $_GPC['qrcodes_top'];
  75. $data['distribution_username_left'] = $_GPC['username_left'];
  76. $data['distribution_username_top'] = $_GPC['username_top'];
  77. $data['distribution_img_src'] = $_GPC['img_src'];
  78. $data['commiss_avatar_rgb'] = $_GPC['commiss_avatar_rgb'];
  79. $data['commiss_nickname_rgb'] = $_GPC['commiss_nickname_rgb'];
  80. D('Seller/Config')->update($data);
  81. M('lionfish_comshop_member')->where( "1" )->save( array('commiss_qrcode' => '') );
  82. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  83. }
  84. $data = D('Seller/Config')->get_all_config();
  85. $this->data = $data;
  86. $this->display();
  87. }
  88. public function addForm()
  89. {
  90. if (IS_POST) {
  91. $data = I('request.data');
  92. D('Seller/Config')->update(array('commiss_diy_form' => serialize( $data ) ));
  93. show_json(0, array('url' => $_SERVER['HTTP_REFERER']));
  94. }
  95. $data = M('lionfish_comshop_config')->where( array('name' => 'commiss_diy_form') )->find();
  96. $form_data = array();
  97. if( !empty($data) )
  98. {
  99. $form_data = unserialize( htmlspecialchars_decode( $data['value'] ));
  100. }
  101. $this->form_data = $form_data;
  102. include $this->display();
  103. }
  104. public function withdraw_config()
  105. {
  106. if (IS_POST) {
  107. $data = I('request.data');
  108. $data['commiss_tixianway_yuer'] = isset($data['commiss_tixianway_yuer']) ? $data['commiss_tixianway_yuer']:1;
  109. $data['commiss_tixianway_weixin'] = isset($data['commiss_tixianway_weixin']) ? $data['commiss_tixianway_weixin']:1;
  110. $data['commiss_tixianway_alipay'] = isset($data['commiss_tixianway_alipay']) ? $data['commiss_tixianway_alipay']:1;
  111. $data['commiss_tixianway_bank'] = isset($data['commiss_tixianway_bank']) ? $data['commiss_tixianway_bank']:1;
  112. $data['commiss_tixian_publish'] = isset($data['commiss_tixian_publish']) ? $data['commiss_tixian_publish']:'';
  113. D('Seller/Config')->update($data);
  114. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  115. }
  116. $data = D('Seller/Config')->get_all_config();
  117. $this->data = $data;
  118. $this->display();
  119. }
  120. public function distributionorder()
  121. {
  122. $time = I('request.time');
  123. $_GPC = I('request.');
  124. $starttime = isset($time['start']) ? strtotime($time['start']) : strtotime(date('Y-m-d'.' 00:00:00'));
  125. $endtime = isset($time['end']) ? strtotime($time['end']) : strtotime(date('Y-m-d'.' 23:59:59'));
  126. $this->searchfield = I('request.searchfield','');
  127. $this->keyword = I('request.keyword','');
  128. $this->searchtime = I('request.searchtime','');
  129. $this->delivery = I('request.delivery','');
  130. $this->starttime = $starttime;
  131. $this->endtime = $endtime;
  132. $this->time = $time;
  133. $order_status_id = I('request.order_status_id',0);
  134. $starttime = isset($_GPC['time']['start']) ? strtotime($_GPC['time']['start']) : strtotime(date('Y-m-d'.' 00:00:00'));
  135. $endtime = isset($_GPC['time']['end']) ? strtotime($_GPC['time']['end']) : strtotime(date('Y-m-d'.' 23:59:59'));
  136. $order_status_arr = D('Seller/Order')->get_order_status_name();
  137. $this->order_status_arr = $order_status_arr;
  138. $_GPC['is_fenxiao'] = 1;//分销订单
  139. $this->_GPC = $_GPC;
  140. $this->is_fenxiao = 1;
  141. $cur_controller = 'distribution/distributionorder';
  142. $need_data = D('Seller/Order')->load_order_list(0,1);
  143. $total = $need_data['total'];
  144. $total_money = $need_data['total_money'];
  145. $list = $need_data['list'];
  146. $pager = $need_data['pager'];
  147. $all_count = $need_data['all_count'];
  148. $count_status_1 = $need_data['count_status_1'];
  149. $count_status_3 = $need_data['count_status_3'];
  150. $count_status_4 = $need_data['count_status_4'];
  151. $count_status_5 = $need_data['count_status_5'];
  152. $count_status_7 = $need_data['count_status_7'];
  153. $count_status_11 = $need_data['count_status_11'];
  154. $count_status_14 = $need_data['count_status_14'];
  155. $this->cur_controller = $cur_controller;
  156. $this->total = $total;
  157. $this->total_money = $total_money;
  158. $this->list = $list;
  159. $this->pager = $pager;
  160. $this->all_count = $all_count;
  161. $this->count_status_1 = $count_status_1;
  162. $this->count_status_3 = $count_status_3;
  163. $this->count_status_4 = $count_status_4;
  164. $this->count_status_5 = $count_status_5;
  165. $this->count_status_7 = $count_status_7;
  166. $this->count_status_11 = $count_status_11;
  167. $this->count_status_14 = $count_status_14;
  168. $this->order_status_id = $order_status_id;
  169. $this->is_community = I('request.is_community', 0);
  170. $this->headid = I('request.headid', 0);
  171. $open_feier_print = D('Home/Front')->get_config_by_name('open_feier_print');
  172. if( empty($open_feier_print) )
  173. {
  174. $open_feier_print = 0;
  175. }
  176. $this->open_feier_print = $open_feier_print;
  177. $this->display('Order/index');
  178. }
  179. public function communityorder()
  180. {
  181. $_GPC = I('request.');
  182. $member_id = $_GPC['member_id'];
  183. $pindex = max(1, intval($_GPC['page']));
  184. $psize = 20;
  185. $where = " and co.member_id = {$member_id} ";
  186. $starttime = strtotime( date('Y-m-d')." 00:00:00" );
  187. $endtime = $starttime + 86400;
  188. if( isset($_GPC['searchtime']) && $_GPC['searchtime'] == 'create_time' )
  189. {
  190. if (!empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) {
  191. $starttime = strtotime($_GPC['time']['start']);
  192. $endtime = strtotime($_GPC['time']['end']);
  193. $where .= ' AND co.addtime >= '.$starttime.' AND co.addtime <= '.$endtime.' ';
  194. }
  195. }
  196. $this->member_id = $member_id;
  197. $this->starttime = $starttime;
  198. $this->endtime = $endtime;
  199. if ($_GPC['order_status'] != '') {
  200. $where .= ' and co.state=' . intval($_GPC['order_status']);
  201. }
  202. $sql = "select co.order_id,co.state,co.money,co.level,co.addtime ,og.total,og.name,og.total
  203. from ".C('DB_PREFIX')."lionfish_comshop_member_commiss_order as co ,
  204. ".C('DB_PREFIX')."lionfish_comshop_order_goods as og
  205. where co.order_goods_id = og.order_goods_id {$where}
  206. order by co.id desc ".' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  207. $list = M()->query($sql);
  208. if( !empty($list) )
  209. {
  210. foreach($list as $key => $val)
  211. {
  212. $val['total'] = sprintf("%.2f",$val['total']);
  213. $val['money'] = sprintf("%.2f",$val['money']);
  214. $val['addtime'] = date('Y-m-d H:i:s',$val['addtime']);
  215. $order_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array('order_id' => $val['order_id'] ) )->find();
  216. $val['order_num_alias'] = $order_info['order_num_alias'];
  217. $list[$key] = $val;
  218. }
  219. }
  220. $sql_count = "select count(1) as count
  221. from ".C('DB_PREFIX')."lionfish_comshop_member_commiss_order as co ,
  222. ".C('DB_PREFIX')."lionfish_comshop_order_goods as og
  223. where co.order_goods_id = og.order_goods_id {$where} ";
  224. $total_arr = M()->query($sql_count);
  225. $total = $total_arr[0]['count'];
  226. if ($_GPC['export'] == '1') {
  227. $export_sql = "select co.order_id,co.state,co.money,co.level,co.addtime ,og.total,og.name,og.total
  228. from ".C('DB_PREFIX')."lionfish_comshop_member_commiss_order as co ,
  229. ".C('DB_PREFIX')."lionfish_comshop_order_goods as og
  230. where co.order_goods_id = og.order_goods_id {$where}
  231. order by co.id desc ";
  232. $export_list = M()->query($export_sql);
  233. if( !empty($export_list) )
  234. {
  235. foreach($export_list as $key => $val)
  236. {
  237. $val['total'] = sprintf("%.2f",$val['total']);
  238. $val['money'] = sprintf("%.2f",$val['money']);
  239. $val['addtime'] = date('Y-m-d H:i:s',$val['addtime']);
  240. $order_info= M('lionfish_comshop_order')->field('order_num_alias')->where( array('order_id' => $val['order_id'] ) )->find();
  241. $val['order_num_alias'] = $order_info['order_num_alias'];
  242. $export_list[$key] = $val;
  243. }
  244. }
  245. foreach($export_list as $key =>&$row)
  246. {
  247. $row['order_num_alias'] = "\t".$row['order_num_alias'];
  248. $row['name'] = $row['name'];
  249. $row['total'] = $row['total'];
  250. $row['money'] = $row['money'];
  251. if($row['state'] == 0)
  252. {
  253. $row['state'] = '待结算';
  254. }else if($row[state] == 1)
  255. {
  256. $row['state'] = '已结算';
  257. }else if($row[state] == 2){
  258. $row['state'] = '订单取消或退款';
  259. }
  260. $row['addtime'] = $row['addtime'];
  261. }
  262. unset($row);
  263. $columns = array(
  264. array('title' => '订单编号', 'field' => 'order_num_alias', 'width' => 24),
  265. array('title' => '商品标题', 'field' => 'name', 'width' => 24),
  266. array('title' => '订单金额', 'field' => 'total', 'width' => 12),
  267. array('title' => '佣金金额', 'field' => 'money', 'width' => 12),
  268. array('title' => '几级分佣', 'field' => 'level', 'width' => 12),
  269. array('title' => '状态', 'field' => 'state', 'width' => 24),
  270. array('title' => '下单时间', 'field' => 'addtime', 'width' => 24),
  271. );
  272. D('Seller/Excel')->export($export_list, array('title' => '会员分销收益明细-' . date('Y-m-d-H-i', time()), 'columns' => $columns));
  273. }
  274. $pager = pagination2($total, $pindex, $psize);
  275. $this->pager = $pager;
  276. $this->list = $list;
  277. $this->_GPC = $_GPC;
  278. $this->display();
  279. }
  280. public function changecommission()
  281. {
  282. $_GPC = I('request.');
  283. $order_id = $_GPC['order_id'];
  284. $order_goods_id = $_GPC['order_goods_id'];
  285. $commiss_level = D('Seller/Front')->get_config_by_name('commiss_level');
  286. $commission_info = D('Home/Commission')->get_order_goods_commission( $order_id, $order_goods_id);
  287. if (empty($commission_info)) {
  288. if (IS_POST) {
  289. show_json(0, array('message' => '未找到订单!'));
  290. }
  291. exit('fail');
  292. }
  293. if (IS_POST) {
  294. $cm1 = $_GPC['cm1'];
  295. if (!is_array($cm1) ) {
  296. show_json(0, array('message' => '未找到修改数据!'));
  297. }
  298. foreach ($cm1 as $id => $money) {
  299. M('lionfish_comshop_member_commiss_order')->where( array('id' => $id) )->save( array('money' => $money) );
  300. }
  301. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  302. }
  303. foreach( $commission_info as $key => $val )
  304. {
  305. $mb_info = M('lionfish_comshop_member')->field('username,avatar')->where( array('member_id' => $val['member_id'] ) )->find();
  306. $val['member_info'] = $mb_info;
  307. $commission_info[$key] = $val;
  308. }
  309. $this->order_id = $order_id;
  310. $this->order_goods_id = $order_goods_id;
  311. $this->commiss_level = $commiss_level;
  312. $this->commission_info = $commission_info;
  313. $this->display();
  314. }
  315. public function level()
  316. {
  317. $data = D('Seller/Config')->get_all_config();
  318. $default = array('id' => 'default', 'levelname' => empty($data['commission_levelname']) ? '默认等级' : $data['commission_levelname'], 'commission1' => $data['commission1'], 'commission2' => $data['commission2'], 'commission3' => $data['commission3']);
  319. $others = M('lionfish_comshop_commission_level')->order('commission1 asc')->select();
  320. $list = array_merge(array($default), $others);
  321. $this->data = $data;
  322. $this->list = $list;
  323. $this->display();
  324. }
  325. public function addlevel()
  326. {
  327. $this->modifylevel();
  328. }
  329. public function editlevel()
  330. {
  331. $this->modifylevel();
  332. }
  333. public function become_agent_check()
  334. {
  335. $_GPC = I('request.');
  336. $member_id = $_GPC['id'];
  337. $state = $_GPC['state'];
  338. $member = M('lionfish_comshop_member')->field('member_id,openid,we_openid,comsiss_state')->where( array('member_id' => $member_id) )->find();
  339. if( $state == 1 )
  340. {
  341. $time = time();
  342. M('lionfish_comshop_member')->where( array('member_id' => $member['member_id']) )->save( array('comsiss_state' => 1,'comsiss_flag' => 1, 'comsiss_time' => $time) );
  343. //检测是否存在账户,没有就新建
  344. D('Home/Commission')->commission_account($member['member_id']);
  345. //TODO....sendmsg 发送成为分销商的信息
  346. }else{
  347. M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->save( array('comsiss_state' => 0,'comsiss_flag' => 1, 'comsiss_time' => 0) );
  348. }
  349. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  350. }
  351. public function agent_check()
  352. {
  353. $_GPC = I('request.');
  354. $id = intval($_GPC['id']);
  355. if (empty($id)) {
  356. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  357. }
  358. $comsiss_state = intval($_GPC['comsiss_state']);
  359. $members = M('lionfish_comshop_member')->field('member_id,openid,we_openid,comsiss_state')->where( 'member_id in( ' . $id . ' )' )->select();
  360. $time = time();
  361. foreach ($members as $member) {
  362. if ($member['comsiss_state'] === $status) {
  363. continue;
  364. }
  365. if ($comsiss_state == 1) {
  366. //M('lionfish_comshop_member')->where( array('member_id' => $member['member_id'] ) )->save( array('comsiss_state' => 1, 'comsiss_time' => $time) );
  367. //检测是否存在账户,没有就新建
  368. D('Home/Commission')->become_commiss_member($member['member_id']);
  369. //TODO....sendmsg 发送成为分销商的信息
  370. }
  371. else {
  372. M('lionfish_comshop_member')->where( array('member_id' => $member['member_id']) )->save( array('comsiss_state' => 0, 'comsiss_time' => 0) );
  373. }
  374. }
  375. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  376. }
  377. public function nextchild_list()
  378. {
  379. $_GPC = I('request.');
  380. $member_id = $_GPC['id'];
  381. $pindex = max(1, intval($_GPC['page']));
  382. $psize = 20;
  383. $size = 20;
  384. $offset = ($pindex - 1) * $size;
  385. $keyword = $_GPC['keyword'];
  386. $this->keyword = $keyword;
  387. $this->member_id = $member_id;
  388. $where = '';
  389. if( !empty($keyword) )
  390. {
  391. $where .= " and ( username like '%{$keyword}%' or telephone like '%{$keyword}%' ) ";
  392. }
  393. $level = D('Home/Front')->get_config_by_name('commiss_level');
  394. $level_1_ids = array();
  395. $level_2_ids = array();
  396. $level_3_ids = array();
  397. $member_id_arr = array($member_id);
  398. if( $level == 1 )
  399. {
  400. $list = array();
  401. $sql = "select * from ".C('DB_PREFIX')."lionfish_comshop_member
  402. where 1 {$where} and agentid in (".implode(',', $member_id_arr).")
  403. order by member_id desc limit {$offset},{$size}";
  404. $list = M()->query($sql);
  405. foreach( $list as $vv )
  406. {
  407. $level_1_ids[$vv['id']] = $vv['id'];
  408. }
  409. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX') .
  410. 'lionfish_comshop_member WHERE 1 ' . "{$where} and agentid in (".implode(',', $member_id_arr).") " );
  411. $total = $total_arr[0]['count'];
  412. }else if( $level == 2 )
  413. {
  414. $list = array();
  415. $sql = "select member_id from ".C('DB_PREFIX')."lionfish_comshop_member
  416. where 1 and agentid in (".implode(',', $member_id_arr).") order by member_id desc ";
  417. $list1 = M()->query($sql);
  418. if( !empty($list1) )
  419. {
  420. foreach( $list1 as $vv )
  421. {
  422. $level_1_ids[$vv['member_id']] = $vv['member_id'];
  423. }
  424. $level_sql2 =" select member_id from ".C('DB_PREFIX').
  425. "lionfish_comshop_member where 1 and
  426. agentid in (select member_id from ".C('DB_PREFIX')."lionfish_comshop_member
  427. where agentid ={$member_id} order by member_id desc ) order by member_id desc ";
  428. $list2 = M()->query($level_sql2);
  429. if( !empty($list2) || !empty($list1) )
  430. {
  431. foreach( $list2 as $vv )
  432. {
  433. $level_2_ids[$vv['member_id']] = $vv['member_id'];
  434. }
  435. $need_ids = empty($level_1_ids) ? array() : $level_1_ids;
  436. if(!empty($level_2_ids))
  437. {
  438. foreach($level_2_ids as $vv)
  439. {
  440. $need_ids[] = $vv;
  441. }
  442. }
  443. $sql =" select * from ".C('DB_PREFIX').
  444. "lionfish_comshop_member where 1 {$where} and
  445. member_id in (".implode(',', $need_ids ).") order by member_id desc limit {$offset},{$size}";
  446. $list = M()->query($sql);
  447. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX').
  448. 'lionfish_comshop_member WHERE 1 ' . "{$where} and member_id in (".implode(',', $need_ids).") " );
  449. $total = $total_arr[0]['count'];
  450. }
  451. }
  452. }else if( $level == 3 ){
  453. $sql = "select member_id from ".C('DB_PREFIX')."lionfish_comshop_member
  454. where agentid in (".implode(',', $member_id_arr).") order by member_id desc ";
  455. $list1 = M()->query($sql);
  456. if( !empty($list1) )
  457. {
  458. foreach( $list1 as $vv )
  459. {
  460. $level_1_ids[$vv['member_id']] = $vv['member_id'];
  461. }
  462. $need_ids = empty($level_1_ids) ? array() : $level_1_ids;
  463. $level_sql2 =" select * from ".C('DB_PREFIX').
  464. "lionfish_comshop_member where
  465. agentid in (select member_id from ".C('DB_PREFIX')."lionfish_comshop_member
  466. where agentid ={$member_id} order by member_id desc ) order by member_id desc ";
  467. $list2 = M()->query($level_sql2);
  468. if( !empty($list2) )
  469. {
  470. foreach( $list2 as $vv )
  471. {
  472. $level_2_ids[$vv['member_id']] = $vv['member_id'];
  473. }
  474. if(!empty($level_2_ids))
  475. {
  476. foreach($level_2_ids as $vv)
  477. {
  478. $need_ids[] = $vv;
  479. }
  480. }
  481. }
  482. $level_sql3 =" select * from ".C('DB_PREFIX').
  483. "lionfish_comshop_member where
  484. agentid in (".implode(',', $need_ids).") order by member_id desc ";
  485. $list3 = M()->query($level_sql3 );
  486. if( !empty($list3) )
  487. {
  488. foreach( $list3 as $vv )
  489. {
  490. $level_3_ids[$vv['member_id']] = $vv['member_id'];
  491. }
  492. if(!empty($level_3_ids))
  493. {
  494. foreach($level_3_ids as $vv)
  495. {
  496. $need_ids[] = $vv;
  497. }
  498. }
  499. }
  500. $level_sql3 =" select * from ".C('DB_PREFIX').
  501. "lionfish_comshop_member where 1 {$where} and member_id in (".implode(',',$need_ids).") order by member_id desc limit {$offset},{$size}";
  502. $list = M()->query($level_sql3);
  503. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX') .
  504. 'lionfish_comshop_member WHERE 1 ' . "{$where} and member_id in (".implode(',', $need_ids).") " );
  505. $total = $total_arr[0]['count'];
  506. }
  507. }
  508. if( !empty($list) )
  509. {
  510. foreach($list as $key => $val)
  511. {
  512. //member_id
  513. $val['child_level'] = 1;
  514. if( isset($level_2_ids[$val['member_id']]) )
  515. {
  516. $val['child_level'] = 2;
  517. }
  518. else if( isset($level_3_ids[$val['member_id']]) )
  519. {
  520. $val['child_level'] = 3;
  521. }
  522. //$val['create_time'] = date('Y-m-d H:i:s', $val['create_time']);
  523. $list[$key] = $val;
  524. }
  525. }
  526. $this->_GPC = $_GPC;
  527. $pager = pagination2($total, $pindex, $psize);
  528. $this->list = $list;
  529. $this->pager = $pager;
  530. $this->display();
  531. }
  532. public function clear_haibao()
  533. {
  534. M('lionfish_comshop_member')->where( "member_id > 0" )->save( array('commiss_qrcode' => '') );
  535. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  536. }
  537. public function sharedetail()
  538. {
  539. $_GPC = I('request.');
  540. $id = $_GPC['id'];
  541. $keyword = $_GPC['keyword'];
  542. $condition = ' and share_id = '.$id." and (agentid=0 or agentid = {$id}) ";
  543. $pindex = max(1, intval($_GPC['page']));
  544. $psize = 20;
  545. if (!empty($_GPC['keyword'])) {
  546. $_GPC['keyword'] = trim($_GPC['keyword']);
  547. $condition .= ' and ( username like "%'.$_GPC['keyword'].'%" or realname like "%'.$_GPC['keyword'].'%" or telephone like "%'.$_GPC['keyword'].'%") ';
  548. }
  549. if ($_GPC['comsiss_state'] != '') {
  550. $condition .= ' and comsiss_state=' . intval($_GPC['comsiss_state']);
  551. }
  552. $sql = 'SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_member
  553. WHERE 1 " . $condition . ' order by member_id desc ';
  554. if (empty($_GPC['export'])) {
  555. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  556. }
  557. $list = M()->query($sql);
  558. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member WHERE 1 ' . $condition);
  559. $total = $total_arr[0]['count'];
  560. if ($_GPC['export'] == '1') {
  561. foreach ($list as &$row) {
  562. $row['sharename'] = empty($val['share_parent_info']) ? '总店' : $val['share_parent_info']['username'];
  563. $row['parentname'] = empty($val['parent_info']) ? '总店' : $val['parent_info']['username'];
  564. $next_member_count_arr = D('Home/Commission')->get_member_all_next_count($val['member_id']);
  565. $row['level1'] = $next_member_count_arr['level_1_count'];
  566. $row['level2'] = $next_member_count_arr['level_2_count'];
  567. $row['level3'] = $next_member_count_arr['level_3_count'];
  568. //commission_info
  569. $row['commission_total'] = $row['commission_info']['commission_total'];
  570. $row['getmoney'] = $row['commission_info']['getmoney'];
  571. $row['createtime'] = date('Y-m-d H:i', $row['create_time']);
  572. $row['comsiss_time'] = empty($row['comsiss_time']) ? '': date('Y-m-d H:i', $row['comsiss_time']);
  573. $row['groupname'] = empty($row['groupname']) ? '无分组' : $row['groupname'];
  574. $row['levelname'] = empty($row['levelname']) ? '普通等级' : $row['levelname'];
  575. $row['parentname'] = empty($row['parentname']) ? '总店' : '[' . $row['agentid'] . ']' . $row['parentname'];
  576. $row['statusstr'] = empty($row['status']) ? '' : '通过';
  577. $row['followstr'] = empty($row['followed']) ? '' : '已关注';
  578. }
  579. unset($row);
  580. $columns = array(
  581. array('title' => 'ID', 'field' => 'member_id', 'width' => 12),
  582. array('title' => '用户名', 'field' => 'username', 'width' => 12),
  583. array('title' => '手机号', 'field' => 'telephone', 'width' => 12),
  584. array('title' => 'openid', 'field' => 'we_openid', 'width' => 24),
  585. array('title' => '推荐人', 'field' => 'sharename', 'width' => 12),
  586. array('title' => '上级', 'field' => 'parentname', 'width' => 12),
  587. array('title' => '分销商等级', 'field' => 'commission_level_name', 'width' => 12),
  588. array('title' => '下线分销商总数', 'field' => 'next_member_count', 'width' => 12),
  589. array('title' => '一级下线分销商数', 'field' => 'level1', 'width' => 12),
  590. array('title' => '二级下线分销商数', 'field' => 'level2', 'width' => 12),
  591. array('title' => '三级下线分销商数', 'field' => 'level3', 'width' => 12),
  592. array('title' => '累计佣金', 'field' => 'commission_total', 'width' => 12),
  593. array('title' => '打款佣金', 'field' => 'getmoney', 'width' => 12),
  594. array('title' => '注册时间', 'field' => 'createtime', 'width' => 12),
  595. array('title' => '成为分销商时间', 'field' => 'comsiss_time', 'width' => 12),
  596. array('title' => '审核状态', 'field' => 'comsiss_time', 'width' => 12)
  597. );
  598. D('Seller/Excel')->export($list, array('title' => $id.'下级分享人数据-' . date('Y-m-d-H-i', time()), 'columns' => $columns));
  599. }
  600. $pager = pagination2($total, $pindex, $psize);
  601. $this->_GPC = $_GPC;
  602. $this->pager = $pager;
  603. $this->list = $list;
  604. $this->keyword = $keyword;
  605. $this->display();
  606. }
  607. public function distribution()
  608. {
  609. $_GPC = I('request.');
  610. $condition = ' and comsiss_flag = 1 ';
  611. $pindex = max(1, intval($_GPC['page']));
  612. $psize = 20;
  613. $type = 0;
  614. if( isset($_GPC['type']) && !empty($_GPC['type']) )
  615. {
  616. $type = $_GPC['type'];
  617. }
  618. switch( $type )
  619. {
  620. case 0:
  621. break;
  622. case 1:
  623. $condition .= " and comsiss_state=1 ";
  624. break;
  625. case 2:
  626. $condition .= " and comsiss_state=0 ";
  627. break;
  628. }
  629. if (!empty($_GPC['keyword'])) {
  630. $_GPC['keyword'] = trim($_GPC['keyword']);
  631. $condition .= ' and ( username like "%'.$_GPC['keyword'].'%" or realname like "%'.$_GPC['keyword'].'%" or telephone like "%'.$_GPC['keyword'].'%") ';
  632. }
  633. $starttime = strtotime( date('Y-m-d')." 00:00:00" );
  634. $endtime = $starttime + 86400;
  635. if( isset($_GPC['searchtime']) && $_GPC['searchtime'] == 'create_time' )
  636. {
  637. if (!empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) {
  638. $starttime = strtotime($_GPC['time']['start']);
  639. $endtime = strtotime($_GPC['time']['end']);
  640. $condition .= ' AND comsiss_time >= '.$starttime.' AND comsiss_time <= '.$endtime.' ';
  641. }
  642. }
  643. $this->starttime = $starttime;
  644. $this->endtime = $endtime;
  645. /**
  646. if (!empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) {
  647. $starttime = strtotime($_GPC['time']['start']);
  648. $endtime = strtotime($_GPC['time']['end']);
  649. $condition .= ' AND comsiss_time >= '.$starttime.' AND comsiss_time <= '.$endtime;
  650. }
  651. **/
  652. if ($_GPC['comsiss_state'] != '') {
  653. $condition .= ' and comsiss_state=' . intval($_GPC['comsiss_state']);
  654. }
  655. if ($_GPC['commission_level_id'] != '') {
  656. $condition .= ' and commission_level_id =' . intval($_GPC['commission_level_id']);
  657. }
  658. if( isset($_GPC['groupid']) && !empty($_GPC['groupid']) )
  659. {
  660. $condition .= ' and groupid = '.$_GPC['groupid'];
  661. }
  662. $sql = 'SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_member
  663. WHERE 1 " . $condition . ' order by member_id desc ';
  664. if (empty($_GPC['export'])) {
  665. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  666. }
  667. $list = M()->query($sql);
  668. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member WHERE 1 ' . $condition);
  669. $total = $total_arr[0]['count'];
  670. $level_list = M()->query("select * from ".C('DB_PREFIX').
  671. 'lionfish_comshop_commission_level order by id asc ');
  672. $keys_level = array();
  673. $keys_level[0] = D('Home/Front')->get_config_by_name('commission_levelname');
  674. if( empty($keys_level[0]) )
  675. {
  676. $keys_level[0] = '普通等级';
  677. }
  678. foreach($level_list as $vv)
  679. {
  680. $keys_level[$vv['id']] = $vv['levelname'];
  681. }
  682. foreach( $list as $key => $val )
  683. {
  684. //普通等级
  685. $val['share_parent_info'] = D('Home/Commission')->get_share_name($val['share_id']);
  686. $val['parent_info'] = D('Home/Commission')->get_parent_info($val['agentid']);
  687. $next_member_count_arr = D('Home/Commission')->get_member_all_next_count($val['member_id']);
  688. $val['next_member_count'] = $next_member_count_arr['total'];
  689. $val['commission_level_name'] = $keys_level[$val['commission_level_id']];
  690. $val['commission_info'] = D('Home/Commission')->get_commission_info( $val['member_id'] );
  691. $list[$key] = $val;
  692. }
  693. if ($_GPC['export'] == '1') {
  694. foreach ($list as &$row) {
  695. $row['sharename'] = empty($val['share_parent_info']) ? '总店' : $val['share_parent_info']['username'];
  696. $row['parentname'] = empty($val['parent_info']) ? '总店' : $val['parent_info']['username'];
  697. $next_member_count_arr = D('Home/Commission')->get_member_all_next_count($val['member_id']);
  698. $row['level1'] = $next_member_count_arr['level_1_count'];
  699. $row['level2'] = $next_member_count_arr['level_2_count'];
  700. $row['level3'] = $next_member_count_arr['level_3_count'];
  701. //commission_info
  702. $row['commission_total'] = $row['commission_info']['commission_total'];
  703. $row['getmoney'] = $row['commission_info']['getmoney'];
  704. $row['createtime'] = date('Y-m-d H:i', $row['create_time']);
  705. $row['comsiss_time'] = empty($row['comsiss_time']) ? '': date('Y-m-d H:i', $row['comsiss_time']);
  706. $row['groupname'] = empty($row['groupname']) ? '无分组' : $row['groupname'];
  707. $row['levelname'] = empty($row['levelname']) ? '普通等级' : $row['levelname'];
  708. $row['parentname'] = empty($row['parentname']) ? '总店' : '[' . $row['agentid'] . ']' . $row['parentname'];
  709. $row['statusstr'] = empty($row['status']) ? '' : '通过';
  710. $row['followstr'] = empty($row['followed']) ? '' : '已关注';
  711. }
  712. unset($row);
  713. $columns = array(
  714. array('title' => 'ID', 'field' => 'member_id', 'width' => 12),
  715. array('title' => '用户名', 'field' => 'username', 'width' => 12),
  716. array('title' => '手机号', 'field' => 'telephone', 'width' => 12),
  717. array('title' => 'openid', 'field' => 'we_openid', 'width' => 24),
  718. array('title' => '推荐人', 'field' => 'sharename', 'width' => 12),
  719. array('title' => '上级', 'field' => 'parentname', 'width' => 12),
  720. array('title' => '分销商等级', 'field' => 'commission_level_name', 'width' => 12),
  721. array('title' => '下线分销商总数', 'field' => 'next_member_count', 'width' => 12),
  722. array('title' => '一级下线分销商数', 'field' => 'level1', 'width' => 12),
  723. array('title' => '二级下线分销商数', 'field' => 'level2', 'width' => 12),
  724. array('title' => '三级下线分销商数', 'field' => 'level3', 'width' => 12),
  725. array('title' => '累计佣金', 'field' => 'commission_total', 'width' => 12),
  726. array('title' => '打款佣金', 'field' => 'getmoney', 'width' => 12),
  727. array('title' => '注册时间', 'field' => 'createtime', 'width' => 12),
  728. array('title' => '成为分销商时间', 'field' => 'comsiss_time', 'width' => 12),
  729. array('title' => '审核状态', 'field' => 'comsiss_time', 'width' => 12)
  730. );
  731. D('Seller/Excel')->export($list, array('title' => '分销商数据-' . date('Y-m-d-H-i', time()), 'columns' => $columns));
  732. }
  733. $pager = pagination2($total, $pindex, $psize);
  734. $this->pager = $pager;
  735. $this->_GPC = $_GPC;
  736. $this->list =$list;
  737. $this->display();
  738. }
  739. private function modifylevel()
  740. {
  741. $_GPC = I('request.');
  742. $id = trim($_GPC['id']);
  743. $set = D('Seller/Config')->get_all_config();
  744. if ($id == 'default') {
  745. $level = array('id' => 'default', 'levelname' => empty($set['commission_levelname']) ? '默认等级' : $set['commission_levelname'], 'commission1' => $set['commission1'], 'commission2' => $set['commission2'], 'commission3' => $set['commission3']);
  746. }
  747. else {
  748. $level = M('lionfish_comshop_commission_level')->where( array('id' => intval($id) ) )->find();
  749. }
  750. if (IS_POST) {
  751. $data = array(
  752. 'levelname' => trim($_GPC['levelname']),
  753. 'commission1' => trim(trim($_GPC['commission1']), '%'),
  754. 'commission2' => trim(trim($_GPC['commission2']), '%'),
  755. 'commission3' => trim(trim($_GPC['commission3']), '%'),
  756. 'ordermoney' => $_GPC['ordermoney']
  757. );
  758. if (!empty($id)) {
  759. if ($id == 'default') {
  760. $updatecontent = '<br/>等级名称: ' . $set['levelname'] . '->' . $data['levelname'] . '<br/>一级佣金比例: ' . $set['commission1'] . '->' . $data['commission1'] . '<br/>二级佣金比例: ' . $set['commission2'] . '->' . $data['commission2'] . '<br/>三级佣金比例: ' . $set['commission3'] . '->' . $data['commission3'];
  761. $set_data = array();
  762. $set_data['commission_levelname'] = $data['levelname'];
  763. $set_data['commission1'] = $data['commission1'];
  764. $set_data['commission2'] = $data['commission2'];
  765. $set_data['commission3'] = $data['commission3'];
  766. D('Seller/Config')->update($set_data);
  767. }
  768. else {
  769. $updatecontent = '<br/>等级名称: ' . $level['levelname'] . '->' . $data['levelname'] . '<br/>一级佣金比例: ' . $level['commission1'] . '->' . $data['commission1'] . '<br/>二级佣金比例: ' . $level['commission2'] . '->' . $data['commission2'] . '<br/>三级佣金比例: ' . $level['commission3'] . '->' . $data['commission3'];
  770. M('lionfish_comshop_commission_level')->where( array('id' => $id) )->save( $data );
  771. }
  772. }
  773. else {
  774. M('lionfish_comshop_commission_level')->add($data);
  775. }
  776. show_json(1, array('url' => U('distribution/level')));
  777. }
  778. $this->level = $level;
  779. $this->display('Distribution/modifylevel');
  780. }
  781. public function withdrawallist()
  782. {
  783. $_GPC = I('request.');
  784. $condition = ' ';
  785. $pindex = max(1, intval($_GPC['page']));
  786. $psize = 20;
  787. if (!empty($_GPC['keyword'])) {
  788. $_GPC['keyword'] = trim($_GPC['keyword']);
  789. $condition .= ' and ( id = '.intval($_GPC['keyword']).') ';
  790. }
  791. $starttime = strtotime( date('Y-m-d')." 00:00:00" );
  792. $endtime = $starttime + 86400;
  793. if (!empty($_GPC['time']['start']) && !empty($_GPC['time']['end'])) {
  794. $starttime = strtotime($_GPC['time']['start']);
  795. $endtime = strtotime($_GPC['time']['end']);
  796. $condition .= ' AND addtime >= '.$starttime.' AND addtime <= '.$endtime;
  797. }
  798. $this->starttime = $starttime;
  799. $this->endtime = $endtime;
  800. if ($_GPC['comsiss_state'] != '') {
  801. $condition .= ' and state=' . intval($_GPC['comsiss_state']);
  802. }
  803. $sql = 'SELECT * FROM ' . C('DB_PREFIX'). "lionfish_comshop_member_tixian_order
  804. WHERE 1 " . $condition . ' order by id desc ';
  805. if (empty($_GPC['export'])) {
  806. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  807. }
  808. $community_tixian_fee = D('Home/Front')->get_config_by_name('community_tixian_fee');
  809. $list = M()->query($sql);
  810. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX').
  811. 'lionfish_comshop_member_tixian_order WHERE 1 ' . $condition);
  812. $total = $total_arr[0]['count'];
  813. $this->_GPC = $_GPC;
  814. //ims_lionfish_community_head_commiss
  815. foreach( $list as $key => $val )
  816. {
  817. //普通等级
  818. $member_info = M('lionfish_comshop_member')->field('username,avatar,we_openid,telephone')->where( array('member_id' => $val['member_id'] ) )->find();
  819. $val['member_info'] = $member_info;
  820. $list[$key] = $val;
  821. }
  822. if ($_GPC['export'] == '1') {
  823. foreach($list as $key =>&$row)
  824. {
  825. $row['username'] = $row['member_info']['username'];
  826. $row['telephone'] = $row['member_info']['telephone'];
  827. $row['bankname'] = $row['bankname'];
  828. if( $row['type'] == 1 )
  829. {
  830. $row['bankname'] = '余额';
  831. }elseif( $row['type'] == 2 ){
  832. $row['bankname'] = '微信零钱';
  833. }elseif($row['type'] == 3){
  834. $row['bankname'] = '支付宝';
  835. }
  836. $row['bankaccount'] = "\t".$row['bankaccount'];
  837. $row['bankusername'] = $row['bankusername'];
  838. $row['get_money'] = $row['money']-$row['service_charge_money'];
  839. $row['addtime'] = date('Y-m-d H:i:s', $row['addtime']);
  840. if(!empty($row['shentime']))
  841. {
  842. $row['shentime'] = date('Y-m-d H:i:s', $row['shentime']);
  843. }
  844. if($row['state'] ==0)
  845. {
  846. $row['state'] = '待审核';
  847. }else if($row[state] ==1)
  848. {
  849. $row['state'] = '已审核,打款';
  850. }else if($row[state] ==2){
  851. $row['state'] = '已拒绝';
  852. }
  853. }
  854. unset($row);
  855. $columns = array(
  856. array('title' => 'ID', 'field' => 'id', 'width' => 12),
  857. array('title' => '用户名', 'field' => 'username', 'width' => 12),
  858. array('title' => '联系方式', 'field' => 'telephone', 'width' => 12),
  859. array('title' => '打款银行', 'field' => 'bankname', 'width' => 24),
  860. array('title' => '打款账户', 'field' => 'bankaccount', 'width' => 24),
  861. array('title' => '真实姓名', 'field' => 'bankusername', 'width' => 24),
  862. array('title' => '申请提现金额', 'field' => 'money', 'width' => 24),
  863. array('title' => '手续费', 'field' => 'service_charge_money', 'width' => 24),
  864. array('title' => '到账金额', 'field' => 'get_money', 'width' => 24),
  865. array('title' => '申请时间', 'field' => 'addtime', 'width' => 24),
  866. array('title' => '审核时间', 'field' => 'shentime', 'width' => 24),
  867. array('title' => '状态', 'field' => 'state', 'width' => 24)
  868. );
  869. D('Seller/Excel')->export($list, array('title' => '会员分销提现数据-' . date('Y-m-d-H-i', time()), 'columns' => $columns));
  870. }
  871. $pager = pagination2($total, $pindex, $psize);
  872. $this->pager = $pager;
  873. $this->list = $list;
  874. $this->display();
  875. }
  876. public function agent_check_apply()
  877. {
  878. $_GPC = I('request.');
  879. $commission_model = D('Home/Commission');
  880. $id = intval($_GPC['id']);
  881. if (empty($id)) {
  882. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  883. }
  884. $comsiss_state = intval($_GPC['state']);
  885. $apply_list = M()->query('SELECT * FROM ' . C('DB_PREFIX'). 'lionfish_comshop_member_tixian_order
  886. WHERE id in( ' . $id . ' ) ');
  887. $time = time();
  888. foreach ($apply_list as $apply) {
  889. if ($apply['state'] == $comsiss_state || $apply['state'] == 1 || $apply['state'] == 2) {
  890. continue;
  891. }
  892. $money = $apply['money'];
  893. if ($comsiss_state == 1) {
  894. switch( $apply['type'] )
  895. {
  896. case 1:
  897. $result = $commission_model->send_apply_yuer( $apply['id'] );
  898. break;
  899. case 2:
  900. $result = $commission_model->send_apply_weixin_yuer( $apply['id'] );
  901. break;
  902. case 3:
  903. $result = $commission_model->send_apply_alipay_bank( $apply['id'] );
  904. break;
  905. case 4:
  906. $result = $commission_model->send_apply_alipay_bank( $apply['id'] );
  907. break;
  908. }
  909. if( $result['code'] == 1)
  910. {
  911. show_json(0, array('url' => $_SERVER['HTTP_REFERER'],'message'=>$result['msg']) );
  912. }
  913. //检测是否存在账户,没有就新建
  914. //TODO....检测是否微信提现到零钱,如果是,那么就准备打款吧
  915. $commission_model->send_apply_success_msg($apply['id']);
  916. }
  917. else if ($comsiss_state == 2) {
  918. M('lionfish_comshop_member_tixian_order')->where( array('id' => $apply['id'] ) )->save( array('state' => 2, 'shentime' => $time) );
  919. //退回冻结的货款
  920. M()->execute("update ".C('DB_PREFIX')."lionfish_comshop_member_commiss set money=money+{$money},dongmoney=dongmoney-{$money}
  921. where member_id=".$apply['member_id']);
  922. }
  923. else {
  924. M('lionfish_comshop_member_tixian_order')->where( array('id' => $apply['id']) )->save( array('state' => 0, 'shentime' => 0) );
  925. }
  926. }
  927. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  928. }
  929. }
  930. ?>