SupplymobileController.class.php 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614
  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 Home\Controller;
  15. class SupplymobileController extends CommonController {
  16. /**
  17. @title 供应商手机端主页接口
  18. @param token
  19. **/
  20. public function supplyindex_info()
  21. {
  22. $gpc = I('request.');
  23. $token = $gpc['token'];
  24. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  25. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  26. {
  27. echo json_encode( array('code' => 1,'msg' => '未登录') );
  28. die();
  29. }
  30. $member_id = $weprogram_token['member_id'];
  31. if($member_id > 0){
  32. //是否开启供应商平台
  33. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  34. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  35. {
  36. $supply_is_open_mobilemanage = 0;
  37. }
  38. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  39. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  40. {
  41. $result = array();
  42. $result['supply_info'] = array(
  43. 'shopname' => $supply_info['shopname'],
  44. 'logo' => tomedia( $supply_info['logo'] )
  45. );
  46. $goods_stock_notice = D('Home/Front')->get_config_by_name('goods_stock_notice');
  47. $notice_gods_count = 0;
  48. if( !empty($goods_stock_notice) && $goods_stock_notice > 0 )
  49. {
  50. //库存警告商品数量
  51. //supply_id
  52. $sql = " select count(g.id) as count from ".C('DB_PREFIX')."lionfish_comshop_goods as g left join ".C('DB_PREFIX')."lionfish_comshop_good_common as gc
  53. on g.id = gc.goods_id where gc.supply_id = ".$supply_info['id']." and g.total < {$goods_stock_notice} ";
  54. $sp_notice_count_arr = M()->query( $sql );
  55. $notice_gods_count = $sp_notice_count_arr[0]['count'];
  56. }
  57. //待发货订单数量
  58. $wait_send_count = 0;
  59. //售后订单
  60. $wait_refund_count = 0;
  61. //今日订单
  62. $today_order_count = 0;
  63. //昨日订单数量
  64. $yestday_order_count = 0;
  65. //总订单数量
  66. $total_order_count = 0;
  67. //待结算金额
  68. $wait_statement_money = 0;
  69. //已结算金额
  70. $has_statement_money = 0;
  71. //已提现金额
  72. $has_get_money = 0;
  73. $wait_statement_money = M('lionfish_supply_commiss_order')->where( array('supply_id' => $supply_info['id'], 'state' => 0 ) )->sum('money');
  74. $has_statement_money = M('lionfish_supply_commiss_order')->where( array('supply_id' => $supply_info['id'], 'state' => 1 ) )->sum('money');
  75. if( empty($wait_statement_money) )
  76. {
  77. $wait_statement_money = 0;
  78. }
  79. if( empty($has_statement_money) )
  80. {
  81. $has_statement_money = 0;
  82. }
  83. //oscshop_
  84. $lionfish_supply_commiss = M('lionfish_supply_commiss')->where( array('supply_id' => $supply_info['id'] ) )->find();
  85. if( !empty($lionfish_supply_commiss) )
  86. {
  87. $has_get_money = $lionfish_supply_commiss['getmoney'];
  88. }
  89. $order_ids_list_tmp = M('lionfish_comshop_order_goods')->field('order_id')->where( array('supply_id' => $supply_info['id'] ) )->select();
  90. if( !empty($order_ids_list_tmp) )
  91. {
  92. $order_ids_tmp_arr = array();
  93. foreach($order_ids_list_tmp as $vv)
  94. {
  95. if( empty($order_ids_tmp_arr) || !in_array( $vv['order_id'], $order_ids_tmp_arr ) )
  96. {
  97. $order_ids_tmp_arr[] = $vv['order_id'];
  98. }
  99. }
  100. $order_ids_tmp_str = implode(',', $order_ids_tmp_arr);
  101. $wait_send_count = M('lionfish_comshop_order')->where(' order_status_id=1 and '." order_id in({$order_ids_tmp_str}) ")->count();
  102. $wait_refund_count = M('lionfish_comshop_order')->where(' order_status_id=12 and '." order_id in({$order_ids_tmp_str}) ")->count();
  103. //今日订单
  104. $today_time = strtotime( date('Y-m-d '.'00:00:00') );
  105. $yesday_time = $today_time - 86400;
  106. $today_order_count = M('lionfish_comshop_order')->where(' date_added >='.$today_time.' and '." order_id in({$order_ids_tmp_str}) ")->count();
  107. $yestday_order_count = M('lionfish_comshop_order')->where(' date_added >='.$yesday_time.' and date_added <'.$today_time.' and '." order_id in({$order_ids_tmp_str}) ")->count();
  108. $total_order_count = count($order_ids_tmp_arr);
  109. }
  110. $result['wait_send_count'] = $wait_send_count;//待发货订单数量
  111. $result['wait_refund_count'] = $wait_refund_count;//售后订单数量
  112. $result['today_order_count'] = $today_order_count;//今日订单数量
  113. $result['yestday_order_count'] = $yestday_order_count;//昨日订单数量
  114. $result['total_order_count'] = $total_order_count;//总订单数量
  115. $result['wait_statement_money'] = $wait_statement_money;//待结算金额
  116. $result['has_statement_money'] = $has_statement_money;//已结算金额
  117. $result['has_get_money'] = $has_get_money;//已提现金额
  118. echo json_encode( array('code' => 0, 'data' =>$result ) );
  119. die();
  120. }else{
  121. echo json_encode( array('code' => 2,'msg' => '未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  122. die();
  123. }
  124. }
  125. }
  126. /**
  127. 供应商商品管理
  128. **/
  129. public function get_supply_goodslist()
  130. {
  131. $gpc = I('request.');
  132. $token = $gpc['token'];
  133. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  134. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  135. {
  136. echo json_encode( array('code' => 1,'msg' => '未登录') );
  137. die();
  138. }
  139. $member_id = $weprogram_token['member_id'];
  140. if($member_id > 0){
  141. //是否开启供应商平台
  142. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  143. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  144. {
  145. $supply_is_open_mobilemanage = 0;
  146. }
  147. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  148. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  149. {
  150. $result = array();
  151. $goods_stock_notice = D('Home/Front')->get_config_by_name('goods_stock_notice');
  152. $goods_stock_notice = empty($goods_stock_notice) ? 0 : $goods_stock_notice;
  153. $page = isset($gpc['page']) && $gpc['page'] >0 ? intval($gpc['page']) : 1;
  154. $per_page = 10;
  155. $offset = ($page - 1) * $per_page;
  156. $where = "";
  157. $grounding = isset($gpc['grounding']) ? $gpc['grounding'] : 1;
  158. if( $grounding != 8 )
  159. {
  160. $where .= " and g.grounding = {$grounding} ";
  161. }else if( $grounding == 8 ){
  162. $where .= " and g.grounding = 1 and g.total<= {$goods_stock_notice} ";
  163. }
  164. $keywords = isset($gpc['keywords']) ? $gpc['keywords'] : '';
  165. if( !empty($keywords) )
  166. {
  167. $where .= " and g.goodsname like '%{$keywords}%' ";
  168. }
  169. //出售中 1
  170. //已下架 0
  171. //待审核 4
  172. //库存警告 8
  173. $sql = " select g.id,g.goodsname,g.total,gc.big_img,g.hasoption from ".C('DB_PREFIX')."lionfish_comshop_goods as g left join ".C('DB_PREFIX')."lionfish_comshop_good_common as gc
  174. on g.id = gc.goods_id where gc.supply_id = ".$supply_info['id']." {$where} order by g.id desc limit {$offset},{$per_page} ";
  175. $goods_list = M()->query( $sql );
  176. if( empty($goods_list) )
  177. {
  178. echo json_encode( array('code' =>0 , 'data' => array()) );
  179. die();
  180. }
  181. foreach( $goods_list as $key => $val )
  182. {
  183. $price_arr = D('Home/Pingoods')->get_goods_price($val['id'],$member_id);
  184. $price = $price_arr['price'];
  185. if( !empty($val['big_img']) )
  186. {
  187. $val['big_img'] = tomedia($val['big_img']);
  188. }
  189. $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
  190. if( !empty($good_image) )
  191. {
  192. $val['skuImage'] = tomedia($good_image['image']);
  193. }
  194. $val['price'] = $price;
  195. $goods_list[$key] = $val;
  196. }
  197. echo json_encode( array('code' => 0, 'data' =>$goods_list ) );
  198. die();
  199. }else{
  200. echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  201. die();
  202. }
  203. }
  204. }
  205. /**
  206. 供应商商品管理---删除、实际放到回收站去
  207. **/
  208. function delete_supply_goods()
  209. {
  210. //grounding/value/3
  211. $gpc = I('request.');
  212. $token = $gpc['token'];
  213. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  214. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  215. {
  216. echo json_encode( array('code' => 1,'msg' => '未登录') );
  217. die();
  218. }
  219. $member_id = $weprogram_token['member_id'];
  220. if($member_id > 0){
  221. //是否开启供应商平台
  222. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  223. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  224. {
  225. $supply_is_open_mobilemanage = 0;
  226. }
  227. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  228. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  229. {
  230. $goods_id = intval( $gpc['goods_id'] );
  231. $gd_info = M('lionfish_comshop_good_common')->where( array('supply_id' => $supply_info['id'], 'goods_id' => $goods_id ) )->find();
  232. if( !empty($gd_info) )
  233. {
  234. $res = M('lionfish_comshop_goods')->where( array('id' =>$goods_id ) )->save( array('grounding' => 3) );
  235. echo json_encode( array('code' => 0) );
  236. die();
  237. }else{
  238. echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
  239. die();
  240. }
  241. }else{
  242. echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  243. die();
  244. }
  245. }
  246. }
  247. /**
  248. 供应商 修改商品的库存(包含多规格)
  249. **/
  250. function modify_supply_goods_quantity()
  251. {
  252. $gpc = I('request.');
  253. $token = $gpc['token'];
  254. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  255. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  256. {
  257. echo json_encode( array('code' => 1,'msg' => '未登录') );
  258. die();
  259. }
  260. $member_id = $weprogram_token['member_id'];
  261. if($member_id > 0){
  262. //是否开启供应商平台
  263. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  264. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  265. {
  266. $supply_is_open_mobilemanage = 0;
  267. }
  268. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  269. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  270. {
  271. $goods_id = intval( $gpc['goods_id'] );
  272. $sku_list_str = $gpc['sku_list_str'];
  273. $is_has_option = $gpc['is_has_option'];
  274. $quantity = isset($gpc['quantity']) ? $gpc['quantity'] : 0;
  275. if( !isset($is_has_option) || empty($is_has_option) )
  276. {
  277. $is_has_option = 0;//无修改规格的库存
  278. }
  279. $gd_info = M('lionfish_comshop_good_common')->where( array('supply_id' => $supply_info['id'], 'goods_id' => $goods_id ) )->find();
  280. if( !empty($gd_info) )
  281. {
  282. $supply_edit_goods_shenhe = D('Home/Front')->get_config_by_name('supply_edit_goods_shenhe');
  283. if( !isset($supply_edit_goods_shenhe) || $supply_edit_goods_shenhe == 0 )
  284. {
  285. $supply_edit_goods_shenhe = 0;
  286. }
  287. //$total
  288. if( $is_has_option == 1 )
  289. {
  290. //sku_list_str skuid_stock,skuid_stock,skuid_stock
  291. $sku_list_arr = explode(',',$sku_list_str);
  292. if( empty($sku_list_arr) )
  293. {
  294. echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
  295. die();
  296. }
  297. M()->startTrans();
  298. $total = 0;
  299. $flag = 1;
  300. foreach($sku_list_arr as $val)
  301. {
  302. $sku_arr = explode('_', $val);
  303. $sku_id = $sku_arr[0];
  304. $sku_quantity = $sku_arr[1] >=0 ? $sku_arr[1] : 0;
  305. $sku_info = M('lionfish_comshop_goods_option_item_value')->where( array('id' => $sku_id, 'goods_id' => $goods_id) )->find();
  306. if( empty($sku_info) )
  307. {
  308. $flag = 0;
  309. break;
  310. }
  311. M('lionfish_comshop_goods_option_item_value')->where( array('id' => $sku_id, 'goods_id' => $goods_id) )->save( array('stock' =>$sku_quantity ) );
  312. $total += $sku_quantity;
  313. }
  314. if($flag == 1)
  315. {
  316. M()->commit();
  317. $up_goods_data = array();
  318. $up_goods_data['total'] = $total;
  319. if($supply_edit_goods_shenhe == 1)
  320. {
  321. $up_goods_data['grounding'] = 4;
  322. }
  323. M('lionfish_comshop_goods')->where( array('id' => $goods_id) )->save( $up_goods_data );
  324. }else if($flag == 0){
  325. M()->rollback();
  326. }
  327. }else{
  328. $up_goods_data = array();
  329. $up_goods_data['total'] = $quantity;
  330. if($supply_edit_goods_shenhe == 1)
  331. {
  332. $up_goods_data['grounding'] = 4;
  333. }
  334. M('lionfish_comshop_goods')->where( array('id' => $goods_id) )->save( $up_goods_data );
  335. }
  336. D('Seller/Redisorder')->sysnc_goods_total($goods_id);
  337. echo json_encode( array('code' => 0 ) );
  338. die();
  339. }else{
  340. echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
  341. die();
  342. }
  343. }else{
  344. echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  345. die();
  346. }
  347. }
  348. }
  349. /**
  350. 供应商 获取商品规格
  351. **/
  352. function get_supply_goods_sku()
  353. {
  354. $gpc = I('request.');
  355. $token = $gpc['token'];
  356. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  357. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  358. {
  359. echo json_encode( array('code' => 1,'msg' => '未登录') );
  360. die();
  361. }
  362. $member_id = $weprogram_token['member_id'];
  363. if($member_id > 0){
  364. //是否开启供应商平台
  365. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  366. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  367. {
  368. $supply_is_open_mobilemanage = 0;
  369. }
  370. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  371. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  372. {
  373. $goods_id = intval( $gpc['goods_id'] );
  374. $option_item_arr = M('lionfish_comshop_goods_option_item_value')->where( array('goods_id' => $goods_id ) )->order('id asc')->select();
  375. $goods_stock_notice = D('Home/Front')->get_config_by_name('goods_stock_notice');
  376. if( empty($goods_stock_notice) )
  377. {
  378. $goods_stock_notice = 0;
  379. }
  380. if( !empty($option_item_arr) )
  381. {
  382. $need_data = array();
  383. foreach( $option_item_arr as $val )
  384. {
  385. $tmp_arr = array();
  386. $tmp_arr['id'] = $val['id'];
  387. $tmp_arr['goods_id'] = $val['goods_id'];
  388. $tmp_arr['stock'] = $val['stock'];
  389. $tmp_arr['title'] = $val['title'];
  390. $need_data[] = $tmp_arr;
  391. }
  392. echo json_encode( array('code' => 0, 'need_data' => $need_data, 'goods_stock_notice' => $goods_stock_notice ) );
  393. die();
  394. }else{
  395. echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
  396. die();
  397. }
  398. }else{
  399. echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  400. die();
  401. }
  402. }
  403. }
  404. /**
  405. 供应商商品管理---下架
  406. **/
  407. function down_supply_goods()
  408. {
  409. //grounding/value/3
  410. $gpc = I('request.');
  411. $token = $gpc['token'];
  412. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  413. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  414. {
  415. echo json_encode( array('code' => 1,'msg' => '未登录') );
  416. die();
  417. }
  418. $member_id = $weprogram_token['member_id'];
  419. if($member_id > 0){
  420. //是否开启供应商平台
  421. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  422. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  423. {
  424. $supply_is_open_mobilemanage = 0;
  425. }
  426. $supply_can_goods_updown = D('Home/Front')->get_config_by_name('supply_can_goods_updown');
  427. if( !isset($supply_can_goods_updown) || $supply_can_goods_updown == 2 )
  428. {
  429. echo json_encode( array('code' => 2, 'msg'=>'供应商暂无权限下架商品') );
  430. die();
  431. }
  432. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  433. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  434. {
  435. $goods_id = intval( $gpc['goods_id'] );
  436. $gd_info = M('lionfish_comshop_good_common')->where( array('supply_id' => $supply_info['id'], 'goods_id' => $goods_id ) )->find();
  437. if( !empty($gd_info) )
  438. {
  439. $res = M('lionfish_comshop_goods')->where( array('id' =>$goods_id ) )->save( array('grounding' => 0 ) );
  440. echo json_encode( array('code' => 0) );
  441. die();
  442. }else{
  443. echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
  444. die();
  445. }
  446. }else{
  447. echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  448. die();
  449. }
  450. }
  451. }
  452. /**
  453. 供应商 团长订单确认配送
  454. **/
  455. public function supply_do_opsend_tuanz()
  456. {
  457. $gpc = I('request.');
  458. $token = $gpc['token'];
  459. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  460. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  461. {
  462. echo json_encode( array('code' => 1,'msg' => '未登录') );
  463. die();
  464. }
  465. $order_id = isset($gpc['order_id']) ? intval($gpc['order_id']) : 0;
  466. if( $order_id <= 0 )
  467. {
  468. echo json_encode( array('code' => 2,'msg' => '非法订单号') );
  469. die();
  470. }
  471. $member_id = $weprogram_token['member_id'];
  472. if($member_id > 0){
  473. //是否开启供应商平台
  474. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  475. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  476. {
  477. $supply_is_open_mobilemanage = 0;
  478. }
  479. $supply_can_confirm_delivery = D('Home/Front')->get_config_by_name('supply_can_confirm_delivery');
  480. if( !isset($supply_can_confirm_delivery) || $supply_can_confirm_delivery == 2 )
  481. {
  482. echo json_encode( array('code' => 2, 'msg'=>'供应商暂无权限确认配送(确认送达团长)') );
  483. die();
  484. }
  485. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  486. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  487. {
  488. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  489. if( empty($order_info) )
  490. {
  491. echo json_encode( array('code' => 2,'msg' => '非法订单号') );
  492. die();
  493. }
  494. //
  495. //order_status_id == 1 delivery opsend_tuanz_over
  496. if( $order_info['order_status_id'] == 1 && in_array( $order_info['delivery'], array('pickup', 'tuanz_send') ) )
  497. {
  498. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'supply_id' => $supply_info['id'] ) )->find();
  499. if( empty($order_goods) )
  500. {
  501. echo json_encode( array('code' => 2,'msg' => '无此订单操作权限') );
  502. die();
  503. }
  504. D('Seller/Order')->do_send_tuanz($order_id,'供应商小程序端发货');
  505. $order_num_alias = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  506. D('Seller/Operatelog')->addOperateLog('detailed_list','供应商小程序端发货--订单编号'.$order_num_alias['order_num_alias']);
  507. //后台自动送达团长
  508. D('Seller/Order')->order_auto_service($order_info,'后台自动确认送达团长');
  509. echo json_encode( array('code' => 0, 'msg' => '发货成功') );
  510. die();
  511. }else{
  512. echo json_encode( array('code' => 2,'msg' => '订单状态不可发货') );
  513. die();
  514. }
  515. }else{
  516. echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  517. die();
  518. }
  519. }
  520. }
  521. /**
  522. 供应商 团长订单确认送达团长
  523. **/
  524. public function supply_do_tuanz_over()
  525. {
  526. $gpc = I('request.');
  527. $token = $gpc['token'];
  528. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  529. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  530. {
  531. echo json_encode( array('code' => 1,'msg' => '未登录') );
  532. die();
  533. }
  534. $order_id = isset($gpc['order_id']) ? intval($gpc['order_id']) : 0;
  535. if( $order_id <= 0 )
  536. {
  537. echo json_encode( array('code' => 2,'msg' => '非法订单号') );
  538. die();
  539. }
  540. $member_id = $weprogram_token['member_id'];
  541. if($member_id > 0){
  542. //是否开启供应商平台
  543. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  544. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  545. {
  546. $supply_is_open_mobilemanage = 0;
  547. }
  548. $supply_can_confirm_delivery = D('Home/Front')->get_config_by_name('supply_can_confirm_delivery');
  549. if( !isset($supply_can_confirm_delivery) || $supply_can_confirm_delivery == 2 )
  550. {
  551. echo json_encode( array('code' => 2, 'msg'=>'供应商暂无权限确认配送(确认送达团长)') );
  552. die();
  553. }
  554. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  555. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  556. {
  557. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  558. if( empty($order_info) )
  559. {
  560. echo json_encode( array('code' => 2,'msg' => '非法订单号') );
  561. die();
  562. }
  563. //
  564. //order_status_id == 1 delivery opsend_tuanz_over
  565. if( $order_info['order_status_id'] == 14 && in_array( $order_info['delivery'], array('pickup', 'tuanz_send') ) )
  566. {
  567. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'supply_id' => $supply_info['id'] ) )->find();
  568. if( empty($order_goods) )
  569. {
  570. echo json_encode( array('code' => 2,'msg' => '无此订单操作权限') );
  571. die();
  572. }
  573. D('Seller/Order')->do_tuanz_over($order_id, '供应商小程序端,确认送达团长');
  574. D('Home/Frontorder')->send_order_operate($order_id);
  575. echo json_encode( array('code' => 0, 'msg' => '送达团长成功') );
  576. die();
  577. }else{
  578. echo json_encode( array('code' => 2,'msg' => '订单状态不可发货') );
  579. die();
  580. }
  581. }else{
  582. echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  583. die();
  584. }
  585. }
  586. }
  587. /**
  588. 供应商 团长订单确认收货
  589. **/
  590. public function supply_do_opreceive()
  591. {
  592. $gpc = I('request.');
  593. $token = $gpc['token'];
  594. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  595. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  596. {
  597. echo json_encode( array('code' => 1,'msg' => '未登录') );
  598. die();
  599. }
  600. $order_id = isset($gpc['order_id']) ? intval($gpc['order_id']) : 0;
  601. if( $order_id <= 0 )
  602. {
  603. echo json_encode( array('code' => 2,'msg' => '非法订单号') );
  604. die();
  605. }
  606. $member_id = $weprogram_token['member_id'];
  607. if($member_id > 0){
  608. //是否开启供应商平台
  609. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  610. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  611. {
  612. $supply_is_open_mobilemanage = 0;
  613. }
  614. $supply_can_confirm_receipt = D('Home/Front')->get_config_by_name('supply_can_confirm_receipt');
  615. if( !isset($supply_can_confirm_receipt) || $supply_can_confirm_receipt == 2 )
  616. {
  617. echo json_encode( array('code' => 2, 'msg'=>'供应商暂无权限确认收货(已发货待收货)') );
  618. die();
  619. }
  620. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  621. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  622. {
  623. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  624. if( empty($order_info) )
  625. {
  626. echo json_encode( array('code' => 2,'msg' => '非法订单号') );
  627. die();
  628. }
  629. //
  630. //order_status_id == 1 delivery opsend_tuanz_over
  631. if( $order_info['order_status_id'] == 4 )
  632. {
  633. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'supply_id' => $supply_info['id'] ) )->find();
  634. if( empty($order_goods) )
  635. {
  636. echo json_encode( array('code' => 2,'msg' => '无此订单操作权限') );
  637. die();
  638. }
  639. D('Seller/Order')->receive_order($order_id);
  640. M('lionfish_comshop_order_history')->where( array('order_id' => $order_id ,'order_status_id' => 6) )->save( array( 'comment' => '供应商小程序端,确认收货') );
  641. echo json_encode( array('code' => 0, 'msg' => '确认收货成功') );
  642. die();
  643. }else{
  644. echo json_encode( array('code' => 2,'msg' => '订单状态不可发货') );
  645. die();
  646. }
  647. }else{
  648. echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  649. die();
  650. }
  651. }
  652. }
  653. /**
  654. 供应商 商品上下架
  655. **/
  656. function up_supply_goods()
  657. {
  658. //grounding/value/3
  659. $gpc = I('request.');
  660. $token = $gpc['token'];
  661. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  662. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  663. {
  664. echo json_encode( array('code' => 1,'msg' => '未登录') );
  665. die();
  666. }
  667. $member_id = $weprogram_token['member_id'];
  668. if($member_id > 0){
  669. //是否开启供应商平台
  670. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  671. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  672. {
  673. $supply_is_open_mobilemanage = 0;
  674. }
  675. $supply_can_goods_updown = D('Home/Front')->get_config_by_name('supply_can_goods_updown');
  676. if( !isset($supply_can_goods_updown) || $supply_can_goods_updown == 2)
  677. {
  678. echo json_encode( array('code' => 2, 'msg'=>'供应商暂无权限上架商品') );
  679. die();
  680. }
  681. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  682. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  683. {
  684. $goods_id = intval( $gpc['goods_id'] );
  685. $supply_add_goods_shenhe = D('Home/Front')->get_config_by_name('supply_add_goods_shenhe');
  686. if($supply_add_goods_shenhe == 1 )
  687. {
  688. M('lionfish_comshop_goods')->where( array('id' => $goods_id) )->save( array('grounding' => 4) );
  689. echo json_encode( array('code' => 2, 'msg'=>'供应商上架商品需等待审核') );
  690. die();
  691. }
  692. $gd_info = M('lionfish_comshop_good_common')->where( array('supply_id' => $supply_info['id'], 'goods_id' => $goods_id ) )->find();
  693. if( !empty($gd_info) )
  694. {
  695. $res = M('lionfish_comshop_goods')->where( array('id' =>$goods_id ) )->save( array('grounding' => 1 ) );
  696. echo json_encode( array('code' => 0) );
  697. die();
  698. }else{
  699. echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
  700. die();
  701. }
  702. }else{
  703. echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  704. die();
  705. }
  706. }
  707. }
  708. /**
  709. 供应商 快递订单点击确认发货,获取物流公司 以便填写单号
  710. **/
  711. public function get_express_list()
  712. {
  713. $gpc = I('request.');
  714. $token = $gpc['token'];
  715. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  716. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  717. {
  718. echo json_encode( array('code' => 1,'msg' => '未登录') );
  719. die();
  720. }
  721. $member_id = $weprogram_token['member_id'];
  722. if($member_id > 0){
  723. //是否开启供应商平台
  724. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  725. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  726. {
  727. $supply_is_open_mobilemanage = 0;
  728. }
  729. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  730. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  731. {
  732. $order_id = $gpc['order_id'];
  733. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  734. if( empty($order_info) )
  735. {
  736. echo json_encode( array('code' => 2,'msg' => '非法订单号') );
  737. die();
  738. }
  739. //
  740. //order_status_id == 1 delivery opsend_tuanz_over
  741. if( $order_info['order_status_id'] == 1 && in_array( $order_info['delivery'], array('express') ) )
  742. {
  743. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'supply_id' => $supply_info['id'] ) )->find();
  744. if( empty($order_goods) )
  745. {
  746. echo json_encode( array('code' => 2,'msg' => '无此订单操作权限') );
  747. die();
  748. }
  749. $province_info = D('Home/Front')->get_area_info($item['shipping_province_id']);
  750. $city_info = D('Home/Front')->get_area_info($item['shipping_city_id']);
  751. $area_info = D('Home/Front')->get_area_info($item['shipping_country_id']);
  752. $express_list = D('Seller/Express')->load_all_express();
  753. $data = array();
  754. $data['shipping_name'] = $order_info['shipping_name'];
  755. $data['shipping_tel'] = $order_info['shipping_tel'];
  756. $data['address'] = $province_info['name'].$city_info['name'].$area_info['name'].$item['shipping_address'];
  757. $data['express_list'] = $express_list;
  758. echo json_encode( array('code' => 0, 'data' => $data ) );
  759. die();
  760. }else{
  761. echo json_encode( array('code' => 2,'msg' => '订单状态不可发货') );
  762. die();
  763. }
  764. }else{
  765. echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  766. die();
  767. }
  768. }
  769. }
  770. /**
  771. 供应商 快递订单 确认发货
  772. **/
  773. public function do_send_order_express()
  774. {
  775. $gpc = I('request.');
  776. $token = $gpc['token'];
  777. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  778. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  779. {
  780. echo json_encode( array('code' => 1,'msg' => '未登录') );
  781. die();
  782. }
  783. $member_id = $weprogram_token['member_id'];
  784. if($member_id > 0){
  785. //是否开启供应商平台
  786. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  787. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  788. {
  789. $supply_is_open_mobilemanage = 0;
  790. }
  791. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  792. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  793. {
  794. $order_id = $gpc['order_id'];
  795. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  796. if( empty($order_info) )
  797. {
  798. echo json_encode( array('code' => 2,'msg' => '非法订单号') );
  799. die();
  800. }
  801. $express_id = $gpc['express_id']; //快递公司id
  802. $shipping_no = $gpc['shipping_no']; //快递单号
  803. if( empty($express_id) )
  804. {
  805. echo json_encode( array('code' => 2, 'msg' => '请选择快递公司') );
  806. die();
  807. }
  808. if( empty($shipping_no) )
  809. {
  810. echo json_encode( array('code' => 2, 'msg' => '请填写快递编号') );
  811. die();
  812. }
  813. if( $order_info['order_status_id'] == 1 && in_array( $order_info['delivery'], array('express') ) )
  814. {
  815. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'supply_id' => $supply_info['id'] ) )->find();
  816. if( empty($order_goods) )
  817. {
  818. echo json_encode( array('code' => 2,'msg' => '无此订单操作权限') );
  819. die();
  820. }
  821. $express_info = D('Seller/Express')->get_express_info($express_id);
  822. $time = time();
  823. $data = array(
  824. 'shipping_method' => trim($express_id),
  825. 'shipping_no' => trim($shipping_no),
  826. 'dispatchname' => $express_info['name'],
  827. 'express_time' => $time
  828. );
  829. $data['order_status_id'] = 4;
  830. M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->save( $data );
  831. $history_data = array();
  832. $history_data['order_id'] = $order_info['order_id'];
  833. $history_data['order_status_id'] = 4;
  834. $history_data['notify'] = 0;
  835. $history_data['comment'] = '供应商前台:订单发货 ID: ' . $order_id . ' 订单号: ' . $order_info['order_num_alias'] . ' <br/>快递公司: ' . $express_info['name'] . ' 快递单号: ' . $shipping_no;
  836. $history_data['date_added'] = time();
  837. M('lionfish_comshop_order_history')->add($history_data);
  838. D('Home/Frontorder')->send_order_operate($order_id);
  839. echo json_encode( array('code' => 0, 'data' => $data ) );
  840. die();
  841. }else{
  842. echo json_encode( array('code' => 2,'msg' => '订单状态不可发货') );
  843. die();
  844. }
  845. }else{
  846. echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  847. die();
  848. }
  849. }
  850. }
  851. /**
  852. 供应商 资金管理 页面
  853. **/
  854. public function supply_managemoney_panel()
  855. {
  856. $gpc = I('request.');
  857. $token = $gpc['token'];
  858. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  859. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  860. {
  861. echo json_encode( array('code' => 1,'msg' => '未登录') );
  862. die();
  863. }
  864. $member_id = $weprogram_token['member_id'];
  865. if($member_id > 0){
  866. //是否开启供应商平台
  867. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  868. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  869. {
  870. $supply_is_open_mobilemanage = 0;
  871. }
  872. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  873. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  874. {
  875. //$supply_info['id']
  876. $supply_id = $supply_info['id'];
  877. $supply_min_apply_money = D('Home/Front')->get_config_by_name('supply_min_money');
  878. if( empty($supply_min_apply_money) )
  879. {
  880. $supply_min_apply_money = 0;
  881. }
  882. $supply_commiss = M('lionfish_supply_commiss')->where( array('supply_id' => $supply_id ) )->find();
  883. $last_tixian_order = array('bankname' =>'微信','bankaccount' => '','bankusername' => '' ,'supply_apply_type' => -1 );
  884. $lionfish_supply_tixian_order = M('lionfish_supply_tixian_order')->where( array('supply_id' => $supply_id ) )->order('id desc')->find();
  885. if( !empty($lionfish_supply_tixian_order) )
  886. {
  887. $last_tixian_order['bankname'] = $lionfish_supply_tixian_order['bankname'];
  888. $last_tixian_order['bankaccount'] = $lionfish_supply_tixian_order['bankaccount'];
  889. $last_tixian_order['bankusername'] = $lionfish_supply_tixian_order['bankusername'];
  890. $last_tixian_order['supply_apply_type'] = $lionfish_supply_tixian_order['supply_apply_type'];
  891. }
  892. $supply_commiss_tixianway_weixin = D('Home/Front')->get_config_by_name('supply_commiss_tixianway_weixin');
  893. $supply_commiss_tixianway_alipay = D('Home/Front')->get_config_by_name('supply_commiss_tixianway_alipay');
  894. $supply_commiss_tixianway_bank = D('Home/Front')->get_config_by_name('supply_commiss_tixianway_bank');
  895. $supply_commiss_tixianway_weixin_offline = D('Home/Front')->get_config_by_name('supply_commiss_tixianway_weixin_offline');
  896. if( isset($supply_commiss_tixianway_weixin) && $supply_commiss_tixianway_weixin == 1 )
  897. {
  898. $supply_commiss_tixianway_weixin = 0;
  899. }else{
  900. $supply_commiss_tixianway_weixin = 1;
  901. }
  902. if( isset($supply_commiss_tixianway_alipay) && $supply_commiss_tixianway_alipay == 1 )
  903. {
  904. $supply_commiss_tixianway_alipay = 0;
  905. }else{
  906. $supply_commiss_tixianway_alipay = 1;
  907. }
  908. if( isset($supply_commiss_tixianway_bank) && $supply_commiss_tixianway_bank == 1 )
  909. {
  910. $supply_commiss_tixianway_bank = 0;
  911. }else{
  912. $supply_commiss_tixianway_bank = 1;
  913. }
  914. if( isset($supply_commiss_tixianway_weixin_offline) && $supply_commiss_tixianway_weixin_offline == 1 )
  915. {
  916. $supply_commiss_tixianway_weixin_offline = 0;
  917. }else{
  918. $supply_commiss_tixianway_weixin_offline = 1;
  919. }
  920. $tixian_waylist = array();
  921. $tixian_waylist[1] = array( 'name' => '微信零钱', 'is_show' => 0, 'is_default_check' => 0 );
  922. $tixian_waylist[2] = array( 'name' => '支付宝', 'is_show' => 0, 'is_default_check' => 0 );
  923. $tixian_waylist[3] = array( 'name' => '银行卡', 'is_show' => 0, 'is_default_check' => 0 );
  924. $tixian_waylist[4] = array( 'name' => '微信私下转', 'is_show' => 0, 'is_default_check' => 0 );
  925. if( $supply_commiss_tixianway_weixin == 1 )
  926. {
  927. $tixian_waylist[1]['is_show'] = 1;
  928. if( $last_tixian_order['bankname'] == '微信' )
  929. {
  930. $tixian_waylist[1]['is_default_check'] = 1;
  931. }
  932. }
  933. if( $supply_commiss_tixianway_alipay == 1 )
  934. {
  935. $tixian_waylist[2]['is_show'] = 1;
  936. if( $last_tixian_order['bankname'] == '支付宝' )
  937. {
  938. $tixian_waylist[2]['is_default_check'] = 1;
  939. }
  940. }
  941. if( $supply_commiss_tixianway_bank == 1 )
  942. {
  943. $tixian_waylist[3]['is_show'] = 1;
  944. if( $last_tixian_order['bankname'] != '微信' && $last_tixian_order['bankname'] != '支付宝' && $last_tixian_order['supply_apply_type'] != 4 )
  945. {
  946. $tixian_waylist[3]['is_default_check'] = 1;
  947. }
  948. }
  949. if( $supply_commiss_tixianway_weixin_offline == 1 )
  950. {
  951. $tixian_waylist[4]['is_show'] = 1;
  952. if( $last_tixian_order['supply_apply_type'] == 4 )
  953. {
  954. $tixian_waylist[4]['is_default_check'] = 1;
  955. }
  956. }
  957. // bankaccount
  958. // $last_tixian_order = array('bankname' =>'微信','bankaccount' => '','bankusername' => '' ,'supply_apply_type' => -1 );
  959. //微信真实姓名 last_tixian_order 中的:bankaccount
  960. //支付宝账号 last_tixian_order 中的:bankaccount
  961. //银行卡里面的 信息: 银行名称 bankname , 银行卡账户 bankaccount , 持卡人姓名 bankusername
  962. //微信私下转 的微信号: bankaccount
  963. if( empty($supply_commiss) )
  964. {
  965. $supply_commiss = array();
  966. $supply_commiss['money'] = 0;//可提现
  967. $supply_commiss['dongmoney'] = 0; //提现中
  968. $supply_commiss['getmoney'] = 0; //已提现金额
  969. }
  970. $supply_tixian_free = D('Home/Front')->get_config_by_name('supply_tixian_moneyfree');
  971. if( !isset($supply_tixian_free) || $supply_tixian_free <= 0 )
  972. {
  973. $supply_tixian_free = 0;
  974. }
  975. $supply_tixian_notice = D('Home/Front')->get_config_by_name('supply_tixian_notice');
  976. if( empty($supply_tixian_notice) )
  977. {
  978. $supply_tixian_notice = '';
  979. }else{
  980. $supply_tixian_notice = htmlspecialchars_decode( htmlspecialchars_decode($supply_tixian_notice) );
  981. }
  982. $member_info = M('lionfish_comshop_member')->field('avatar,username')
  983. ->where( array('member_id' => $member_id) )->find();
  984. $result = array();
  985. $result['supply_min_apply_money'] = $supply_min_apply_money;//最小提现金额
  986. $result['tixian_waylist'] = $tixian_waylist;//可提现的银行类型
  987. $result['supply_commiss'] = $supply_commiss;//供应商账户信息
  988. $result['supply_tixian_free'] = $supply_tixian_free;//提现手续费
  989. $result['supply_tixian_notice'] = $supply_tixian_notice;//提现规则
  990. $result['member_info'] = $member_info;//用户信息
  991. echo json_encode( array('code' => 0, 'data' =>$result ) );
  992. die();
  993. }else{
  994. echo json_encode( array('code' => 2,'msg' => '未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  995. die();
  996. }
  997. }
  998. }
  999. /**
  1000. 供应商 收支记录页面
  1001. **/
  1002. public function supply_applymoney()
  1003. {
  1004. $gpc = I('request.');
  1005. $token = $gpc['token'];
  1006. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1007. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1008. {
  1009. echo json_encode( array('code' => 1,'msg' => '未登录') );
  1010. die();
  1011. }
  1012. $member_id = $weprogram_token['member_id'];
  1013. if($member_id > 0){
  1014. //是否开启供应商平台
  1015. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  1016. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  1017. {
  1018. $supply_is_open_mobilemanage = 0;
  1019. }
  1020. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  1021. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  1022. {
  1023. //$supply_info['id']
  1024. $supply_id = $supply_info['id'];
  1025. $supply_apply_type = $gpc['supply_apply_type'];//提现类型: 1 微信零钱 2 支付宝 3银行卡 4微信线下转账
  1026. $supply_min_apply_money = D('Home/Front')->get_config_by_name('supply_min_money');
  1027. if( empty($supply_min_apply_money) )
  1028. {
  1029. $supply_min_apply_money = 0;
  1030. }
  1031. $account = $gpc['account'];//微信真实姓名 + 支付宝账户 + 银行卡账户 + 微信线下转的微信名称
  1032. if($supply_apply_type == 3){
  1033. $reg = '/^[\d]{16,19}$/ ';
  1034. if(!preg_match($reg,$account,$match)){
  1035. echo json_encode( array('code' => 2, 'msg' => '银行卡账户格式错误') );
  1036. die();
  1037. }
  1038. }
  1039. $card_name = $gpc['card_name']; //银行卡名称
  1040. $card_username = $gpc['card_username']; //持卡人姓名
  1041. $ti_money = floatval( $gpc['ti_money'] ); //提现金额
  1042. $supply_commiss = M('lionfish_supply_commiss')->where( array('supply_id' => $supply_id ) )->find();
  1043. if($ti_money < $supply_min_apply_money){
  1044. echo json_encode( array('code' => 2, 'msg' => '最低提现'.$supply_min_apply_money ) );
  1045. die();
  1046. }
  1047. if($ti_money <=0){
  1048. echo json_encode( array('code' => 2, 'msg' => '最低提现大于0元' ) );
  1049. die();
  1050. }
  1051. if($ti_money > $supply_commiss['money']){
  1052. echo json_encode( array('code' => 2, 'msg' => '当前最多提现'.$supply_commiss['money'] ) );
  1053. die();
  1054. }
  1055. $supply_tixian_free = D('Home/Front')->get_config_by_name('supply_tixian_moneyfree');
  1056. if( !isset($supply_tixian_free) || $supply_tixian_free <= 0 )
  1057. {
  1058. $supply_tixian_free = 0;
  1059. }
  1060. $ins_data = array();
  1061. $ins_data['supply_id'] = $supply_id;
  1062. $ins_data['money'] = $ti_money;
  1063. $ins_data['service_charge'] = round( ($supply_tixian_free * $ti_money) / 100 ,2);
  1064. $ins_data['server_bili'] = $supply_tixian_free;
  1065. $ins_data['state'] = 0;
  1066. $ins_data['shentime'] = 0;
  1067. $ins_data['is_send_fail'] = 0;
  1068. $ins_data['fail_msg'] = '';
  1069. $ins_data['supply_apply_type'] = $supply_apply_type;
  1070. //1 微信 2 支付宝 3银行卡
  1071. if($supply_apply_type == 1)
  1072. {
  1073. $ins_data['bankname'] = '微信零钱';
  1074. $ins_data['bankaccount'] = $account;
  1075. $ins_data['bankusername'] = '';
  1076. }else if($supply_apply_type == 2){
  1077. $ins_data['bankname'] = '支付宝';
  1078. $ins_data['bankaccount'] = $account;
  1079. $ins_data['bankusername'] = $card_username;
  1080. }else if($supply_apply_type == 3){
  1081. $ins_data['bankname'] = $card_name;
  1082. $ins_data['bankaccount'] = $account;
  1083. $ins_data['bankusername'] = $card_username;
  1084. }else if($supply_apply_type == 4){
  1085. $ins_data['bankname'] = '微信私下转';
  1086. $ins_data['bankaccount'] = $account;
  1087. $ins_data['bankusername'] = '';
  1088. }
  1089. $ins_data['addtime'] = time();
  1090. M('lionfish_supply_tixian_order')->add($ins_data);
  1091. M('lionfish_supply_commiss')->where( array('supply_id' => $supply_id ) )->setInc('money',-$ti_money);
  1092. M('lionfish_supply_commiss')->where( array('supply_id' => $supply_id ) )->setInc('dongmoney',$ti_money);
  1093. echo json_encode( array('code' => 0, 'msg' =>'提交成功,等待审核' ) );
  1094. die();
  1095. }else{
  1096. echo json_encode( array('code' => 2,'msg' => '未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  1097. die();
  1098. }
  1099. }
  1100. }
  1101. /**
  1102. 供应商 提现记录
  1103. **/
  1104. public function supply_apply_flowlist()
  1105. {
  1106. $gpc = I('request.');
  1107. $token = $gpc['token'];
  1108. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1109. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1110. {
  1111. echo json_encode( array('code' => 1,'msg' => '未登录') );
  1112. die();
  1113. }
  1114. $member_id = $weprogram_token['member_id'];
  1115. if($member_id > 0){
  1116. //是否开启供应商平台
  1117. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  1118. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  1119. {
  1120. $supply_is_open_mobilemanage = 0;
  1121. }
  1122. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  1123. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  1124. {
  1125. //$supply_info['id']
  1126. $supply_id = $supply_info['id'];
  1127. $page = isset($gpc['page']) ? intval($gpc['page']) : 1;
  1128. if( $page <= 0 )
  1129. {
  1130. $page = 1;
  1131. }
  1132. $perpage = 20;
  1133. $offset = ($page - 1) * $perpage;
  1134. $list = M('lionfish_supply_tixian_order')->where( array('supply_id' => $supply_id ) )->order('id desc ')->limit($offset, $perpage)->select();
  1135. $data = array();
  1136. if( !empty($list) )
  1137. {
  1138. foreach( $list as $val )
  1139. {
  1140. $tmp = array();
  1141. if( $val['state'] == 0 )
  1142. {
  1143. $tmp['state_str'] = '提现中';
  1144. }else if( $val['state'] == 1 )
  1145. {
  1146. $tmp['state_str'] = '提现成功';
  1147. }else if( $val['state'] == 2 )
  1148. {
  1149. $tmp['state_str'] = '拒绝提现';
  1150. }
  1151. $tmp['money'] = $val['money'];
  1152. $tmp['addtime'] = date('Y-m-d H:i:s', $val['addtime'] );
  1153. $data[] = $tmp;
  1154. }
  1155. }
  1156. echo json_encode( array('code' => 0, 'data' => $data ) );
  1157. die();
  1158. }else{
  1159. echo json_encode( array('code' => 2,'msg' => '未开启供应商手机端或未授权供应商手机端或供应商未审核') );
  1160. die();
  1161. }
  1162. }
  1163. }
  1164. }