12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470 |
- <?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;
- use Home\Model\OrderModel;
- class OrderController extends CommonController {
-
- protected function _initialize(){
- parent::_initialize();
- // 获取当前用户ID
- }
-
- /**
- 直接取消订单
- 1、已付款待发货 状态
- 2、是不是自己的订单
- 3、判断后台是否开启了状态
- 4、记录日志
- 5、处理订单,
- 6、处理退款,
- 7、打印小票
-
- 结束
- **/
- public function del_cancle_order()
- {
- $gpc = I('request.');
- $_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' => 2) );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
-
- $order_id = $_GPC['order_id'];
-
- $order_info = M('lionfish_comshop_order')->where( array('member_id' => $member_id,'order_id' => $order_id) )->find();
- $order_member_name = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
-
- if( empty($order_info) )
- {
- echo json_encode( array('code' => 1, 'msg' => '订单不存在') );
- die();
- }
-
- if( $order_info['order_status_id'] == 1)
- {
- $order_can_del_cancle = D('Home/Front')->get_config_by_name('order_can_del_cancle');
-
- if( empty($order_can_del_cancle) || $order_can_del_cancle == 0 )
- {
- //4、记录日志
- $order_history = array();
- $order_history['order_id'] = $order_id;
- $order_history['order_status_id'] = 5;
- $order_history['notify'] = 0;
- $order_history['comment'] = '会员前台申请,直接取消已支付待发货订单';
- $order_history['date_added'] = time();
-
- M('lionfish_comshop_order_history')->add($order_history);
-
-
- //5、处理订单
- $result = D('Home/Weixin')->del_cancle_order($order_id);
-
- //6、发送取消通知订单给平台
-
- $weixin_template_cancle_order = D('Home/Front')->get_config_by_name('weixin_template_cancle_order');
- $platform_send_info_member_id = D('Home/Front')->get_config_by_name('platform_send_info_member');
- if( !empty($weixin_template_cancle_order) && !empty($platform_send_info_member_id) )
- {
- $weixin_template_order =array();
- $weixin_appid = D('Home/Front')->get_config_by_name('weixin_appid' );
-
- if( !empty($weixin_appid) && !empty($weixin_template_cancle_order) )
- {
- $head_pathinfo = "lionfish_comshop/pages/index/index";
-
- $pl_member_id = explode(",", $platform_send_info_member_id);
-
- foreach($pl_member_id as $m_id){
- $weopenid = M('lionfish_comshop_member')->where( array('member_id' => $m_id ) )->find();
- $weixin_template_order = array(
- 'appid' => $weixin_appid,
- 'template_id' => $weixin_template_cancle_order,
- 'pagepath' => $head_pathinfo,
- 'data' => array(
- 'first' => array('value' => '您好,您收到了一个取消订单,请尽快处理','color' => '#030303'),
- 'keyword1' => array('value' => $order_info['order_num_alias'],'color' => '#030303'),
- 'keyword2' => array('value' => '取消订单','color' => '#030303'),
- 'keyword3' => array('value' => sprintf("%01.2f", $order_info['total']),'color' => '#030303'),
- 'keyword4' => array('value' => date('Y-m-d H:i:s'),'color' => '#030303'),
- 'keyword5' => array('value' => $order_member_name['username'],'color' => '#030303'),
- 'remark' => array('value' => '此订单已于'.date('Y-m-d H:i:s').'被用户取消,请尽快处理','color' => '#030303'),
- )
- );
-
- D('Seller/User')->just_send_wxtemplate($weopenid['we_openid'], 0, $weixin_template_order );
- }
-
-
- }
- }
- if( $result['code'] == 0 && $order_info['type'] != 'integral')
- {
-
- $is_print_cancleorder = D('Home/Front')->get_config_by_name('is_print_cancleorder');
- if( isset($is_print_cancleorder) && $is_print_cancleorder == 1 )
- {
- D('Seller/Printaction')->check_print_order($order_id,'用户取消订单');
- D('Seller/Printaction')->check_print_order2($order_id,'用户取消订单');
- }
-
- echo json_encode( array('code' => 0 ) );
- die();
- }
- else if($result['code'] == 0 && $order_info['type'] == 'integral')
- {
- echo json_encode( array('code' => 0 ) );
- die();
- }
- else{
- echo json_encode( array('code' => 1, 'msg' => $result['msg'] ) );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 1, 'msg' => '未开启此项功能') );
- die();
- }
-
- }else{
- echo json_encode( array('code' => 1, 'msg' => '订单状态不正确,只有已支付,未发货的订单才能取消') );
- die();
- }
-
-
- }
-
- public function order_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' => 2) );
- die();
- }
-
- $member_id = $weprogram_token['member_id'];
- $order_id = $gpc['id'];
-
- $is_supply = isset($gpc['is_supply']) ? $gpc['is_supply'] :'';
-
- if( $is_supply > 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 )
- {
- $ck_order_goods = M('lionfish_comshop_order_goods')->where( array('supply_id' => $supply_info['id'], 'order_id' => $order_id ) )->find();
-
- if( !empty($ck_order_goods) )
- {
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $ck_order_goods['order_id']) )->find();
- }else{
- echo json_encode( array('code' => 2 , 'msg' => '非法操作') );
- die();
- }
- }else{
- echo json_encode( array('code' => 2, 'msg' => '非法操作') );
- die();
- }
- }else{
- $order_info = M('lionfish_comshop_order')->where( array('member_id' => $member_id,'order_id' => $order_id) )->find();
- }
- //gpc
- if($order_info['is_change_price'] == 1){
- $order_info['admin_change_price'] = $order_info['total'] - $order_info['old_price'];
- }
-
- $pick_up_info = array();
- $pick_order_info = array();
-
- if( $order_info['delivery'] == 'pickup' )
- {
- //查询自提点
- $pick_order_info = array();
-
- $pick_id = 0;
- $pick_up_info = array();
-
- }
- if( $order_info['delivery'] == 'localtown_delivery' && ($order_info['order_status_id'] != 3 && $order_info['order_status_id'] != 5 ) )
- {
- $order_info['orderdistribution_order'] = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_info['order_id'] ) )->find();
- if( !empty($order_info['orderdistribution_order']) && $order_info['orderdistribution_order'] > 0 )
- {
- $orderdistribution = M('lionfish_comshop_orderdistribution')->where( array('id' => $order_info['orderdistribution_order']['orderdistribution_id'] ) )->find();
- $order_info['orderdistribution_order']['username'] = $orderdistribution['username'];
- }
- }
- $order_status_info = M('lionfish_comshop_order_status')->where( array('order_status_id' => $order_info['order_status_id'] ) )->find();
-
- //10 name
- if($order_info['order_status_id'] == 10)
- {
- $order_status_info['name'] = '等待退款';
- }
- else if($order_info['order_status_id'] == 4 && $order_info['delivery'] =='pickup')
- {
- //delivery 6
- $order_status_info['name'] = '待自提';
- //已自提
- }
- else if($order_info['order_status_id'] == 6 && $order_info['delivery'] =='pickup')
- {
- //delivery 6
- $order_status_info['name'] = '已自提';
-
- }
- else if($order_info['order_status_id'] == 1 && $order_info['type'] == 'lottery')
- {
- //等待开奖
- //一等奖
- if($order_info['lottery_win'] == 1)
- {
- $order_status_info['name'] = '一等奖';
- }else {
- $order_status_info['name'] = '等待开奖';
- }
-
- }
- //核销订单
- if( $order_info['delivery'] == 'hexiao' ){
- if($order_info['store_id'] == 0){
- $order_info['shopname'] = '平台自营';
- }else{
- $store_info = M('lionfish_comshop_supply')->where( array('id' => $order_info['store_id'] ) )->find();
- $order_info['shopname'] = $store_info['shopname'];
- }
- //订单卷码
- $order_info['hexiao_volume_code'] = $order_info['hexiao_volume_code'];
- //二维码
- if(empty($order_info['hexiao_qr_code'])){
- $order_info['hexiao_qr_code'] = D('Home/Salesroom')->_get_ordergoods_hxqrcode($order_id,'',$order_info['hexiao_volume_code']);
- }else{
- $order_info['hexiao_qr_code'] = tomedia($order_info['hexiao_qr_code']);
- }
- //门店列表
- $salesroom_list = D('Home/Salesroom')->get_order_salesroom($order_id,0);
- foreach($salesroom_list as $slk=>$slv){
- $member_lon = $gpc['longitude'];
- $member_lat = $gpc['latitude'];
- $salesroom_list[$slk]['distance'] = D('Home/Salesroom')->cal_salesroom_distance($slv,$member_lon,$member_lat);
- }
- $distances = array_column($salesroom_list,'distance');
- array_multisort($distances,SORT_ASC,$salesroom_list);
- $order_info['salesroom_list'] = $salesroom_list;
- }
- //$order_info['type']
-
- //open_auto_delete
-
-
- if($order_info['order_status_id'] == 3)
- {
- $open_auto_delete = D('Home/Front')->get_config_by_name('open_auto_delete');
- $auto_cancle_order_time = D('Home/Front')->get_config_by_name('auto_cancle_order_time');
-
- $order_info['open_auto_delete'] = $open_auto_delete;
- //date_added
- if($open_auto_delete == 1)
- {
- $order_info['over_buy_time'] = $order_info['date_added'] + 3600 * $auto_cancle_order_time;
- $order_info['cur_time'] = time();
- }
-
- }
-
-
- $shipping_province = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_province_id'] ) )->find();
-
- $shipping_city = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_city_id'] ) )->find();
-
- $shipping_country = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_country_id'] ) )->find();
-
-
- $order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->select();
-
-
- $shiji_total_money = 0;
- $member_youhui = 0.00;
-
-
- $pick_up_time = "";
- $pick_up_type = -1;
- $pick_up_weekday = '';
- $today_time = $order_info['pay_time'];
-
- $arr = array('天','一','二','三','四','五','六');
-
- $url = D('Home/Front')->get_config_by_name('shop_domain').'/';
-
- $attachment_type = D('Home/Front')->get_config_by_name('attachment_type');
- $qiniu_url = D('Home/Front')->get_config_by_name('qiniu_url');
- $is_can_received = 1;//是否可以收货,1、可以,0、不可以
- $hx_receive_info = array();//核销订单已收到待收货情况
- $receive_count = 0;//已收货
- $wait_count = 0;//待收货
- $goods_quantity = 0;//商品数量
- $refund_goods_quantity = 0;//退款商品数量
- $volume_code_list = array();//卷码列表
- $hx_order_count = 0;//按订单核销商品订单数
- $hx_time_count = 0;//按次数核销商品订单数
- $vi = 0;
- foreach($order_goods_list as $key => $order_goods)
- {
- $order_goods['name'] = htmlspecialchars_decode(stripslashes($order_goods['name']));
- $order_refund_goods = M('lionfish_comshop_order_refund')->where( array('order_id' =>$order_id,'order_goods_id' => $order_goods['order_goods_id'] ) )->order('ref_id desc')->find();
-
- if(!empty($order_refund_goods))
- {
- $order_refund_goods['addtime'] = date('Y-m-d H:i:s', $order_refund_goods['addtime']);
- if($order_refund_goods['state'] == 0 || $order_refund_goods['state'] == 2){
- $is_can_received = 0;
- }
- }
-
- $order_option_info = M('lionfish_comshop_order_option')->field('value')->where( array('order_goods_id' => $order_goods['order_goods_id'],'order_id' => $order_id) )->select();
-
- $order_goods['order_refund_goods'] = $order_refund_goods;
-
- foreach($order_option_info as $option)
- {
- $order_goods['option_str'][] = $option['value'];
- }
- if(empty($order_goods['option_str']))
- {
- //option_str
- $order_goods['option_str'] = '';
- }else{
- $order_goods['option_str'] = implode(',', $order_goods['option_str']);
- }
- //
- $order_goods['shipping_fare'] = round($order_goods['shipping_fare'],2);
- $order_goods['price'] = round($order_goods['price'],2);
- $order_goods['total'] = round($order_goods['total'],2);
-
- if( $order_goods['is_vipcard_buy'] == 1 || $order_goods['is_level_buy'] ==1 )
- {
- $order_goods['price'] = round($order_goods['oldprice'],2);
- }
- $order_goods['real_total'] = round($order_goods['quantity'] * $order_goods['price'],2);
-
- /**
- $goods_images = file_image_thumb_resize($vv['goods_images'],400);
- if(is_array($goods_images))
- {
- $vv['goods_images'] = $vv['goods_images'];
- }else{
- $vv['goods_images']= tomedia( file_image_thumb_resize($vv['goods_images'],400) );
- }
-
- **/
-
-
- if($attachment_type == 1)
- {
- $goods_images = $qiniu_url.resize($order_goods['goods_images'],400,400);
- }else{
- $goods_images = $url.resize($order_goods['goods_images'],400,400);
- }
-
- if( !is_array($goods_images) )
- {
- $order_goods['image']= tomedia( $goods_images );
- $order_goods['goods_images']= tomedia( $goods_images );
- }else{
- $order_goods['image']= $order_goods['goods_images'];
- }
-
- $order_goods['hascomment'] = 0;
-
- $order_goods_comment_info = M('lionfish_comshop_order_comment')->field('comment_id')->where( array('goods_id' => $order_goods['goods_id'],'order_id' =>$order_id) )->find();
-
-
- if( !empty($order_goods_comment_info) )
- {
- $order_goods['hascomment'] = 1;
- }
-
- $order_goods['can_ti_refund'] = 1;
-
- $disable_info = M('lionfish_comshop_order_refund_disable')->where( array('order_id' => $order_id, 'order_goods_id' => $order_goods['order_goods_id']) )->find();
-
- if( !empty($disable_info) )
- {
- $order_goods['can_ti_refund'] = 0;
- }
-
- if($order_goods['is_refund_state'] == 1)
- {
- //已经再申请退款中了。或者已经退款了。
- $order_refund_info = M('lionfish_comshop_order_refund')->field('state')->where( array('order_id' => $order_id,'order_goods_id' => $order_goods['order_goods_id'] ) )->find();
-
- if( $order_refund_info['state'] == 3 )
- {
- $order_goods['is_refund_state'] = 2;
- }
- }
-
- //无售后期
- $open_aftersale = D('Home/Front')->get_config_by_name('open_aftersale');
- if( empty($open_aftersale) )
- {
- $order_goods['is_statements_state'] = 1;
- }
- //ims_
-
- $goods_info = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $order_goods['goods_id']) )->find();
-
- $goods_cm_info = M('lionfish_comshop_good_common')->field('pick_up_type,pick_up_modify,goods_share_image')->where( array('goods_id' => $order_goods['goods_id']) )->find();
-
- if($pick_up_type == -1 || $goods_cm_info['pick_up_type'] > $pick_up_type)
- {
- $pick_up_type = $goods_cm_info['pick_up_type'];
-
- if($pick_up_type == 0)
- {
- $pick_up_time = date('m-d', $today_time);
- //$pick_up_weekday = '周'.$arr[date('w',$today_time)];
- }else if( $pick_up_type == 1 ){
- $pick_up_time = date('m-d', $today_time+86400);
- //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400)];
- }else if( $pick_up_type == 2 )
- {
- $pick_up_time = date('m-d', $today_time+86400*2);
- //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400*2)];
- }else if($pick_up_type == 3)
- {
- $pick_up_time = $goods_cm_info['pick_up_modify'];
- }
- }
-
- if( !empty($goods_cm_info['goods_share_image']) )
- {
- $order_goods['goods_share_image']= tomedia( $goods_cm_info['goods_share_image'] );
- }else{
- $order_goods['goods_share_image'] = $order_goods['image'];
- }
-
- $order_goods['shop_price'] = $goods_info['price'];
-
-
- $store_info = array('s_true_name' =>'','s_logo' => '');
-
- $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
-
- //$store_info['s_logo'] = D('Home/Front')->get_config_by_name('shoplogo');
-
- if( !empty($store_info['s_logo']) )
- {
- $store_info['s_logo'] = tomedia($store_info['s_logo']);
- }else{
- $store_info['s_logo'] = '';
- }
-
-
- $order_goods['store_info'] = $store_info;
- //核销订单
- if( $order_info['delivery'] == 'hexiao' ){
- $order_goods_saleshexiao = M('lionfish_comshop_order_goods_saleshexiao')->where( array('order_id' =>$order_id,'order_goods_id' => $order_goods['order_goods_id'] ) )->find();
- //有效期截止
- $order_goods['effect_end_time'] = date('Y-m-d H:i:s',$order_goods_saleshexiao['effect_end_time']);
- // 是否核销过期:0 否,1、是
- $order_goods['is_hexiao_expire'] = $order_goods_saleshexiao['effect_end_time']>time()?0:1;
- //总核销次数
- $order_goods['hexiao_count'] = $order_goods_saleshexiao['hexiao_count'];
- //剩余核销次数
- $order_goods['remain_hexiao_count'] = $order_goods_saleshexiao['remain_hexiao_count'];
- //核销方式:0 订单核销,1、自定义核销次数
- $order_goods['hexiao_type'] = $order_goods_saleshexiao['hexiao_type'];
- //商品核销卷码
- $order_goods['hexiao_volume_code'] = $order_goods_saleshexiao['hexiao_volume_code'];
- //商品核销二维码
- if(empty($order_goods['hexiao_qr_code'])){
- $order_goods['hexiao_qr_code'] = D('Home/Salesroom')->_get_ordergoods_hxqrcode($order_id,$order_goods['order_goods_id'],$order_goods['hexiao_volume_code']);
- }else{
- $order_goods['hexiao_qr_code'] = tomedia($order_goods['hexiao_qr_code']);
- }
- //是否核销完毕:0 否,1、是
- $order_goods['is_hexiao_over'] = $order_goods_saleshexiao['is_hexiao_over'];
- //核销过期操作时间
- $order_goods['expire_act_time'] = $order_goods_saleshexiao['expire_act_time'];
- $volume_code_list[$vi]['hexiao_volume_code'] = $order_goods['hexiao_volume_code'];
- if($order_goods['is_hexiao_over'] == 1){
- $receive_count = $receive_count + $order_goods_saleshexiao['goods_quantity'] - $order_goods_saleshexiao['refund_quantity'];
- $volume_code_list[$vi]['is_use'] = 1;
- }else{
- $receive_count = $receive_count + floor(($order_goods_saleshexiao['hexiao_count'] - $order_goods_saleshexiao['refund_quantity']*$order_goods_saleshexiao['one_hexiao_count'] - $order_goods_saleshexiao['remain_hexiao_count'])/$order_goods_saleshexiao['one_hexiao_count']);
- $volume_code_list[$vi]['is_use'] = 0;
- }
- // 是否核销过期:0 否,1、是
- $volume_code_list[$vi]['is_hexiao_expire'] = $order_goods_saleshexiao['effect_end_time']>time()?0:1;
- $volume_code_list[$vi]['effect_end_time'] = date('Y-m-d H:i:s',$order_goods_saleshexiao['effect_end_time']);
- $volume_code_list[$vi]['refund_quantity'] = $order_goods_saleshexiao['refund_quantity'];
-
- if($order_goods['hexiao_type'] == 0){
- $hx_order_count = $hx_order_count + 1;
- }else{
- $hx_time_count = $hx_time_count + 1;
- }
- //核销商品门店信息
- $salesroom_list = D('Home/Salesroom')->get_order_goods_salesroom($order_goods['order_goods_id'],$gpc['longitude'],$gpc['latitude'],0);
- $order_goods['salesroom_list'] = $salesroom_list;
- $vi++;
- }
- if( $order_goods['is_refund_state'] == 1 || ($order_goods['has_refund_money'] > 0 && $order_goods['has_refund_quantity'] > 0) )
- {
- $order_goods['is_refund_state'] = 1;
- $where = " order_id = '".$order_goods['order_id']."' and order_goods_id = '".$order_goods['order_goods_id']."' and state in (0,2,3) ";
- $refund_info = M('lionfish_comshop_order_refund')->field('ref_id,order_id,ref_money,real_refund_quantity,state')->where( $where )->find();
- if(!empty($refund_info)){
- $order_goods['refund_info'] = $refund_info;
- }else{
- $refund_info = array();
- $refund_info['order_id'] = $order_goods['order_id'];
- $refund_info['ref_money'] = $order_goods['has_refund_money'];
- $refund_info['real_refund_quantity'] = $order_goods['has_refund_quantity'];
- $refund_info['state'] = 3;
- $order_goods['refund_info'] = $refund_info;
- }
- }
-
- unset($order_goods['model']);
- unset($order_goods['rela_goodsoption_valueid']);
- unset($order_goods['comment']);
-
-
- //ims_ ims_lionfish_comshop_order_goods_refund addtime
-
- $order_goods_refund_list = M('lionfish_comshop_order_goods_refund')->field('real_refund_quantity,money,addtime')->where( "order_goods_id=".$order_goods['order_goods_id'] )->order('id asc')->select();
-
- if( empty($order_goods_refund_list) )
- {
- $order_goods_refund_list = array();
- }else{
-
- foreach( $order_goods_refund_list as $kre => $rval )
- {
- $rval['addtime'] = date('Y-m-d H:i:s', $rval['addtime']);
- $order_goods_refund_list[$kre] = $rval;
- $refund_goods_quantity = $refund_goods_quantity + $rval['real_refund_quantity'];
- }
- }
-
- $order_goods['order_goods_refund_list'] = $order_goods_refund_list;
- $goods_quantity = $goods_quantity + $order_goods['quantity'];
- $order_goods_list[$key] = $order_goods;
- $shiji_total_money += $order_goods['quantity'] * $order_goods['price'];
-
- $member_youhui += ($order_goods['real_total'] - $order_goods['total']);
- }
- //核销订单
- if( $order_info['delivery'] == 'hexiao' ){
- $hx_receive_info['goods_count'] = count($order_goods_list);//商品种类
- $hx_receive_info['goods_quantity'] = $goods_quantity;//商品总数量
- $hx_receive_info['receive_count'] = $receive_count;//已收货商品数量
- $hx_receive_info['wait_count'] = $goods_quantity-$receive_count-$refund_goods_quantity;//待收货商品数量
- $hx_receive_info['refund_goods_quantity'] = $refund_goods_quantity;//已退款商品数量
- $hx_receive_info['volume_code_list'] = $volume_code_list;//商品卷码列表
- $hx_record = D('Home/Salesroom')->get_last_ordergoods_hexiaorecord($order_id);
- if(!empty($hx_record)){
- //使用地址
- if(empty($hx_record['salesroom_name'])){
- $hx_receive_info['salesroom_name'] = $hx_record['smember_name'];
- }else{
- $hx_receive_info['salesroom_name'] = $hx_record['salesroom_name'];
- }
- //使用时间
- $hx_receive_info['use_time'] = date('Y-m-d H:i:s',$hx_record['addtime']);
- }
- if($hx_order_count > 0 && $hx_time_count > 0){//混合订单
- $order_info['order_hexiao_type'] = 2;
- }else if($hx_order_count > 0 && $hx_time_count == 0){//按订单核销
- $order_info['order_hexiao_type'] = 0;
- }else if($hx_order_count == 0 && $hx_time_count > 0){//按次数核销
- $order_info['order_hexiao_type'] = 1;
- }
- $order_info['hx_receive_info'] = $hx_receive_info;//核销订单已收到待收货情况
- }
-
- unset($order_info['store_id']);
- unset($order_info['email']);
- unset($order_info['shipping_city_id']);
- unset($order_info['shipping_country_id']);
- unset($order_info['shipping_province_id']);
- //unset($order_info['comment']);
- unset($order_info['voucher_id']);
- unset($order_info['is_balance']);
- unset($order_info['lottery_win']);
- unset($order_info['ip']);
- unset($order_info['ip_region']);
- unset($order_info['user_agent']);
-
- $order_info['is_can_received'] = $is_can_received;
- $order_info['shipping_fare'] = round($order_info['shipping_fare'],2) < 0.01 ? '0.00':round($order_info['shipping_fare'],2) ;
- $order_info['voucher_credit'] = round($order_info['voucher_credit'],2) < 0.01 ? '0.00':round($order_info['voucher_credit'],2) ;
- $order_info['fullreduction_money'] = round($order_info['fullreduction_money'],2) < 0.01 ? '0.00':round($order_info['fullreduction_money'],2) ;
-
- $need_data = array();
-
- if($order_info['type'] == 'integral')
- {
- //暂时屏蔽积分商城
- $order_info['score'] = round($order_info['total'],2);
- }
-
-
- $order_info['total'] = round($order_info['total'] + $order_info['packing_fare'] +$order_info['shipping_fare']-$order_info['voucher_credit']-$order_info['fullreduction_money'] - $order_info['score_for_money'] + $order_info['localtown_add_shipping_fare'] - $order_info['fare_shipping_free'],2);
-
- if($order_info['total'] < 0)
- {
- $order_info['total'] = '0.00';
- }
-
-
-
- $order_info['real_total'] = round($shiji_total_money,2)+$order_info['shipping_fare'];
- $order_info['price'] = round($order_info['price'],2);
- $order_info['member_youhui'] = round($member_youhui,2) < 0.01 ? '0.00':round($member_youhui,2);
- $order_info['pick_up_time'] = $pick_up_time;
-
-
- $order_info['shipping_fare'] = sprintf("%.2f",$order_info['shipping_fare']);
- $order_info['voucher_credit'] = sprintf("%.2f",$order_info['voucher_credit']);
- $order_info['fullreduction_money'] = sprintf("%.2f",$order_info['fullreduction_money']);
- $order_info['total'] = sprintf("%.2f",$order_info['total']);
- $order_info['real_total'] = sprintf("%.2f",$order_info['real_total']);
-
-
- $order_info['date_added'] = date('Y-m-d H:i:s', $order_info['date_added']);
-
-
- if($order_info['delivery'] =='pickup')
- {
-
-
- }else{
-
-
- }
-
-
- if( !empty($order_info['pay_time']) && $order_info['pay_time'] >0 )
- {
- $order_info['pay_date'] = date('Y-m-d H:i:s', $order_info['pay_time']);
- }else{
- $order_info['pay_date'] = '';
- }
-
- $order_info['express_tuanz_date'] = date('Y-m-d H:i:s', $order_info['express_tuanz_time']);
- $order_info['receive_date'] = date('Y-m-d H:i:s', $order_info['receive_time']);
-
-
- //"delivery": "pickup", enum('express', 'pickup', 'tuanz_send')
- if($order_info['delivery'] == 'express')
- {
- $placeorder_trans_name = D('Home/Front')->get_config_by_name('placeorder_trans_name' );
- $order_info['delivery_name'] = $placeorder_trans_name?$placeorder_trans_name:'快递';
- }else if($order_info['delivery'] == 'pickup')
- {
- $delivery_ziti_name = D('Home/Front')->get_config_by_name('delivery_ziti_name' );
- $order_info['delivery_name'] = $delivery_ziti_name?$delivery_ziti_name:'自提';
- }else if($order_info['delivery'] == 'tuanz_send'){
- $delivery_tuanzshipping_name = D('Home/Front')->get_config_by_name('delivery_tuanzshipping_name' );
- $order_info['delivery_name'] = $delivery_tuanzshipping_name?$delivery_tuanzshipping_name:'团长配送';
- }
- $pin_rebate = [];
- //拼团获取返利信息
- if($order_info['type'] == 'pintuan'){
- $pin_rebate['reward_amount'] = 0;
- $pin_rebate['rebate_reward'] = 0;
- $pin_order = M('lionfish_comshop_pin_order')->where( array('order_id' => $order_id ) )->find();
- //获取拼团信息
- $pin_info = M('lionfish_comshop_pin')->where( array('pin_id' =>$pin_order['pin_id'] ) )->find();
- if($pin_info['is_pintuan_rebate'] == 1){
- if($pin_info['rebate_reward'] == 1){//积分
- $integral_flow = M('lionfish_comshop_member_integral_flow')->where( array('order_id' => $order_id,'type'=>'pintuan_rebate') )->find();
- if(!empty($integral_flow)){
- $pin_rebate['reward_amount'] = $integral_flow['score'];
- $pin_rebate['rebate_reward'] = 1;
- }
- }else if($pin_info['rebate_reward'] == 2){//余额
- $charge_flow = M('lionfish_comshop_member_charge_flow')->where( array('trans_id' => $order_id,'state'=>21) )->find();
- if(!empty($charge_flow)){
- $pin_rebate['reward_amount'] = $charge_flow['money'];
- $pin_rebate['rebate_reward'] = 2;
- }
- }
- }
- }
- //获取订单表单信息
- $order_form = D('Home/Allform')->getOrderFormInfo($order_id, $member_id);
- $need_data['order_form'] = $order_form;
-
- $need_data['order_info'] = $order_info;
- $need_data['order_status_info'] = $order_status_info;
- $need_data['shipping_province'] = $shipping_province;
- $need_data['shipping_city'] = $shipping_city;
- $need_data['shipping_country'] = $shipping_country;
- $need_data['order_goods_list'] = $order_goods_list;
-
- $need_data['goods_count'] = count($order_goods_list);
- $need_data['pin_rebate'] = $pin_rebate;
-
- //$order_info['order_status_id'] 13 平台介入退款
- $order_refund_historylist = array();
- $pingtai_deal = 0;
-
- //判断是否已经平台处理完毕
-
- $order_refund_historylist = M('lionfish_comshop_order_refund_history')->where( array('order_id' => $order_id) )->order('addtime asc')->select();
-
- foreach($order_refund_historylist as $key => $val)
- {
- if($val['type'] ==3)
- {
- $pingtai_deal = 1;
- }
- }
-
- $order_refund = M('lionfish_comshop_order_refund')->where( array('order_id' => $order_id) )->find();
-
- if(!empty($order_refund))
- {
- $order_refund['addtime'] = date('Y-m-d H:i:s', $order_refund['addtime']);
- }
-
- $need_data['pick_up'] = $pick_up_info;
-
-
-
- if( empty($pick_order_info['qrcode']) && false)
- {
-
- }
-
- $need_data['pick_order_info'] = $pick_order_info;
-
- $order_pay_after_share = D('Home/Front')->get_config_by_name('order_pay_after_share');
-
-
- if($order_pay_after_share==1){
- $order_pay_after_share_title = D('Home/Front')->get_config_by_name('order_pay_after_share_title');
- $order_pay_after_share_img = D('Home/Front')->get_config_by_name('order_pay_after_share_img');
- $order_pay_after_share_img = !empty($order_pay_after_share_img) ? tomedia($order_pay_after_share_img) : '';
- $need_data['share_img'] = empty($order_pay_after_share_img) ? $need_data['order_goods_list'][0]['image']: $order_pay_after_share_img;
- $need_data['share_title'] = $order_pay_after_share_title;
- }else{
- if(empty($need_data['order_goods_list'][0]['goods_share_image']))
- {
- $need_data['share_img'] = $need_data['order_goods_list'][0]['image'];
- }
- }
-
-
- $order_can_del_cancle = D('Home/Front')->get_config_by_name('order_can_del_cancle');
-
- $order_can_del_cancle = empty($order_can_del_cancle) || $order_can_del_cancle == 0 ? 1 : 0;
-
- $is_hidden_orderlist_phone = D('Home/Front')->get_config_by_name('is_hidden_orderlist_phone');
-
- $is_show_guess_like = D('Home/Front')->get_config_by_name('is_show_order_guess_like');
-
- $user_service_switch = D('Home/Front')->get_config_by_name('user_service_switch');
- $common_header_backgroundimage = D('Home/Front')->get_config_by_name('common_header_backgroundimage');
- if($common_header_backgroundimage){
- $common_header_backgroundimage = tomedia($common_header_backgroundimage);
- }
-
- $order_can_shen_refund = D('Home/Front')->get_config_by_name('is_score_can_refund');
-
- if( $order_info['type'] == 'integral' )
- {
- if( !isset($order_can_shen_refund) || empty($order_can_shen_refund) )
- {
- $order_can_shen_refund = 0;
- }else{
- $order_can_shen_refund = 1;
- }
- }else{
- $order_can_shen_refund = 1;
- }
-
- $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
- $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
-
- if( !isset($order_note_open) || $order_note_open == 0)
- {
- $order_note_open = 0;
- }
-
- if( !isset($order_note_name) || empty($order_note_name) )
- {
- $order_note_name = '店名';
- }
- $open_comment_gift = D('Home/Front')->get_config_by_name('open_comment_gift');
- $open_comment_gift = !empty($open_comment_gift) ? $open_comment_gift : 0;
- $result = D('Seller/Order')->check_comment_gift_score($member_id);
- if(!$result['is_comment_gift']){
- $open_comment_gift = 0;
- }
- //预售信息数组 begin
- $presale_info = [];
- $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $order_id );
- if( $presale_result['code'] == 0 )
- {
- $presale_info = $presale_result['data'];
- }
- //end
- //礼品卡订单信息 begin
- $virtualcard_result = D('Seller/VirtualCard')->getVirtualCardOrderInfO( $order_id );
- $virtualcard_info = [];
- if( $virtualcard_result['code'] == 0 && $virtualcard_result['data']['state'] > 0 )
- {
- $virtualcard_info = $virtualcard_result['data'];
- }
- //end
- echo json_encode(
- array(
- 'code' => 0,
- 'data' => $need_data,
- 'order_note_open' => $order_note_open,
- 'order_note_name' => $order_note_name,
- 'pingtai_deal' => $pingtai_deal,
- 'order_refund' => $order_refund,
- 'order_can_shen_refund' => $order_can_shen_refund,
- 'order_can_del_cancle' => $order_can_del_cancle,
- 'order_pay_after_share' => $order_pay_after_share,
- 'is_hidden_orderlist_phone' => $is_hidden_orderlist_phone,
- 'is_show_guess_like' => $is_show_guess_like,
- 'user_service_switch' => $user_service_switch,
- 'open_comment_gift' => $open_comment_gift,
- 'common_header_backgroundimage' => $common_header_backgroundimage,
- 'presale_info' => $presale_info,//预售信息
- 'virtualcard_info' => $virtualcard_info,//礼品卡信息
- )
- );
-
- }
-
- public function sign_dan_order()
- {
- $gpc = I('request.');
-
- $token = $gpc['token'];
- $order_id = $gpc['order_id'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- $member_id = $weprogram_token['member_id'];
-
-
- $community_info = D('Home/Front')->get_member_community_info($member_id);
-
- $order_info = M('lionfish_comshop_order')->where( array('head_id' => $community_info['id'],'order_id' => $order_id) )->find();
-
- if(!empty($order_info) && $order_info['order_status_id'] == 14)
- {
- $oh = array();
- $oh['order_id']=$order_id;
- $oh['order_status_id']= 4;
-
- $oh['comment']='团长签收货物';
- $oh['date_added']=time();
- $oh['notify']= $order_info['order_status_id'];
-
- M('lionfish_comshop_order_history')->add( $oh );
-
- //更改订单为已发货
- D('Home/Frontorder')->send_order_operate($order_id);
- echo json_encode( array('code' => 0) );
- }else{
- echo json_encode( array('code' => 1) );
- }
-
-
- }
-
- public function order_commission()
- {
- $gpc = I('request.');
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
- $member_id = $weprogram_token['member_id'];
-
- if( empty($member_id) )
- {
- echo json_encode( array('code' => 1) );
- die();
- }
-
- $community_info = D('Home/Front')->get_member_community_info($member_id);
- $head_id = $community_info['id'];
-
- $choose_date = $gpc['chooseDate'];
-
- $choose_date = str_replace('年','-', $choose_date);
- $choose_date = str_replace('月','-', $choose_date);
- $choose_date = $choose_date.'01 00:00:00';
-
- $BeginDate=date('Y-m-d', strtotime($choose_date));
-
- $end_date = date('Y-m-d', strtotime("$BeginDate +1 month -1 day")).' 23:59:59';
-
- $begin_time = strtotime($BeginDate.' 00:00:00');
- $end_time = strtotime($end_date);
-
- $where = " and addtime >= {$begin_time} and addtime < {$end_time} ";
-
- $money = M('lionfish_community_head_commiss_order')->where("head_id={$head_id} and state=0 {$where}")->sum('money');
- if( empty($money))
- {
- $money = 0;
- }
- echo json_encode( array('code' => 0, 'money' => $money) );
- die();
-
-
-
- }
-
- public function refundorderlist()
- {
- $gpc = I('request.');
-
- $is_tuanz = isset($gpc['is_tuanz']) ? $gpc['is_tuanz'] :0;
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- $member_id = $weprogram_token['member_id'];
-
-
-
- $page = isset($gpc['page']) ? $gpc['page']:'1';
-
- $size = isset($gpc['size']) ? $gpc['size']:'6';
- $offset = ($page - 1)* $size;
-
- $type = isset($gpc['type']) ? $gpc['type']:'';
-
-
- $where = ' and o.member_id = '.$member_id;
-
- $fields = " orf.state as refund_state ,orf.order_goods_id as r_order_goods_id, ";
-
- $currentTab = isset($gpc['currentTab']) ? $gpc['currentTab']:0;
-
-
- if($currentTab == 0)
- {
-
- }else if($currentTab == 1){
- //售后
- $where .= ' and o.order_status_id = 12 ';
- }else if($currentTab == 2){
- $where .= ' and orf.state =3 ';
- }else if($currentTab == 3)
- {
- $where .= ' and orf.state =1 ';
- }
-
- $sql = "select orf.ref_id,orf.state,orf.order_goods_id,o.order_id,o.order_num_alias,o.date_added,o.delivery,o.is_pin,{$fields} o.is_zhuli,o.shipping_fare,o.shipping_tel,o.shipping_name,o.voucher_credit,o.fullreduction_money,o.store_id,o.total,o.order_status_id,o.lottery_win,o.type from ".C('DB_PREFIX')."lionfish_comshop_order_refund as orf left join " .C('DB_PREFIX')."lionfish_comshop_order as o on orf.order_id = o.order_id
- where 1 {$where}
- order by orf.addtime desc limit {$offset},{$size}";
-
- $list = M()->query($sql);
-
- $lionfish_comshop_order_status_list = M('lionfish_comshop_order_status')->select();
-
- $url = D('Home/Front')->get_config_by_name('shop_domain');
-
- $status_arr = array();
-
- foreach( $lionfish_comshop_order_status_list as $kk => $val )
- {
- $status_arr[ $val['order_status_id'] ] = $val['name'];
- }
-
- //createTime
- foreach($list as $key => $val)
- {
-
- $val['createTime'] = date('Y-m-d H:i:s', $val['date_added']);
-
- switch( $val['state'] )
- {
- case 0:
- $val['status_name'] = '申请中';
- break;
- case 1:
- $val['status_name'] = '商家拒绝';
- break;
- case 2:
-
- break;
- case 3:
- $val['status_name'] = '退款成功';
- break;
- case 4:
- $val['status_name'] = '退款失败';
- break;
- case 5:
- $val['status_name'] = '撤销申请';
- break;
- }
-
-
- if($val['shipping_fare']<=0.001 || $val['delivery'] == 'pickup')
- {
- $val['shipping_fare'] = '免运费';
- }else{
- $val['shipping_fare'] = ''.$val['shipping_fare'];
- }
-
-
- if($val['order_status_id'] == 10)
- {
- $val['status_name'] = '等待退款';
- }
- else if($val['order_status_id'] == 4 && $val['delivery'] =='pickup')
- {
- //delivery 6
- $val['status_name'] = '待自提';
- //已自提
- }
- else if($val['order_status_id'] == 6 && $val['delivery'] =='pickup')
- {
- //delivery 6
- $val['status_name'] = '已自提';
- //已自提
- }
- else if($val['order_status_id'] == 1 && $val['type'] == 'lottery')
- {
- //等待开奖
- //一等奖
- if($val['lottery_win'] == 1)
- {
- $val['status_name'] = '一等奖';
- }else {
- $val['status_name'] = '等待开奖';
- }
- }
- else if($val['order_status_id'] == 2 && $val['type'] == 'lottery')
- {
- //等待开奖
- $val['status_name'] = '等待开奖';
- }
-
- $quantity = 0;
-
- if( $val['order_goods_id'] > 0 )
- {
- $goods_sql = "select order_goods_id,head_disc,member_disc,level_name,goods_id,is_pin,shipping_fare,name,goods_images,quantity,price,total,rela_goodsoption_valueid
- from ".C('DB_PREFIX')."lionfish_comshop_order_goods where order_goods_id=".$val['order_goods_id']." and order_id= ".$val['order_id']."";
-
- }else{
- $goods_sql = "select order_goods_id,head_disc,member_disc,level_name,goods_id,is_pin,shipping_fare,name,goods_images,quantity,price,total,rela_goodsoption_valueid
- from ".C('DB_PREFIX')."lionfish_comshop_order_goods where order_id= ".$val['order_id']."";
-
- }
-
-
- $goods_list = M()->query($goods_sql); //M()->query($goods_sql);
- $total_commision = 0;
- if($val['delivery'] =='tuanz_send')
- {
- $total_commision += $val['shipping_fare'];
- }
-
- foreach($goods_list as $kk => $vv)
- {
- //commision
-
- $order_option_list = M('lionfish_comshop_order_option')->where( array('order_goods_id' =>$vv['order_goods_id'] ) )->select();
-
-
- if( !empty($vv['goods_images']))
- {
-
- $goods_images = $url. '/'.resize($vv['goods_images'],400,400);
- if(is_array($goods_images))
- {
- $vv['goods_images'] = $vv['goods_images'];
- }else{
- $vv['goods_images']= $url.'/'.resize($vv['goods_images'],400,400) ;
- }
-
- }else{
- $vv['goods_images']= '';
- }
-
-
- $goods_filed = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $vv['goods_id'] ) )->find();
-
- $vv['orign_price'] = $goods_filed['price'];
- $quantity += $vv['quantity'];
- foreach($order_option_list as $option)
- {
- $vv['option_str'][] = $option['value'];
- }
- if( !isset($vv['option_str']) )
- {
- $vv['option_str'] = '';
- }else{
- $vv['option_str'] = implode(',', $vv['option_str']);
- }
- // $vv['price'] = round($vv['price'],2);
- $vv['price'] = sprintf("%.2f",$vv['price']);
- $vv['orign_price'] = sprintf("%.2f",$vv['orign_price']);
- $vv['total'] = sprintf("%.2f",$vv['total']);
-
-
- $goods_list[$kk] = $vv;
- }
- $val['total_commision'] = $total_commision;
- $val['quantity'] = $quantity;
- if( empty($val['store_id']) )
- {
- $val['store_id'] = 1;
- }
-
-
- $store_info = array('s_true_name' =>'','s_logo' => '');
-
- $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
-
- $store_info['s_logo'] = D('Home/Front')->get_config_by_name('shoplogo');
-
-
-
- if( !empty($store_info['s_logo']))
- {
- $store_info['s_logo'] = tomedia($store_info['s_logo']);
- }else{
-
- $store_info['s_logo'] = '';
- }
-
-
- $order_goods['store_info'] = $store_info;
-
- $val['store_info'] = $store_info;
-
- $val['goods_list'] = $goods_list;
-
- $val['total'] = $val['total'] + $val['shipping_fare']-$val['voucher_credit']-$val['fullreduction_money'];
- if($val['total'] < 0)
- {
- $val['total'] = 0;
- }
-
- $val['total'] = sprintf("%.2f",$val['total']);
- $list[$key] = $val;
- }
-
- $need_data = array('code' => 0);
-
- if( !empty($list) )
- {
- $need_data['data'] = $list;
-
- }else {
- $need_data = array('code' => 1);
- }
-
- echo json_encode( $need_data );
- die();
-
- }
-
-
-
- public function orderlist()
- {
- $gpc = I('request.');
- $_GPC = $gpc;
-
- $is_tuanz = isset($gpc['is_tuanz']) ? $gpc['is_tuanz'] :0;
- $is_supply = isset($gpc['is_supply']) ? $gpc['is_supply'] :0;
-
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- $member_id = $weprogram_token['member_id'];
-
- $sqlcondition = "";
- $left_join = "";
-
- $page = isset($gpc['page']) ? $gpc['page']:'1';
-
- $size = isset($gpc['size']) ? $gpc['size']:'6';
- $offset = ($page - 1)* $size;
-
- $type = isset($gpc['type']) ? $gpc['type']:'';
-
- $order_status = isset($gpc['order_status']) ? $gpc['order_status']:'-1';
-
-
- $soli_id = isset($_GPC['soli_id']) ? $_GPC['soli_id'] : 0;//是否群接龙
-
- if($is_tuanz == 1)
- {
- $community_info = D('Home/Front')->get_member_community_info($member_id);
-
- if( isset($_GPC['chooseDate']) && !empty($_GPC['chooseDate']) )
- {
- $where = ' and o.head_id = '.$community_info['id'] ;
- }else{
- //$where = ' and o.head_id = '.$community_info['id'].' and o.delivery != "express" ';
- $where = ' and o.head_id = '.$community_info['id'].' ';
- }
-
- $searchfield = isset($_GPC['searchfield']) && !empty($_GPC['searchfield']) ? $_GPC['searchfield'] : '';
-
- if( !empty($searchfield) && !empty($_GPC['keyword']))
- {
- $keyword = $_GPC['keyword'];
-
- switch($searchfield)
- {
- case 'ordersn':
- $where .= ' AND locate("'.$keyword.'",o.order_num_alias)>0';
- break;
- case 'member':
- $where .= ' AND (locate("'.$keyword.'",m.username)>0 or "'.$keyword.'"=o.member_id )';
- $left_join .= ' left join ' . C('DB_PREFIX'). 'lionfish_comshop_member as m on m.member_id = o.member_id ';
- break;
- case 'address':
- $where .= ' AND ( locate("'.$keyword.'",o.shipping_name)>0 )';
-
- break;
- case 'mobile':
- $where .= ' AND ( locate("'.$keyword.'",o.shipping_tel)>0 )';
-
- break;
- case 'location':
- $where .= ' AND (locate("'.$keyword.'",o.shipping_address)>0 )';
- break;
- case 'shipping_no':
- $where .= ' AND (locate("'.$keyword.'",o.shipping_no)>0 )';
- break;
- case 'goodstitle':
- $left_join = ' inner join ( select DISTINCT(og.order_id) from ' . C('DB_PREFIX') . 'lionfish_comshop_order_goods as og where (locate("'.$keyword.'",og.name)>0)) gs on gs.order_id=o.order_id';
-
- break;
- case 'trans_id':
- $where .= ' AND (locate("'.$keyword.'",o.transaction_id)>0 )';
- break;
-
- }
- }
-
- }
- else if( $is_supply == 1 )
- {
- $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 )
- {
- $keyword = $_GPC['keyword'];
-
- if( !empty($keyword) )
- {
- $left_join = ' inner join ( select DISTINCT(og.order_id) from ' . C('DB_PREFIX') . 'lionfish_comshop_order_goods as og where (locate("'.$keyword.'",og.name)>0) and og.supply_id = '.$supply_info['id'].' ) gs on gs.order_id=o.order_id';
- }else{
- $left_join = ' inner join ( select DISTINCT(og.order_id) from ' . C('DB_PREFIX') . 'lionfish_comshop_order_goods as og where og.supply_id = '.$supply_info['id'].' ) gs on gs.order_id=o.order_id';
- }
- //$where = " and o.delivery != 'hexiao'";
-
- }else{
-
- echo json_encode( array('code' => 2, 'msg' => '未开启此项功能') );
- die();
- }
- }
- else{
- $where = ' and o.member_id = '.$member_id;
- }
-
- if( isset($gpc['chooseDate']) && !empty($gpc['chooseDate']) )
- {
- $choose_date = $gpc['chooseDate'];
-
- $choose_date = str_replace('年','-', $choose_date);
- $choose_date = str_replace('月','-', $choose_date);
- $choose_date = $choose_date.'01 00:00:00';
-
- $BeginDate=date('Y-m-d', strtotime($choose_date));
-
- $end_date = date('Y-m-d', strtotime("$BeginDate +1 month -1 day")).' 23:59:59';
-
- $begin_time = strtotime($BeginDate.' 00:00:00');
- $end_time = strtotime($end_date);
-
-
- $where .= ' and o.date_added >= '.$begin_time.' and o.date_added < '.$end_time;
- }
-
- //全部 -1 待付款 3 待配送1 待提货4 已提货6
- //order_status $order_status
- $join = "";
- $fields = "";
-
- switch($order_status)
- {
- case -1:
- //全部 -1
-
- break;
- case 3:
- //待付款 3
- $where .= ' and o.order_status_id = 3 ';
- break;
- case 1:
- //待配送1
- $where .= ' and o.order_status_id = 1 ';
-
- break;
- case 4:
- //待提货4
- $where .= ' and o.order_status_id = 4 ';
- break;
- case 14:
- //待提货4
- $where .= ' and o.order_status_id = 14 ';
- break;
-
- case 22:
- //待确认佣金的
- $where .= ' and o.order_status_id in (1,4,14) ';
- break;
- case 357:
- //待确认佣金的
- $where .= ' and o.order_status_id in (3,5,7) ';
- break;
- case 6:
- //已提货6
- $where .= ' and o.order_status_id in (6,11) ';
- break;
- case 11:
- //已完成
- $where .= ' and o.order_status_id = 11 ';
- break;
- case 12:
- $fields = " orf.state as refund_state , ";
-
- $currentTab = isset($gpc['currentTab']) ? $gpc['currentTab']:0;
-
- $join = " ".C('DB_PREFIX').'lionfish_comshop_order_refund as orf, ';
- $where .= ' and o.order_id = orf.order_id ';
- if($currentTab == 0)
- {
-
- }else if($currentTab == 1){
- //售后
- $where .= ' and o.order_status_id = 12 ';
- }else if($currentTab == 2){
- $where .= ' and orf.state =3 ';
- }else if($currentTab == 3)
- {
- $where .= ' and orf.state =1 ';
- }
-
- break;
- case 7:
- //已退款
- $where .= ' and o.order_status_id = 7 ';
- break;
- }
-
- $where .= ' and o.type != "ignore" ';
-
- if( isset($soli_id) && $soli_id > 0 )
- {
- $where .= " and o.soli_id = {$soli_id} ";
- }
-
-
- if( !empty($type) )
- {
- //$where .= ' and o.type != "ignore" ';
- }
-
- $sql = "select o.order_id,o.order_num_alias,o.date_added,o.delivery,o.is_pin,{$fields} o.is_zhuli,o.packing_fare,o.shipping_fare,o.shipping_tel,o.shipping_name,o.voucher_credit,o.score_for_money,o.fullreduction_money,o.store_id,o.total,o.order_status_id,o.lottery_win,o.type,os.name as status_name,o.ziti_mobile,o.localtown_add_shipping_fare,o.fare_shipping_free,o.third_distribution_type,o.payment_code "
- . " from ".C('DB_PREFIX')."lionfish_comshop_order as o {$left_join}, {$join}
- ".C('DB_PREFIX')."lionfish_comshop_order_status as os ".$sqlcondition."
- where o.order_status_id = os.order_status_id {$where}
- order by o.date_added desc limit {$offset},{$size}";
- $list = M()->query($sql);
-
- $open_auto_delete = D('Home/Front')->get_config_by_name('open_auto_delete');
-
- $cancle_hour = D('Home/Front')->get_config_by_name('auto_cancle_order_time');
- $cancle_hour_time = time() - 3600 * $cancle_hour;
-
-
- $url = D('Home/Front')->get_config_by_name('shop_domain');
- //createTime
- foreach($list as $key => $val)
- {
-
- //判断是否需要取消订单
- //order_status_id 3 open_auto_delete
-
- if($open_auto_delete == 1 && $val['order_status_id'] == 3 && $val['date_added'] < $cancle_hour_time )
- {
- D('Home/Frontorder')->cancel_order($val['order_id'], true);
-
- $val['order_status_id'] == 5;
- }
- $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $val['order_id'] );
- if( $presale_result['code'] == 0 )
- {
- $val['is_presale'] = 1;
- }else{
- $val['is_presale'] = 0;
- }
-
-
- if($val['delivery'] == 'pickup')
- {
- //$val['total'] = round($val['total'],2) - round($val['voucher_credit'],2);
- }else{
- //$val['total'] = round($val['total'],2)+round($val['shipping_fare'],2) - round($val['voucher_credit'],2);
- }
- $val['createTime'] = date('Y-m-d H:i:s', $val['date_added']);
-
- // $val['delivery'] =='pickup'
-
- if($val['shipping_fare']<=0.001 || $val['delivery'] == 'pickup')
- {
- $val['shipping_fare'] = 0.00;
- }else{
- $val['shipping_fare'] = ''.$val['shipping_fare'];
- }
-
-
- if($val['order_status_id'] == 10)
- {
- $val['status_name'] = '等待退款';
- }
- else if($val['order_status_id'] == 4 && $val['delivery'] =='pickup')
- {
- //delivery 6
- $val['status_name'] = '待自提';
- //已自提
- }
- else if($val['order_status_id'] == 6 && $val['delivery'] =='pickup')
- {
- //delivery 6
- $val['status_name'] = '已自提';
- //已自提
- }
- else if($val['order_status_id'] == 1 && $val['type'] == 'lottery')
- {
- //等待开奖
- //一等奖
- if($val['lottery_win'] == 1)
- {
- $val['status_name'] = '一等奖';
- }else {
- $val['status_name'] = '等待开奖';
- }
- }
- else if($val['order_status_id'] == 2 && $val['type'] == 'lottery')
- {
- //等待开奖
- $val['status_name'] = '等待开奖';
- }
-
- $quantity = 0;
-
-
- $goods_list = M('lionfish_comshop_order_goods')->field('order_id,order_goods_id,head_disc,member_disc,level_name,goods_id,is_pin,shipping_fare,name,goods_images,quantity,price,total,old_total,fullreduction_money,voucher_credit,rela_goodsoption_valueid,is_refund_state,has_refund_money,has_refund_quantity')->where( array('order_id' => $val['order_id']) )->select();
-
- $total_commision = 0;
- if($val['delivery'] =='tuanz_send')
- {
- $total_commision += $val['shipping_fare'];
- }
-
-
- foreach($goods_list as $kk => $vv)
- {
- //commision
-
- if($is_tuanz == 1){
-
-
- $community_order_info = M('lionfish_community_head_commiss_order')->where( array('head_id' => $community_info['id'],'order_goods_id' => $vv['order_goods_id']) )->find();
-
-
- if(!empty($community_order_info))
- {
- $vv['commision'] = $community_order_info['money']-$community_order_info['add_shipping_fare'];
- $vv['commision'] = sprintf("%.2f",$vv['commision']);
- if($community_order_info['state'] == 2){
- $vv['commision'] = 0;
- }
- $total_commision += $vv['commision'];
- }else{
- $vv['commision'] = "0.00";
- }
- $vv['head_shipping_fare'] = $community_order_info['add_shipping_fare'];//团长配送费
-
-
- $vv['old_commision'] = $vv['commision'];
- $vv['del_commision'] = 0;
-
- //fen_type
- $vv['fen_type'] = $community_order_info['fen_type'];// 0 按照比例, 1按照金额
- $vv['fen_bili'] = $community_order_info['bili'];//比例
- $vv['fen_gumoney'] = $community_order_info['bili'];//按照金额
-
- $order_jishu = $vv['total'] -$vv['fullreduction_money']-$vv['voucher_credit']-$vv['has_refund_money'];
-
- $vv['order_jishu'] = $order_jishu;//有效金额:(基数)
-
- //has_refund_commission = 0
- $order_goods_refund_list = M('lionfish_comshop_order_goods_refund')->where( array('order_id' => $val['order_id'],'order_goods_id' => $vv['order_goods_id'] ) )->select();
-
-
- if( !empty($order_goods_refund_list) )
- {
- $kvbal_total_back_head_orderbuycommiss = 0;//合计退掉佣金
-
- foreach( $order_goods_refund_list as $kvval )
- {
- $kvbal_total_back_head_orderbuycommiss += $kvval['back_head_orderbuycommiss'];
- }
- $vv['del_commision'] = $kvbal_total_back_head_orderbuycommiss;
-
- $vv['old_commision'] += $vv['del_commision'];
- }
-
-
- }
-
- $order_option_list = M('lionfish_comshop_order_option')->where( array('order_goods_id' => $vv['order_goods_id']) )->select();
-
- if( !empty($vv['goods_images']))
- {
-
- $goods_images = $url. '/'.resize($vv['goods_images'],400,400);
- if(is_array($goods_images))
- {
- $vv['goods_images'] = $vv['goods_images'];
- }else{
- $vv['goods_images']= $url.'/'.resize($vv['goods_images'],400,400) ;
- }
-
- }else{
- $vv['goods_images']= '';
- }
-
-
- $goods_filed = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $vv['goods_id']) )->find();
-
- $vv['orign_price'] = $goods_filed['price'];
- $quantity += $vv['quantity'];
- foreach($order_option_list as $option)
- {
- $vv['option_str'][] = $option['value'];
- }
- if( !isset($vv['option_str']) )
- {
- $vv['option_str'] = '';
- }else{
- $vv['option_str'] = implode(',', $vv['option_str']);
- }
-
- // $vv['price'] = round($vv['price'],2);
- $vv['price'] = sprintf("%.2f",$vv['price']);
- $vv['orign_price'] = sprintf("%.2f",$vv['orign_price']);
- //$vv['total'] = sprintf("%.2f",$vv['total']);
- $vv['total'] = sprintf("%.2f",$vv['old_total']);
- if( $vv['is_refund_state'] == 1 || ($vv['has_refund_money'] > 0 && $vv['has_refund_quantity'] > 0) )
- {
- $vv['is_refund_state'] = 1;
- $where = " order_id = '".$vv['order_id']."' and order_goods_id = '".$vv['order_goods_id']."' and state in (0,2,3) ";
- $refund_info = M('lionfish_comshop_order_refund')->field('ref_id,order_id,ref_money,real_refund_quantity,state')->where( $where )->find();
- if(!empty($refund_info)){
- $vv['refund_info'] = $refund_info;
- }else{
- $refund_info = array();
- $refund_info['order_id'] = $val['order_id'];
- $refund_info['ref_money'] = $vv['has_refund_money'];
- $refund_info['real_refund_quantity'] = $vv['has_refund_quantity'];
- $refund_info['state'] = 3;
- $vv['refund_info'] = $refund_info;
- }
- }
- $goods_list[$kk] = $vv;
- }
-
- $val['total_commision'] = $total_commision;
- $val['quantity'] = $quantity;
- if( empty($val['store_id']) )
- {
- $val['store_id'] = 1;
- }
-
-
- $store_info = array('s_true_name' =>'','s_logo' => '');
-
- $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
-
- $store_info['s_logo'] = D('Home/Front')->get_config_by_name('shoplogo');
-
-
-
- if( !empty($store_info['s_logo']))
- {
- $store_info['s_logo'] = tomedia($store_info['s_logo']);
- }else{
-
- $store_info['s_logo'] = '';
- }
-
-
- $order_goods['store_info'] = $store_info;
-
-
-
-
- $val['store_info'] = $store_info;
-
-
- $val['goods_list'] = $goods_list;
-
- if($val['type'] == 'integral')
- {
- //暂时屏蔽积分
- $val['score'] = round($val['total'],2);
- }
-
- $val['total'] = $val['total'] + $val['packing_fare'] + $val['shipping_fare']-$val['voucher_credit']-$val['fullreduction_money']-$val['score_for_money']+$val['localtown_add_shipping_fare']-$val['fare_shipping_free'];
- if($val['total'] < 0)
- {
- $val['total'] = 0;
- }
-
- $val['total'] = sprintf("%.2f",$val['total']);
- if( $val['delivery'] == 'localtown_delivery' && ($val['order_status_id'] != 3 && $val['order_status_id'] != 5 ) )
- {
- $val['orderdistribution_order'] = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $val['order_id'] ) )->find();
- if( !empty($val['orderdistribution_order']) && $val['orderdistribution_order'] > 0 )
- {
- $orderdistribution = M('lionfish_comshop_orderdistribution')->where( array('id' => $val['orderdistribution_order']['orderdistribution_id'] ) )->find();
- $val['orderdistribution_order']['username'] = $orderdistribution['username'];
- }
- }
- $list[$key] = $val;
- }
-
- $need_data = array('code' => 0);
-
- if( !empty($list) )
- {
- $need_data['data'] = $list;
-
- }else {
- $need_data = array('code' => 1);
- }
-
-
- $open_aftersale = D('Home/Front')->get_config_by_name('open_aftersale');
-
- if( empty($open_aftersale) )
- {
- $open_aftersale = 0;
- }
-
- $open_aftersale_time = D('Home/Front')->get_config_by_name('open_aftersale_time');
- if( empty($open_aftersale_time) )
- {
- $open_aftersale_time = 0;
- }
-
- $need_data['open_aftersale'] = $open_aftersale;
- $need_data['open_aftersale_time'] = $open_aftersale_time;
-
-
- echo json_encode( $need_data );
- die();
-
- }
-
- function receive_order_list()
- {
- $gpc = I('request.');
-
-
-
- $order_data = $gpc['order_data'];
- $token = $gpc['token'];
-
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- $member_id = $weprogram_token['member_id'];
-
- $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->find();
-
- if( empty($member_info) )
- {
- echo json_encode( array('code' => 1) );
- die();
- }
-
- $community_info = D('Home/Front')->get_member_community_info($member_id);
-
- $is_member_hexiao = false;
- if( empty($community_info) && $member_info['pickup_id'] > 0 )
- {
- $parent_community_info = M('lionfish_comshop_community_pickup_member')->where( array('member_id' =>$member_id ) )->find();
-
-
- if(!empty($parent_community_info))
- {
- $is_member_hexiao = true;
- $community_info = M('lionfish_community_head')->where( array('id' => $parent_community_info['community_id'] ) )->find();
- }
- }
-
-
- if( empty($community_info) || $community_info['state'] != 1 )
- {
- echo json_encode( array('code' => 1) );
- die();
- }
- if( is_array($order_data) )
- {
- $order_data_str = implode(',', $order_data);
- }else{
- $order_data_str = $order_data;
- }
-
-
- $where = ' and o.head_id = '.$community_info['id'];
-
- $where .= ' and o.order_status_id = 4 and order_id in ('.$order_data_str.') ';
-
-
-
-
- $sql = "select o.order_id,o.order_num_alias
- from ".C('DB_PREFIX')."lionfish_comshop_order as o ,
- ".C('DB_PREFIX')."lionfish_comshop_order_status as os
- where o.order_status_id = os.order_status_id {$where}
- order by o.date_added desc ";
-
- $list = M()->query($sql);
-
- if( !empty($list) )
- {
- foreach($list as $val)
- {
- D('Home/Frontorder')->receive_order($val['order_id']);
- if($is_member_hexiao)
- {
- $pickup_member_record_data = array();
- $pickup_member_record_data['order_id'] = $val['order_id'];
- $pickup_member_record_data['order_sn'] = $val['order_num_alias'];
- $pickup_member_record_data['community_id'] = $community_info['id'];
- $pickup_member_record_data['member_id'] = $member_id;
- $pickup_member_record_data['addtime'] = time();
-
- M('lionfish_comshop_community_pickup_member_record')->add( $pickup_member_record_data );
- }
-
- }
- echo json_encode( array('code' => 0) );
- die();
- }else{
- echo json_encode( array('code' => 1) );
- die();
- }
-
- //load_model_class('frontorder')->receive_order($order_id);
-
- //string(15) "35,34,31,19,5,2"
- //string(32) "b55feabc517fa686f79c1bbd303cdeda"
-
- }
-
- function receive_order()
- {
- $gpc = I('request.');
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- $member_id = $weprogram_token['member_id'];
-
- $order_id = $gpc['order_id'];
- if( empty($member_id) )
- {
- $result['code'] = 2;
- $result['msg'] = '登录失效';
- echo json_encode($result);
- die();
- }
-
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id,'member_id' => $member_id) )->find();
-
- if(empty($order_info)){
- $result['code'] = 1;
- $result['msg'] = '非法操作,会员不存在该订单';
- echo json_encode($result);
- die();
- }
- //检查订单是否能确认收货(存在售后未完成无法确认收货)
- $result = D('Seller/Order')->check_order_receive($order_id);
- if($result['status'] == 0){
- $result['code'] = 1;
- $result['msg'] = '您的订单处于售后处理中,请完成后再确认收货!';
- echo json_encode($result);
- die();
- }
- if($order_info['delivery'] == 'localtown_delivery'){
- $result = D('Seller/Order')->check_localtown_order_receive($order_id);
- if($result['status'] == 0){
- $result['code'] = 1;
- $result['msg'] = '该订单未有配送员接单或还未指定配送员,无法确认收货!';
- echo json_encode($result);
- die();
- }
- M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id) )->save( array('state' => 4) );
- D('Home/LocaltownDelivery')->write_distribution_log( $order_id, 0 , 4 , "用户确认收货" );
- }
- D('Home/Frontorder')->receive_order($order_id);
- $result['code'] = 0;
- echo json_encode($result);
- die();
- }
-
- /**
- 取消订单操作
- **/
- public function cancel_order()
- {
-
- $gpc = I('request.');
- $token = $gpc['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- $member_id = $weprogram_token['member_id'];
-
- $order_id = $gpc['order_id'];
- if( empty($member_id) )
- {
- $result['code'] = 2;
- $result['msg'] = '登录失效';
- echo json_encode($result);
- die();
- }
-
- $order_info = M('lionfish_comshop_order')->where( array('member_id' => $member_id,'order_id' => $order_id) )->find();
-
- if(empty($order_info)){
- $result['code'] = 1;
- $result['msg'] = '非法操作,会员不存在该订单';
- echo json_encode($result);
- die();
- }
-
- //order_status_id == 3
- if($order_info['order_status_id'] != 3)
- {
- $result['code'] = 1;
- $result['msg'] = '订单可能已取消,请刷新页面';
- echo json_encode($result);
- die();
- }
- D('Home/Frontorder')->cancel_order($order_id);
-
- $result['code'] = 0;
- echo json_encode($result);
- die();
-
- }
-
- public function order_head_info()
- {
- $_GPC = I('request.');
-
- $token = $_GPC['token'];
-
- $is_share = $_GPC['is_share'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
- $member_id = $weprogram_token['member_id'];
-
-
- $order_id = $_GPC['id'];
-
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
- if($order_info['is_change_price'] == 1){
- $order_info['admin_change_price'] = $order_info['total'] - $order_info['old_price'];
- }
- $pick_up_info = array();
- $pick_order_info = array();
-
- $community_info = D('Home/Front')->get_member_community_info($member_id);
-
-
- if($is_share){
-
- $userInfo = M('lionfish_comshop_member')->field('avatar')->where( array('member_id' => $order_info['member_id'] ) )->find();
-
- $order_info['avatar'] = $userInfo['avatar'];
- }
-
- if( $order_info['delivery'] == 'pickup' )
- {
- //查询自提点
- //$pick_order_info = M('lionfish_comshop_pick_order')->where( array('order_id' => $order_id) )->find();
-
- //$pick_id = $pick_order_info['pick_id'];
-
- //$pick_up_info = M('lionfish_comshop_pick_up')->where( array('id' => $pick_id ) )->find();
-
- }
- $order_status_info = M('lionfish_comshop_order_status')->where( array('order_status_id' => $order_info['order_status_id']) )->find();
-
- //10 name
- if($order_info['order_status_id'] == 10)
- {
- $order_status_info['name'] = '等待退款';
- }
- else if($order_info['order_status_id'] == 4 && $order_info['delivery'] =='pickup')
- {
- //delivery 6
- $order_status_info['name'] = '待自提';
- //已自提
- }
- else if($order_info['order_status_id'] == 6 && $order_info['delivery'] =='pickup')
- {
- //delivery 6
- $order_status_info['name'] = '已自提';
-
- }
- else if($order_info['order_status_id'] == 1 && $order_info['type'] == 'lottery')
- {
- //等待开奖
- //一等奖
- if($order_info['lottery_win'] == 1)
- {
- $order_status_info['name'] = '一等奖';
- }else {
- $order_status_info['name'] = '等待开奖';
- }
- }
-
- //$order_info['type']
- //open_auto_delete
-
- if($order_info['order_status_id'] == 3)
- {
- $open_auto_delete = D('Home/Front')->get_config_by_name('open_auto_delete');
-
- $auto_cancle_order_time = D('Home/Front')->get_config_by_name('auto_cancle_order_time');
-
- $order_info['open_auto_delete'] = $open_auto_delete;
- //date_added
- if($open_auto_delete == 1)
- {
- $order_info['over_buy_time'] = $order_info['date_added'] + 3600 * $auto_cancle_order_time;
- $order_info['cur_time'] = time();
- }
-
- }
-
-
-
- $shipping_province = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_province_id'] ) )->find();
-
- $shipping_city = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_city_id'] ) )->find();
-
- $shipping_country = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_country_id']) )->find();
-
- $order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->select();
-
- $shiji_total_money = 0;
- $member_youhui = 0.00;
-
-
- $pick_up_time = "";
- $pick_up_type = -1;
- $pick_up_weekday = '';
- $today_time = $order_info['pay_time'];
- $arr = array('天','一','二','三','四','五','六');
-
- foreach($order_goods_list as $key => $order_goods)
- {
- $order_goods['name'] = htmlspecialchars_decode($order_goods['name']);
- $order_option_info = M('lionfish_comshop_order_option')->field('value')->where( array('order_goods_id' => $order_goods['order_goods_id'],'order_id' => $order_id) )->select();
-
-
- foreach($order_option_info as $option)
- {
- $order_goods['option_str'][] = $option['value'];
- }
- if(empty($order_goods['option_str']))
- {
- //option_str
- $order_goods['option_str'] = '';
- }else{
- $order_goods['option_str'] = implode(',', $order_goods['option_str']);
- }
- //
- $order_goods['shipping_fare'] = round($order_goods['shipping_fare'],2);
- //$order_goods['price'] = round($order_goods['price'],2);
- $order_goods['price'] = round($order_goods['price'],2);
- $order_goods['total'] = round($order_goods['total'],2);
- $order_goods['old_total'] = round($order_goods['old_total'],2);
-
- if( $order_goods['is_vipcard_buy'] == 1 || $order_goods['is_level_buy'] ==1 )
- {
- $order_goods['price'] = round($order_goods['oldprice'],2);
- }
- $order_goods['real_total'] = round($order_goods['quantity'] * $order_goods['price'],2);
-
-
- $community_order_info = M('lionfish_community_head_commiss_order')->where( array('head_id' => $community_info['id'],'order_goods_id' => $order_goods['order_goods_id']) )->find();
-
- if(!empty($community_order_info))
- {
- $order_goods['commision'] = $community_order_info['money']-$community_order_info['add_shipping_fare'];
- if($community_order_info['state'] == 2){
- $order_goods['commision'] = 0;
- }
- }else{
- $order_goods['commision'] = 0;
- }
-
-
- $order_goods['old_commision'] = $order_goods['commision'];
- $order_goods['del_commision'] = 0;
-
- $order_goods['statements_end_date'] = date('Y-m-d H:i:s', $order_goods['statements_end_time']);
-
- //has_refund_commission = 0
-
- $order_goods_refund_list = M('lionfish_comshop_order_goods_refund')->where( "order_id={$order_id} and order_goods_id=".$order_goods['order_goods_id'] )->select();
-
- $refund_shipping_fare = 0;//退配送费
- if( !empty($order_goods_refund_list) )
- {
- $kvbal_total_back_head_orderbuycommiss = 0;//合计退掉佣金
-
- foreach( $order_goods_refund_list as $kvval )
- {
- $kvbal_total_back_head_orderbuycommiss += $kvval['back_head_orderbuycommiss'];
- $refund_shipping_fare += $kvval['refund_shipping_fare'];
- }
- $order_goods['del_commision'] = $kvbal_total_back_head_orderbuycommiss;
-
- $order_goods['old_commision'] += $order_goods['del_commision'];
- }
- //fen_type
- $order_goods['fen_type'] = $community_order_info['fen_type'];// 0 按照比例, 1按照金额
- $order_goods['fen_bili'] = $community_order_info['bili'];//比例
- $order_goods['fen_gumoney'] = $community_order_info['bili'];//按照金额
-
- $order_jishu = $order_goods['total'] -$order_goods['fullreduction_money']-$order_goods['voucher_credit']-$order_goods['has_refund_money'];
-
- $order_goods['order_jishu'] = $order_jishu;//有效金额:(基数)
-
- $order_goods['head_shipping_fare'] = $community_order_info['add_shipping_fare'];//团长配送费
-
-
-
- /**
- $goods_images = file_image_thumb_resize($vv['goods_images'],400);
- if(is_array($goods_images))
- {
- $vv['goods_images'] = $vv['goods_images'];
- }else{
- $vv['goods_images']= tomedia( file_image_thumb_resize($vv['goods_images'],400) );
- }
-
- **/
- $goods_images = $order_goods['goods_images'];
-
- if( !is_array($goods_images) )
- {
- $order_goods['image']= tomedia( $goods_images );
- $order_goods['goods_images']= tomedia( $goods_images );
- }else{
- $order_goods['image']= $order_goods['goods_images'];
- }
-
- $order_goods['hascomment'] = 0;
-
- $order_goods_comment_info = M('lionfish_comshop_order_comment')->field('comment_id')->where( array('goods_id' => $order_goods['goods_id'],'order_id' => $order_id) )->find();
-
- if( !empty($order_goods_comment_info) )
- {
- $order_goods['hascomment'] = 1;
- }
-
- //ims_
-
- $goods_info = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $order_goods['goods_id']) )->find();
-
- $goods_cm_info = M('lionfish_comshop_good_common')->field('pick_up_type,pick_up_modify')->where( array('goods_id' => $order_goods['goods_id']) )->find();
-
- if($pick_up_type == -1 || $goods_cm_info['pick_up_type'] > $pick_up_type)
- {
- $pick_up_type = $goods_cm_info['pick_up_type'];
-
- if($pick_up_type == 0)
- {
- $pick_up_time = date('m-d', $today_time);
- //$pick_up_weekday = '周'.$arr[date('w',$today_time)];
- }else if( $pick_up_type == 1 ){
- $pick_up_time = date('m-d', $today_time+86400);
- //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400)];
- }else if( $pick_up_type == 2 )
- {
- $pick_up_time = date('m-d', $today_time+86400*2);
- //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400*2)];
- }else if($pick_up_type == 3)
- {
- $pick_up_time = $goods_cm_info['pick_up_modify'];
- }
- }
-
- $order_goods['shop_price'] = $goods_info['price'];
-
-
- $store_info = array('s_true_name' =>'','s_logo' => '');
-
- $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
-
- if( !empty($store_info['s_logo']) )
- {
- $store_info['s_logo'] = tomedia($store_info['s_logo']);
- }else{
- $store_info['s_logo'] = '';
- }
- if( $order_goods['is_refund_state'] == 1 || ($order_goods['has_refund_money'] > 0 && $order_goods['has_refund_quantity'] > 0) )
- {
- $order_goods['is_refund_state'] = 1;
- $where = " order_id = '".$order_goods['order_id']."' and order_goods_id = '".$order_goods['order_goods_id']."' and state in (0,2,3) ";
- $refund_info = M('lionfish_comshop_order_refund')->field('ref_id,order_id,ref_money,real_refund_quantity,state')->where( $where )->find();
- if(!empty($refund_info)){
- $order_goods['refund_info'] = $refund_info;
- }else{
- $refund_info = array();
- $refund_info['order_id'] = $order_goods['order_id'];
- $refund_info['ref_money'] = $order_goods['has_refund_money'];
- $refund_info['real_refund_quantity'] = $order_goods['has_refund_quantity'];
- $refund_info['state'] = 3;
- $order_goods['refund_info'] = $refund_info;
- }
- }
-
-
- $order_goods['store_info'] = $store_info;
-
- unset($order_goods['model']);
- unset($order_goods['rela_goodsoption_valueid']);
- unset($order_goods['comment']);
-
- $order_goods_list[$key] = $order_goods;
- $shiji_total_money += $order_goods['quantity'] * $order_goods['price'];
-
- $member_youhui += ($order_goods['real_total'] - $order_goods['total']);
- }
-
- unset($order_info['store_id']);
- unset($order_info['email']);
- unset($order_info['shipping_city_id']);
- unset($order_info['shipping_country_id']);
- unset($order_info['shipping_province_id']);
- //unset($order_info['comment']);
- unset($order_info['voucher_id']);
- unset($order_info['is_balance']);
- unset($order_info['lottery_win']);
- unset($order_info['ip']);
- unset($order_info['ip_region']);
- unset($order_info['user_agent']);
-
-
-
- $order_info['shipping_fare'] = round($order_info['shipping_fare'],2) < 0.01 ? '0.00':round($order_info['shipping_fare'],2) ;
- $order_info['voucher_credit'] = round($order_info['voucher_credit'],2) < 0.01 ? '0.00':round($order_info['voucher_credit'],2) ;
- $order_info['fullreduction_money'] = round($order_info['fullreduction_money'],2) < 0.01 ? '0.00':round($order_info['fullreduction_money'],2) ;
-
-
- $order_info['total'] = round($order_info['total'],2)< 0.01 ? '0.00':round($order_info['total']+$order_info['shipping_fare']-$order_info['voucher_credit']-$order_info['fullreduction_money']+$order_info['localtown_add_shipping_fare']+$order_info['packing_fare'],2)-$order_info['fare_shipping_free'] ;
-
- if($order_info['total'] < 0)
- {
- $order_info['total'] = '0.00';
- }
-
-
- $order_info['total'] = round($order_info['total'],2)< 0.01 ? '0.00':round($order_info['total'],2) ;
- $order_info['real_total'] = round($shiji_total_money,2)+$order_info['shipping_fare'];
- $order_info['price'] = round($order_info['price'],2);
- $order_info['member_youhui'] = round($member_youhui,2) < 0.01 ? '0.00':round($member_youhui,2);
- $order_info['pick_up_time'] = $pick_up_time;
-
-
- $order_info['shipping_fare'] = sprintf("%.2f",$order_info['shipping_fare']);
- $order_info['voucher_credit'] = sprintf("%.2f",$order_info['voucher_credit']);
- $order_info['fullreduction_money'] = sprintf("%.2f",$order_info['fullreduction_money']);
- $order_info['total'] = sprintf("%.2f",$order_info['total']);
- $order_info['real_total'] = sprintf("%.2f",$order_info['real_total']);
- $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
- $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
- if( !isset($order_note_open) || $order_note_open == 0)
- {
- $order_note_open = 0;
- }
- if( !isset($order_note_name) || empty($order_note_name) )
- {
- $order_note_name = '店名';
- }
- $order_info['order_note_open'] = $order_note_open;
- $order_info['order_note_name'] = $order_note_name;
- $order_info['note_content'] = $order_info['note_content']!='null' ? $order_info['note_content'] : '';
-
-
- $order_info['date_added'] = date('Y-m-d H:i:s', $order_info['date_added']);
- $need_data = array();
-
- if($order_info['delivery'] =='pickup')
- {
-
-
- }else{
-
-
- }
-
- if($order_info['type'] == 'integral')
- {
- //暂时屏蔽积分商城
- //$integral_order = M('integral_order')->field('score')->where( array('order_id' => $order_id) )->find();
- //$need_data['score'] = intval($integral_order['score']);
-
- }
- if( !empty($order_info['pay_time']) && $order_info['pay_time'] >0 )
- {
- $order_info['pay_date'] = date('Y-m-d H:i:s', $order_info['pay_time']);
- }else{
- $order_info['pay_date'] = '';
- }
-
- $order_info['express_tuanz_date'] = empty($order_info['express_tuanz_time']) ? '' : date('Y-m-d H:i:s', $order_info['express_tuanz_time']);
- $order_info['receive_date'] = date('Y-m-d H:i:s', $order_info['receive_time']);
-
- if($is_share==1){ $order_info['shipping_tel'] = substr_replace($order_info['shipping_tel'],'****',3,4); }
- //货到付款订单
- if($order_info['payment_code'] == 'cashon_delivery'){
- $order_info['cashondelivery_code_img'] = D('Home/Front')->getCashonDeliveryCode();
- }
- $need_data['order_info'] = $order_info;
- $need_data['order_status_info'] = $order_status_info;
- $need_data['shipping_province'] = $shipping_province;
- $need_data['shipping_city'] = $shipping_city;
- $need_data['shipping_country'] = $shipping_country;
- $need_data['order_goods_list'] = $order_goods_list;
-
- $need_data['goods_count'] = count($order_goods_list);
-
- //$order_info['order_status_id'] 13 平台介入退款
- $order_refund_historylist = array();
- $pingtai_deal = 0;
-
- //判断是否已经平台处理完毕
-
- $order_refund_historylist = M('lionfish_comshop_order_refund_history')->where( array('order_id' => $order_id) )->order('addtime asc')->select();
-
- foreach($order_refund_historylist as $key => $val)
- {
- if($val['type'] ==3)
- {
- $pingtai_deal = 1;
- }
- }
-
- $order_refund = M('lionfish_comshop_order_refund')->where( array('order_id' => $order_id) )->find();
-
- if(!empty($order_refund))
- {
- $order_refund['addtime'] = date('Y-m-d H:i:s', $order_refund['addtime']);
- }
-
- $need_data['pick_up'] = $pick_up_info;
-
- if( empty($pick_order_info['qrcode']) && false)
- {
-
- }
-
- $need_data['pick_order_info'] = $pick_order_info;
-
- $open_aftersale = D('Home/Front')->get_config_by_name('open_aftersale');
-
- if( empty($open_aftersale) )
- {
- $open_aftersale = 0;
- }
-
- $open_aftersale_time = D('Home/Front')->get_config_by_name('open_aftersale_time');
- if( empty($open_aftersale_time) )
- {
- $open_aftersale_time = 0;
- }
-
- echo json_encode( array('code' => 0,'data' => $need_data,'pingtai_deal' => $pingtai_deal,'order_refund' => $order_refund, 'open_aftersale' => $open_aftersale, 'open_aftersale_time' => $open_aftersale_time ) );
- die();
- }
-
-
- public function order_share_info(){
-
- $_GPC = I('request.');
- $is_share = $_GPC['is_share'];
-
- $token = $_GPC['token'];
-
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
-
-
- $member_id = $weprogram_token['member_id'];
-
- $order_id = $_GPC['id'];
-
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
- if($is_share){
-
- $userInfo = M('lionfish_comshop_member')->field('avatar')->where( array('member_id' => $order_info['member_id'] ) )->find();
-
- $order_info['avatar'] = $userInfo['avatar'];
- }
-
- $pick_up_info = array();
- $pick_order_info = array();
-
- if( $order_info['delivery'] == 'pickup' )
- {
- //查询自提点
- // $pick_order_info = M('lionfish_comshop_pick_order')->where( array('order_id' => $order_id ) )->find();
-
- // $pick_id = $pick_order_info['pick_id'];
-
- // $pick_up_info = M('lionfish_comshop_pick_up')->where( array('id' => $pick_id ) )->find();
-
- }
-
- $order_status_info = M('lionfish_comshop_order_status')->where( array('order_status_id' => $order_info['order_status_id'] ) )->find();
-
- //10 name
- if($order_info['order_status_id'] == 10)
- {
- $order_status_info['name'] = '等待退款';
- }
- else if($order_info['order_status_id'] == 4 && $order_info['delivery'] =='pickup')
- {
- //delivery 6
- $order_status_info['name'] = '待自提';
- //已自提
- }
- else if($order_info['order_status_id'] == 6 && $order_info['delivery'] =='pickup')
- {
- //delivery 6
- $order_status_info['name'] = '已自提';
-
- }
- else if($order_info['order_status_id'] == 1 && $order_info['type'] == 'lottery')
- {
- //等待开奖
- //一等奖
- if($order_info['lottery_win'] == 1)
- {
- $order_status_info['name'] = '一等奖';
- }else {
- $order_status_info['name'] = '等待开奖';
- }
-
- }
-
- //$order_info['type']
- //open_auto_delete
- if($order_info['order_status_id'] == 3)
- {
- $open_auto_delete = D('Home/Front')->get_config_by_name('open_auto_delete');
- $auto_cancle_order_time = D('Home/Front')->get_config_by_name('auto_cancle_order_time');
-
- $order_info['open_auto_delete'] = $open_auto_delete;
- //date_added
- if($open_auto_delete == 1)
- {
- $order_info['over_buy_time'] = $order_info['date_added'] + 3600 * $auto_cancle_order_time;
- $order_info['cur_time'] = time();
- }
- }
-
-
- $shipping_province = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_province_id'] ) )->find();
-
- $shipping_city = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_city_id'] ) )->find();
-
- $shipping_country = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_country_id'] ) )->find();
-
- $order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->select();
-
-
- $shiji_total_money = 0;
- $member_youhui = 0.00;
-
- $pick_up_time = "";
- $pick_up_type = -1;
- $pick_up_weekday = '';
- $today_time = $order_info['pay_time'];
-
- $arr = array('天','一','二','三','四','五','六');
-
- foreach($order_goods_list as $key => $order_goods)
- {
- $order_goods['name'] = htmlspecialchars_decode($order_goods['name']);
- $order_refund_goods = M('lionfish_comshop_order_refund')->where( array('order_id' => $order_id, 'order_goods_id' => $order_goods['order_goods_id'] ) )->order('ref_id desc')->find();
-
-
- if(!empty($order_refund_goods))
- {
- $order_refund_goods['addtime'] = date('Y-m-d H:i:s', $order_refund_goods['addtime']);
- }
-
-
- $order_option_info = M('lionfish_comshop_order_option')->field('value')->where( array('order_id' => $order_id ,'order_goods_id' => $order_goods['order_goods_id'] ) )->select();
-
-
- $order_goods['order_refund_goods'] = $order_refund_goods;
-
- foreach($order_option_info as $option)
- {
- $order_goods['option_str'][] = $option['value'];
- }
- if(empty($order_goods['option_str']))
- {
- //option_str
- $order_goods['option_str'] = '';
- }else{
- $order_goods['option_str'] = implode(',', $order_goods['option_str']);
- }
- //
- $order_goods['shipping_fare'] = round($order_goods['shipping_fare'],2);
- $order_goods['price'] = round($order_goods['price'],2);
- $order_goods['total'] = round($order_goods['total'],2);
-
- if( $order_goods['is_vipcard_buy'] == 1 || $order_goods['is_level_buy'] ==1 )
- {
- $order_goods['price'] = round($order_goods['oldprice'],2);
- }
-
-
- $order_goods['real_total'] = round($order_goods['quantity'] * $order_goods['price'],2);
-
- /**
- $goods_images = file_image_thumb_resize($vv['goods_images'],400);
- if(is_array($goods_images))
- {
- $vv['goods_images'] = $vv['goods_images'];
- }else{
- $vv['goods_images']= tomedia( file_image_thumb_resize($vv['goods_images'],400) );
- }
-
- **/
- $goods_images = $order_goods['goods_images'];
-
- if( !is_array($goods_images) )
- {
- $order_goods['image']= tomedia( $goods_images );
- $order_goods['goods_images']= tomedia( $goods_images );
- }else{
- $order_goods['image']= $order_goods['goods_images'];
- }
-
- $order_goods['hascomment'] = 0;
-
- $order_goods_comment_info = M('lionfish_comshop_order_comment')->field('comment_id')->where( array('order_id' => $order_id, 'goods_id' => $order_goods['goods_id'] ) )->find();
-
- if( !empty($order_goods_comment_info) )
- {
- $order_goods['hascomment'] = 1;
- }
-
- $order_goods['can_ti_refund'] = 1;
-
- $disable_info = M('lionfish_comshop_order_refund_disable')->where( array('order_id' => $order_id, 'order_goods_id' => $order_goods['order_goods_id'] ) )->find();
-
-
- if( !empty($disable_info) )
- {
- $order_goods['can_ti_refund'] = 0;
- }
-
-
- if($order_goods['is_refund_state'] == 1)
- {
- //已经再申请退款中了。或者已经退款了。
-
- $order_refund_info = M('lionfish_comshop_order_refund')->field('state')->where( array('order_id' =>$order_id,'order_goods_id' => $order_goods['order_goods_id'] ) )->find();
-
- if( $order_refund_info['state'] == 3 )
- {
- $order_goods['is_refund_state'] = 2;
- }
-
-
- }
-
- //ims_
- $goods_info = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $order_goods['goods_id'] ) )->find();
-
- $goods_cm_info = M('lionfish_comshop_good_common')->field('pick_up_type,pick_up_modify,goods_share_image')->where( array('goods_id' => $order_goods['goods_id'] ) )->find();
-
-
- if($pick_up_type == -1 || $goods_cm_info['pick_up_type'] > $pick_up_type)
- {
- $pick_up_type = $goods_cm_info['pick_up_type'];
-
- if($pick_up_type == 0)
- {
- $pick_up_time = date('m-d', $today_time);
- //$pick_up_weekday = '周'.$arr[date('w',$today_time)];
- }else if( $pick_up_type == 1 ){
- $pick_up_time = date('m-d', $today_time+86400);
- //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400)];
- }else if( $pick_up_type == 2 )
- {
- $pick_up_time = date('m-d', $today_time+86400*2);
- //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400*2)];
- }else if($pick_up_type == 3)
- {
- $pick_up_time = $goods_cm_info['pick_up_modify'];
- }
- }
- if( !empty($goods_cm_info['goods_share_image']) )
- {
- $order_goods['goods_share_image']= tomedia( $goods_cm_info['goods_share_image'] );
- }else{
- $order_goods['goods_share_image'] = $order_goods['image'];
- }
-
- $order_goods['shop_price'] = $goods_info['price'];
-
-
- $store_info = array('s_true_name' =>'','s_logo' => '');
-
- $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
-
- //$store_info['s_logo'] = load_model_class('front')->get_config_by_name('shoplogo');
-
- if( !empty($store_info['s_logo']) )
- {
- $store_info['s_logo'] = tomedia($store_info['s_logo']);
- }else{
- $store_info['s_logo'] = '';
- }
-
-
- $order_goods['store_info'] = $store_info;
-
- unset($order_goods['model']);
- unset($order_goods['rela_goodsoption_valueid']);
- unset($order_goods['comment']);
-
- //ims_ ims_lionfish_comshop_order_goods_refund addtime
-
- $order_goods_refund_list = M('lionfish_comshop_order_goods_refund')->field('real_refund_quantity,money,addtime')->where( array('order_goods_id' =>$order_goods['order_goods_id'] ) )->order('id asc')->select();
-
- if( empty($order_goods_refund_list) )
- {
- $order_goods_refund_list = array();
- }else{
-
- foreach( $order_goods_refund_list as $kre => $rval )
- {
- $rval['addtime'] = date('Y-m-d H:i:s', $rval['addtime']);
- $order_goods_refund_list[$kre] = $rval;
- }
- }
-
- $order_goods['order_goods_refund_list'] = $order_goods_refund_list;
-
- $order_goods_list[$key] = $order_goods;
- $shiji_total_money += $order_goods['quantity'] * $order_goods['price'];
-
- $member_youhui += ($order_goods['real_total'] - $order_goods['total']);
- }
-
- unset($order_info['store_id']);
- unset($order_info['email']);
- unset($order_info['shipping_city_id']);
- unset($order_info['shipping_country_id']);
- unset($order_info['shipping_province_id']);
- // unset($order_info['comment']);
- unset($order_info['voucher_id']);
- unset($order_info['is_balance']);
- unset($order_info['lottery_win']);
- unset($order_info['ip']);
- unset($order_info['ip_region']);
- unset($order_info['user_agent']);
-
-
- //enum('express', 'pickup', 'tuanz_send')
-
-
- //var_dump($order_info['total'],$order_info['shipping_fare'],$order['voucher_credit'],$order['fullreduction_money'] );die();
-
-
- $order_info['shipping_fare'] = round($order_info['shipping_fare'],2) < 0.01 ? '0.00':round($order_info['shipping_fare'],2) ;
- $order_info['voucher_credit'] = round($order_info['voucher_credit'],2) < 0.01 ? '0.00':round($order_info['voucher_credit'],2) ;
- $order_info['fullreduction_money'] = round($order_info['fullreduction_money'],2) < 0.01 ? '0.00':round($order_info['fullreduction_money'],2) ;
-
- $need_data = array();
-
- if($order_info['type'] == 'integral')
- {
- //暂时屏蔽积分商城
- $order_info['score'] = round($order_info['total'],2);
-
- }
-
- $order_info['total'] = round($order_info['total']+$order_info['shipping_fare']-$order_info['voucher_credit']-$order_info['fullreduction_money'] - $order_info['score_for_money'],2) ;
-
- if($order_info['total'] < 0)
- {
- $order_info['total'] = '0.00';
- }
-
-
-
- $order_info['real_total'] = round($shiji_total_money,2)+$order_info['shipping_fare'];
- $order_info['price'] = round($order_info['price'],2);
- $order_info['member_youhui'] = round($member_youhui,2) < 0.01 ? '0.00':round($member_youhui,2);
- $order_info['pick_up_time'] = $pick_up_time;
-
-
- $order_info['shipping_fare'] = sprintf("%.2f",$order_info['shipping_fare']);
- $order_info['voucher_credit'] = sprintf("%.2f",$order_info['voucher_credit']);
- $order_info['fullreduction_money'] = sprintf("%.2f",$order_info['fullreduction_money']);
- $order_info['total'] = sprintf("%.2f",$order_info['total']);
- $order_info['real_total'] = sprintf("%.2f",$order_info['real_total']);
-
-
-
-
- $order_info['date_added'] = date('Y-m-d H:i:s', $order_info['date_added']);
-
-
- // if($order_info['delivery'] =='pickup')
- // {}else{}
-
- if( !empty($order_info['pay_time']) && $order_info['pay_time'] >0 )
- {
- $order_info['pay_date'] = date('Y-m-d H:i:s', $order_info['pay_time']);
- }else{
- $order_info['pay_date'] = '';
- }
-
- $order_info['express_tuanz_date'] = date('Y-m-d H:i:s', $order_info['express_tuanz_time']);
- $order_info['receive_date'] = date('Y-m-d H:i:s', $order_info['receive_time']);
-
- //"delivery": "pickup", enum('express', 'pickup', 'tuanz_send')
- if($order_info['delivery'] == 'express')
- {
- $order_info['delivery_name'] = '快递';
- }else if($order_info['delivery'] == 'pickup')
- {
- $order_info['delivery_name'] = '用户自提';
- }else if($order_info['delivery'] == 'tuanz_send'){
- $order_info['delivery_name'] = '团长配送';
- }
-
- $need_data['order_info'] = $order_info;
- $need_data['order_status_info'] = $order_status_info;
- $need_data['shipping_province'] = $shipping_province;
- $need_data['shipping_city'] = $shipping_city;
- $need_data['shipping_country'] = $shipping_country;
- $need_data['order_goods_list'] = $order_goods_list;
-
- $need_data['goods_count'] = count($order_goods_list);
-
- //$order_info['order_status_id'] 13 平台介入退款
- $order_refund_historylist = array();
- $pingtai_deal = 0;
-
- //判断是否已经平台处理完毕
-
- $order_refund_historylist = M('lionfish_comshop_order_refund_history')->where( array('order_id' => $order_id ) )->order('addtime asc')->select();
-
-
- foreach($order_refund_historylist as $key => $val)
- {
- if($val['type'] ==3)
- {
- $pingtai_deal = 1;
- }
- }
-
- $order_refund = M('lionfish_comshop_order_refund')->where( array('order_id' => $order_id ) )->find();
-
- if(!empty($order_refund))
- {
- $order_refund['addtime'] = date('Y-m-d H:i:s', $order_refund['addtime']);
- }
-
- $need_data['pick_up'] = $pick_up_info;
-
-
-
- $need_data['pick_order_info'] = $pick_order_info;
- $order_pay_after_share = D('Home/Front')->get_config_by_name('order_pay_after_share');
- if($order_pay_after_share==1){
- $order_pay_after_share_img = D('Home/Front')->get_config_by_name('order_pay_after_share_img');
- $order_pay_after_share_img = $order_pay_after_share_img ? tomedia($order_pay_after_share_img) : '';
- $need_data['share_img'] = $order_pay_after_share_img;
- }
-
- //$order_info['order_status_id']
- //0开启,1关闭 取消订单
- $order_can_del_cancle = D('Home/Front')->get_config_by_name('order_can_del_cancle');
- $order_can_del_cancle = empty($order_can_del_cancle) || $order_can_del_cancle == 0 ? 1 : 0;
-
- $is_hidden_orderlist_phone = D('Home/Front')->get_config_by_name('is_hidden_orderlist_phone');
- $is_show_guess_like = D('Home/Front')->get_config_by_name('is_show_order_guess_like');
- $user_service_switch = D('Home/Front')->get_config_by_name('user_service_switch');
-
- echo json_encode(
- array(
- 'code' => 0,
- 'data' => $need_data,
- 'pingtai_deal' => $pingtai_deal,
- 'order_refund' => $order_refund,
- 'order_can_del_cancle' => $order_can_del_cancle,
- 'order_pay_after_share' => $order_pay_after_share,
- 'is_hidden_orderlist_phone' => $is_hidden_orderlist_phone,
- 'is_show_guess_like' => $is_show_guess_like,
- 'user_service_switch' => $user_service_switch
- )
- );
- die();
- }
- /**
- * 订单确认付款
- */
- public function order_pay(){
- $gpc = I('request.');
- $token = $gpc['token'];
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
- $member_id = $weprogram_token['member_id'];
- $order_id = $gpc['order_id'];
- $is_supply = $gpc['is_supply'];
- if( empty($member_id) )
- {
- $result['code'] = 2;
- $result['msg'] = '登录失效';
- echo json_encode($result);
- die();
- }
- $supply_info = array();
- $order_info = array();
- if($is_supply == 1){
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
- if(empty($supply_info)){
- $result['code'] = 1;
- $result['msg'] = '您不是供应商,无法操作';
- echo json_encode($result);
- die();
- }
- $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
- }
- if(empty($order_info)){
- $result['code'] = 1;
- $result['msg'] = '非法操作,供应商不存在该订单';
- echo json_encode($result);
- die();
- }
- //order_status_id == 3
- if($order_info['order_status_id'] != 3)
- {
- $result['code'] = 1;
- $result['msg'] = '订单不是未付款订单,无法确认付款';
- echo json_encode($result);
- die();
- }
- D('Seller/Order')->admin_pay_order($order_id,1);
- $result['code'] = 0;
- echo json_encode($result);
- die();
- }
- /**
- * 订单改价页面
- */
- public function order_change(){
- $gpc = I('request.');
- $token = $gpc['token'];
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
- $member_id = $weprogram_token['member_id'];
- $order_id = $gpc['order_id'];
- $is_supply = $gpc['is_supply'];
- if( empty($member_id) )
- {
- $result['code'] = 2;
- $result['msg'] = '登录失效';
- echo json_encode($result);
- die();
- }
- $supply_info = array();
- $order_info = array();
- if($is_supply == 1){
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
- if(empty($supply_info)){
- $result['code'] = 1;
- $result['msg'] = '您不是供应商,无法操作';
- echo json_encode($result);
- die();
- }
- $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
- }
- if(empty($order_info)){
- $result['code'] = 1;
- $result['msg'] = '非法操作,供应商不存在该订单';
- echo json_encode($result);
- die();
- }
- //order_status_id == 3
- if($order_info['order_status_id'] != 3)
- {
- $result['code'] = 1;
- $result['msg'] = '订单不是未付款订单,无法改价';
- echo json_encode($result);
- die();
- }
- $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->select();
- $member_youhui = 0;
- foreach($order_goods as $k=>$v){
- $order_goods[$k]['goods_img_url'] = tomedia($v['goods_images']);
- $order_goods[$k]['max_total'] = round($v['total']-$v['fullreduction_money']-$v['voucher_credit']-$v['score_for_money'],2);
- $member_youhui += round(($v['oldprice'] - $v['price'])*$v['quantity'],2);
- $order_goods[$k]['goods_optiontitle'] = D('Seller/Order')->get_order_option_sku($v['order_id'], $v['order_goods_id']);
- $order_goods[$k]['price'] = sprintf("%.2f", $v['price']);
- }
- $youhui_total = round($order_info['voucher_credit']+$order_info['fullreduction_money']+$order_info['score_for_money']+$member_youhui,2);
- $order_info['youhui_total'] = sprintf("%.2f", $youhui_total);
- $order_info['changeprice'] = sprintf("%.2f", $order_info['total'] - $order_info['old_price']);
- $order_info['buyer_total'] = sprintf("%.2f", $order_info['total'] + $order_info['shipping_fare']-$order_info['voucher_credit']-$order_info['fullreduction_money'] - $order_info['score_for_money'] - $member_youhui);
- echo json_encode(
- array(
- 'code' => 0,
- 'order_goods' => $order_goods,
- 'orders' => $order_info
- )
- );
- die();
- }
- /**
- * 订单改价
- */
- public function order_changeprice(){
- $gpc = I('request.');
- $order_id = $gpc['order_id'];
- $order_goods_ids = $gpc['order_goods_id'];
- $change_prices = $gpc['change_price'];
- $is_supply = $gpc['is_supply'];
- $token = $gpc['token'];
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
- $member_id = $weprogram_token['member_id'];
- if( empty($member_id) )
- {
- $result['code'] = 2;
- $result['msg'] = '登录失效';
- echo json_encode($result);
- die();
- }
- $supply_info = array();
- $order_info = array();
- if($is_supply == 1){
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
- if(empty($supply_info)){
- $result['code'] = 1;
- $result['msg'] = '您不是供应商,无法操作';
- echo json_encode($result);
- die();
- }
- $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
- }
- if(empty($order_info)){
- $result['code'] = 1;
- $result['msg'] = '非法操作,供应商不存在该订单';
- echo json_encode($result);
- die();
- }
- //order_status_id == 3
- if($order_info['order_status_id'] != 3)
- {
- $result['code'] = 1;
- $result['msg'] = '订单不是未付款订单,无法改价';
- echo json_encode($result);
- die();
- }
- if(empty($order_goods_ids) || empty($change_prices)){
- $result['code'] = 1;
- $result['msg'] = '商品订单号和价格参数不能为空';
- echo json_encode($result);
- die();
- }
- $order_goods_ids = explode(',',$order_goods_ids);
- $change_prices = explode(',',$change_prices);
- if(count($order_goods_ids) != count($change_prices)){
- $result['code'] = 1;
- $result['msg'] = '商品订单号和价格参数不匹配';
- echo json_encode($result);
- die();
- }
- //改价后的商品实付价格不能低于0.1元
- foreach($order_goods_ids as $k=>$order_goods_id){
- $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_id' =>$order_id,'order_goods_id' =>$order_goods_id ) )->find();
- $total = $order_goods_info['total'];
- $fullreduction_money = $order_goods_info['fullreduction_money'];
- $voucher_credit = $order_goods_info['voucher_credit'];
- $score_for_money = $order_goods_info['score_for_money'];
- $total = round($total - $fullreduction_money - $voucher_credit - $score_for_money,2);
- if(!empty($change_prices[$k])){
- $change_price = $change_prices[$k];
- $total = floatval($total) + floatval($change_price);
- if(bccomp($total, '0.1', 2) == -1){
- $result['code'] = 1;
- $result['msg'] = '改价后的商品实付价格不能低于0.1元';
- echo json_encode($result);
- die();
- }
- }
- }
- $change_amount = 0;
- foreach($order_goods_ids as $k=>$order_goods_id){
- $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_id' =>$order_id,'order_goods_id' =>$order_goods_id ) )->find();
- $total = $order_goods_info['total'];
- $update_data = array();
- if(!empty($change_prices[$k])){
- $change_amount = $change_amount + $change_prices[$k];
- $change_price = $change_prices[$k];
- $update_data['total'] = round(floatval($total) + floatval($change_price),2);
- $update_data['is_change_price'] = 1;
- M('lionfish_comshop_order_goods')->where( array('order_id' =>$order_id,'order_goods_id' => $order_goods_id ) )->save( $update_data);
- }
- }
- $order_info = M('lionfish_comshop_order')->where( array('order_id' =>$order_id) )->find();
- $order_total = $order_info['total'];
- $order_data = array();
- $order_data['total'] = round(floatval($order_total) + floatval($change_amount),2);
- $order_data['is_change_price'] = 1;
- M('lionfish_comshop_order')->where( array('order_id' =>$order_id) )->save($order_data);
- $oh = array();
- $oh['order_id'] = $order_id;
- $oh['order_status_id']=15;
- $oh['comment']='订单改价';
- $oh['date_added']=time();
- M('lionfish_comshop_order_history')->add($oh);
- $result['code'] = 0;
- echo json_encode($result);
- die();
- }
- /**
- * 供应商确定配送订单
- */
- public function order_delivery(){
- $gpc = I('request.');
- $token = $gpc['token'];
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
- $member_id = $weprogram_token['member_id'];
- $order_id = $gpc['order_id'];
- $is_supply = $gpc['is_supply'];
- if( empty($member_id) )
- {
- $result['code'] = 2;
- $result['msg'] = '登录失效';
- echo json_encode($result);
- die();
- }
- $supply_info = array();
- $order_info = array();
- if($is_supply == 1){
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
- if(empty($supply_info)){
- $result['code'] = 1;
- $result['msg'] = '您不是供应商,无法操作';
- echo json_encode($result);
- die();
- }
- $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
- }
- if(empty($order_info)){
- $result['code'] = 1;
- $result['msg'] = '非法操作,供应商不存在该订单';
- echo json_encode($result);
- die();
- }
- if($order_info['order_status_id'] != 1)
- {
- $result['code'] = 1;
- $result['msg'] = '订单不是待发货订单,无法确认配送';
- echo json_encode($result);
- die();
- }
- D('Seller/Order')->do_send_localtown($order_id,'供应商操作,开始配送货物');
- $result['code'] = 0;
- echo json_encode($result);
- die();
- }
- /**
- * 选择配送员
- */
- public function choosemember()
- {
- $_GPC = I('request.');
- $kwd = trim($_GPC['keyword']);
- $token = $_GPC['token'];
- $order_id = $_GPC['order_id'];
- $is_supply = $_GPC['is_supply'];
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
- $member_id = $weprogram_token['member_id'];
- if( empty($member_id) )
- {
- $result['code'] = 2;
- $result['msg'] = '登录失效';
- echo json_encode($result);
- die();
- }
- $supply_info = array();
- $order_info = array();
- if($is_supply == 1){
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
- if(empty($supply_info)){
- $result['code'] = 1;
- $result['msg'] = '您不是供应商,无法操作';
- echo json_encode($result);
- die();
- }
- $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
- }
- if(empty($order_info)){
- $result['code'] = 1;
- $result['msg'] = '非法操作,供应商不存在该订单';
- echo json_encode($result);
- die();
- }
- if($order_info['order_status_id'] != 4)
- {
- $result['code'] = 1;
- $result['msg'] = '订单不是已发货,待收货订单,无法指定配送员';
- echo json_encode($result);
- die();
- }
- $condition = ' 1 ';
- if (!empty($kwd)) {
- $condition .= ' and ( username LIKE "%'.$kwd .'%" or mobile like "%'.$kwd .'%" )';
- }
- $condition .= ' and store_id='.$order_info['store_id'];
- /**
- 分页开始
- **/
- $per_page = 10;
- $page = isset($_GPC['page']) ? $_GPC['page'] : 1;
- $offset = ($page - 1) * $per_page;
- /**
- 分页结束
- **/
- $sql = 'SELECT * FROM ' . C('DB_PREFIX') . 'lionfish_comshop_orderdistribution where '
- . $condition .
- ' order by id asc limit '.$offset.','.$per_page;
- $list = M()->query($sql);
- if( !empty($list) )
- {
- echo json_encode( array('code' => 0, 'data' => $list) );
- die();
- }else{
- echo json_encode( array('code' => 1, 'msg'=>'暂无数据') );
- die();
- }
- }
- public function sub_orderchoose_distribution(){
- $_GPC = I('request.');
- $token = $_GPC['token'];
- $order_id = $_GPC['order_id'];
- $is_supply = $_GPC['is_supply'];
- $distribution_id = $_GPC['distribution_id'];
- $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
- $member_id = $weprogram_token['member_id'];
- if( empty($member_id) )
- {
- $result['code'] = 2;
- $result['msg'] = '登录失效';
- echo json_encode($result);
- die();
- }
- $supply_info = array();
- $order_info = array();
- if($is_supply == 1){
- $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
- if(empty($supply_info)){
- echo json_encode(array('code' => 1, 'msg' => '您不是供应商,无法操作'));
- die();
- }
- $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
- }
- if(empty($order_info)){
- echo json_encode(array('code' => 1, 'msg' => '非法操作,供应商不存在该订单'));
- die();
- }
- if($order_info['order_status_id'] != 4)
- {
- echo json_encode(array('code' => 1, 'msg' => '订单不是已发货,待收货订单,无法指定配送员'));
- die();
- }
- $distribution_info = M('lionfish_comshop_orderdistribution')->where(array('id'=>$distribution_id,'store_id'=>$supply_info['id']))->find();
- if(empty($distribution_info)){
- echo json_encode(array('code' => 1, 'msg' => '配送员不存在'));
- die();
- }
- $res = D('Home/LocaltownDelivery')->distribution_get_order( $distribution_id , $order_id);
- if($res)
- {
- echo json_encode( array('code' => 0, 'msg' => '分配成功') );
- die();
- }else{
- echo json_encode( array('code' => 1, 'msg' => '已被分配,请刷新页面') );
- die();
- }
- }
- public function share_order(){
- $gpc = I('request.');
- $order_id = $gpc['order_id'];
- $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
- $head_id = $order_info['head_id'];
- $member_id = $order_info['member_id'];
- if(empty($order_info)){
- echo json_encode( array('code' => 3, 'msg' => '订单信息不存在') );
- die();
- }
- $cart= D('Home/Car');
- $order_array = array();
- $order_status_id = $order_info['order_status_id'];
- $order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id) )->order('order_goods_id asc')->select();
- $order_goods_array = array();
- $goods_quantity = 0;
- foreach($order_goods_list as $k=>$val){
- $goods_common_info = "";
- $where='1=1';
- if( $head_id > 0 )
- {
- $where .= " and (g.is_all_sale = 1 or g.id in (SELECT goods_id from ".C('DB_PREFIX')."lionfish_community_head_goods where head_id = {$head_id}) ) ";
- }
- $sql_pingoods = "select g.*,gc.begin_time,gc.end_time,gc.big_img,gc.is_take_fullreduction,gc.labelname,gc.video,gc.pick_up_type,gc.pick_up_modify,gc.oneday_limit_count, gc.total_limit_count, gc.one_limit_count,gc.goods_start_count from " .C('DB_PREFIX')."lionfish_comshop_goods as g,".C('DB_PREFIX')."lionfish_comshop_good_common as gc where {$where} and g.id=gc.goods_id limit 1 ";
- $goods_common_info = M()->query($sql_pingoods);
- $goods_common_info = $goods_common_info[0];
- $tmp_data = array();
- $order_goods_array[$k]['actId'] = $goods_common_info['id'];
- $order_goods_array[$k]['spuName'] = htmlspecialchars_decode($goods_common_info['goodsname']);
- $order_goods_array[$k]['spuCanBuyNum'] = $goods_common_info['total'];
- $order_goods_array[$k]['spuDescribe'] = $goods_common_info['subtitle'];
- $order_goods_array[$k]['end_time'] = $goods_common_info['end_time'];
- $order_goods_array[$k]['soldNum'] = $goods_common_info['seller_count'] + $goods_common_info['sales'];
- $order_goods_array[$k]['oneday_limit_count'] = $goods_common_info['oneday_limit_count'];
- $order_goods_array[$k]['total_limit_count'] = $goods_common_info['total_limit_count'];
- $order_goods_array[$k]['one_limit_count'] = $goods_common_info['one_limit_count'];
- $order_goods_array[$k]['goods_start_count'] = $goods_common_info['goods_start_count'];
- $productprice = $goods_common_info['productprice'];
- $order_goods_array[$k]['marketPrice'] = explode('.', $productprice);
- if( !empty($goods_common_info['big_img']) )
- {
- $order_goods_array[$k]['bigImg'] = tomedia($goods_common_info['big_img']);
- }
- $good_image = D('Home/Pingoods')->get_goods_images($goods_common_info['id']);
- if( !empty($good_image) )
- {
- $order_goods_array[$k]['skuImage'] = tomedia($good_image['image']);
- }
- $price_arr = D('Home/Pingoods')->get_goods_price($goods_common_info['id'], $member_id);
- $price = $price_arr['price'];
- $order_goods_array[$k]['actPrice'] = explode('.', $price);
- //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
- $order_goods_array[$k]['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($goods_common_info['id'], $member_id, $head_id ,$token);
- if( !empty($tmp_data['skuList']) )
- {
- $order_goods_array[$k]['car_count'] = 0;
- }else{
- $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
- if( empty($car_count) )
- {
- $order_goods_array[$k]['car_count'] = 0;
- }else{
- $order_goods_array[$k]['car_count'] = $car_count;
- }
- }
- $goods_quantity = $goods_quantity + $val['quantity'];
- if($order_status_id != 3 && $order_status_id != 5){//不是未付款和取消订单
- $order_goods_array[$k]['price'] = $val['price'];
- $order_goods_array[$k]['oldprice'] = $val['oldprice'];
- }
- }
- if($order_status_id != 3 && $order_status_id != 5) {//不是未付款和取消订单
- $order_array['goods_quantity'] = $goods_quantity;//商品数量
- $order_array['goods_count'] = count($order_goods_list);//商品种类数
- $order_array['order_total'] = $order_info['total'];//订单总金额
- $order_array['old_order_total'] = $order_info['old_price'];//订单原金额
- $order_array['save_money'] = $order_info['old_price'] - $order_info['total'];//省了多少钱
- }
- //用户信息
- $member_id = $order_info['member_id'];
- $member_info = M('lionfish_comshop_member')->where(array('member_id'=>$member_id))->find();
- $member_array = [];
- $member_array['avatar'] = $member_info['avatar'];//用户头像
- $member_array['username'] = $member_info['username'];//用户昵称
- //团长信息
- if($order_info['delivery'] != 'hexiao'){
- $head_id = $order_info['head_id'];
- $head_info = M('lionfish_community_head')->where(array('id'=>$head_id))->field('id,member_id,community_name,head_name,head_mobile,province_id,city_id,country_id,area_id,address')->find();
- $head_member_info = M('lionfish_comshop_member')->where(array('member_id'=>$head_info['member_id']))->find();
- $head_info['province_name'] = D('Seller/area')->get_area_info($head_info['province_id']);
- $head_info['city_name'] = D('Seller/area')->get_area_info($head_info['city_id']);
- $head_info['area_name'] = D('Seller/area')->get_area_info($head_info['area_id']);
- $head_info['country_name'] = D('Seller/area')->get_area_info($head_info['country_id']);
- $head_info['fulladdress'] = $head_info['province_name'].$head_info['city_name'].$head_info['area_name'].$head_info['country_name'].$head_info['address'];
- $head_info['head_images'] = $head_member_info['avatar'];
- $order_array['head_info'] = $head_info;
- }else{
- //门店信息
- $salesroom_list = D('Home/Salesroom')->get_order_salesroom($order_id,0);
- $order_array['salesroom_info'] = array();
- if(!empty($salesroom_list)){
- $order_array['salesroom_info'] = $salesroom_list[0];
- }
- }
- $need_data = array();
- $need_data['orders'] = $order_array;
- $need_data['order_goods_list'] = $order_goods_array;
- $need_data['members'] = $member_array;
- echo json_encode(
- array(
- 'code' => 0,
- 'data' => $need_data
- )
- );
- }
- }
|