SupplymobileController.class.php 48 KB

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