SupplyController.class.php 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028
  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 SupplyController extends CommonController {
  16. public function index()
  17. {
  18. $export = I('get.export',0);
  19. $condition = ' 1=1 ';
  20. $pindex = $pindex = I('get.page', 1);
  21. $psize = 20;
  22. $keyword = I('get.keyword','','trim');
  23. if (!empty($keyword)) {
  24. $condition .= ' and ( shopname like "'.'%' . $keyword . '%'.'" or name like "'.'%' . $keyword . '%'.'" or mobile like "'.'%' . $keyword . '%'.'" ) ';
  25. }
  26. $this->keyword = $keyword;
  27. $time = I('get.time');
  28. if (!empty($time['start']) && !empty($time['end'])) {
  29. $starttime = strtotime($time['start']);
  30. $endtime = strtotime($time['end']);
  31. $this->starttime = $starttime;
  32. $this->endtime = $endtime;
  33. $condition .= ' AND apptime >= '.$starttime.' AND apptime <= '.$endtime;
  34. }
  35. $comsiss_state = I('get.comsiss_state','');
  36. if ($comsiss_state != '') {
  37. $condition .= ' and state=' . intval($comsiss_state);
  38. }
  39. $this->comsiss_state = $comsiss_state;
  40. $sql = 'SELECT * FROM ' . C('DB_PREFIX') . "lionfish_comshop_supply \r\n
  41. WHERE " . $condition . ' order by id desc ';
  42. if (empty($export)) {
  43. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  44. }
  45. $list = M()->query($sql);
  46. $total = M('lionfish_comshop_supply')->where($condition)->count();
  47. foreach( $list as $key => $val )
  48. {
  49. //goods_count
  50. $goods_count = M('lionfish_comshop_good_common')->where( array('supply_id' => $val['id']) )->count();
  51. $val['goods_count'] = $goods_count;
  52. $list[$key] = $val;
  53. }
  54. if ($export == '1') {
  55. foreach ($list as &$row) {
  56. $row['username'] = $val['member_info']['username'];
  57. $row['we_openid'] = $val['member_info']['we_openid'];
  58. $row['commission_total'] = 0;
  59. $row['getmoney'] = 0;
  60. $row['fulladdress'] = $row['province_name'].$row['city_name'].$row['area_name'].$row['country_name'].$row['address'];
  61. $row['addtime'] = date('Y-m-d H:i:s', $row['addtime']);
  62. $row['apptime'] = date('Y-m-d H:i:s', $row['apptime']);
  63. $row['state'] = $row['state'] == 1 ? '已审核':'未审核';
  64. }
  65. unset($row);
  66. $columns = array(
  67. array('title' => 'ID', 'field' => 'id', 'width' => 12),
  68. array('title' => '店铺名称', 'field' => 'shopname', 'width' => 12),
  69. array('title' => '供应商名称', 'field' => 'name', 'width' => 12),
  70. array('title' => '联系方式', 'field' => 'mobile', 'width' => 12),
  71. array('title' => '商品数量', 'field' => 'goods_count', 'width' => 12),
  72. array('title' => '注册时间', 'field' => 'addtime', 'width' => 12),
  73. array('title' => '成为团长时间', 'field' => 'apptime', 'width' => 12),
  74. array('title' => '审核状态', 'field' => 'state', 'width' => 12)
  75. );
  76. D('Seller/Excel')->export($list, array('title' => '供应商数据-' . date('Y-m-d-H-i', time()), 'columns' => $columns));
  77. }
  78. $pager = pagination2($total, $pindex, $psize);
  79. $this->list = $list;
  80. $this->pager = $pager;
  81. $this->display('Supply/supply');
  82. }
  83. public function authority()
  84. {
  85. $_GPC = I('request.');
  86. if (IS_POST) {
  87. $data = ((is_array($_GPC['data']) ? $_GPC['data'] : array()));
  88. $data['supply_can_goods_updown'] = isset($data['supply_can_goods_updown']) ? $data['supply_can_goods_updown'] : 2;
  89. $data['supply_can_vir_count'] = isset($data['supply_can_vir_count']) ? $data['supply_can_vir_count'] : 2;
  90. $data['supply_can_goods_istop'] = isset($data['supply_can_goods_istop']) ? $data['supply_can_goods_istop'] : 2;
  91. $data['supply_can_goods_isindex'] = isset($data['supply_can_goods_isindex']) ? $data['supply_can_goods_isindex'] : 2;
  92. $data['supply_can_goods_sendscore'] = isset($data['supply_can_goods_sendscore']) ? $data['supply_can_goods_sendscore'] : 2;
  93. $data['supply_can_goods_newbuy'] = isset($data['supply_can_goods_newbuy']) ? $data['supply_can_goods_newbuy'] : 2;
  94. $data['supply_can_look_headinfo'] = isset($data['supply_can_look_headinfo']) ? $data['supply_can_look_headinfo'] : 2;
  95. $data['supply_can_nowrfund_order'] = isset($data['supply_can_nowrfund_order']) ? $data['supply_can_nowrfund_order'] : 2;
  96. $data['supply_can_goods_spike'] = isset($data['supply_can_goods_spike']) ? $data['supply_can_goods_spike'] : 2;
  97. $data['supply_can_confirm_delivery'] = isset($data['supply_can_confirm_delivery']) ? $data['supply_can_confirm_delivery'] : 2;
  98. $data['supply_can_confirm_receipt'] = isset($data['supply_can_confirm_receipt']) ? $data['supply_can_confirm_receipt'] : 2;
  99. D('Seller/Config')->update($data);
  100. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  101. }
  102. $data = D('Seller/Config')->get_all_config();
  103. $this->data = $data;
  104. $this->_GPC = $_GPC;
  105. $this->display();
  106. }
  107. public function distributionpostal()
  108. {
  109. $_GPC = I('request.');
  110. if (IS_POST) {
  111. $data = ((is_array($_GPC['data']) ? $_GPC['data'] : array()));
  112. $data['supply_commiss_tixianway_yuer'] = isset($data['supply_commiss_tixianway_yuer']) ? $data['supply_commiss_tixianway_yuer'] : 1;
  113. $data['supply_commiss_tixianway_weixin'] = isset($data['supply_commiss_tixianway_weixin']) ? $data['supply_commiss_tixianway_weixin'] : 1;
  114. $data['supply_commiss_tixianway_alipay'] = isset($data['supply_commiss_tixianway_alipay']) ? $data['supply_commiss_tixianway_alipay'] : 1;
  115. $data['supply_commiss_tixianway_bank'] = isset($data['supply_commiss_tixianway_bank']) ? $data['supply_commiss_tixianway_bank'] : 1;
  116. $data['supply_commiss_tixianway_weixin_offline'] = isset($data['supply_commiss_tixianway_weixin_offline']) ? $data['supply_commiss_tixianway_weixin_offline'] : 1;
  117. D('Seller/Config')->update($data);
  118. show_json(1, array('url' => U('Supply/distributionpostal')) );
  119. }
  120. $data = D('Seller/Config')->get_all_config();
  121. $this->data = $data;
  122. $this->display();
  123. }
  124. public function agent_check_first()
  125. {
  126. $_GPC = I('request.');
  127. $id = intval($_GPC['id']);
  128. if ( IS_POST ) {
  129. $type = $_GPC['type'];
  130. $time = time();
  131. M('lionfish_comshop_supply')->where( array('id' => $id ) )->save( array('type' => $type,'state' => 1, 'apptime' => $time) );
  132. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  133. }
  134. $this->id = $id;
  135. include $this->display();
  136. }
  137. public function agent_tixian()
  138. {
  139. $_GPC = I('request.');
  140. $id = intval($_GPC['id']);
  141. if (empty($id)) {
  142. $id = (is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0);
  143. }
  144. $comsiss_state = intval($_GPC['state']);
  145. $members = M()->query('SELECT * FROM ' . C('DB_PREFIX'). 'lionfish_supply_tixian_order
  146. WHERE id in( ' . $id . ' ) ');
  147. $time = time();
  148. $open_weixin_qiye_pay = D('Home/Front')->get_config_by_name('open_weixin_qiye_pay');
  149. $lib_path = dirname(dirname( dirname(__FILE__) )).'/Lib/';
  150. require_once $lib_path."/Weixin/lib/WxPay.Api.php";
  151. foreach ($members as $member) {
  152. if ($member['state'] === $comsiss_state) {
  153. continue;
  154. }
  155. if ($comsiss_state == 1) {
  156. if( $member['state'] == 0 )
  157. {
  158. if( $member['supply_apply_type'] == 1 )
  159. {
  160. if( !empty($open_weixin_qiye_pay) && $open_weixin_qiye_pay == 1 )
  161. {
  162. $supper_info = M('lionfish_comshop_supply')->field('member_id')->where( array('id' => $member['supply_id'] ) )->find();
  163. if( !empty($supper_info['member_id']) && $supper_info['member_id'] > 0 )
  164. {
  165. $mb_info = M('lionfish_comshop_member')->field('we_openid')->where( array('member_id' => $supper_info['member_id'] ) )->find();
  166. $partner_trade_no = build_order_no($member['id']);
  167. $desc = date('Y-m-d H:i:s', $member['addtime']).'申请的提现已到账';
  168. $username = $member['bankaccount'];
  169. $amount = ($member['money']) * 100;
  170. $openid = $mb_info['we_openid'];
  171. $res = \WxPayApi::payToUser($openid,$amount,$username,$desc,$partner_trade_no,$_W['uniacid']);
  172. if(empty($res) || $res['result_code'] =='FAIL')
  173. {
  174. show_json(0, array('message' => $res['err_code_des'] ));
  175. }
  176. }else{
  177. show_json(0, array('message' => '请编辑供应商资料绑定会员,才能进行微信零钱提现'));
  178. }
  179. }else{
  180. show_json(0, array('message' => '请前往团长提现设置开启微信企业付款,供应商提现公用资料'));
  181. }
  182. }
  183. M('lionfish_supply_tixian_order')->where( array('id' => $member['id'] ) )->save( array('state' => 1, 'shentime' => $time) );
  184. //打款
  185. M()->execute("update ".C('DB_PREFIX')."lionfish_supply_commiss set dongmoney=dongmoney-{$member[money]},getmoney=getmoney+{$member[money]}
  186. where supply_id=".$member['supply_id']);
  187. }
  188. }
  189. else {
  190. if( $member['state'] == 0 )
  191. {
  192. M('lionfish_supply_tixian_order')->where( array('id' => $member['id']) )->save( array('state' => 2, 'shentime' => 0) );
  193. //退款
  194. M()->execute( "update ".C('DB_PREFIX')."lionfish_supply_commiss set dongmoney=dongmoney-{$member[money]},money=money+{$member[money]}
  195. where supply_id=".$member['supply_id'] );
  196. }
  197. }
  198. }
  199. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  200. }
  201. public function test()
  202. {
  203. $list = M('lionfish_supply_commiss_order')->where( array('state' =>0) )->select();
  204. foreach( $list as $val )
  205. {
  206. M('lionfish_supply_commiss_order')->where( array('id' => $val['id']) )->save( array('money' => $val['money'] - $val['head_commiss_money'] ) );
  207. }
  208. echo 'success';
  209. die();
  210. }
  211. //---begin
  212. public function floworder()
  213. {
  214. $_GPC = I('request.');
  215. $supper_info = get_agent_logininfo();
  216. $condition = ' supply_id='. $supper_info['id'].' ';
  217. $pindex = max(1, intval($_GPC['page']));
  218. $psize = 20;
  219. $sql = 'SELECT * FROM ' . C('DB_PREFIX'). "lionfish_supply_commiss_order
  220. WHERE " . $condition . ' order by id desc ';
  221. if( isset($_GPC['export']) && $_GPC['export'] == 1 )
  222. {
  223. }else{
  224. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  225. }
  226. $list = M()->query($sql);
  227. $total = M('lionfish_supply_commiss_order')->where( $condition )->count();
  228. foreach( $list as $key => $val )
  229. {
  230. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $val['order_goods_id'] ) )->find();
  231. $val['goods_name'] = $order_goods['name'];
  232. $val['option_sku'] = D('Seller/Order')->get_order_option_sku($order_goods['order_id'], $order_goods['order_goods_id']);
  233. $commission_list = M('lionfish_community_head_commiss_order')->where( "order_id=".$order_goods['order_id']." and order_goods_id=".$order_goods['order_goods_id'] )->select();
  234. $val['commission_list'] = $commission_list;
  235. $list[$key] = $val;
  236. }
  237. if( isset($_GPC['export']) && $_GPC['export'] == 1 )
  238. {
  239. $columns = array(
  240. array('title' => '订单id', 'field' => 'order_id', 'width' => 16),
  241. array('title' => '商品名称', 'field' => 'goods_name', 'width' => 32),
  242. array('title' => '金额', 'field' => 'total_money', 'width' => 16),
  243. array('title' => '团长佣金', 'field' => 'head_commiss_money', 'width' => 16),
  244. array('title' => '服务费比例', 'field' => 'comunity_blili', 'width' => 16),
  245. array('title' => '服务费金额', 'field' => 'fuwu_money', 'width' => 16),
  246. array('title' => '实收金额', 'field' => 'money', 'width' => 16),
  247. array('title' => '状态', 'field' => 'state', 'width' => 16),
  248. );
  249. $exportlist = array();
  250. foreach($list as $val)
  251. {
  252. $tmp_exval = array();
  253. $tmp_exval['order_id'] = $val['order_id'];
  254. $tmp_exval['goods_name'] = $val['goods_name'].$val['option_sku'];
  255. $tmp_exval['total_money'] = $val['total_money'];
  256. $tmp_exval['head_commiss_money'] = '-'.$val['head_commiss_money'];
  257. $tmp_exval['comunity_blili'] = $val['comunity_blili'].'%';
  258. $tmp_exval['fuwu_money'] = '-'.( round($val['total_money']*$val['comunity_blili']/100,2));
  259. $tmp_exval['money'] = $val['money'];
  260. if( $val[state] ==2 ){
  261. $tmp_exval['state'] = '订单取消';
  262. }else if( $val[state] ==1 ){
  263. $tmp_exval['state'] = '已结算';
  264. }else{
  265. $tmp_exval['state'] = '待结算';
  266. }
  267. $exportlist[] = $tmp_exval;
  268. }
  269. D('Seller/Excel')->export($exportlist, array('title' => '资金流水', 'columns' => $columns));
  270. }
  271. $pager = pagination2($total, $pindex, $psize);
  272. $this->list = $list;
  273. $this->pager = $pager;
  274. $this->display('Supply/floworder');
  275. }
  276. public function admintixianlist()
  277. {
  278. $_GPC = I('request.');
  279. $condition = ' 1 ';
  280. $pindex = max(1, intval($_GPC['page']));
  281. $psize = 20;
  282. $sql = 'SELECT * FROM ' . C('DB_PREFIX') . "lionfish_supply_tixian_order
  283. WHERE " . $condition . ' order by id desc ';
  284. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  285. $list = M()->query($sql);
  286. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX').
  287. 'lionfish_supply_tixian_order WHERE ' . $condition );
  288. $total = $total_arr[0]['count'];
  289. foreach( $list as $key => $val )
  290. {
  291. $supper_info = D('Home/Front')->get_supply_info($val['supply_id']);
  292. $val['supper_info'] = $supper_info;
  293. $list[$key] = $val;
  294. }
  295. $pager = pagination2($total, $pindex, $psize);
  296. $this->list = $list;
  297. $this->pager = $pager;
  298. $this->display();
  299. }
  300. public function tixianlist()
  301. {
  302. $_GPC = I('request.');
  303. $supper_info = get_agent_logininfo();
  304. $condition = ' supply_id= '.$supper_info['id'];
  305. $pindex = max(1, intval($_GPC['page']));
  306. $psize = 20;
  307. $sql = 'SELECT * FROM ' . C('DB_PREFIX') . "lionfish_supply_tixian_order
  308. WHERE " . $condition . ' order by id desc ';
  309. $sql .= ' limit ' . (($pindex - 1) * $psize) . ',' . $psize;
  310. $list = M()->query($sql);
  311. $total_arr = M()->query('SELECT count(1) as count FROM ' . C('DB_PREFIX').
  312. 'lionfish_supply_tixian_order WHERE ' . $condition);
  313. $total = $total_arr[0]['count'];
  314. foreach( $list as $key => $val )
  315. {
  316. $list[$key] = $val;
  317. }
  318. $pager = pagination2($total, $pindex, $psize);
  319. $supply_commiss = M('lionfish_supply_commiss')->where( array('supply_id' => $supper_info['id'] ) )->find();
  320. //TODO...
  321. if( empty($supply_commiss) )
  322. {
  323. $lionfish_supply_commiss_data = array();
  324. $lionfish_supply_commiss_data['supply_id'] = $supper_info['id'];
  325. $lionfish_supply_commiss_data['money'] = 0;
  326. $lionfish_supply_commiss_data['dongmoney'] = 0;
  327. $lionfish_supply_commiss_data['getmoney'] = 0;
  328. M('lionfish_supply_commiss')->add( $lionfish_supply_commiss_data );
  329. $supply_commiss = array();
  330. $supply_commiss['money'] = 0;
  331. $supply_commiss['dongmoney'] = 0;
  332. $supply_commiss['getmoney'] = 0;
  333. }
  334. $this->supply_commiss = $supply_commiss;
  335. $this->list = $list;
  336. $this->pager = $pager;
  337. $this->display('Supply/tixianlist');
  338. }
  339. public function apply_money()
  340. {
  341. $_GPC = I('request.');
  342. $supper_info = get_agent_logininfo();
  343. $supply_min_apply_money = D('Home/Front')->get_config_by_name('supply_min_money');
  344. if( empty($supply_min_apply_money) )
  345. {
  346. $supply_min_apply_money = 0;
  347. }
  348. $supply_commiss = M('lionfish_supply_commiss')->where( array('supply_id' =>$supper_info['id'] ) )->find();
  349. $last_tixian_order = array('bankname' =>'微信','bankaccount' => '','bankusername' => '' ,'supply_apply_type' => -1 );
  350. $lionfish_supply_tixian_order = M('lionfish_supply_tixian_order')->where( array('supply_id' =>$supper_info['id'] ) )->order('id desc')->find();
  351. if( !empty($lionfish_supply_tixian_order) )
  352. {
  353. $last_tixian_order['bankname'] = $lionfish_supply_tixian_order['bankname'];
  354. $last_tixian_order['bankaccount'] = $lionfish_supply_tixian_order['bankaccount'];
  355. $last_tixian_order['bankusername'] = $lionfish_supply_tixian_order['bankusername'];
  356. $last_tixian_order['supply_apply_type'] = $lionfish_supply_tixian_order['supply_apply_type'];
  357. }
  358. $this->supply_min_apply_money = $supply_min_apply_money;
  359. $this->supply_commiss = $supply_commiss;
  360. $this->last_tixian_order = $last_tixian_order;
  361. $this->lionfish_supply_tixian_order = $lionfish_supply_tixian_order;
  362. $sup_info = M('lionfish_comshop_supply')->where( array('id' => $supper_info['id'] ) )->find();
  363. //member_id
  364. $bind_member = array();
  365. if( $sup_info['member_id'] > 0 )
  366. {
  367. $bind_member = M('lionfish_comshop_member')->where( array('member_id' => $sup_info['member_id'] ) )->find();
  368. }
  369. $this->bind_member = $bind_member;
  370. if (IS_POST) {
  371. $supply_apply_type = $_GPC['supply_apply_type'];
  372. //1 微信 2 支付宝 3银行卡
  373. //bankname bankaccount bankusername
  374. $weixin_account = $_GPC['weixin_account'];
  375. $alipay_account = $_GPC['alipay_account'];
  376. $card_name = $_GPC['card_name'];
  377. $card_account = $_GPC['card_account'];
  378. $card_username = $_GPC['card_username'];
  379. $weixin_account_xx = $_GPC['weixin_account_xx'];
  380. $ti_money = floatval( $_GPC['ti_money'] );
  381. if($ti_money < $supply_min_apply_money){
  382. show_json(0, array('message' => '最低提现'.$supply_min_apply_money));
  383. }
  384. if($ti_money <=0){
  385. show_json(0, array('message' => '最低提现大于0元'));
  386. }
  387. if($ti_money > $supply_commiss['money']){
  388. show_json(0, array('message' => '当前最多提现'.$supply_commiss['money']));
  389. }
  390. $supper_in = M('lionfish_comshop_supply')->field('commiss_bili')->where( array('id' => $supper_info['id'] ) )->find();
  391. $ins_data = array();
  392. $ins_data['supply_id'] = $supper_info['id'];
  393. $ins_data['money'] = $ti_money;
  394. $ins_data['service_charge'] = round( ($ti_money * $supper_in['commiss_bili']) /100 );
  395. $ins_data['state'] = 0;
  396. $ins_data['shentime'] = 0;
  397. $ins_data['is_send_fail'] = 0;
  398. $ins_data['fail_msg'] = '';
  399. $ins_data['supply_apply_type'] = $supply_apply_type;
  400. //1 微信 2 支付宝 3银行卡
  401. if($supply_apply_type == 1)
  402. {
  403. $ins_data['bankname'] = '微信零钱';
  404. $ins_data['bankaccount'] = $weixin_account;
  405. $ins_data['bankusername'] = '';
  406. }else if($supply_apply_type == 2){
  407. $ins_data['bankname'] = '支付宝';
  408. $ins_data['bankaccount'] = $alipay_account;
  409. $ins_data['bankusername'] = '';
  410. }else if($supply_apply_type == 3){
  411. $ins_data['bankname'] = $card_name;
  412. $ins_data['bankaccount'] = $card_account;
  413. $ins_data['bankusername'] = $card_username;
  414. }else if($supply_apply_type == 4){
  415. $ins_data['bankname'] = '微信私下转';
  416. $ins_data['bankaccount'] = $weixin_account_xx;
  417. $ins_data['bankusername'] = '';
  418. }
  419. $ins_data['addtime'] = time();
  420. M('lionfish_supply_tixian_order')->add($ins_data);
  421. M('lionfish_supply_commiss')->where( array('supply_id' => $supper_info['id'] ) )->setInc('money',-$ti_money);
  422. M('lionfish_supply_commiss')->where( array('supply_id' => $supper_info['id'] ) )->setInc('dongmoney',$ti_money);
  423. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  424. }
  425. $data = D('Seller/Config')->get_all_config();
  426. $supply_commiss_tixianway_weixin = !isset($data['supply_commiss_tixianway_weixin']) || (isset($data['supply_commiss_tixianway_weixin']) && $data['supply_commiss_tixianway_weixin'] ==2) ? 2 : 0;
  427. $supply_commiss_tixianway_alipay = !isset($data['supply_commiss_tixianway_alipay']) || (isset($data['supply_commiss_tixianway_alipay']) && $data['supply_commiss_tixianway_alipay'] ==2) ? 2 : 0;
  428. $supply_commiss_tixianway_bank = !isset($data['supply_commiss_tixianway_bank']) || (isset($data['supply_commiss_tixianway_bank']) && $data['supply_commiss_tixianway_bank'] ==2) ? 2 : 0;
  429. $supply_commiss_tixianway_weixin_offline = !isset($data['supply_commiss_tixianway_weixin_offline']) || (isset($data['supply_commiss_tixianway_weixin_offline']) && $data['supply_commiss_tixianway_weixin_offline'] ==2) ? 2 : 0;
  430. $this->data = $data;
  431. $this->supply_commiss_tixianway_weixin = $supply_commiss_tixianway_weixin;
  432. $this->supply_commiss_tixianway_alipay = $supply_commiss_tixianway_alipay;
  433. $this->supply_commiss_tixianway_bank = $supply_commiss_tixianway_bank;
  434. $this->supply_commiss_tixianway_weixin_offline = $supply_commiss_tixianway_weixin_offline;
  435. $this->display();
  436. }
  437. /**
  438. 供应商登录
  439. **/
  440. public function login()
  441. {
  442. $this->display();
  443. }
  444. /**
  445. 供应商登录提交密码
  446. **/
  447. public function login_do()
  448. {
  449. $_GPC = I('request.');
  450. //mobile:mobile, password:password}
  451. $mobile = trim($_GPC['mobile']);
  452. $password = trim($_GPC['password']);
  453. if( empty($mobile) || empty($password) )
  454. {
  455. echo json_encode( array('code' => 1, 'msg' => '请填写您的账号密码!') );
  456. die();
  457. }
  458. $record = array( );
  459. $temp = M('lionfish_comshop_supply')->where( array('login_name' => $mobile ) )->find();
  460. if( !empty($temp) )
  461. {
  462. $password = md5( $temp["login_slat"].$password );
  463. if( $password == $temp["login_password"] )
  464. {
  465. $record = $temp;
  466. }
  467. }
  468. if( !empty($record) )
  469. {
  470. if( $record["state"] == 0)
  471. {
  472. echo json_encode( array('code' => 1, 'msg' => '您的账号正在审核或是已经被系统禁止,请联系网站管理员解决!') );
  473. die();
  474. }
  475. if( !empty($_W["siteclose"]) )
  476. {
  477. echo json_encode( array('code' => 1, 'msg' => "站点已关闭,关闭原因:" . $_W["setting"]["copyright"]["reason"] ) );
  478. die();
  479. }
  480. if (C('USER_AUTH_ON')) {
  481. unset($_SESSION[C('USER_AUTH_KEY')]);
  482. unset($_SESSION[C('ADMIN_AUTH_KEY')]);
  483. }
  484. session('seller_auth', array());
  485. session('seller_auth_sign', -1);
  486. $auth = array(
  487. 'uid' => $record["id"],
  488. 'shopname' => $temp['shopname'],
  489. 'username' => $temp['shopname'],
  490. 'type' => $record['type'],
  491. 'role' => 'agenter',
  492. 'role_id' => 0,
  493. 'last_login_time' => $seller['s_last_login_time'],
  494. );
  495. session('agent_auth', $auth);
  496. session('agent_auth_sign', data_auth_sign($auth));
  497. if( empty($forward) )
  498. {
  499. $forward = $_GPC["forward"];
  500. }
  501. if( empty($forward) )
  502. {
  503. $forward = U('index/index');
  504. }
  505. //message("欢迎回来," . $record["title"] . "。", $forward, "success" );
  506. cookie('last_login_page',2);
  507. echo json_encode( array('code' => 0, 'url' => $forward ) );
  508. die();
  509. }
  510. else
  511. {
  512. echo json_encode( array('code' => 1, 'msg' => "您的账号密码错误!") );
  513. die();
  514. }
  515. die();
  516. }
  517. //---end
  518. public function config()
  519. {
  520. $gpc = I('request.');
  521. if (IS_POST) {
  522. $data = ((is_array($gpc['data']) ? $gpc['data'] : array()));
  523. D('Seller/Config')->update($data);
  524. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  525. }
  526. $data = D('Seller/Config')->get_all_config();
  527. $this->data = $data;
  528. $this->display();
  529. }
  530. public function baseconfig()
  531. {
  532. $gpc = I('request.');
  533. if (IS_POST) {
  534. $data = ((is_array($gpc['data']) ? $gpc['data'] : array()));
  535. D('Seller/Config')->update($data);
  536. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  537. }
  538. $data = D('Seller/Config')->get_all_config();
  539. $this->data = $data;
  540. $this->display();
  541. }
  542. public function agent_check()
  543. {
  544. $id = I('get.id',0);
  545. if (empty($id)) {
  546. $ids = I('post.ids');
  547. $id = (is_array($ids) ? implode(',', $ids) : 0);
  548. }
  549. $comsiss_state = I('request.state');
  550. $members = M('lionfish_comshop_supply')->field('id,state')->where( array('id' => array('in', $id) ) )->select();
  551. $time = time();
  552. foreach ($members as $member) {
  553. if ($member['state'] === $comsiss_state) {
  554. continue;
  555. }
  556. if ($comsiss_state == 1) {
  557. $res = M('lionfish_comshop_supply')->where(array('id' => $member['id']))->save( array('state' => 1, 'apptime' => $time) );
  558. }
  559. else if($comsiss_state == 2)
  560. {
  561. M('lionfish_comshop_supply')->where( array('id' => $member['id']) )->save( array('state' => 2, 'apptime' => $time ) );
  562. }
  563. else {
  564. M('lionfish_comshop_supply')->where(array('id' => $member['id']))->save( array('state' => 0, 'apptime' => 0) );
  565. }
  566. }
  567. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  568. }
  569. public function zhenquery()
  570. {
  571. $kwd = I('get.keyword','','trim');
  572. $is_ajax = I('request.is_ajax',0,'intval');
  573. $condition = ' state=1 ';
  574. if (!empty($kwd)) {
  575. $condition .= ' AND ( `shopname` LIKE "'.'%' . $kwd . '%'.'" or `name` like "'.'%' . $kwd . '%'.'" or `mobile` like "'.'%' . $kwd . '%'.'" )';
  576. }
  577. /**
  578. 分页开始
  579. **/
  580. $page = I('request.page',1,'intval');
  581. $page = max(1, $page);
  582. $page_size = 10;
  583. /**
  584. 分页结束
  585. **/
  586. $ds = M('lionfish_comshop_supply')->where( $condition )->order('id desc')->limit( (($page - 1) * $page_size) . ',' . $page_size )->select();
  587. $total = M('lionfish_comshop_supply')->where( $condition )->count();
  588. $ret_html = '';
  589. foreach ($ds as &$value) {
  590. $value['nickname'] = htmlspecialchars($value['username'], ENT_QUOTES);
  591. $value['logo'] = tomedia($value['logo']);
  592. $value['supply_id'] = $value['id'];
  593. if($is_ajax == 1)
  594. {
  595. $ret_html .= '<tr>';
  596. $ret_html .= '<td><img src="'.$value['logo'].'" style="width:30px;height:30px;padding1px;border:1px solid #ccc" />';
  597. $ret_html .= $value['shopname'];
  598. $ret_html .= '<td>'.$value['name'].'</td>';
  599. $ret_html .= '<td>'.$value['mobile'].'</td>';
  600. $ret_html .= '<td style="width:80px;"><a href="javascript:;" class="choose_dan_link" data-json=\''.json_encode($value).'\'>选择</a></td>';
  601. $ret_html .= '</tr>';
  602. }
  603. }
  604. $pager = pagination($total, $page, $page_size,'',$context = array('before' => 5, 'after' => 4, 'isajax' => 1));
  605. unset($value);
  606. if( $is_ajax == 1 )
  607. {
  608. echo json_encode( array('code' => 0, 'html' => $ret_html,'pager' => $pager) );
  609. die();
  610. }
  611. $this->ds = $ds;
  612. $this->pager = $pager;
  613. $this->display('Supply/query');
  614. }
  615. public function addsupply()
  616. {
  617. $id = I('get.id', 0);
  618. if (IS_POST) {
  619. $data = array();
  620. $data['id'] = $id;
  621. $data['shopname'] = I('post.shopname');
  622. $data['logo'] = I('post.logo');
  623. $data['name'] = I('post.name');
  624. $data['mobile'] = I('post.mobile');
  625. $data['state'] = I('post.state');
  626. $data['login_name'] = I('post.login_name');
  627. $data['login_password'] = I('post.login_password');
  628. $data['type'] = I('post.type');
  629. $data['commiss_bili'] = I('post.commiss_bili');
  630. $data['member_id'] = I('post.member_id');
  631. $goods_industrial = I('post.goods_industrial');
  632. $data['qualifications'] = serialize($goods_industrial);
  633. $data['storename'] = I('post.storename');
  634. $data['banner'] = I('post.banner');
  635. $data['apptime'] = time();
  636. $data['addtime'] = time();
  637. $rs = D('Seller/supply')->modify_supply($data);
  638. if($rs)
  639. {
  640. show_json(1, array('url' => U('supply/index')));
  641. }else{
  642. show_json(0, array('message' => '保存失败'));
  643. }
  644. //show_json(1, array('url' => U('distribution/level')));
  645. // show_json(0, array('message' => '未找到订单!'));
  646. //show_json(1, array('url' => referer()));
  647. }
  648. if($id > 0)
  649. {
  650. $item = M('lionfish_comshop_supply')->where( array('id' => $id) )->find();
  651. $this->item = $item;
  652. $saler = array();
  653. if( $item['member_id'] > 0 )
  654. {
  655. $saler = M('lionfish_comshop_member')->field('member_id, username as nickname,avatar')->where( array('member_id' => $item['member_id'] ) )->find();
  656. }
  657. $piclist = array();
  658. if( !empty($item['qualifications']) )
  659. {
  660. $item['qualifications'] = unserialize($item['qualifications']);
  661. foreach($item['qualifications'] as $val)
  662. {
  663. //$piclist[] = tomedia($val);
  664. $piclist[] = array('image' =>$val, 'thumb' => tomedia($val) ); //$val['image'];
  665. }
  666. }
  667. $this->piclist = $piclist;
  668. $this->saler = $saler;
  669. }
  670. $this->id = $id;
  671. $this->display();
  672. }
  673. public function changename()
  674. {
  675. $_GPC = I('request.');
  676. $id = intval($_GPC['id']);
  677. //ids
  678. if (empty($id)) {
  679. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  680. }
  681. if (empty($id)) {
  682. show_json(0, array('message' => '参数错误'));
  683. }
  684. $type = trim($_GPC['type']);
  685. $value = trim($_GPC['value']);
  686. $items = M('lionfish_supply_tixian_order')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  687. foreach ($items as $item ) {
  688. M('lionfish_supply_tixian_order')->where( array('id' => $item['id']) )->save( array('bankaccount' => $value) );
  689. }
  690. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  691. }
  692. public function deletesupply()
  693. {
  694. $_GPC = I('request.');
  695. $id = intval($_GPC['id']);
  696. if (empty($id)) {
  697. $id = ((is_array($_GPC['ids']) ? implode(',', $_GPC['ids']) : 0));
  698. }
  699. $items = M('lionfish_comshop_supply')->field('id')->where( 'id in( ' . $id . ' )' )->select();
  700. foreach ($items as $item ) {
  701. M('lionfish_comshop_supply')->where( array('id' => $item['id']) )->delete();
  702. }
  703. show_json(1, array('url' => $_SERVER['HTTP_REFERER']));
  704. }
  705. }
  706. ?>