123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614 |
- <?php
- /**
- * lionfish 商城系统
- *
- * ==========================================================================
- * @link http://www.liofis.com/
- * @copyright Copyright (c) 2015 liofis.com.
- * @license http://www.liofis.com/license.html License
- * ==========================================================================
- *
- * @author fish
- *
- */
- namespace Home\Controller;
- class SupplymobileController extends CommonController {
-
-
- /**
- @title 供应商手机端主页接口
- @param token
- **/
-
- public function supplyindex_info()
- {
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $result = array();
- $result['supply_info'] = array(
- 'shopname' => $supply_info['shopname'],
- 'logo' => tomedia( $supply_info['logo'] )
- );
-
- $goods_stock_notice = D('Home/Front')->get_config_by_name('goods_stock_notice');
-
- $notice_gods_count = 0;
-
- if( !empty($goods_stock_notice) && $goods_stock_notice > 0 )
- {
- //库存警告商品数量
- //supply_id
-
- $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
- on g.id = gc.goods_id where gc.supply_id = ".$supply_info['id']." and g.total < {$goods_stock_notice} ";
-
-
- $sp_notice_count_arr = M()->query( $sql );
-
- $notice_gods_count = $sp_notice_count_arr[0]['count'];
- }
-
- //待发货订单数量
- $wait_send_count = 0;
- //售后订单
- $wait_refund_count = 0;
- //今日订单
- $today_order_count = 0;
- //昨日订单数量
- $yestday_order_count = 0;
- //总订单数量
- $total_order_count = 0;
-
- //待结算金额
- $wait_statement_money = 0;
- //已结算金额
- $has_statement_money = 0;
- //已提现金额
- $has_get_money = 0;
-
- $wait_statement_money = M('lionfish_supply_commiss_order')->where( array('supply_id' => $supply_info['id'], 'state' => 0 ) )->sum('money');
- $has_statement_money = M('lionfish_supply_commiss_order')->where( array('supply_id' => $supply_info['id'], 'state' => 1 ) )->sum('money');
-
- if( empty($wait_statement_money) )
- {
- $wait_statement_money = 0;
- }
- if( empty($has_statement_money) )
- {
- $has_statement_money = 0;
- }
-
- //oscshop_
- $lionfish_supply_commiss = M('lionfish_supply_commiss')->where( array('supply_id' => $supply_info['id'] ) )->find();
-
- if( !empty($lionfish_supply_commiss) )
- {
- $has_get_money = $lionfish_supply_commiss['getmoney'];
- }
-
- $order_ids_list_tmp = M('lionfish_comshop_order_goods')->field('order_id')->where( array('supply_id' => $supply_info['id'] ) )->select();
-
- if( !empty($order_ids_list_tmp) )
- {
- $order_ids_tmp_arr = array();
- foreach($order_ids_list_tmp as $vv)
- {
- if( empty($order_ids_tmp_arr) || !in_array( $vv['order_id'], $order_ids_tmp_arr ) )
- {
- $order_ids_tmp_arr[] = $vv['order_id'];
- }
- }
- $order_ids_tmp_str = implode(',', $order_ids_tmp_arr);
-
- $wait_send_count = M('lionfish_comshop_order')->where(' order_status_id=1 and '." order_id in({$order_ids_tmp_str}) ")->count();
- $wait_refund_count = M('lionfish_comshop_order')->where(' order_status_id=12 and '." order_id in({$order_ids_tmp_str}) ")->count();
- //今日订单
- $today_time = strtotime( date('Y-m-d '.'00:00:00') );
-
- $yesday_time = $today_time - 86400;
-
- $today_order_count = M('lionfish_comshop_order')->where(' date_added >='.$today_time.' and '." order_id in({$order_ids_tmp_str}) ")->count();
-
- $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();
-
- $total_order_count = count($order_ids_tmp_arr);
- }
-
-
- $result['wait_send_count'] = $wait_send_count;//待发货订单数量
- $result['wait_refund_count'] = $wait_refund_count;//售后订单数量
- $result['today_order_count'] = $today_order_count;//今日订单数量
- $result['yestday_order_count'] = $yestday_order_count;//昨日订单数量
- $result['total_order_count'] = $total_order_count;//总订单数量
- $result['wait_statement_money'] = $wait_statement_money;//待结算金额
- $result['has_statement_money'] = $has_statement_money;//已结算金额
- $result['has_get_money'] = $has_get_money;//已提现金额
-
- echo json_encode( array('code' => 0, 'data' =>$result ) );
- die();
-
- }else{
- echo json_encode( array('code' => 2,'msg' => '未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
- /**
- 供应商商品管理
- **/
-
- public function get_supply_goodslist()
- {
-
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $result = array();
-
- $goods_stock_notice = D('Home/Front')->get_config_by_name('goods_stock_notice');
-
- $goods_stock_notice = empty($goods_stock_notice) ? 0 : $goods_stock_notice;
-
-
- $page = isset($gpc['page']) && $gpc['page'] >0 ? intval($gpc['page']) : 1;
-
- $per_page = 10;
-
- $offset = ($page - 1) * $per_page;
-
- $where = "";
-
- $grounding = isset($gpc['grounding']) ? $gpc['grounding'] : 1;
-
- if( $grounding != 8 )
- {
- $where .= " and g.grounding = {$grounding} ";
- }else if( $grounding == 8 ){
- $where .= " and g.grounding = 1 and g.total<= {$goods_stock_notice} ";
- }
-
- $keywords = isset($gpc['keywords']) ? $gpc['keywords'] : '';
-
- if( !empty($keywords) )
- {
- $where .= " and g.goodsname like '%{$keywords}%' ";
- }
-
- //出售中 1
- //已下架 0
- //待审核 4
- //库存警告 8
-
- $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
- on g.id = gc.goods_id where gc.supply_id = ".$supply_info['id']." {$where} order by g.id desc limit {$offset},{$per_page} ";
-
-
- $goods_list = M()->query( $sql );
-
-
- if( empty($goods_list) )
- {
- echo json_encode( array('code' =>0 , 'data' => array()) );
- die();
- }
-
- foreach( $goods_list as $key => $val )
- {
- $price_arr = D('Home/Pingoods')->get_goods_price($val['id'],$member_id);
- $price = $price_arr['price'];
-
- if( !empty($val['big_img']) )
- {
- $val['big_img'] = tomedia($val['big_img']);
- }
- $good_image = D('Home/Pingoods')->get_goods_images($val['id']);
- if( !empty($good_image) )
- {
- $val['skuImage'] = tomedia($good_image['image']);
- }
-
- $val['price'] = $price;
-
- $goods_list[$key] = $val;
- }
-
-
-
-
- echo json_encode( array('code' => 0, 'data' =>$goods_list ) );
- die();
-
- }else{
- echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
- /**
- 供应商商品管理---删除、实际放到回收站去
- **/
- function delete_supply_goods()
- {
- //grounding/value/3
-
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $goods_id = intval( $gpc['goods_id'] );
-
- $gd_info = M('lionfish_comshop_good_common')->where( array('supply_id' => $supply_info['id'], 'goods_id' => $goods_id ) )->find();
-
- if( !empty($gd_info) )
- {
- $res = M('lionfish_comshop_goods')->where( array('id' =>$goods_id ) )->save( array('grounding' => 3) );
-
- echo json_encode( array('code' => 0) );
- die();
- }else{
- echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
- /**
- 供应商 修改商品的库存(包含多规格)
- **/
-
- function modify_supply_goods_quantity()
- {
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $goods_id = intval( $gpc['goods_id'] );
- $sku_list_str = $gpc['sku_list_str'];
- $is_has_option = $gpc['is_has_option'];
- $quantity = isset($gpc['quantity']) ? $gpc['quantity'] : 0;
-
- if( !isset($is_has_option) || empty($is_has_option) )
- {
- $is_has_option = 0;//无修改规格的库存
- }
-
- $gd_info = M('lionfish_comshop_good_common')->where( array('supply_id' => $supply_info['id'], 'goods_id' => $goods_id ) )->find();
-
- if( !empty($gd_info) )
- {
- $supply_edit_goods_shenhe = D('Home/Front')->get_config_by_name('supply_edit_goods_shenhe');
- if( !isset($supply_edit_goods_shenhe) || $supply_edit_goods_shenhe == 0 )
- {
- $supply_edit_goods_shenhe = 0;
- }
-
- //$total
- if( $is_has_option == 1 )
- {
- //sku_list_str skuid_stock,skuid_stock,skuid_stock
- $sku_list_arr = explode(',',$sku_list_str);
- if( empty($sku_list_arr) )
- {
- echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
- die();
- }
- M()->startTrans();
-
- $total = 0;
- $flag = 1;
-
- foreach($sku_list_arr as $val)
- {
- $sku_arr = explode('_', $val);
-
- $sku_id = $sku_arr[0];
- $sku_quantity = $sku_arr[1] >=0 ? $sku_arr[1] : 0;
-
-
- $sku_info = M('lionfish_comshop_goods_option_item_value')->where( array('id' => $sku_id, 'goods_id' => $goods_id) )->find();
-
- if( empty($sku_info) )
- {
- $flag = 0;
- break;
- }
-
- M('lionfish_comshop_goods_option_item_value')->where( array('id' => $sku_id, 'goods_id' => $goods_id) )->save( array('stock' =>$sku_quantity ) );
-
- $total += $sku_quantity;
-
- }
-
- if($flag == 1)
- {
- M()->commit();
-
- $up_goods_data = array();
- $up_goods_data['total'] = $total;
- if($supply_edit_goods_shenhe == 1)
- {
- $up_goods_data['grounding'] = 4;
- }
- M('lionfish_comshop_goods')->where( array('id' => $goods_id) )->save( $up_goods_data );
-
- }else if($flag == 0){
- M()->rollback();
- }
-
- }else{
- $up_goods_data = array();
- $up_goods_data['total'] = $quantity;
- if($supply_edit_goods_shenhe == 1)
- {
- $up_goods_data['grounding'] = 4;
- }
- M('lionfish_comshop_goods')->where( array('id' => $goods_id) )->save( $up_goods_data );
- }
-
- D('Seller/Redisorder')->sysnc_goods_total($goods_id);
-
- echo json_encode( array('code' => 0 ) );
- die();
- }else{
- echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
- }
-
-
- /**
- 供应商 获取商品规格
- **/
-
- function get_supply_goods_sku()
- {
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $goods_id = intval( $gpc['goods_id'] );
-
- $option_item_arr = M('lionfish_comshop_goods_option_item_value')->where( array('goods_id' => $goods_id ) )->order('id asc')->select();
-
- $goods_stock_notice = D('Home/Front')->get_config_by_name('goods_stock_notice');
-
- if( empty($goods_stock_notice) )
- {
- $goods_stock_notice = 0;
- }
-
- if( !empty($option_item_arr) )
- {
- $need_data = array();
-
- foreach( $option_item_arr as $val )
- {
- $tmp_arr = array();
- $tmp_arr['id'] = $val['id'];
- $tmp_arr['goods_id'] = $val['goods_id'];
- $tmp_arr['stock'] = $val['stock'];
- $tmp_arr['title'] = $val['title'];
-
- $need_data[] = $tmp_arr;
- }
-
-
- echo json_encode( array('code' => 0, 'need_data' => $need_data, 'goods_stock_notice' => $goods_stock_notice ) );
- die();
- }else{
- echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
- }
-
- /**
- 供应商商品管理---下架
- **/
- function down_supply_goods()
- {
- //grounding/value/3
-
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
-
- $supply_can_goods_updown = D('Home/Front')->get_config_by_name('supply_can_goods_updown');
- if( !isset($supply_can_goods_updown) || $supply_can_goods_updown == 2 )
- {
- echo json_encode( array('code' => 2, 'msg'=>'供应商暂无权限下架商品') );
- die();
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $goods_id = intval( $gpc['goods_id'] );
-
- $gd_info = M('lionfish_comshop_good_common')->where( array('supply_id' => $supply_info['id'], 'goods_id' => $goods_id ) )->find();
-
- if( !empty($gd_info) )
- {
- $res = M('lionfish_comshop_goods')->where( array('id' =>$goods_id ) )->save( array('grounding' => 0 ) );
-
- echo json_encode( array('code' => 0) );
- die();
- }else{
- echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
- /**
- 供应商 团长订单确认配送
- **/
- public function supply_do_opsend_tuanz()
- {
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $order_id = isset($gpc['order_id']) ? intval($gpc['order_id']) : 0;
-
- if( $order_id <= 0 )
- {
- echo json_encode( array('code' => 2,'msg' => '非法订单号') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
- $supply_can_confirm_delivery = D('Home/Front')->get_config_by_name('supply_can_confirm_delivery');
- if( !isset($supply_can_confirm_delivery) || $supply_can_confirm_delivery == 2 )
- {
- echo json_encode( array('code' => 2, 'msg'=>'供应商暂无权限确认配送(确认送达团长)') );
- die();
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
-
- if( empty($order_info) )
- {
- echo json_encode( array('code' => 2,'msg' => '非法订单号') );
- die();
- }
- //
- //order_status_id == 1 delivery opsend_tuanz_over
-
- if( $order_info['order_status_id'] == 1 && in_array( $order_info['delivery'], array('pickup', 'tuanz_send') ) )
- {
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'supply_id' => $supply_info['id'] ) )->find();
-
- if( empty($order_goods) )
- {
- echo json_encode( array('code' => 2,'msg' => '无此订单操作权限') );
- die();
- }
-
- D('Seller/Order')->do_send_tuanz($order_id,'供应商小程序端发货');
- $order_num_alias = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
- D('Seller/Operatelog')->addOperateLog('detailed_list','供应商小程序端发货--订单编号'.$order_num_alias['order_num_alias']);
-
- //后台自动送达团长
- D('Seller/Order')->order_auto_service($order_info,'后台自动确认送达团长');
- echo json_encode( array('code' => 0, 'msg' => '发货成功') );
-
- die();
- }else{
- echo json_encode( array('code' => 2,'msg' => '订单状态不可发货') );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
-
- /**
- 供应商 团长订单确认送达团长
- **/
- public function supply_do_tuanz_over()
- {
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $order_id = isset($gpc['order_id']) ? intval($gpc['order_id']) : 0;
-
- if( $order_id <= 0 )
- {
- echo json_encode( array('code' => 2,'msg' => '非法订单号') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
- $supply_can_confirm_delivery = D('Home/Front')->get_config_by_name('supply_can_confirm_delivery');
- if( !isset($supply_can_confirm_delivery) || $supply_can_confirm_delivery == 2 )
- {
- echo json_encode( array('code' => 2, 'msg'=>'供应商暂无权限确认配送(确认送达团长)') );
- die();
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
-
- if( empty($order_info) )
- {
- echo json_encode( array('code' => 2,'msg' => '非法订单号') );
- die();
- }
- //
- //order_status_id == 1 delivery opsend_tuanz_over
-
- if( $order_info['order_status_id'] == 14 && in_array( $order_info['delivery'], array('pickup', 'tuanz_send') ) )
- {
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'supply_id' => $supply_info['id'] ) )->find();
-
- if( empty($order_goods) )
- {
- echo json_encode( array('code' => 2,'msg' => '无此订单操作权限') );
- die();
- }
-
- D('Seller/Order')->do_tuanz_over($order_id, '供应商小程序端,确认送达团长');
-
- D('Home/Frontorder')->send_order_operate($order_id);
-
- echo json_encode( array('code' => 0, 'msg' => '送达团长成功') );
-
- die();
- }else{
- echo json_encode( array('code' => 2,'msg' => '订单状态不可发货') );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
-
- /**
- 供应商 团长订单确认收货
- **/
- public function supply_do_opreceive()
- {
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $order_id = isset($gpc['order_id']) ? intval($gpc['order_id']) : 0;
-
- if( $order_id <= 0 )
- {
- echo json_encode( array('code' => 2,'msg' => '非法订单号') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
- $supply_can_confirm_receipt = D('Home/Front')->get_config_by_name('supply_can_confirm_receipt');
- if( !isset($supply_can_confirm_receipt) || $supply_can_confirm_receipt == 2 )
- {
- echo json_encode( array('code' => 2, 'msg'=>'供应商暂无权限确认收货(已发货待收货)') );
- die();
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
-
- if( empty($order_info) )
- {
- echo json_encode( array('code' => 2,'msg' => '非法订单号') );
- die();
- }
- //
- //order_status_id == 1 delivery opsend_tuanz_over
-
- if( $order_info['order_status_id'] == 4 )
- {
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'supply_id' => $supply_info['id'] ) )->find();
-
- if( empty($order_goods) )
- {
- echo json_encode( array('code' => 2,'msg' => '无此订单操作权限') );
- die();
- }
-
- D('Seller/Order')->receive_order($order_id);
-
- M('lionfish_comshop_order_history')->where( array('order_id' => $order_id ,'order_status_id' => 6) )->save( array( 'comment' => '供应商小程序端,确认收货') );
-
-
- echo json_encode( array('code' => 0, 'msg' => '确认收货成功') );
-
- die();
- }else{
- echo json_encode( array('code' => 2,'msg' => '订单状态不可发货') );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
-
-
-
- /**
- 供应商 商品上下架
- **/
- function up_supply_goods()
- {
- //grounding/value/3
-
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
-
- $supply_can_goods_updown = D('Home/Front')->get_config_by_name('supply_can_goods_updown');
- if( !isset($supply_can_goods_updown) || $supply_can_goods_updown == 2)
- {
- echo json_encode( array('code' => 2, 'msg'=>'供应商暂无权限上架商品') );
- die();
- }
-
-
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $goods_id = intval( $gpc['goods_id'] );
-
- $supply_add_goods_shenhe = D('Home/Front')->get_config_by_name('supply_add_goods_shenhe');
-
- if($supply_add_goods_shenhe == 1 )
- {
- M('lionfish_comshop_goods')->where( array('id' => $goods_id) )->save( array('grounding' => 4) );
- echo json_encode( array('code' => 2, 'msg'=>'供应商上架商品需等待审核') );
- die();
- }
-
-
- $gd_info = M('lionfish_comshop_good_common')->where( array('supply_id' => $supply_info['id'], 'goods_id' => $goods_id ) )->find();
-
- if( !empty($gd_info) )
- {
- $res = M('lionfish_comshop_goods')->where( array('id' =>$goods_id ) )->save( array('grounding' => 1 ) );
-
- echo json_encode( array('code' => 0) );
- die();
- }else{
- echo json_encode( array('code' => 2, 'msg'=>'非法操作') );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
- /**
- 供应商 快递订单点击确认发货,获取物流公司 以便填写单号
- **/
-
- public function get_express_list()
- {
-
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $order_id = $gpc['order_id'];
-
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
-
- if( empty($order_info) )
- {
- echo json_encode( array('code' => 2,'msg' => '非法订单号') );
- die();
- }
- //
- //order_status_id == 1 delivery opsend_tuanz_over
-
- if( $order_info['order_status_id'] == 1 && in_array( $order_info['delivery'], array('express') ) )
- {
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'supply_id' => $supply_info['id'] ) )->find();
-
- if( empty($order_goods) )
- {
- echo json_encode( array('code' => 2,'msg' => '无此订单操作权限') );
- die();
- }
-
- $province_info = D('Home/Front')->get_area_info($item['shipping_province_id']);
- $city_info = D('Home/Front')->get_area_info($item['shipping_city_id']);
- $area_info = D('Home/Front')->get_area_info($item['shipping_country_id']);
-
- $express_list = D('Seller/Express')->load_all_express();
-
-
- $data = array();
- $data['shipping_name'] = $order_info['shipping_name'];
- $data['shipping_tel'] = $order_info['shipping_tel'];
- $data['address'] = $province_info['name'].$city_info['name'].$area_info['name'].$item['shipping_address'];
-
- $data['express_list'] = $express_list;
-
-
- echo json_encode( array('code' => 0, 'data' => $data ) );
-
- die();
- }else{
- echo json_encode( array('code' => 2,'msg' => '订单状态不可发货') );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
-
- /**
- 供应商 快递订单 确认发货
- **/
- public function do_send_order_express()
- {
-
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- $order_id = $gpc['order_id'];
-
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
-
- if( empty($order_info) )
- {
- echo json_encode( array('code' => 2,'msg' => '非法订单号') );
- die();
- }
-
- $express_id = $gpc['express_id']; //快递公司id
- $shipping_no = $gpc['shipping_no']; //快递单号
-
- if( empty($express_id) )
- {
- echo json_encode( array('code' => 2, 'msg' => '请选择快递公司') );
- die();
- }
- if( empty($shipping_no) )
- {
- echo json_encode( array('code' => 2, 'msg' => '请填写快递编号') );
- die();
- }
-
-
- if( $order_info['order_status_id'] == 1 && in_array( $order_info['delivery'], array('express') ) )
- {
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'supply_id' => $supply_info['id'] ) )->find();
-
- if( empty($order_goods) )
- {
- echo json_encode( array('code' => 2,'msg' => '无此订单操作权限') );
- die();
- }
-
-
- $express_info = D('Seller/Express')->get_express_info($express_id);
-
- $time = time();
- $data = array(
- 'shipping_method' => trim($express_id),
- 'shipping_no' => trim($shipping_no),
- 'dispatchname' => $express_info['name'],
- 'express_time' => $time
- );
-
- $data['order_status_id'] = 4;
-
-
- M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->save( $data );
-
-
-
- $history_data = array();
- $history_data['order_id'] = $order_info['order_id'];
- $history_data['order_status_id'] = 4;
- $history_data['notify'] = 0;
- $history_data['comment'] = '供应商前台:订单发货 ID: ' . $order_id . ' 订单号: ' . $order_info['order_num_alias'] . ' <br/>快递公司: ' . $express_info['name'] . ' 快递单号: ' . $shipping_no;
- $history_data['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add($history_data);
-
- D('Home/Frontorder')->send_order_operate($order_id);
-
-
- echo json_encode( array('code' => 0, 'data' => $data ) );
-
- die();
- }else{
- echo json_encode( array('code' => 2,'msg' => '订单状态不可发货') );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 2,'msg'=>'未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
- /**
- 供应商 资金管理 页面
- **/
-
- public function supply_managemoney_panel()
- {
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- //$supply_info['id']
- $supply_id = $supply_info['id'];
-
-
- $supply_min_apply_money = D('Home/Front')->get_config_by_name('supply_min_money');
-
- if( empty($supply_min_apply_money) )
- {
- $supply_min_apply_money = 0;
- }
-
- $supply_commiss = M('lionfish_supply_commiss')->where( array('supply_id' => $supply_id ) )->find();
-
- $last_tixian_order = array('bankname' =>'微信','bankaccount' => '','bankusername' => '' ,'supply_apply_type' => -1 );
-
- $lionfish_supply_tixian_order = M('lionfish_supply_tixian_order')->where( array('supply_id' => $supply_id ) )->order('id desc')->find();
-
- if( !empty($lionfish_supply_tixian_order) )
- {
- $last_tixian_order['bankname'] = $lionfish_supply_tixian_order['bankname'];
- $last_tixian_order['bankaccount'] = $lionfish_supply_tixian_order['bankaccount'];
- $last_tixian_order['bankusername'] = $lionfish_supply_tixian_order['bankusername'];
- $last_tixian_order['supply_apply_type'] = $lionfish_supply_tixian_order['supply_apply_type'];
- }
-
- $supply_commiss_tixianway_weixin = D('Home/Front')->get_config_by_name('supply_commiss_tixianway_weixin');
- $supply_commiss_tixianway_alipay = D('Home/Front')->get_config_by_name('supply_commiss_tixianway_alipay');
- $supply_commiss_tixianway_bank = D('Home/Front')->get_config_by_name('supply_commiss_tixianway_bank');
- $supply_commiss_tixianway_weixin_offline = D('Home/Front')->get_config_by_name('supply_commiss_tixianway_weixin_offline');
-
- if( isset($supply_commiss_tixianway_weixin) && $supply_commiss_tixianway_weixin == 1 )
- {
- $supply_commiss_tixianway_weixin = 0;
- }else{
- $supply_commiss_tixianway_weixin = 1;
- }
-
- if( isset($supply_commiss_tixianway_alipay) && $supply_commiss_tixianway_alipay == 1 )
- {
- $supply_commiss_tixianway_alipay = 0;
- }else{
- $supply_commiss_tixianway_alipay = 1;
- }
-
- if( isset($supply_commiss_tixianway_bank) && $supply_commiss_tixianway_bank == 1 )
- {
- $supply_commiss_tixianway_bank = 0;
- }else{
- $supply_commiss_tixianway_bank = 1;
- }
-
- if( isset($supply_commiss_tixianway_weixin_offline) && $supply_commiss_tixianway_weixin_offline == 1 )
- {
- $supply_commiss_tixianway_weixin_offline = 0;
- }else{
- $supply_commiss_tixianway_weixin_offline = 1;
- }
-
- $tixian_waylist = array();
-
- $tixian_waylist[1] = array( 'name' => '微信零钱', 'is_show' => 0, 'is_default_check' => 0 );
- $tixian_waylist[2] = array( 'name' => '支付宝', 'is_show' => 0, 'is_default_check' => 0 );
- $tixian_waylist[3] = array( 'name' => '银行卡', 'is_show' => 0, 'is_default_check' => 0 );
- $tixian_waylist[4] = array( 'name' => '微信私下转', 'is_show' => 0, 'is_default_check' => 0 );
-
- if( $supply_commiss_tixianway_weixin == 1 )
- {
- $tixian_waylist[1]['is_show'] = 1;
-
- if( $last_tixian_order['bankname'] == '微信' )
- {
- $tixian_waylist[1]['is_default_check'] = 1;
- }
- }
-
- if( $supply_commiss_tixianway_alipay == 1 )
- {
- $tixian_waylist[2]['is_show'] = 1;
-
- if( $last_tixian_order['bankname'] == '支付宝' )
- {
- $tixian_waylist[2]['is_default_check'] = 1;
- }
- }
-
- if( $supply_commiss_tixianway_bank == 1 )
- {
- $tixian_waylist[3]['is_show'] = 1;
-
- if( $last_tixian_order['bankname'] != '微信' && $last_tixian_order['bankname'] != '支付宝' && $last_tixian_order['supply_apply_type'] != 4 )
- {
- $tixian_waylist[3]['is_default_check'] = 1;
- }
- }
-
- if( $supply_commiss_tixianway_weixin_offline == 1 )
- {
- $tixian_waylist[4]['is_show'] = 1;
-
- if( $last_tixian_order['supply_apply_type'] == 4 )
- {
- $tixian_waylist[4]['is_default_check'] = 1;
- }
- }
-
- // bankaccount
- // $last_tixian_order = array('bankname' =>'微信','bankaccount' => '','bankusername' => '' ,'supply_apply_type' => -1 );
-
- //微信真实姓名 last_tixian_order 中的:bankaccount
- //支付宝账号 last_tixian_order 中的:bankaccount
-
- //银行卡里面的 信息: 银行名称 bankname , 银行卡账户 bankaccount , 持卡人姓名 bankusername
-
- //微信私下转 的微信号: bankaccount
-
- if( empty($supply_commiss) )
- {
- $supply_commiss = array();
- $supply_commiss['money'] = 0;//可提现
- $supply_commiss['dongmoney'] = 0; //提现中
- $supply_commiss['getmoney'] = 0; //已提现金额
- }
-
-
-
- $supply_tixian_free = D('Home/Front')->get_config_by_name('supply_tixian_moneyfree');
-
- if( !isset($supply_tixian_free) || $supply_tixian_free <= 0 )
- {
- $supply_tixian_free = 0;
- }
-
-
-
- $supply_tixian_notice = D('Home/Front')->get_config_by_name('supply_tixian_notice');
-
- if( empty($supply_tixian_notice) )
- {
- $supply_tixian_notice = '';
- }else{
-
- $supply_tixian_notice = htmlspecialchars_decode( htmlspecialchars_decode($supply_tixian_notice) );
- }
- $member_info = M('lionfish_comshop_member')->field('avatar,username')
- ->where( array('member_id' => $member_id) )->find();
-
- $result = array();
- $result['supply_min_apply_money'] = $supply_min_apply_money;//最小提现金额
- $result['tixian_waylist'] = $tixian_waylist;//可提现的银行类型
-
- $result['supply_commiss'] = $supply_commiss;//供应商账户信息
- $result['supply_tixian_free'] = $supply_tixian_free;//提现手续费
- $result['supply_tixian_notice'] = $supply_tixian_notice;//提现规则
- $result['member_info'] = $member_info;//用户信息
-
- echo json_encode( array('code' => 0, 'data' =>$result ) );
- die();
-
- }else{
- echo json_encode( array('code' => 2,'msg' => '未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
- /**
- 供应商 收支记录页面
- **/
- public function supply_applymoney()
- {
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- //$supply_info['id']
- $supply_id = $supply_info['id'];
-
- $supply_apply_type = $gpc['supply_apply_type'];//提现类型: 1 微信零钱 2 支付宝 3银行卡 4微信线下转账
-
-
- $supply_min_apply_money = D('Home/Front')->get_config_by_name('supply_min_money');
-
- if( empty($supply_min_apply_money) )
- {
- $supply_min_apply_money = 0;
- }
-
- $account = $gpc['account'];//微信真实姓名 + 支付宝账户 + 银行卡账户 + 微信线下转的微信名称
- if($supply_apply_type == 3){
- $reg = '/^[\d]{16,19}$/ ';
- if(!preg_match($reg,$account,$match)){
- echo json_encode( array('code' => 2, 'msg' => '银行卡账户格式错误') );
- die();
- }
- }
-
- $card_name = $gpc['card_name']; //银行卡名称
- $card_username = $gpc['card_username']; //持卡人姓名
- $ti_money = floatval( $gpc['ti_money'] ); //提现金额
-
- $supply_commiss = M('lionfish_supply_commiss')->where( array('supply_id' => $supply_id ) )->find();
-
- if($ti_money < $supply_min_apply_money){
- echo json_encode( array('code' => 2, 'msg' => '最低提现'.$supply_min_apply_money ) );
- die();
- }
-
- if($ti_money <=0){
- echo json_encode( array('code' => 2, 'msg' => '最低提现大于0元' ) );
- die();
- }
-
- if($ti_money > $supply_commiss['money']){
- echo json_encode( array('code' => 2, 'msg' => '当前最多提现'.$supply_commiss['money'] ) );
- die();
- }
-
-
- $supply_tixian_free = D('Home/Front')->get_config_by_name('supply_tixian_moneyfree');
-
- if( !isset($supply_tixian_free) || $supply_tixian_free <= 0 )
- {
- $supply_tixian_free = 0;
- }
-
-
- $ins_data = array();
- $ins_data['supply_id'] = $supply_id;
- $ins_data['money'] = $ti_money;
- $ins_data['service_charge'] = round( ($supply_tixian_free * $ti_money) / 100 ,2);
- $ins_data['server_bili'] = $supply_tixian_free;
-
- $ins_data['state'] = 0;
- $ins_data['shentime'] = 0;
- $ins_data['is_send_fail'] = 0;
- $ins_data['fail_msg'] = '';
- $ins_data['supply_apply_type'] = $supply_apply_type;
-
- //1 微信 2 支付宝 3银行卡
- if($supply_apply_type == 1)
- {
- $ins_data['bankname'] = '微信零钱';
- $ins_data['bankaccount'] = $account;
- $ins_data['bankusername'] = '';
- }else if($supply_apply_type == 2){
- $ins_data['bankname'] = '支付宝';
- $ins_data['bankaccount'] = $account;
- $ins_data['bankusername'] = $card_username;
- }else if($supply_apply_type == 3){
- $ins_data['bankname'] = $card_name;
- $ins_data['bankaccount'] = $account;
- $ins_data['bankusername'] = $card_username;
- }else if($supply_apply_type == 4){
- $ins_data['bankname'] = '微信私下转';
- $ins_data['bankaccount'] = $account;
- $ins_data['bankusername'] = '';
- }
-
- $ins_data['addtime'] = time();
-
- M('lionfish_supply_tixian_order')->add($ins_data);
-
- M('lionfish_supply_commiss')->where( array('supply_id' => $supply_id ) )->setInc('money',-$ti_money);
- M('lionfish_supply_commiss')->where( array('supply_id' => $supply_id ) )->setInc('dongmoney',$ti_money);
-
- echo json_encode( array('code' => 0, 'msg' =>'提交成功,等待审核' ) );
- die();
-
- }else{
- echo json_encode( array('code' => 2,'msg' => '未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
-
- /**
- 供应商 提现记录
- **/
-
- public function supply_apply_flowlist()
- {
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
- {
- echo json_encode( array('code' => 1,'msg' => '未登录') );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- if($member_id > 0){
-
- //是否开启供应商平台
- $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
-
- if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
- {
- $supply_is_open_mobilemanage = 0;
- }
-
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
-
- if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
- {
- //$supply_info['id']
- $supply_id = $supply_info['id'];
-
- $page = isset($gpc['page']) ? intval($gpc['page']) : 1;
-
- if( $page <= 0 )
- {
- $page = 1;
- }
-
- $perpage = 20;
-
- $offset = ($page - 1) * $perpage;
-
- $list = M('lionfish_supply_tixian_order')->where( array('supply_id' => $supply_id ) )->order('id desc ')->limit($offset, $perpage)->select();
-
- $data = array();
-
- if( !empty($list) )
- {
-
- foreach( $list as $val )
- {
- $tmp = array();
-
- if( $val['state'] == 0 )
- {
- $tmp['state_str'] = '提现中';
-
- }else if( $val['state'] == 1 )
- {
- $tmp['state_str'] = '提现成功';
- }else if( $val['state'] == 2 )
- {
- $tmp['state_str'] = '拒绝提现';
- }
-
- $tmp['money'] = $val['money'];
- $tmp['addtime'] = date('Y-m-d H:i:s', $val['addtime'] );
-
- $data[] = $tmp;
- }
-
- }
-
- echo json_encode( array('code' => 0, 'data' => $data ) );
- die();
-
- }else{
- echo json_encode( array('code' => 2,'msg' => '未开启供应商手机端或未授权供应商手机端或供应商未审核') );
- die();
- }
- }
-
- }
-
-
-
-
-
-
-
-
-
- }
|