OrderController.class.php 112 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. use Home\Model\OrderModel;
  16. class OrderController extends CommonController {
  17. protected function _initialize(){
  18. parent::_initialize();
  19. // 获取当前用户ID
  20. }
  21. /**
  22. 直接取消订单
  23. 1、已付款待发货 状态
  24. 2、是不是自己的订单
  25. 3、判断后台是否开启了状态
  26. 4、记录日志
  27. 5、处理订单,
  28. 6、处理退款,
  29. 7、打印小票
  30. 结束
  31. **/
  32. public function del_cancle_order()
  33. {
  34. $gpc = I('request.');
  35. $_GPC = I('request.');
  36. $token = $gpc['token'];
  37. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  38. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  39. {
  40. echo json_encode( array('code' => 2) );
  41. die();
  42. }
  43. $member_id = $weprogram_token['member_id'];
  44. $order_id = $_GPC['order_id'];
  45. $order_info = M('lionfish_comshop_order')->where( array('member_id' => $member_id,'order_id' => $order_id) )->find();
  46. $order_member_name = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  47. if( empty($order_info) )
  48. {
  49. echo json_encode( array('code' => 1, 'msg' => '订单不存在') );
  50. die();
  51. }
  52. if( $order_info['order_status_id'] == 1)
  53. {
  54. $order_can_del_cancle = D('Home/Front')->get_config_by_name('order_can_del_cancle');
  55. if( empty($order_can_del_cancle) || $order_can_del_cancle == 0 )
  56. {
  57. //4、记录日志
  58. $order_history = array();
  59. $order_history['order_id'] = $order_id;
  60. $order_history['order_status_id'] = 5;
  61. $order_history['notify'] = 0;
  62. $order_history['comment'] = '会员前台申请,直接取消已支付待发货订单';
  63. $order_history['date_added'] = time();
  64. M('lionfish_comshop_order_history')->add($order_history);
  65. //5、处理订单
  66. $result = D('Home/Weixin')->del_cancle_order($order_id);
  67. //6、发送取消通知订单给平台
  68. $weixin_template_cancle_order = D('Home/Front')->get_config_by_name('weixin_template_cancle_order');
  69. $platform_send_info_member_id = D('Home/Front')->get_config_by_name('platform_send_info_member');
  70. if( !empty($weixin_template_cancle_order) && !empty($platform_send_info_member_id) )
  71. {
  72. $weixin_template_order =array();
  73. $weixin_appid = D('Home/Front')->get_config_by_name('weixin_appid' );
  74. if( !empty($weixin_appid) && !empty($weixin_template_cancle_order) )
  75. {
  76. $head_pathinfo = "lionfish_comshop/pages/index/index";
  77. $pl_member_id = explode(",", $platform_send_info_member_id);
  78. foreach($pl_member_id as $m_id){
  79. $weopenid = M('lionfish_comshop_member')->where( array('member_id' => $m_id ) )->find();
  80. $weixin_template_order = array(
  81. 'appid' => $weixin_appid,
  82. 'template_id' => $weixin_template_cancle_order,
  83. 'pagepath' => $head_pathinfo,
  84. 'data' => array(
  85. 'first' => array('value' => '您好,您收到了一个取消订单,请尽快处理','color' => '#030303'),
  86. 'keyword1' => array('value' => $order_info['order_num_alias'],'color' => '#030303'),
  87. 'keyword2' => array('value' => '取消订单','color' => '#030303'),
  88. 'keyword3' => array('value' => sprintf("%01.2f", $order_info['total']),'color' => '#030303'),
  89. 'keyword4' => array('value' => date('Y-m-d H:i:s'),'color' => '#030303'),
  90. 'keyword5' => array('value' => $order_member_name['username'],'color' => '#030303'),
  91. 'remark' => array('value' => '此订单已于'.date('Y-m-d H:i:s').'被用户取消,请尽快处理','color' => '#030303'),
  92. )
  93. );
  94. D('Seller/User')->just_send_wxtemplate($weopenid['we_openid'], 0, $weixin_template_order );
  95. }
  96. }
  97. }
  98. if( $result['code'] == 0 && $order_info['type'] != 'integral')
  99. {
  100. $is_print_cancleorder = D('Home/Front')->get_config_by_name('is_print_cancleorder');
  101. if( isset($is_print_cancleorder) && $is_print_cancleorder == 1 )
  102. {
  103. D('Seller/Printaction')->check_print_order($order_id,'用户取消订单');
  104. D('Seller/Printaction')->check_print_order2($order_id,'用户取消订单');
  105. }
  106. echo json_encode( array('code' => 0 ) );
  107. die();
  108. }
  109. else if($result['code'] == 0 && $order_info['type'] == 'integral')
  110. {
  111. echo json_encode( array('code' => 0 ) );
  112. die();
  113. }
  114. else{
  115. echo json_encode( array('code' => 1, 'msg' => $result['msg'] ) );
  116. die();
  117. }
  118. }else{
  119. echo json_encode( array('code' => 1, 'msg' => '未开启此项功能') );
  120. die();
  121. }
  122. }else{
  123. echo json_encode( array('code' => 1, 'msg' => '订单状态不正确,只有已支付,未发货的订单才能取消') );
  124. die();
  125. }
  126. }
  127. public function order_info()
  128. {
  129. $gpc = I('request.');
  130. $token = $gpc['token'];
  131. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  132. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  133. {
  134. echo json_encode( array('code' => 2) );
  135. die();
  136. }
  137. $member_id = $weprogram_token['member_id'];
  138. $order_id = $gpc['id'];
  139. $is_supply = isset($gpc['is_supply']) ? $gpc['is_supply'] :'';
  140. if( $is_supply > 0 )
  141. {
  142. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  143. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  144. {
  145. $supply_is_open_mobilemanage = 0;
  146. }
  147. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  148. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  149. {
  150. $ck_order_goods = M('lionfish_comshop_order_goods')->where( array('supply_id' => $supply_info['id'], 'order_id' => $order_id ) )->find();
  151. if( !empty($ck_order_goods) )
  152. {
  153. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $ck_order_goods['order_id']) )->find();
  154. }else{
  155. echo json_encode( array('code' => 2 , 'msg' => '非法操作') );
  156. die();
  157. }
  158. }else{
  159. echo json_encode( array('code' => 2, 'msg' => '非法操作') );
  160. die();
  161. }
  162. }else{
  163. $order_info = M('lionfish_comshop_order')->where( array('member_id' => $member_id,'order_id' => $order_id) )->find();
  164. }
  165. //gpc
  166. if($order_info['is_change_price'] == 1){
  167. $order_info['admin_change_price'] = $order_info['total'] - $order_info['old_price'];
  168. }
  169. $pick_up_info = array();
  170. $pick_order_info = array();
  171. if( $order_info['delivery'] == 'pickup' )
  172. {
  173. //查询自提点
  174. $pick_order_info = array();
  175. $pick_id = 0;
  176. $pick_up_info = array();
  177. }
  178. if( $order_info['delivery'] == 'localtown_delivery' && ($order_info['order_status_id'] != 3 && $order_info['order_status_id'] != 5 ) )
  179. {
  180. $order_info['orderdistribution_order'] = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_info['order_id'] ) )->find();
  181. if( !empty($order_info['orderdistribution_order']) && $order_info['orderdistribution_order'] > 0 )
  182. {
  183. $orderdistribution = M('lionfish_comshop_orderdistribution')->where( array('id' => $order_info['orderdistribution_order']['orderdistribution_id'] ) )->find();
  184. $order_info['orderdistribution_order']['username'] = $orderdistribution['username'];
  185. }
  186. }
  187. $order_status_info = M('lionfish_comshop_order_status')->where( array('order_status_id' => $order_info['order_status_id'] ) )->find();
  188. //10 name
  189. if($order_info['order_status_id'] == 10)
  190. {
  191. $order_status_info['name'] = '等待退款';
  192. }
  193. else if($order_info['order_status_id'] == 4 && $order_info['delivery'] =='pickup')
  194. {
  195. //delivery 6
  196. $order_status_info['name'] = '待自提';
  197. //已自提
  198. }
  199. else if($order_info['order_status_id'] == 6 && $order_info['delivery'] =='pickup')
  200. {
  201. //delivery 6
  202. $order_status_info['name'] = '已自提';
  203. }
  204. else if($order_info['order_status_id'] == 1 && $order_info['type'] == 'lottery')
  205. {
  206. //等待开奖
  207. //一等奖
  208. if($order_info['lottery_win'] == 1)
  209. {
  210. $order_status_info['name'] = '一等奖';
  211. }else {
  212. $order_status_info['name'] = '等待开奖';
  213. }
  214. }
  215. //核销订单
  216. if( $order_info['delivery'] == 'hexiao' ){
  217. if($order_info['store_id'] == 0){
  218. $order_info['shopname'] = '平台自营';
  219. }else{
  220. $store_info = M('lionfish_comshop_supply')->where( array('id' => $order_info['store_id'] ) )->find();
  221. $order_info['shopname'] = $store_info['shopname'];
  222. }
  223. //订单卷码
  224. $order_info['hexiao_volume_code'] = $order_info['hexiao_volume_code'];
  225. //二维码
  226. if(empty($order_info['hexiao_qr_code'])){
  227. $order_info['hexiao_qr_code'] = D('Home/Salesroom')->_get_ordergoods_hxqrcode($order_id,'',$order_info['hexiao_volume_code']);
  228. }else{
  229. $order_info['hexiao_qr_code'] = tomedia($order_info['hexiao_qr_code']);
  230. }
  231. //门店列表
  232. $salesroom_list = D('Home/Salesroom')->get_order_salesroom($order_id,0);
  233. foreach($salesroom_list as $slk=>$slv){
  234. $member_lon = $gpc['longitude'];
  235. $member_lat = $gpc['latitude'];
  236. $salesroom_list[$slk]['distance'] = D('Home/Salesroom')->cal_salesroom_distance($slv,$member_lon,$member_lat);
  237. }
  238. $distances = array_column($salesroom_list,'distance');
  239. array_multisort($distances,SORT_ASC,$salesroom_list);
  240. $order_info['salesroom_list'] = $salesroom_list;
  241. }
  242. //$order_info['type']
  243. //open_auto_delete
  244. if($order_info['order_status_id'] == 3)
  245. {
  246. $open_auto_delete = D('Home/Front')->get_config_by_name('open_auto_delete');
  247. $auto_cancle_order_time = D('Home/Front')->get_config_by_name('auto_cancle_order_time');
  248. $order_info['open_auto_delete'] = $open_auto_delete;
  249. //date_added
  250. if($open_auto_delete == 1)
  251. {
  252. $order_info['over_buy_time'] = $order_info['date_added'] + 3600 * $auto_cancle_order_time;
  253. $order_info['cur_time'] = time();
  254. }
  255. }
  256. $shipping_province = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_province_id'] ) )->find();
  257. $shipping_city = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_city_id'] ) )->find();
  258. $shipping_country = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_country_id'] ) )->find();
  259. $order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->select();
  260. $shiji_total_money = 0;
  261. $member_youhui = 0.00;
  262. $pick_up_time = "";
  263. $pick_up_type = -1;
  264. $pick_up_weekday = '';
  265. $today_time = $order_info['pay_time'];
  266. $arr = array('天','一','二','三','四','五','六');
  267. $url = D('Home/Front')->get_config_by_name('shop_domain').'/';
  268. $attachment_type = D('Home/Front')->get_config_by_name('attachment_type');
  269. $qiniu_url = D('Home/Front')->get_config_by_name('qiniu_url');
  270. $is_can_received = 1;//是否可以收货,1、可以,0、不可以
  271. $hx_receive_info = array();//核销订单已收到待收货情况
  272. $receive_count = 0;//已收货
  273. $wait_count = 0;//待收货
  274. $goods_quantity = 0;//商品数量
  275. $refund_goods_quantity = 0;//退款商品数量
  276. $volume_code_list = array();//卷码列表
  277. $hx_order_count = 0;//按订单核销商品订单数
  278. $hx_time_count = 0;//按次数核销商品订单数
  279. $vi = 0;
  280. foreach($order_goods_list as $key => $order_goods)
  281. {
  282. $order_goods['name'] = htmlspecialchars_decode(stripslashes($order_goods['name']));
  283. $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();
  284. if(!empty($order_refund_goods))
  285. {
  286. $order_refund_goods['addtime'] = date('Y-m-d H:i:s', $order_refund_goods['addtime']);
  287. if($order_refund_goods['state'] == 0 || $order_refund_goods['state'] == 2){
  288. $is_can_received = 0;
  289. }
  290. }
  291. $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();
  292. $order_goods['order_refund_goods'] = $order_refund_goods;
  293. foreach($order_option_info as $option)
  294. {
  295. $order_goods['option_str'][] = $option['value'];
  296. }
  297. if(empty($order_goods['option_str']))
  298. {
  299. //option_str
  300. $order_goods['option_str'] = '';
  301. }else{
  302. $order_goods['option_str'] = implode(',', $order_goods['option_str']);
  303. }
  304. //
  305. $order_goods['shipping_fare'] = round($order_goods['shipping_fare'],2);
  306. $order_goods['price'] = round($order_goods['price'],2);
  307. $order_goods['total'] = round($order_goods['total'],2);
  308. if( $order_goods['is_vipcard_buy'] == 1 || $order_goods['is_level_buy'] ==1 )
  309. {
  310. $order_goods['price'] = round($order_goods['oldprice'],2);
  311. }
  312. $order_goods['real_total'] = round($order_goods['quantity'] * $order_goods['price'],2);
  313. /**
  314. $goods_images = file_image_thumb_resize($vv['goods_images'],400);
  315. if(is_array($goods_images))
  316. {
  317. $vv['goods_images'] = $vv['goods_images'];
  318. }else{
  319. $vv['goods_images']= tomedia( file_image_thumb_resize($vv['goods_images'],400) );
  320. }
  321. **/
  322. if($attachment_type == 1)
  323. {
  324. $goods_images = $qiniu_url.resize($order_goods['goods_images'],400,400);
  325. }else{
  326. $goods_images = $url.resize($order_goods['goods_images'],400,400);
  327. }
  328. if( !is_array($goods_images) )
  329. {
  330. $order_goods['image']= tomedia( $goods_images );
  331. $order_goods['goods_images']= tomedia( $goods_images );
  332. }else{
  333. $order_goods['image']= $order_goods['goods_images'];
  334. }
  335. $order_goods['hascomment'] = 0;
  336. $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();
  337. if( !empty($order_goods_comment_info) )
  338. {
  339. $order_goods['hascomment'] = 1;
  340. }
  341. $order_goods['can_ti_refund'] = 1;
  342. $disable_info = M('lionfish_comshop_order_refund_disable')->where( array('order_id' => $order_id, 'order_goods_id' => $order_goods['order_goods_id']) )->find();
  343. if( !empty($disable_info) )
  344. {
  345. $order_goods['can_ti_refund'] = 0;
  346. }
  347. if($order_goods['is_refund_state'] == 1)
  348. {
  349. //已经再申请退款中了。或者已经退款了。
  350. $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();
  351. if( $order_refund_info['state'] == 3 )
  352. {
  353. $order_goods['is_refund_state'] = 2;
  354. }
  355. }
  356. //无售后期
  357. $open_aftersale = D('Home/Front')->get_config_by_name('open_aftersale');
  358. if( empty($open_aftersale) )
  359. {
  360. $order_goods['is_statements_state'] = 1;
  361. }
  362. //ims_
  363. $goods_info = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $order_goods['goods_id']) )->find();
  364. $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();
  365. if($pick_up_type == -1 || $goods_cm_info['pick_up_type'] > $pick_up_type)
  366. {
  367. $pick_up_type = $goods_cm_info['pick_up_type'];
  368. if($pick_up_type == 0)
  369. {
  370. $pick_up_time = date('m-d', $today_time);
  371. //$pick_up_weekday = '周'.$arr[date('w',$today_time)];
  372. }else if( $pick_up_type == 1 ){
  373. $pick_up_time = date('m-d', $today_time+86400);
  374. //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400)];
  375. }else if( $pick_up_type == 2 )
  376. {
  377. $pick_up_time = date('m-d', $today_time+86400*2);
  378. //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400*2)];
  379. }else if($pick_up_type == 3)
  380. {
  381. $pick_up_time = $goods_cm_info['pick_up_modify'];
  382. }
  383. }
  384. if( !empty($goods_cm_info['goods_share_image']) )
  385. {
  386. $order_goods['goods_share_image']= tomedia( $goods_cm_info['goods_share_image'] );
  387. }else{
  388. $order_goods['goods_share_image'] = $order_goods['image'];
  389. }
  390. $order_goods['shop_price'] = $goods_info['price'];
  391. $store_info = array('s_true_name' =>'','s_logo' => '');
  392. $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
  393. //$store_info['s_logo'] = D('Home/Front')->get_config_by_name('shoplogo');
  394. if( !empty($store_info['s_logo']) )
  395. {
  396. $store_info['s_logo'] = tomedia($store_info['s_logo']);
  397. }else{
  398. $store_info['s_logo'] = '';
  399. }
  400. $order_goods['store_info'] = $store_info;
  401. //核销订单
  402. if( $order_info['delivery'] == 'hexiao' ){
  403. $order_goods_saleshexiao = M('lionfish_comshop_order_goods_saleshexiao')->where( array('order_id' =>$order_id,'order_goods_id' => $order_goods['order_goods_id'] ) )->find();
  404. //有效期截止
  405. $order_goods['effect_end_time'] = date('Y-m-d H:i:s',$order_goods_saleshexiao['effect_end_time']);
  406. // 是否核销过期:0 否,1、是
  407. $order_goods['is_hexiao_expire'] = $order_goods_saleshexiao['effect_end_time']>time()?0:1;
  408. //总核销次数
  409. $order_goods['hexiao_count'] = $order_goods_saleshexiao['hexiao_count'];
  410. //剩余核销次数
  411. $order_goods['remain_hexiao_count'] = $order_goods_saleshexiao['remain_hexiao_count'];
  412. //核销方式:0 订单核销,1、自定义核销次数
  413. $order_goods['hexiao_type'] = $order_goods_saleshexiao['hexiao_type'];
  414. //商品核销卷码
  415. $order_goods['hexiao_volume_code'] = $order_goods_saleshexiao['hexiao_volume_code'];
  416. //商品核销二维码
  417. if(empty($order_goods['hexiao_qr_code'])){
  418. $order_goods['hexiao_qr_code'] = D('Home/Salesroom')->_get_ordergoods_hxqrcode($order_id,$order_goods['order_goods_id'],$order_goods['hexiao_volume_code']);
  419. }else{
  420. $order_goods['hexiao_qr_code'] = tomedia($order_goods['hexiao_qr_code']);
  421. }
  422. //是否核销完毕:0 否,1、是
  423. $order_goods['is_hexiao_over'] = $order_goods_saleshexiao['is_hexiao_over'];
  424. //核销过期操作时间
  425. $order_goods['expire_act_time'] = $order_goods_saleshexiao['expire_act_time'];
  426. $volume_code_list[$vi]['hexiao_volume_code'] = $order_goods['hexiao_volume_code'];
  427. if($order_goods['is_hexiao_over'] == 1){
  428. $receive_count = $receive_count + $order_goods_saleshexiao['goods_quantity'] - $order_goods_saleshexiao['refund_quantity'];
  429. $volume_code_list[$vi]['is_use'] = 1;
  430. }else{
  431. $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']);
  432. $volume_code_list[$vi]['is_use'] = 0;
  433. }
  434. // 是否核销过期:0 否,1、是
  435. $volume_code_list[$vi]['is_hexiao_expire'] = $order_goods_saleshexiao['effect_end_time']>time()?0:1;
  436. $volume_code_list[$vi]['effect_end_time'] = date('Y-m-d H:i:s',$order_goods_saleshexiao['effect_end_time']);
  437. $volume_code_list[$vi]['refund_quantity'] = $order_goods_saleshexiao['refund_quantity'];
  438. if($order_goods['hexiao_type'] == 0){
  439. $hx_order_count = $hx_order_count + 1;
  440. }else{
  441. $hx_time_count = $hx_time_count + 1;
  442. }
  443. //核销商品门店信息
  444. $salesroom_list = D('Home/Salesroom')->get_order_goods_salesroom($order_goods['order_goods_id'],$gpc['longitude'],$gpc['latitude'],0);
  445. $order_goods['salesroom_list'] = $salesroom_list;
  446. $vi++;
  447. }
  448. if( $order_goods['is_refund_state'] == 1 || ($order_goods['has_refund_money'] > 0 && $order_goods['has_refund_quantity'] > 0) )
  449. {
  450. $order_goods['is_refund_state'] = 1;
  451. $where = " order_id = '".$order_goods['order_id']."' and order_goods_id = '".$order_goods['order_goods_id']."' and state in (0,2,3) ";
  452. $refund_info = M('lionfish_comshop_order_refund')->field('ref_id,order_id,ref_money,real_refund_quantity,state')->where( $where )->find();
  453. if(!empty($refund_info)){
  454. $order_goods['refund_info'] = $refund_info;
  455. }else{
  456. $refund_info = array();
  457. $refund_info['order_id'] = $order_goods['order_id'];
  458. $refund_info['ref_money'] = $order_goods['has_refund_money'];
  459. $refund_info['real_refund_quantity'] = $order_goods['has_refund_quantity'];
  460. $refund_info['state'] = 3;
  461. $order_goods['refund_info'] = $refund_info;
  462. }
  463. }
  464. unset($order_goods['model']);
  465. unset($order_goods['rela_goodsoption_valueid']);
  466. unset($order_goods['comment']);
  467. //ims_ ims_lionfish_comshop_order_goods_refund addtime
  468. $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();
  469. if( empty($order_goods_refund_list) )
  470. {
  471. $order_goods_refund_list = array();
  472. }else{
  473. foreach( $order_goods_refund_list as $kre => $rval )
  474. {
  475. $rval['addtime'] = date('Y-m-d H:i:s', $rval['addtime']);
  476. $order_goods_refund_list[$kre] = $rval;
  477. $refund_goods_quantity = $refund_goods_quantity + $rval['real_refund_quantity'];
  478. }
  479. }
  480. $order_goods['order_goods_refund_list'] = $order_goods_refund_list;
  481. $goods_quantity = $goods_quantity + $order_goods['quantity'];
  482. $order_goods_list[$key] = $order_goods;
  483. $shiji_total_money += $order_goods['quantity'] * $order_goods['price'];
  484. $member_youhui += ($order_goods['real_total'] - $order_goods['total']);
  485. }
  486. //核销订单
  487. if( $order_info['delivery'] == 'hexiao' ){
  488. $hx_receive_info['goods_count'] = count($order_goods_list);//商品种类
  489. $hx_receive_info['goods_quantity'] = $goods_quantity;//商品总数量
  490. $hx_receive_info['receive_count'] = $receive_count;//已收货商品数量
  491. $hx_receive_info['wait_count'] = $goods_quantity-$receive_count-$refund_goods_quantity;//待收货商品数量
  492. $hx_receive_info['refund_goods_quantity'] = $refund_goods_quantity;//已退款商品数量
  493. $hx_receive_info['volume_code_list'] = $volume_code_list;//商品卷码列表
  494. $hx_record = D('Home/Salesroom')->get_last_ordergoods_hexiaorecord($order_id);
  495. if(!empty($hx_record)){
  496. //使用地址
  497. if(empty($hx_record['salesroom_name'])){
  498. $hx_receive_info['salesroom_name'] = $hx_record['smember_name'];
  499. }else{
  500. $hx_receive_info['salesroom_name'] = $hx_record['salesroom_name'];
  501. }
  502. //使用时间
  503. $hx_receive_info['use_time'] = date('Y-m-d H:i:s',$hx_record['addtime']);
  504. }
  505. if($hx_order_count > 0 && $hx_time_count > 0){//混合订单
  506. $order_info['order_hexiao_type'] = 2;
  507. }else if($hx_order_count > 0 && $hx_time_count == 0){//按订单核销
  508. $order_info['order_hexiao_type'] = 0;
  509. }else if($hx_order_count == 0 && $hx_time_count > 0){//按次数核销
  510. $order_info['order_hexiao_type'] = 1;
  511. }
  512. $order_info['hx_receive_info'] = $hx_receive_info;//核销订单已收到待收货情况
  513. }
  514. unset($order_info['store_id']);
  515. unset($order_info['email']);
  516. unset($order_info['shipping_city_id']);
  517. unset($order_info['shipping_country_id']);
  518. unset($order_info['shipping_province_id']);
  519. //unset($order_info['comment']);
  520. unset($order_info['voucher_id']);
  521. unset($order_info['is_balance']);
  522. unset($order_info['lottery_win']);
  523. unset($order_info['ip']);
  524. unset($order_info['ip_region']);
  525. unset($order_info['user_agent']);
  526. $order_info['is_can_received'] = $is_can_received;
  527. $order_info['shipping_fare'] = round($order_info['shipping_fare'],2) < 0.01 ? '0.00':round($order_info['shipping_fare'],2) ;
  528. $order_info['voucher_credit'] = round($order_info['voucher_credit'],2) < 0.01 ? '0.00':round($order_info['voucher_credit'],2) ;
  529. $order_info['fullreduction_money'] = round($order_info['fullreduction_money'],2) < 0.01 ? '0.00':round($order_info['fullreduction_money'],2) ;
  530. $need_data = array();
  531. if($order_info['type'] == 'integral')
  532. {
  533. //暂时屏蔽积分商城
  534. $order_info['score'] = round($order_info['total'],2);
  535. }
  536. $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);
  537. if($order_info['total'] < 0)
  538. {
  539. $order_info['total'] = '0.00';
  540. }
  541. $order_info['real_total'] = round($shiji_total_money,2)+$order_info['shipping_fare'];
  542. $order_info['price'] = round($order_info['price'],2);
  543. $order_info['member_youhui'] = round($member_youhui,2) < 0.01 ? '0.00':round($member_youhui,2);
  544. $order_info['pick_up_time'] = $pick_up_time;
  545. $order_info['shipping_fare'] = sprintf("%.2f",$order_info['shipping_fare']);
  546. $order_info['voucher_credit'] = sprintf("%.2f",$order_info['voucher_credit']);
  547. $order_info['fullreduction_money'] = sprintf("%.2f",$order_info['fullreduction_money']);
  548. $order_info['total'] = sprintf("%.2f",$order_info['total']);
  549. $order_info['real_total'] = sprintf("%.2f",$order_info['real_total']);
  550. $order_info['date_added'] = date('Y-m-d H:i:s', $order_info['date_added']);
  551. if($order_info['delivery'] =='pickup')
  552. {
  553. }else{
  554. }
  555. if( !empty($order_info['pay_time']) && $order_info['pay_time'] >0 )
  556. {
  557. $order_info['pay_date'] = date('Y-m-d H:i:s', $order_info['pay_time']);
  558. }else{
  559. $order_info['pay_date'] = '';
  560. }
  561. $order_info['express_tuanz_date'] = date('Y-m-d H:i:s', $order_info['express_tuanz_time']);
  562. $order_info['receive_date'] = date('Y-m-d H:i:s', $order_info['receive_time']);
  563. //"delivery": "pickup", enum('express', 'pickup', 'tuanz_send')
  564. if($order_info['delivery'] == 'express')
  565. {
  566. $placeorder_trans_name = D('Home/Front')->get_config_by_name('placeorder_trans_name' );
  567. $order_info['delivery_name'] = $placeorder_trans_name?$placeorder_trans_name:'快递';
  568. }else if($order_info['delivery'] == 'pickup')
  569. {
  570. $delivery_ziti_name = D('Home/Front')->get_config_by_name('delivery_ziti_name' );
  571. $order_info['delivery_name'] = $delivery_ziti_name?$delivery_ziti_name:'自提';
  572. }else if($order_info['delivery'] == 'tuanz_send'){
  573. $delivery_tuanzshipping_name = D('Home/Front')->get_config_by_name('delivery_tuanzshipping_name' );
  574. $order_info['delivery_name'] = $delivery_tuanzshipping_name?$delivery_tuanzshipping_name:'团长配送';
  575. }
  576. $pin_rebate = [];
  577. //拼团获取返利信息
  578. if($order_info['type'] == 'pintuan'){
  579. $pin_rebate['reward_amount'] = 0;
  580. $pin_rebate['rebate_reward'] = 0;
  581. $pin_order = M('lionfish_comshop_pin_order')->where( array('order_id' => $order_id ) )->find();
  582. //获取拼团信息
  583. $pin_info = M('lionfish_comshop_pin')->where( array('pin_id' =>$pin_order['pin_id'] ) )->find();
  584. if($pin_info['is_pintuan_rebate'] == 1){
  585. if($pin_info['rebate_reward'] == 1){//积分
  586. $integral_flow = M('lionfish_comshop_member_integral_flow')->where( array('order_id' => $order_id,'type'=>'pintuan_rebate') )->find();
  587. if(!empty($integral_flow)){
  588. $pin_rebate['reward_amount'] = $integral_flow['score'];
  589. $pin_rebate['rebate_reward'] = 1;
  590. }
  591. }else if($pin_info['rebate_reward'] == 2){//余额
  592. $charge_flow = M('lionfish_comshop_member_charge_flow')->where( array('trans_id' => $order_id,'state'=>21) )->find();
  593. if(!empty($charge_flow)){
  594. $pin_rebate['reward_amount'] = $charge_flow['money'];
  595. $pin_rebate['rebate_reward'] = 2;
  596. }
  597. }
  598. }
  599. }
  600. //获取订单表单信息
  601. $order_form = D('Home/Allform')->getOrderFormInfo($order_id, $member_id);
  602. $need_data['order_form'] = $order_form;
  603. $need_data['order_info'] = $order_info;
  604. $need_data['order_status_info'] = $order_status_info;
  605. $need_data['shipping_province'] = $shipping_province;
  606. $need_data['shipping_city'] = $shipping_city;
  607. $need_data['shipping_country'] = $shipping_country;
  608. $need_data['order_goods_list'] = $order_goods_list;
  609. $need_data['goods_count'] = count($order_goods_list);
  610. $need_data['pin_rebate'] = $pin_rebate;
  611. //$order_info['order_status_id'] 13 平台介入退款
  612. $order_refund_historylist = array();
  613. $pingtai_deal = 0;
  614. //判断是否已经平台处理完毕
  615. $order_refund_historylist = M('lionfish_comshop_order_refund_history')->where( array('order_id' => $order_id) )->order('addtime asc')->select();
  616. foreach($order_refund_historylist as $key => $val)
  617. {
  618. if($val['type'] ==3)
  619. {
  620. $pingtai_deal = 1;
  621. }
  622. }
  623. $order_refund = M('lionfish_comshop_order_refund')->where( array('order_id' => $order_id) )->find();
  624. if(!empty($order_refund))
  625. {
  626. $order_refund['addtime'] = date('Y-m-d H:i:s', $order_refund['addtime']);
  627. }
  628. $need_data['pick_up'] = $pick_up_info;
  629. if( empty($pick_order_info['qrcode']) && false)
  630. {
  631. }
  632. $need_data['pick_order_info'] = $pick_order_info;
  633. $order_pay_after_share = D('Home/Front')->get_config_by_name('order_pay_after_share');
  634. if($order_pay_after_share==1){
  635. $order_pay_after_share_title = D('Home/Front')->get_config_by_name('order_pay_after_share_title');
  636. $order_pay_after_share_img = D('Home/Front')->get_config_by_name('order_pay_after_share_img');
  637. $order_pay_after_share_img = !empty($order_pay_after_share_img) ? tomedia($order_pay_after_share_img) : '';
  638. $need_data['share_img'] = empty($order_pay_after_share_img) ? $need_data['order_goods_list'][0]['image']: $order_pay_after_share_img;
  639. $need_data['share_title'] = $order_pay_after_share_title;
  640. }else{
  641. if(empty($need_data['order_goods_list'][0]['goods_share_image']))
  642. {
  643. $need_data['share_img'] = $need_data['order_goods_list'][0]['image'];
  644. }
  645. }
  646. $order_can_del_cancle = D('Home/Front')->get_config_by_name('order_can_del_cancle');
  647. $order_can_del_cancle = empty($order_can_del_cancle) || $order_can_del_cancle == 0 ? 1 : 0;
  648. $is_hidden_orderlist_phone = D('Home/Front')->get_config_by_name('is_hidden_orderlist_phone');
  649. $is_show_guess_like = D('Home/Front')->get_config_by_name('is_show_order_guess_like');
  650. $user_service_switch = D('Home/Front')->get_config_by_name('user_service_switch');
  651. $common_header_backgroundimage = D('Home/Front')->get_config_by_name('common_header_backgroundimage');
  652. if($common_header_backgroundimage){
  653. $common_header_backgroundimage = tomedia($common_header_backgroundimage);
  654. }
  655. $order_can_shen_refund = D('Home/Front')->get_config_by_name('is_score_can_refund');
  656. if( $order_info['type'] == 'integral' )
  657. {
  658. if( !isset($order_can_shen_refund) || empty($order_can_shen_refund) )
  659. {
  660. $order_can_shen_refund = 0;
  661. }else{
  662. $order_can_shen_refund = 1;
  663. }
  664. }else{
  665. $order_can_shen_refund = 1;
  666. }
  667. $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
  668. $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
  669. if( !isset($order_note_open) || $order_note_open == 0)
  670. {
  671. $order_note_open = 0;
  672. }
  673. if( !isset($order_note_name) || empty($order_note_name) )
  674. {
  675. $order_note_name = '店名';
  676. }
  677. $open_comment_gift = D('Home/Front')->get_config_by_name('open_comment_gift');
  678. $open_comment_gift = !empty($open_comment_gift) ? $open_comment_gift : 0;
  679. $result = D('Seller/Order')->check_comment_gift_score($member_id);
  680. if(!$result['is_comment_gift']){
  681. $open_comment_gift = 0;
  682. }
  683. //预售信息数组 begin
  684. $presale_info = [];
  685. $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $order_id );
  686. if( $presale_result['code'] == 0 )
  687. {
  688. $presale_info = $presale_result['data'];
  689. }
  690. //end
  691. //礼品卡订单信息 begin
  692. $virtualcard_result = D('Seller/VirtualCard')->getVirtualCardOrderInfO( $order_id );
  693. $virtualcard_info = [];
  694. if( $virtualcard_result['code'] == 0 && $virtualcard_result['data']['state'] > 0 )
  695. {
  696. $virtualcard_info = $virtualcard_result['data'];
  697. }
  698. //end
  699. echo json_encode(
  700. array(
  701. 'code' => 0,
  702. 'data' => $need_data,
  703. 'order_note_open' => $order_note_open,
  704. 'order_note_name' => $order_note_name,
  705. 'pingtai_deal' => $pingtai_deal,
  706. 'order_refund' => $order_refund,
  707. 'order_can_shen_refund' => $order_can_shen_refund,
  708. 'order_can_del_cancle' => $order_can_del_cancle,
  709. 'order_pay_after_share' => $order_pay_after_share,
  710. 'is_hidden_orderlist_phone' => $is_hidden_orderlist_phone,
  711. 'is_show_guess_like' => $is_show_guess_like,
  712. 'user_service_switch' => $user_service_switch,
  713. 'open_comment_gift' => $open_comment_gift,
  714. 'common_header_backgroundimage' => $common_header_backgroundimage,
  715. 'presale_info' => $presale_info,//预售信息
  716. 'virtualcard_info' => $virtualcard_info,//礼品卡信息
  717. )
  718. );
  719. }
  720. public function sign_dan_order()
  721. {
  722. $gpc = I('request.');
  723. $token = $gpc['token'];
  724. $order_id = $gpc['order_id'];
  725. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  726. $member_id = $weprogram_token['member_id'];
  727. $community_info = D('Home/Front')->get_member_community_info($member_id);
  728. $order_info = M('lionfish_comshop_order')->where( array('head_id' => $community_info['id'],'order_id' => $order_id) )->find();
  729. if(!empty($order_info) && $order_info['order_status_id'] == 14)
  730. {
  731. $oh = array();
  732. $oh['order_id']=$order_id;
  733. $oh['order_status_id']= 4;
  734. $oh['comment']='团长签收货物';
  735. $oh['date_added']=time();
  736. $oh['notify']= $order_info['order_status_id'];
  737. M('lionfish_comshop_order_history')->add( $oh );
  738. //更改订单为已发货
  739. D('Home/Frontorder')->send_order_operate($order_id);
  740. echo json_encode( array('code' => 0) );
  741. }else{
  742. echo json_encode( array('code' => 1) );
  743. }
  744. }
  745. public function order_commission()
  746. {
  747. $gpc = I('request.');
  748. $token = $gpc['token'];
  749. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  750. $member_id = $weprogram_token['member_id'];
  751. if( empty($member_id) )
  752. {
  753. echo json_encode( array('code' => 1) );
  754. die();
  755. }
  756. $community_info = D('Home/Front')->get_member_community_info($member_id);
  757. $head_id = $community_info['id'];
  758. $choose_date = $gpc['chooseDate'];
  759. $choose_date = str_replace('年','-', $choose_date);
  760. $choose_date = str_replace('月','-', $choose_date);
  761. $choose_date = $choose_date.'01 00:00:00';
  762. $BeginDate=date('Y-m-d', strtotime($choose_date));
  763. $end_date = date('Y-m-d', strtotime("$BeginDate +1 month -1 day")).' 23:59:59';
  764. $begin_time = strtotime($BeginDate.' 00:00:00');
  765. $end_time = strtotime($end_date);
  766. $where = " and addtime >= {$begin_time} and addtime < {$end_time} ";
  767. $money = M('lionfish_community_head_commiss_order')->where("head_id={$head_id} and state=0 {$where}")->sum('money');
  768. if( empty($money))
  769. {
  770. $money = 0;
  771. }
  772. echo json_encode( array('code' => 0, 'money' => $money) );
  773. die();
  774. }
  775. public function refundorderlist()
  776. {
  777. $gpc = I('request.');
  778. $is_tuanz = isset($gpc['is_tuanz']) ? $gpc['is_tuanz'] :0;
  779. $token = $gpc['token'];
  780. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  781. $member_id = $weprogram_token['member_id'];
  782. $page = isset($gpc['page']) ? $gpc['page']:'1';
  783. $size = isset($gpc['size']) ? $gpc['size']:'6';
  784. $offset = ($page - 1)* $size;
  785. $type = isset($gpc['type']) ? $gpc['type']:'';
  786. $where = ' and o.member_id = '.$member_id;
  787. $fields = " orf.state as refund_state ,orf.order_goods_id as r_order_goods_id, ";
  788. $currentTab = isset($gpc['currentTab']) ? $gpc['currentTab']:0;
  789. if($currentTab == 0)
  790. {
  791. }else if($currentTab == 1){
  792. //售后
  793. $where .= ' and o.order_status_id = 12 ';
  794. }else if($currentTab == 2){
  795. $where .= ' and orf.state =3 ';
  796. }else if($currentTab == 3)
  797. {
  798. $where .= ' and orf.state =1 ';
  799. }
  800. $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
  801. where 1 {$where}
  802. order by orf.addtime desc limit {$offset},{$size}";
  803. $list = M()->query($sql);
  804. $lionfish_comshop_order_status_list = M('lionfish_comshop_order_status')->select();
  805. $url = D('Home/Front')->get_config_by_name('shop_domain');
  806. $status_arr = array();
  807. foreach( $lionfish_comshop_order_status_list as $kk => $val )
  808. {
  809. $status_arr[ $val['order_status_id'] ] = $val['name'];
  810. }
  811. //createTime
  812. foreach($list as $key => $val)
  813. {
  814. $val['createTime'] = date('Y-m-d H:i:s', $val['date_added']);
  815. switch( $val['state'] )
  816. {
  817. case 0:
  818. $val['status_name'] = '申请中';
  819. break;
  820. case 1:
  821. $val['status_name'] = '商家拒绝';
  822. break;
  823. case 2:
  824. break;
  825. case 3:
  826. $val['status_name'] = '退款成功';
  827. break;
  828. case 4:
  829. $val['status_name'] = '退款失败';
  830. break;
  831. case 5:
  832. $val['status_name'] = '撤销申请';
  833. break;
  834. }
  835. if($val['shipping_fare']<=0.001 || $val['delivery'] == 'pickup')
  836. {
  837. $val['shipping_fare'] = '免运费';
  838. }else{
  839. $val['shipping_fare'] = ''.$val['shipping_fare'];
  840. }
  841. if($val['order_status_id'] == 10)
  842. {
  843. $val['status_name'] = '等待退款';
  844. }
  845. else if($val['order_status_id'] == 4 && $val['delivery'] =='pickup')
  846. {
  847. //delivery 6
  848. $val['status_name'] = '待自提';
  849. //已自提
  850. }
  851. else if($val['order_status_id'] == 6 && $val['delivery'] =='pickup')
  852. {
  853. //delivery 6
  854. $val['status_name'] = '已自提';
  855. //已自提
  856. }
  857. else if($val['order_status_id'] == 1 && $val['type'] == 'lottery')
  858. {
  859. //等待开奖
  860. //一等奖
  861. if($val['lottery_win'] == 1)
  862. {
  863. $val['status_name'] = '一等奖';
  864. }else {
  865. $val['status_name'] = '等待开奖';
  866. }
  867. }
  868. else if($val['order_status_id'] == 2 && $val['type'] == 'lottery')
  869. {
  870. //等待开奖
  871. $val['status_name'] = '等待开奖';
  872. }
  873. $quantity = 0;
  874. if( $val['order_goods_id'] > 0 )
  875. {
  876. $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
  877. from ".C('DB_PREFIX')."lionfish_comshop_order_goods where order_goods_id=".$val['order_goods_id']." and order_id= ".$val['order_id']."";
  878. }else{
  879. $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
  880. from ".C('DB_PREFIX')."lionfish_comshop_order_goods where order_id= ".$val['order_id']."";
  881. }
  882. $goods_list = M()->query($goods_sql); //M()->query($goods_sql);
  883. $total_commision = 0;
  884. if($val['delivery'] =='tuanz_send')
  885. {
  886. $total_commision += $val['shipping_fare'];
  887. }
  888. foreach($goods_list as $kk => $vv)
  889. {
  890. //commision
  891. $order_option_list = M('lionfish_comshop_order_option')->where( array('order_goods_id' =>$vv['order_goods_id'] ) )->select();
  892. if( !empty($vv['goods_images']))
  893. {
  894. $goods_images = $url. '/'.resize($vv['goods_images'],400,400);
  895. if(is_array($goods_images))
  896. {
  897. $vv['goods_images'] = $vv['goods_images'];
  898. }else{
  899. $vv['goods_images']= $url.'/'.resize($vv['goods_images'],400,400) ;
  900. }
  901. }else{
  902. $vv['goods_images']= '';
  903. }
  904. $goods_filed = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $vv['goods_id'] ) )->find();
  905. $vv['orign_price'] = $goods_filed['price'];
  906. $quantity += $vv['quantity'];
  907. foreach($order_option_list as $option)
  908. {
  909. $vv['option_str'][] = $option['value'];
  910. }
  911. if( !isset($vv['option_str']) )
  912. {
  913. $vv['option_str'] = '';
  914. }else{
  915. $vv['option_str'] = implode(',', $vv['option_str']);
  916. }
  917. // $vv['price'] = round($vv['price'],2);
  918. $vv['price'] = sprintf("%.2f",$vv['price']);
  919. $vv['orign_price'] = sprintf("%.2f",$vv['orign_price']);
  920. $vv['total'] = sprintf("%.2f",$vv['total']);
  921. $goods_list[$kk] = $vv;
  922. }
  923. $val['total_commision'] = $total_commision;
  924. $val['quantity'] = $quantity;
  925. if( empty($val['store_id']) )
  926. {
  927. $val['store_id'] = 1;
  928. }
  929. $store_info = array('s_true_name' =>'','s_logo' => '');
  930. $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
  931. $store_info['s_logo'] = D('Home/Front')->get_config_by_name('shoplogo');
  932. if( !empty($store_info['s_logo']))
  933. {
  934. $store_info['s_logo'] = tomedia($store_info['s_logo']);
  935. }else{
  936. $store_info['s_logo'] = '';
  937. }
  938. $order_goods['store_info'] = $store_info;
  939. $val['store_info'] = $store_info;
  940. $val['goods_list'] = $goods_list;
  941. $val['total'] = $val['total'] + $val['shipping_fare']-$val['voucher_credit']-$val['fullreduction_money'];
  942. if($val['total'] < 0)
  943. {
  944. $val['total'] = 0;
  945. }
  946. $val['total'] = sprintf("%.2f",$val['total']);
  947. $list[$key] = $val;
  948. }
  949. $need_data = array('code' => 0);
  950. if( !empty($list) )
  951. {
  952. $need_data['data'] = $list;
  953. }else {
  954. $need_data = array('code' => 1);
  955. }
  956. echo json_encode( $need_data );
  957. die();
  958. }
  959. public function orderlist()
  960. {
  961. $gpc = I('request.');
  962. $_GPC = $gpc;
  963. $is_tuanz = isset($gpc['is_tuanz']) ? $gpc['is_tuanz'] :0;
  964. $is_supply = isset($gpc['is_supply']) ? $gpc['is_supply'] :0;
  965. $token = $gpc['token'];
  966. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  967. $member_id = $weprogram_token['member_id'];
  968. $sqlcondition = "";
  969. $left_join = "";
  970. $page = isset($gpc['page']) ? $gpc['page']:'1';
  971. $size = isset($gpc['size']) ? $gpc['size']:'6';
  972. $offset = ($page - 1)* $size;
  973. $type = isset($gpc['type']) ? $gpc['type']:'';
  974. $order_status = isset($gpc['order_status']) ? $gpc['order_status']:'-1';
  975. $soli_id = isset($_GPC['soli_id']) ? $_GPC['soli_id'] : 0;//是否群接龙
  976. if($is_tuanz == 1)
  977. {
  978. $community_info = D('Home/Front')->get_member_community_info($member_id);
  979. if( isset($_GPC['chooseDate']) && !empty($_GPC['chooseDate']) )
  980. {
  981. $where = ' and o.head_id = '.$community_info['id'] ;
  982. }else{
  983. //$where = ' and o.head_id = '.$community_info['id'].' and o.delivery != "express" ';
  984. $where = ' and o.head_id = '.$community_info['id'].' ';
  985. }
  986. $searchfield = isset($_GPC['searchfield']) && !empty($_GPC['searchfield']) ? $_GPC['searchfield'] : '';
  987. if( !empty($searchfield) && !empty($_GPC['keyword']))
  988. {
  989. $keyword = $_GPC['keyword'];
  990. switch($searchfield)
  991. {
  992. case 'ordersn':
  993. $where .= ' AND locate("'.$keyword.'",o.order_num_alias)>0';
  994. break;
  995. case 'member':
  996. $where .= ' AND (locate("'.$keyword.'",m.username)>0 or "'.$keyword.'"=o.member_id )';
  997. $left_join .= ' left join ' . C('DB_PREFIX'). 'lionfish_comshop_member as m on m.member_id = o.member_id ';
  998. break;
  999. case 'address':
  1000. $where .= ' AND ( locate("'.$keyword.'",o.shipping_name)>0 )';
  1001. break;
  1002. case 'mobile':
  1003. $where .= ' AND ( locate("'.$keyword.'",o.shipping_tel)>0 )';
  1004. break;
  1005. case 'location':
  1006. $where .= ' AND (locate("'.$keyword.'",o.shipping_address)>0 )';
  1007. break;
  1008. case 'shipping_no':
  1009. $where .= ' AND (locate("'.$keyword.'",o.shipping_no)>0 )';
  1010. break;
  1011. case 'goodstitle':
  1012. $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';
  1013. break;
  1014. case 'trans_id':
  1015. $where .= ' AND (locate("'.$keyword.'",o.transaction_id)>0 )';
  1016. break;
  1017. }
  1018. }
  1019. }
  1020. else if( $is_supply == 1 )
  1021. {
  1022. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  1023. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  1024. {
  1025. $supply_is_open_mobilemanage = 0;
  1026. }
  1027. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  1028. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  1029. {
  1030. $keyword = $_GPC['keyword'];
  1031. if( !empty($keyword) )
  1032. {
  1033. $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';
  1034. }else{
  1035. $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';
  1036. }
  1037. //$where = " and o.delivery != 'hexiao'";
  1038. }else{
  1039. echo json_encode( array('code' => 2, 'msg' => '未开启此项功能') );
  1040. die();
  1041. }
  1042. }
  1043. else{
  1044. $where = ' and o.member_id = '.$member_id;
  1045. }
  1046. if( isset($gpc['chooseDate']) && !empty($gpc['chooseDate']) )
  1047. {
  1048. $choose_date = $gpc['chooseDate'];
  1049. $choose_date = str_replace('年','-', $choose_date);
  1050. $choose_date = str_replace('月','-', $choose_date);
  1051. $choose_date = $choose_date.'01 00:00:00';
  1052. $BeginDate=date('Y-m-d', strtotime($choose_date));
  1053. $end_date = date('Y-m-d', strtotime("$BeginDate +1 month -1 day")).' 23:59:59';
  1054. $begin_time = strtotime($BeginDate.' 00:00:00');
  1055. $end_time = strtotime($end_date);
  1056. $where .= ' and o.date_added >= '.$begin_time.' and o.date_added < '.$end_time;
  1057. }
  1058. //全部 -1 待付款 3 待配送1 待提货4 已提货6
  1059. //order_status $order_status
  1060. $join = "";
  1061. $fields = "";
  1062. switch($order_status)
  1063. {
  1064. case -1:
  1065. //全部 -1
  1066. break;
  1067. case 3:
  1068. //待付款 3
  1069. $where .= ' and o.order_status_id = 3 ';
  1070. break;
  1071. case 1:
  1072. //待配送1
  1073. $where .= ' and o.order_status_id = 1 ';
  1074. break;
  1075. case 4:
  1076. //待提货4
  1077. $where .= ' and o.order_status_id = 4 ';
  1078. break;
  1079. case 14:
  1080. //待提货4
  1081. $where .= ' and o.order_status_id = 14 ';
  1082. break;
  1083. case 22:
  1084. //待确认佣金的
  1085. $where .= ' and o.order_status_id in (1,4,14) ';
  1086. break;
  1087. case 357:
  1088. //待确认佣金的
  1089. $where .= ' and o.order_status_id in (3,5,7) ';
  1090. break;
  1091. case 6:
  1092. //已提货6
  1093. $where .= ' and o.order_status_id in (6,11) ';
  1094. break;
  1095. case 11:
  1096. //已完成
  1097. $where .= ' and o.order_status_id = 11 ';
  1098. break;
  1099. case 12:
  1100. $fields = " orf.state as refund_state , ";
  1101. $currentTab = isset($gpc['currentTab']) ? $gpc['currentTab']:0;
  1102. $join = " ".C('DB_PREFIX').'lionfish_comshop_order_refund as orf, ';
  1103. $where .= ' and o.order_id = orf.order_id ';
  1104. if($currentTab == 0)
  1105. {
  1106. }else if($currentTab == 1){
  1107. //售后
  1108. $where .= ' and o.order_status_id = 12 ';
  1109. }else if($currentTab == 2){
  1110. $where .= ' and orf.state =3 ';
  1111. }else if($currentTab == 3)
  1112. {
  1113. $where .= ' and orf.state =1 ';
  1114. }
  1115. break;
  1116. case 7:
  1117. //已退款
  1118. $where .= ' and o.order_status_id = 7 ';
  1119. break;
  1120. }
  1121. $where .= ' and o.type != "ignore" ';
  1122. if( isset($soli_id) && $soli_id > 0 )
  1123. {
  1124. $where .= " and o.soli_id = {$soli_id} ";
  1125. }
  1126. if( !empty($type) )
  1127. {
  1128. //$where .= ' and o.type != "ignore" ';
  1129. }
  1130. $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 "
  1131. . " from ".C('DB_PREFIX')."lionfish_comshop_order as o {$left_join}, {$join}
  1132. ".C('DB_PREFIX')."lionfish_comshop_order_status as os ".$sqlcondition."
  1133. where o.order_status_id = os.order_status_id {$where}
  1134. order by o.date_added desc limit {$offset},{$size}";
  1135. $list = M()->query($sql);
  1136. $open_auto_delete = D('Home/Front')->get_config_by_name('open_auto_delete');
  1137. $cancle_hour = D('Home/Front')->get_config_by_name('auto_cancle_order_time');
  1138. $cancle_hour_time = time() - 3600 * $cancle_hour;
  1139. $url = D('Home/Front')->get_config_by_name('shop_domain');
  1140. //createTime
  1141. foreach($list as $key => $val)
  1142. {
  1143. //判断是否需要取消订单
  1144. //order_status_id 3 open_auto_delete
  1145. if($open_auto_delete == 1 && $val['order_status_id'] == 3 && $val['date_added'] < $cancle_hour_time )
  1146. {
  1147. D('Home/Frontorder')->cancel_order($val['order_id'], true);
  1148. $val['order_status_id'] == 5;
  1149. }
  1150. $presale_result = D('Home/PresaleGoods')->getOrderPresaleInfo( $val['order_id'] );
  1151. if( $presale_result['code'] == 0 )
  1152. {
  1153. $val['is_presale'] = 1;
  1154. }else{
  1155. $val['is_presale'] = 0;
  1156. }
  1157. if($val['delivery'] == 'pickup')
  1158. {
  1159. //$val['total'] = round($val['total'],2) - round($val['voucher_credit'],2);
  1160. }else{
  1161. //$val['total'] = round($val['total'],2)+round($val['shipping_fare'],2) - round($val['voucher_credit'],2);
  1162. }
  1163. $val['createTime'] = date('Y-m-d H:i:s', $val['date_added']);
  1164. // $val['delivery'] =='pickup'
  1165. if($val['shipping_fare']<=0.001 || $val['delivery'] == 'pickup')
  1166. {
  1167. $val['shipping_fare'] = 0.00;
  1168. }else{
  1169. $val['shipping_fare'] = ''.$val['shipping_fare'];
  1170. }
  1171. if($val['order_status_id'] == 10)
  1172. {
  1173. $val['status_name'] = '等待退款';
  1174. }
  1175. else if($val['order_status_id'] == 4 && $val['delivery'] =='pickup')
  1176. {
  1177. //delivery 6
  1178. $val['status_name'] = '待自提';
  1179. //已自提
  1180. }
  1181. else if($val['order_status_id'] == 6 && $val['delivery'] =='pickup')
  1182. {
  1183. //delivery 6
  1184. $val['status_name'] = '已自提';
  1185. //已自提
  1186. }
  1187. else if($val['order_status_id'] == 1 && $val['type'] == 'lottery')
  1188. {
  1189. //等待开奖
  1190. //一等奖
  1191. if($val['lottery_win'] == 1)
  1192. {
  1193. $val['status_name'] = '一等奖';
  1194. }else {
  1195. $val['status_name'] = '等待开奖';
  1196. }
  1197. }
  1198. else if($val['order_status_id'] == 2 && $val['type'] == 'lottery')
  1199. {
  1200. //等待开奖
  1201. $val['status_name'] = '等待开奖';
  1202. }
  1203. $quantity = 0;
  1204. $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();
  1205. $total_commision = 0;
  1206. if($val['delivery'] =='tuanz_send')
  1207. {
  1208. $total_commision += $val['shipping_fare'];
  1209. }
  1210. foreach($goods_list as $kk => $vv)
  1211. {
  1212. //commision
  1213. if($is_tuanz == 1){
  1214. $community_order_info = M('lionfish_community_head_commiss_order')->where( array('head_id' => $community_info['id'],'order_goods_id' => $vv['order_goods_id']) )->find();
  1215. if(!empty($community_order_info))
  1216. {
  1217. $vv['commision'] = $community_order_info['money']-$community_order_info['add_shipping_fare'];
  1218. $vv['commision'] = sprintf("%.2f",$vv['commision']);
  1219. if($community_order_info['state'] == 2){
  1220. $vv['commision'] = 0;
  1221. }
  1222. $total_commision += $vv['commision'];
  1223. }else{
  1224. $vv['commision'] = "0.00";
  1225. }
  1226. $vv['head_shipping_fare'] = $community_order_info['add_shipping_fare'];//团长配送费
  1227. $vv['old_commision'] = $vv['commision'];
  1228. $vv['del_commision'] = 0;
  1229. //fen_type
  1230. $vv['fen_type'] = $community_order_info['fen_type'];// 0 按照比例, 1按照金额
  1231. $vv['fen_bili'] = $community_order_info['bili'];//比例
  1232. $vv['fen_gumoney'] = $community_order_info['bili'];//按照金额
  1233. $order_jishu = $vv['total'] -$vv['fullreduction_money']-$vv['voucher_credit']-$vv['has_refund_money'];
  1234. $vv['order_jishu'] = $order_jishu;//有效金额:(基数)
  1235. //has_refund_commission = 0
  1236. $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();
  1237. if( !empty($order_goods_refund_list) )
  1238. {
  1239. $kvbal_total_back_head_orderbuycommiss = 0;//合计退掉佣金
  1240. foreach( $order_goods_refund_list as $kvval )
  1241. {
  1242. $kvbal_total_back_head_orderbuycommiss += $kvval['back_head_orderbuycommiss'];
  1243. }
  1244. $vv['del_commision'] = $kvbal_total_back_head_orderbuycommiss;
  1245. $vv['old_commision'] += $vv['del_commision'];
  1246. }
  1247. }
  1248. $order_option_list = M('lionfish_comshop_order_option')->where( array('order_goods_id' => $vv['order_goods_id']) )->select();
  1249. if( !empty($vv['goods_images']))
  1250. {
  1251. $goods_images = $url. '/'.resize($vv['goods_images'],400,400);
  1252. if(is_array($goods_images))
  1253. {
  1254. $vv['goods_images'] = $vv['goods_images'];
  1255. }else{
  1256. $vv['goods_images']= $url.'/'.resize($vv['goods_images'],400,400) ;
  1257. }
  1258. }else{
  1259. $vv['goods_images']= '';
  1260. }
  1261. $goods_filed = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $vv['goods_id']) )->find();
  1262. $vv['orign_price'] = $goods_filed['price'];
  1263. $quantity += $vv['quantity'];
  1264. foreach($order_option_list as $option)
  1265. {
  1266. $vv['option_str'][] = $option['value'];
  1267. }
  1268. if( !isset($vv['option_str']) )
  1269. {
  1270. $vv['option_str'] = '';
  1271. }else{
  1272. $vv['option_str'] = implode(',', $vv['option_str']);
  1273. }
  1274. // $vv['price'] = round($vv['price'],2);
  1275. $vv['price'] = sprintf("%.2f",$vv['price']);
  1276. $vv['orign_price'] = sprintf("%.2f",$vv['orign_price']);
  1277. //$vv['total'] = sprintf("%.2f",$vv['total']);
  1278. $vv['total'] = sprintf("%.2f",$vv['old_total']);
  1279. if( $vv['is_refund_state'] == 1 || ($vv['has_refund_money'] > 0 && $vv['has_refund_quantity'] > 0) )
  1280. {
  1281. $vv['is_refund_state'] = 1;
  1282. $where = " order_id = '".$vv['order_id']."' and order_goods_id = '".$vv['order_goods_id']."' and state in (0,2,3) ";
  1283. $refund_info = M('lionfish_comshop_order_refund')->field('ref_id,order_id,ref_money,real_refund_quantity,state')->where( $where )->find();
  1284. if(!empty($refund_info)){
  1285. $vv['refund_info'] = $refund_info;
  1286. }else{
  1287. $refund_info = array();
  1288. $refund_info['order_id'] = $val['order_id'];
  1289. $refund_info['ref_money'] = $vv['has_refund_money'];
  1290. $refund_info['real_refund_quantity'] = $vv['has_refund_quantity'];
  1291. $refund_info['state'] = 3;
  1292. $vv['refund_info'] = $refund_info;
  1293. }
  1294. }
  1295. $goods_list[$kk] = $vv;
  1296. }
  1297. $val['total_commision'] = $total_commision;
  1298. $val['quantity'] = $quantity;
  1299. if( empty($val['store_id']) )
  1300. {
  1301. $val['store_id'] = 1;
  1302. }
  1303. $store_info = array('s_true_name' =>'','s_logo' => '');
  1304. $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
  1305. $store_info['s_logo'] = D('Home/Front')->get_config_by_name('shoplogo');
  1306. if( !empty($store_info['s_logo']))
  1307. {
  1308. $store_info['s_logo'] = tomedia($store_info['s_logo']);
  1309. }else{
  1310. $store_info['s_logo'] = '';
  1311. }
  1312. $order_goods['store_info'] = $store_info;
  1313. $val['store_info'] = $store_info;
  1314. $val['goods_list'] = $goods_list;
  1315. if($val['type'] == 'integral')
  1316. {
  1317. //暂时屏蔽积分
  1318. $val['score'] = round($val['total'],2);
  1319. }
  1320. $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'];
  1321. if($val['total'] < 0)
  1322. {
  1323. $val['total'] = 0;
  1324. }
  1325. $val['total'] = sprintf("%.2f",$val['total']);
  1326. if( $val['delivery'] == 'localtown_delivery' && ($val['order_status_id'] != 3 && $val['order_status_id'] != 5 ) )
  1327. {
  1328. $val['orderdistribution_order'] = M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $val['order_id'] ) )->find();
  1329. if( !empty($val['orderdistribution_order']) && $val['orderdistribution_order'] > 0 )
  1330. {
  1331. $orderdistribution = M('lionfish_comshop_orderdistribution')->where( array('id' => $val['orderdistribution_order']['orderdistribution_id'] ) )->find();
  1332. $val['orderdistribution_order']['username'] = $orderdistribution['username'];
  1333. }
  1334. }
  1335. $list[$key] = $val;
  1336. }
  1337. $need_data = array('code' => 0);
  1338. if( !empty($list) )
  1339. {
  1340. $need_data['data'] = $list;
  1341. }else {
  1342. $need_data = array('code' => 1);
  1343. }
  1344. $open_aftersale = D('Home/Front')->get_config_by_name('open_aftersale');
  1345. if( empty($open_aftersale) )
  1346. {
  1347. $open_aftersale = 0;
  1348. }
  1349. $open_aftersale_time = D('Home/Front')->get_config_by_name('open_aftersale_time');
  1350. if( empty($open_aftersale_time) )
  1351. {
  1352. $open_aftersale_time = 0;
  1353. }
  1354. $need_data['open_aftersale'] = $open_aftersale;
  1355. $need_data['open_aftersale_time'] = $open_aftersale_time;
  1356. echo json_encode( $need_data );
  1357. die();
  1358. }
  1359. function receive_order_list()
  1360. {
  1361. $gpc = I('request.');
  1362. $order_data = $gpc['order_data'];
  1363. $token = $gpc['token'];
  1364. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1365. $member_id = $weprogram_token['member_id'];
  1366. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->find();
  1367. if( empty($member_info) )
  1368. {
  1369. echo json_encode( array('code' => 1) );
  1370. die();
  1371. }
  1372. $community_info = D('Home/Front')->get_member_community_info($member_id);
  1373. $is_member_hexiao = false;
  1374. if( empty($community_info) && $member_info['pickup_id'] > 0 )
  1375. {
  1376. $parent_community_info = M('lionfish_comshop_community_pickup_member')->where( array('member_id' =>$member_id ) )->find();
  1377. if(!empty($parent_community_info))
  1378. {
  1379. $is_member_hexiao = true;
  1380. $community_info = M('lionfish_community_head')->where( array('id' => $parent_community_info['community_id'] ) )->find();
  1381. }
  1382. }
  1383. if( empty($community_info) || $community_info['state'] != 1 )
  1384. {
  1385. echo json_encode( array('code' => 1) );
  1386. die();
  1387. }
  1388. if( is_array($order_data) )
  1389. {
  1390. $order_data_str = implode(',', $order_data);
  1391. }else{
  1392. $order_data_str = $order_data;
  1393. }
  1394. $where = ' and o.head_id = '.$community_info['id'];
  1395. $where .= ' and o.order_status_id = 4 and order_id in ('.$order_data_str.') ';
  1396. $sql = "select o.order_id,o.order_num_alias
  1397. from ".C('DB_PREFIX')."lionfish_comshop_order as o ,
  1398. ".C('DB_PREFIX')."lionfish_comshop_order_status as os
  1399. where o.order_status_id = os.order_status_id {$where}
  1400. order by o.date_added desc ";
  1401. $list = M()->query($sql);
  1402. if( !empty($list) )
  1403. {
  1404. foreach($list as $val)
  1405. {
  1406. D('Home/Frontorder')->receive_order($val['order_id']);
  1407. if($is_member_hexiao)
  1408. {
  1409. $pickup_member_record_data = array();
  1410. $pickup_member_record_data['order_id'] = $val['order_id'];
  1411. $pickup_member_record_data['order_sn'] = $val['order_num_alias'];
  1412. $pickup_member_record_data['community_id'] = $community_info['id'];
  1413. $pickup_member_record_data['member_id'] = $member_id;
  1414. $pickup_member_record_data['addtime'] = time();
  1415. M('lionfish_comshop_community_pickup_member_record')->add( $pickup_member_record_data );
  1416. }
  1417. }
  1418. echo json_encode( array('code' => 0) );
  1419. die();
  1420. }else{
  1421. echo json_encode( array('code' => 1) );
  1422. die();
  1423. }
  1424. //load_model_class('frontorder')->receive_order($order_id);
  1425. //string(15) "35,34,31,19,5,2"
  1426. //string(32) "b55feabc517fa686f79c1bbd303cdeda"
  1427. }
  1428. function receive_order()
  1429. {
  1430. $gpc = I('request.');
  1431. $token = $gpc['token'];
  1432. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1433. $member_id = $weprogram_token['member_id'];
  1434. $order_id = $gpc['order_id'];
  1435. if( empty($member_id) )
  1436. {
  1437. $result['code'] = 2;
  1438. $result['msg'] = '登录失效';
  1439. echo json_encode($result);
  1440. die();
  1441. }
  1442. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id,'member_id' => $member_id) )->find();
  1443. if(empty($order_info)){
  1444. $result['code'] = 1;
  1445. $result['msg'] = '非法操作,会员不存在该订单';
  1446. echo json_encode($result);
  1447. die();
  1448. }
  1449. //检查订单是否能确认收货(存在售后未完成无法确认收货)
  1450. $result = D('Seller/Order')->check_order_receive($order_id);
  1451. if($result['status'] == 0){
  1452. $result['code'] = 1;
  1453. $result['msg'] = '您的订单处于售后处理中,请完成后再确认收货!';
  1454. echo json_encode($result);
  1455. die();
  1456. }
  1457. if($order_info['delivery'] == 'localtown_delivery'){
  1458. $result = D('Seller/Order')->check_localtown_order_receive($order_id);
  1459. if($result['status'] == 0){
  1460. $result['code'] = 1;
  1461. $result['msg'] = '该订单未有配送员接单或还未指定配送员,无法确认收货!';
  1462. echo json_encode($result);
  1463. die();
  1464. }
  1465. M('lionfish_comshop_orderdistribution_order')->where( array('order_id' => $order_id) )->save( array('state' => 4) );
  1466. D('Home/LocaltownDelivery')->write_distribution_log( $order_id, 0 , 4 , "用户确认收货" );
  1467. }
  1468. D('Home/Frontorder')->receive_order($order_id);
  1469. $result['code'] = 0;
  1470. echo json_encode($result);
  1471. die();
  1472. }
  1473. /**
  1474. 取消订单操作
  1475. **/
  1476. public function cancel_order()
  1477. {
  1478. $gpc = I('request.');
  1479. $token = $gpc['token'];
  1480. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1481. $member_id = $weprogram_token['member_id'];
  1482. $order_id = $gpc['order_id'];
  1483. if( empty($member_id) )
  1484. {
  1485. $result['code'] = 2;
  1486. $result['msg'] = '登录失效';
  1487. echo json_encode($result);
  1488. die();
  1489. }
  1490. $order_info = M('lionfish_comshop_order')->where( array('member_id' => $member_id,'order_id' => $order_id) )->find();
  1491. if(empty($order_info)){
  1492. $result['code'] = 1;
  1493. $result['msg'] = '非法操作,会员不存在该订单';
  1494. echo json_encode($result);
  1495. die();
  1496. }
  1497. //order_status_id == 3
  1498. if($order_info['order_status_id'] != 3)
  1499. {
  1500. $result['code'] = 1;
  1501. $result['msg'] = '订单可能已取消,请刷新页面';
  1502. echo json_encode($result);
  1503. die();
  1504. }
  1505. D('Home/Frontorder')->cancel_order($order_id);
  1506. $result['code'] = 0;
  1507. echo json_encode($result);
  1508. die();
  1509. }
  1510. public function order_head_info()
  1511. {
  1512. $_GPC = I('request.');
  1513. $token = $_GPC['token'];
  1514. $is_share = $_GPC['is_share'];
  1515. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1516. $member_id = $weprogram_token['member_id'];
  1517. $order_id = $_GPC['id'];
  1518. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
  1519. if($order_info['is_change_price'] == 1){
  1520. $order_info['admin_change_price'] = $order_info['total'] - $order_info['old_price'];
  1521. }
  1522. $pick_up_info = array();
  1523. $pick_order_info = array();
  1524. $community_info = D('Home/Front')->get_member_community_info($member_id);
  1525. if($is_share){
  1526. $userInfo = M('lionfish_comshop_member')->field('avatar')->where( array('member_id' => $order_info['member_id'] ) )->find();
  1527. $order_info['avatar'] = $userInfo['avatar'];
  1528. }
  1529. if( $order_info['delivery'] == 'pickup' )
  1530. {
  1531. //查询自提点
  1532. //$pick_order_info = M('lionfish_comshop_pick_order')->where( array('order_id' => $order_id) )->find();
  1533. //$pick_id = $pick_order_info['pick_id'];
  1534. //$pick_up_info = M('lionfish_comshop_pick_up')->where( array('id' => $pick_id ) )->find();
  1535. }
  1536. $order_status_info = M('lionfish_comshop_order_status')->where( array('order_status_id' => $order_info['order_status_id']) )->find();
  1537. //10 name
  1538. if($order_info['order_status_id'] == 10)
  1539. {
  1540. $order_status_info['name'] = '等待退款';
  1541. }
  1542. else if($order_info['order_status_id'] == 4 && $order_info['delivery'] =='pickup')
  1543. {
  1544. //delivery 6
  1545. $order_status_info['name'] = '待自提';
  1546. //已自提
  1547. }
  1548. else if($order_info['order_status_id'] == 6 && $order_info['delivery'] =='pickup')
  1549. {
  1550. //delivery 6
  1551. $order_status_info['name'] = '已自提';
  1552. }
  1553. else if($order_info['order_status_id'] == 1 && $order_info['type'] == 'lottery')
  1554. {
  1555. //等待开奖
  1556. //一等奖
  1557. if($order_info['lottery_win'] == 1)
  1558. {
  1559. $order_status_info['name'] = '一等奖';
  1560. }else {
  1561. $order_status_info['name'] = '等待开奖';
  1562. }
  1563. }
  1564. //$order_info['type']
  1565. //open_auto_delete
  1566. if($order_info['order_status_id'] == 3)
  1567. {
  1568. $open_auto_delete = D('Home/Front')->get_config_by_name('open_auto_delete');
  1569. $auto_cancle_order_time = D('Home/Front')->get_config_by_name('auto_cancle_order_time');
  1570. $order_info['open_auto_delete'] = $open_auto_delete;
  1571. //date_added
  1572. if($open_auto_delete == 1)
  1573. {
  1574. $order_info['over_buy_time'] = $order_info['date_added'] + 3600 * $auto_cancle_order_time;
  1575. $order_info['cur_time'] = time();
  1576. }
  1577. }
  1578. $shipping_province = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_province_id'] ) )->find();
  1579. $shipping_city = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_city_id'] ) )->find();
  1580. $shipping_country = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_country_id']) )->find();
  1581. $order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->select();
  1582. $shiji_total_money = 0;
  1583. $member_youhui = 0.00;
  1584. $pick_up_time = "";
  1585. $pick_up_type = -1;
  1586. $pick_up_weekday = '';
  1587. $today_time = $order_info['pay_time'];
  1588. $arr = array('天','一','二','三','四','五','六');
  1589. foreach($order_goods_list as $key => $order_goods)
  1590. {
  1591. $order_goods['name'] = htmlspecialchars_decode($order_goods['name']);
  1592. $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();
  1593. foreach($order_option_info as $option)
  1594. {
  1595. $order_goods['option_str'][] = $option['value'];
  1596. }
  1597. if(empty($order_goods['option_str']))
  1598. {
  1599. //option_str
  1600. $order_goods['option_str'] = '';
  1601. }else{
  1602. $order_goods['option_str'] = implode(',', $order_goods['option_str']);
  1603. }
  1604. //
  1605. $order_goods['shipping_fare'] = round($order_goods['shipping_fare'],2);
  1606. //$order_goods['price'] = round($order_goods['price'],2);
  1607. $order_goods['price'] = round($order_goods['price'],2);
  1608. $order_goods['total'] = round($order_goods['total'],2);
  1609. $order_goods['old_total'] = round($order_goods['old_total'],2);
  1610. if( $order_goods['is_vipcard_buy'] == 1 || $order_goods['is_level_buy'] ==1 )
  1611. {
  1612. $order_goods['price'] = round($order_goods['oldprice'],2);
  1613. }
  1614. $order_goods['real_total'] = round($order_goods['quantity'] * $order_goods['price'],2);
  1615. $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();
  1616. if(!empty($community_order_info))
  1617. {
  1618. $order_goods['commision'] = $community_order_info['money']-$community_order_info['add_shipping_fare'];
  1619. if($community_order_info['state'] == 2){
  1620. $order_goods['commision'] = 0;
  1621. }
  1622. }else{
  1623. $order_goods['commision'] = 0;
  1624. }
  1625. $order_goods['old_commision'] = $order_goods['commision'];
  1626. $order_goods['del_commision'] = 0;
  1627. $order_goods['statements_end_date'] = date('Y-m-d H:i:s', $order_goods['statements_end_time']);
  1628. //has_refund_commission = 0
  1629. $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();
  1630. $refund_shipping_fare = 0;//退配送费
  1631. if( !empty($order_goods_refund_list) )
  1632. {
  1633. $kvbal_total_back_head_orderbuycommiss = 0;//合计退掉佣金
  1634. foreach( $order_goods_refund_list as $kvval )
  1635. {
  1636. $kvbal_total_back_head_orderbuycommiss += $kvval['back_head_orderbuycommiss'];
  1637. $refund_shipping_fare += $kvval['refund_shipping_fare'];
  1638. }
  1639. $order_goods['del_commision'] = $kvbal_total_back_head_orderbuycommiss;
  1640. $order_goods['old_commision'] += $order_goods['del_commision'];
  1641. }
  1642. //fen_type
  1643. $order_goods['fen_type'] = $community_order_info['fen_type'];// 0 按照比例, 1按照金额
  1644. $order_goods['fen_bili'] = $community_order_info['bili'];//比例
  1645. $order_goods['fen_gumoney'] = $community_order_info['bili'];//按照金额
  1646. $order_jishu = $order_goods['total'] -$order_goods['fullreduction_money']-$order_goods['voucher_credit']-$order_goods['has_refund_money'];
  1647. $order_goods['order_jishu'] = $order_jishu;//有效金额:(基数)
  1648. $order_goods['head_shipping_fare'] = $community_order_info['add_shipping_fare'];//团长配送费
  1649. /**
  1650. $goods_images = file_image_thumb_resize($vv['goods_images'],400);
  1651. if(is_array($goods_images))
  1652. {
  1653. $vv['goods_images'] = $vv['goods_images'];
  1654. }else{
  1655. $vv['goods_images']= tomedia( file_image_thumb_resize($vv['goods_images'],400) );
  1656. }
  1657. **/
  1658. $goods_images = $order_goods['goods_images'];
  1659. if( !is_array($goods_images) )
  1660. {
  1661. $order_goods['image']= tomedia( $goods_images );
  1662. $order_goods['goods_images']= tomedia( $goods_images );
  1663. }else{
  1664. $order_goods['image']= $order_goods['goods_images'];
  1665. }
  1666. $order_goods['hascomment'] = 0;
  1667. $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();
  1668. if( !empty($order_goods_comment_info) )
  1669. {
  1670. $order_goods['hascomment'] = 1;
  1671. }
  1672. //ims_
  1673. $goods_info = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $order_goods['goods_id']) )->find();
  1674. $goods_cm_info = M('lionfish_comshop_good_common')->field('pick_up_type,pick_up_modify')->where( array('goods_id' => $order_goods['goods_id']) )->find();
  1675. if($pick_up_type == -1 || $goods_cm_info['pick_up_type'] > $pick_up_type)
  1676. {
  1677. $pick_up_type = $goods_cm_info['pick_up_type'];
  1678. if($pick_up_type == 0)
  1679. {
  1680. $pick_up_time = date('m-d', $today_time);
  1681. //$pick_up_weekday = '周'.$arr[date('w',$today_time)];
  1682. }else if( $pick_up_type == 1 ){
  1683. $pick_up_time = date('m-d', $today_time+86400);
  1684. //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400)];
  1685. }else if( $pick_up_type == 2 )
  1686. {
  1687. $pick_up_time = date('m-d', $today_time+86400*2);
  1688. //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400*2)];
  1689. }else if($pick_up_type == 3)
  1690. {
  1691. $pick_up_time = $goods_cm_info['pick_up_modify'];
  1692. }
  1693. }
  1694. $order_goods['shop_price'] = $goods_info['price'];
  1695. $store_info = array('s_true_name' =>'','s_logo' => '');
  1696. $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
  1697. if( !empty($store_info['s_logo']) )
  1698. {
  1699. $store_info['s_logo'] = tomedia($store_info['s_logo']);
  1700. }else{
  1701. $store_info['s_logo'] = '';
  1702. }
  1703. if( $order_goods['is_refund_state'] == 1 || ($order_goods['has_refund_money'] > 0 && $order_goods['has_refund_quantity'] > 0) )
  1704. {
  1705. $order_goods['is_refund_state'] = 1;
  1706. $where = " order_id = '".$order_goods['order_id']."' and order_goods_id = '".$order_goods['order_goods_id']."' and state in (0,2,3) ";
  1707. $refund_info = M('lionfish_comshop_order_refund')->field('ref_id,order_id,ref_money,real_refund_quantity,state')->where( $where )->find();
  1708. if(!empty($refund_info)){
  1709. $order_goods['refund_info'] = $refund_info;
  1710. }else{
  1711. $refund_info = array();
  1712. $refund_info['order_id'] = $order_goods['order_id'];
  1713. $refund_info['ref_money'] = $order_goods['has_refund_money'];
  1714. $refund_info['real_refund_quantity'] = $order_goods['has_refund_quantity'];
  1715. $refund_info['state'] = 3;
  1716. $order_goods['refund_info'] = $refund_info;
  1717. }
  1718. }
  1719. $order_goods['store_info'] = $store_info;
  1720. unset($order_goods['model']);
  1721. unset($order_goods['rela_goodsoption_valueid']);
  1722. unset($order_goods['comment']);
  1723. $order_goods_list[$key] = $order_goods;
  1724. $shiji_total_money += $order_goods['quantity'] * $order_goods['price'];
  1725. $member_youhui += ($order_goods['real_total'] - $order_goods['total']);
  1726. }
  1727. unset($order_info['store_id']);
  1728. unset($order_info['email']);
  1729. unset($order_info['shipping_city_id']);
  1730. unset($order_info['shipping_country_id']);
  1731. unset($order_info['shipping_province_id']);
  1732. //unset($order_info['comment']);
  1733. unset($order_info['voucher_id']);
  1734. unset($order_info['is_balance']);
  1735. unset($order_info['lottery_win']);
  1736. unset($order_info['ip']);
  1737. unset($order_info['ip_region']);
  1738. unset($order_info['user_agent']);
  1739. $order_info['shipping_fare'] = round($order_info['shipping_fare'],2) < 0.01 ? '0.00':round($order_info['shipping_fare'],2) ;
  1740. $order_info['voucher_credit'] = round($order_info['voucher_credit'],2) < 0.01 ? '0.00':round($order_info['voucher_credit'],2) ;
  1741. $order_info['fullreduction_money'] = round($order_info['fullreduction_money'],2) < 0.01 ? '0.00':round($order_info['fullreduction_money'],2) ;
  1742. $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'] ;
  1743. if($order_info['total'] < 0)
  1744. {
  1745. $order_info['total'] = '0.00';
  1746. }
  1747. $order_info['total'] = round($order_info['total'],2)< 0.01 ? '0.00':round($order_info['total'],2) ;
  1748. $order_info['real_total'] = round($shiji_total_money,2)+$order_info['shipping_fare'];
  1749. $order_info['price'] = round($order_info['price'],2);
  1750. $order_info['member_youhui'] = round($member_youhui,2) < 0.01 ? '0.00':round($member_youhui,2);
  1751. $order_info['pick_up_time'] = $pick_up_time;
  1752. $order_info['shipping_fare'] = sprintf("%.2f",$order_info['shipping_fare']);
  1753. $order_info['voucher_credit'] = sprintf("%.2f",$order_info['voucher_credit']);
  1754. $order_info['fullreduction_money'] = sprintf("%.2f",$order_info['fullreduction_money']);
  1755. $order_info['total'] = sprintf("%.2f",$order_info['total']);
  1756. $order_info['real_total'] = sprintf("%.2f",$order_info['real_total']);
  1757. $order_note_open = D('Home/Front')->get_config_by_name('order_note_open');
  1758. $order_note_name = D('Home/Front')->get_config_by_name('order_note_name');
  1759. if( !isset($order_note_open) || $order_note_open == 0)
  1760. {
  1761. $order_note_open = 0;
  1762. }
  1763. if( !isset($order_note_name) || empty($order_note_name) )
  1764. {
  1765. $order_note_name = '店名';
  1766. }
  1767. $order_info['order_note_open'] = $order_note_open;
  1768. $order_info['order_note_name'] = $order_note_name;
  1769. $order_info['note_content'] = $order_info['note_content']!='null' ? $order_info['note_content'] : '';
  1770. $order_info['date_added'] = date('Y-m-d H:i:s', $order_info['date_added']);
  1771. $need_data = array();
  1772. if($order_info['delivery'] =='pickup')
  1773. {
  1774. }else{
  1775. }
  1776. if($order_info['type'] == 'integral')
  1777. {
  1778. //暂时屏蔽积分商城
  1779. //$integral_order = M('integral_order')->field('score')->where( array('order_id' => $order_id) )->find();
  1780. //$need_data['score'] = intval($integral_order['score']);
  1781. }
  1782. if( !empty($order_info['pay_time']) && $order_info['pay_time'] >0 )
  1783. {
  1784. $order_info['pay_date'] = date('Y-m-d H:i:s', $order_info['pay_time']);
  1785. }else{
  1786. $order_info['pay_date'] = '';
  1787. }
  1788. $order_info['express_tuanz_date'] = empty($order_info['express_tuanz_time']) ? '' : date('Y-m-d H:i:s', $order_info['express_tuanz_time']);
  1789. $order_info['receive_date'] = date('Y-m-d H:i:s', $order_info['receive_time']);
  1790. if($is_share==1){ $order_info['shipping_tel'] = substr_replace($order_info['shipping_tel'],'****',3,4); }
  1791. //货到付款订单
  1792. if($order_info['payment_code'] == 'cashon_delivery'){
  1793. $order_info['cashondelivery_code_img'] = D('Home/Front')->getCashonDeliveryCode();
  1794. }
  1795. $need_data['order_info'] = $order_info;
  1796. $need_data['order_status_info'] = $order_status_info;
  1797. $need_data['shipping_province'] = $shipping_province;
  1798. $need_data['shipping_city'] = $shipping_city;
  1799. $need_data['shipping_country'] = $shipping_country;
  1800. $need_data['order_goods_list'] = $order_goods_list;
  1801. $need_data['goods_count'] = count($order_goods_list);
  1802. //$order_info['order_status_id'] 13 平台介入退款
  1803. $order_refund_historylist = array();
  1804. $pingtai_deal = 0;
  1805. //判断是否已经平台处理完毕
  1806. $order_refund_historylist = M('lionfish_comshop_order_refund_history')->where( array('order_id' => $order_id) )->order('addtime asc')->select();
  1807. foreach($order_refund_historylist as $key => $val)
  1808. {
  1809. if($val['type'] ==3)
  1810. {
  1811. $pingtai_deal = 1;
  1812. }
  1813. }
  1814. $order_refund = M('lionfish_comshop_order_refund')->where( array('order_id' => $order_id) )->find();
  1815. if(!empty($order_refund))
  1816. {
  1817. $order_refund['addtime'] = date('Y-m-d H:i:s', $order_refund['addtime']);
  1818. }
  1819. $need_data['pick_up'] = $pick_up_info;
  1820. if( empty($pick_order_info['qrcode']) && false)
  1821. {
  1822. }
  1823. $need_data['pick_order_info'] = $pick_order_info;
  1824. $open_aftersale = D('Home/Front')->get_config_by_name('open_aftersale');
  1825. if( empty($open_aftersale) )
  1826. {
  1827. $open_aftersale = 0;
  1828. }
  1829. $open_aftersale_time = D('Home/Front')->get_config_by_name('open_aftersale_time');
  1830. if( empty($open_aftersale_time) )
  1831. {
  1832. $open_aftersale_time = 0;
  1833. }
  1834. 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 ) );
  1835. die();
  1836. }
  1837. public function order_share_info(){
  1838. $_GPC = I('request.');
  1839. $is_share = $_GPC['is_share'];
  1840. $token = $_GPC['token'];
  1841. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1842. $member_id = $weprogram_token['member_id'];
  1843. $order_id = $_GPC['id'];
  1844. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  1845. if($is_share){
  1846. $userInfo = M('lionfish_comshop_member')->field('avatar')->where( array('member_id' => $order_info['member_id'] ) )->find();
  1847. $order_info['avatar'] = $userInfo['avatar'];
  1848. }
  1849. $pick_up_info = array();
  1850. $pick_order_info = array();
  1851. if( $order_info['delivery'] == 'pickup' )
  1852. {
  1853. //查询自提点
  1854. // $pick_order_info = M('lionfish_comshop_pick_order')->where( array('order_id' => $order_id ) )->find();
  1855. // $pick_id = $pick_order_info['pick_id'];
  1856. // $pick_up_info = M('lionfish_comshop_pick_up')->where( array('id' => $pick_id ) )->find();
  1857. }
  1858. $order_status_info = M('lionfish_comshop_order_status')->where( array('order_status_id' => $order_info['order_status_id'] ) )->find();
  1859. //10 name
  1860. if($order_info['order_status_id'] == 10)
  1861. {
  1862. $order_status_info['name'] = '等待退款';
  1863. }
  1864. else if($order_info['order_status_id'] == 4 && $order_info['delivery'] =='pickup')
  1865. {
  1866. //delivery 6
  1867. $order_status_info['name'] = '待自提';
  1868. //已自提
  1869. }
  1870. else if($order_info['order_status_id'] == 6 && $order_info['delivery'] =='pickup')
  1871. {
  1872. //delivery 6
  1873. $order_status_info['name'] = '已自提';
  1874. }
  1875. else if($order_info['order_status_id'] == 1 && $order_info['type'] == 'lottery')
  1876. {
  1877. //等待开奖
  1878. //一等奖
  1879. if($order_info['lottery_win'] == 1)
  1880. {
  1881. $order_status_info['name'] = '一等奖';
  1882. }else {
  1883. $order_status_info['name'] = '等待开奖';
  1884. }
  1885. }
  1886. //$order_info['type']
  1887. //open_auto_delete
  1888. if($order_info['order_status_id'] == 3)
  1889. {
  1890. $open_auto_delete = D('Home/Front')->get_config_by_name('open_auto_delete');
  1891. $auto_cancle_order_time = D('Home/Front')->get_config_by_name('auto_cancle_order_time');
  1892. $order_info['open_auto_delete'] = $open_auto_delete;
  1893. //date_added
  1894. if($open_auto_delete == 1)
  1895. {
  1896. $order_info['over_buy_time'] = $order_info['date_added'] + 3600 * $auto_cancle_order_time;
  1897. $order_info['cur_time'] = time();
  1898. }
  1899. }
  1900. $shipping_province = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_province_id'] ) )->find();
  1901. $shipping_city = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_city_id'] ) )->find();
  1902. $shipping_country = M('lionfish_comshop_area')->where( array('id' => $order_info['shipping_country_id'] ) )->find();
  1903. $order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->select();
  1904. $shiji_total_money = 0;
  1905. $member_youhui = 0.00;
  1906. $pick_up_time = "";
  1907. $pick_up_type = -1;
  1908. $pick_up_weekday = '';
  1909. $today_time = $order_info['pay_time'];
  1910. $arr = array('天','一','二','三','四','五','六');
  1911. foreach($order_goods_list as $key => $order_goods)
  1912. {
  1913. $order_goods['name'] = htmlspecialchars_decode($order_goods['name']);
  1914. $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();
  1915. if(!empty($order_refund_goods))
  1916. {
  1917. $order_refund_goods['addtime'] = date('Y-m-d H:i:s', $order_refund_goods['addtime']);
  1918. }
  1919. $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();
  1920. $order_goods['order_refund_goods'] = $order_refund_goods;
  1921. foreach($order_option_info as $option)
  1922. {
  1923. $order_goods['option_str'][] = $option['value'];
  1924. }
  1925. if(empty($order_goods['option_str']))
  1926. {
  1927. //option_str
  1928. $order_goods['option_str'] = '';
  1929. }else{
  1930. $order_goods['option_str'] = implode(',', $order_goods['option_str']);
  1931. }
  1932. //
  1933. $order_goods['shipping_fare'] = round($order_goods['shipping_fare'],2);
  1934. $order_goods['price'] = round($order_goods['price'],2);
  1935. $order_goods['total'] = round($order_goods['total'],2);
  1936. if( $order_goods['is_vipcard_buy'] == 1 || $order_goods['is_level_buy'] ==1 )
  1937. {
  1938. $order_goods['price'] = round($order_goods['oldprice'],2);
  1939. }
  1940. $order_goods['real_total'] = round($order_goods['quantity'] * $order_goods['price'],2);
  1941. /**
  1942. $goods_images = file_image_thumb_resize($vv['goods_images'],400);
  1943. if(is_array($goods_images))
  1944. {
  1945. $vv['goods_images'] = $vv['goods_images'];
  1946. }else{
  1947. $vv['goods_images']= tomedia( file_image_thumb_resize($vv['goods_images'],400) );
  1948. }
  1949. **/
  1950. $goods_images = $order_goods['goods_images'];
  1951. if( !is_array($goods_images) )
  1952. {
  1953. $order_goods['image']= tomedia( $goods_images );
  1954. $order_goods['goods_images']= tomedia( $goods_images );
  1955. }else{
  1956. $order_goods['image']= $order_goods['goods_images'];
  1957. }
  1958. $order_goods['hascomment'] = 0;
  1959. $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();
  1960. if( !empty($order_goods_comment_info) )
  1961. {
  1962. $order_goods['hascomment'] = 1;
  1963. }
  1964. $order_goods['can_ti_refund'] = 1;
  1965. $disable_info = M('lionfish_comshop_order_refund_disable')->where( array('order_id' => $order_id, 'order_goods_id' => $order_goods['order_goods_id'] ) )->find();
  1966. if( !empty($disable_info) )
  1967. {
  1968. $order_goods['can_ti_refund'] = 0;
  1969. }
  1970. if($order_goods['is_refund_state'] == 1)
  1971. {
  1972. //已经再申请退款中了。或者已经退款了。
  1973. $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();
  1974. if( $order_refund_info['state'] == 3 )
  1975. {
  1976. $order_goods['is_refund_state'] = 2;
  1977. }
  1978. }
  1979. //ims_
  1980. $goods_info = M('lionfish_comshop_goods')->field('productprice as price')->where( array('id' => $order_goods['goods_id'] ) )->find();
  1981. $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();
  1982. if($pick_up_type == -1 || $goods_cm_info['pick_up_type'] > $pick_up_type)
  1983. {
  1984. $pick_up_type = $goods_cm_info['pick_up_type'];
  1985. if($pick_up_type == 0)
  1986. {
  1987. $pick_up_time = date('m-d', $today_time);
  1988. //$pick_up_weekday = '周'.$arr[date('w',$today_time)];
  1989. }else if( $pick_up_type == 1 ){
  1990. $pick_up_time = date('m-d', $today_time+86400);
  1991. //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400)];
  1992. }else if( $pick_up_type == 2 )
  1993. {
  1994. $pick_up_time = date('m-d', $today_time+86400*2);
  1995. //$pick_up_weekday = '周'.$arr[date('w',$today_time+86400*2)];
  1996. }else if($pick_up_type == 3)
  1997. {
  1998. $pick_up_time = $goods_cm_info['pick_up_modify'];
  1999. }
  2000. }
  2001. if( !empty($goods_cm_info['goods_share_image']) )
  2002. {
  2003. $order_goods['goods_share_image']= tomedia( $goods_cm_info['goods_share_image'] );
  2004. }else{
  2005. $order_goods['goods_share_image'] = $order_goods['image'];
  2006. }
  2007. $order_goods['shop_price'] = $goods_info['price'];
  2008. $store_info = array('s_true_name' =>'','s_logo' => '');
  2009. $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
  2010. //$store_info['s_logo'] = load_model_class('front')->get_config_by_name('shoplogo');
  2011. if( !empty($store_info['s_logo']) )
  2012. {
  2013. $store_info['s_logo'] = tomedia($store_info['s_logo']);
  2014. }else{
  2015. $store_info['s_logo'] = '';
  2016. }
  2017. $order_goods['store_info'] = $store_info;
  2018. unset($order_goods['model']);
  2019. unset($order_goods['rela_goodsoption_valueid']);
  2020. unset($order_goods['comment']);
  2021. //ims_ ims_lionfish_comshop_order_goods_refund addtime
  2022. $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();
  2023. if( empty($order_goods_refund_list) )
  2024. {
  2025. $order_goods_refund_list = array();
  2026. }else{
  2027. foreach( $order_goods_refund_list as $kre => $rval )
  2028. {
  2029. $rval['addtime'] = date('Y-m-d H:i:s', $rval['addtime']);
  2030. $order_goods_refund_list[$kre] = $rval;
  2031. }
  2032. }
  2033. $order_goods['order_goods_refund_list'] = $order_goods_refund_list;
  2034. $order_goods_list[$key] = $order_goods;
  2035. $shiji_total_money += $order_goods['quantity'] * $order_goods['price'];
  2036. $member_youhui += ($order_goods['real_total'] - $order_goods['total']);
  2037. }
  2038. unset($order_info['store_id']);
  2039. unset($order_info['email']);
  2040. unset($order_info['shipping_city_id']);
  2041. unset($order_info['shipping_country_id']);
  2042. unset($order_info['shipping_province_id']);
  2043. // unset($order_info['comment']);
  2044. unset($order_info['voucher_id']);
  2045. unset($order_info['is_balance']);
  2046. unset($order_info['lottery_win']);
  2047. unset($order_info['ip']);
  2048. unset($order_info['ip_region']);
  2049. unset($order_info['user_agent']);
  2050. //enum('express', 'pickup', 'tuanz_send')
  2051. //var_dump($order_info['total'],$order_info['shipping_fare'],$order['voucher_credit'],$order['fullreduction_money'] );die();
  2052. $order_info['shipping_fare'] = round($order_info['shipping_fare'],2) < 0.01 ? '0.00':round($order_info['shipping_fare'],2) ;
  2053. $order_info['voucher_credit'] = round($order_info['voucher_credit'],2) < 0.01 ? '0.00':round($order_info['voucher_credit'],2) ;
  2054. $order_info['fullreduction_money'] = round($order_info['fullreduction_money'],2) < 0.01 ? '0.00':round($order_info['fullreduction_money'],2) ;
  2055. $need_data = array();
  2056. if($order_info['type'] == 'integral')
  2057. {
  2058. //暂时屏蔽积分商城
  2059. $order_info['score'] = round($order_info['total'],2);
  2060. }
  2061. $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) ;
  2062. if($order_info['total'] < 0)
  2063. {
  2064. $order_info['total'] = '0.00';
  2065. }
  2066. $order_info['real_total'] = round($shiji_total_money,2)+$order_info['shipping_fare'];
  2067. $order_info['price'] = round($order_info['price'],2);
  2068. $order_info['member_youhui'] = round($member_youhui,2) < 0.01 ? '0.00':round($member_youhui,2);
  2069. $order_info['pick_up_time'] = $pick_up_time;
  2070. $order_info['shipping_fare'] = sprintf("%.2f",$order_info['shipping_fare']);
  2071. $order_info['voucher_credit'] = sprintf("%.2f",$order_info['voucher_credit']);
  2072. $order_info['fullreduction_money'] = sprintf("%.2f",$order_info['fullreduction_money']);
  2073. $order_info['total'] = sprintf("%.2f",$order_info['total']);
  2074. $order_info['real_total'] = sprintf("%.2f",$order_info['real_total']);
  2075. $order_info['date_added'] = date('Y-m-d H:i:s', $order_info['date_added']);
  2076. // if($order_info['delivery'] =='pickup')
  2077. // {}else{}
  2078. if( !empty($order_info['pay_time']) && $order_info['pay_time'] >0 )
  2079. {
  2080. $order_info['pay_date'] = date('Y-m-d H:i:s', $order_info['pay_time']);
  2081. }else{
  2082. $order_info['pay_date'] = '';
  2083. }
  2084. $order_info['express_tuanz_date'] = date('Y-m-d H:i:s', $order_info['express_tuanz_time']);
  2085. $order_info['receive_date'] = date('Y-m-d H:i:s', $order_info['receive_time']);
  2086. //"delivery": "pickup", enum('express', 'pickup', 'tuanz_send')
  2087. if($order_info['delivery'] == 'express')
  2088. {
  2089. $order_info['delivery_name'] = '快递';
  2090. }else if($order_info['delivery'] == 'pickup')
  2091. {
  2092. $order_info['delivery_name'] = '用户自提';
  2093. }else if($order_info['delivery'] == 'tuanz_send'){
  2094. $order_info['delivery_name'] = '团长配送';
  2095. }
  2096. $need_data['order_info'] = $order_info;
  2097. $need_data['order_status_info'] = $order_status_info;
  2098. $need_data['shipping_province'] = $shipping_province;
  2099. $need_data['shipping_city'] = $shipping_city;
  2100. $need_data['shipping_country'] = $shipping_country;
  2101. $need_data['order_goods_list'] = $order_goods_list;
  2102. $need_data['goods_count'] = count($order_goods_list);
  2103. //$order_info['order_status_id'] 13 平台介入退款
  2104. $order_refund_historylist = array();
  2105. $pingtai_deal = 0;
  2106. //判断是否已经平台处理完毕
  2107. $order_refund_historylist = M('lionfish_comshop_order_refund_history')->where( array('order_id' => $order_id ) )->order('addtime asc')->select();
  2108. foreach($order_refund_historylist as $key => $val)
  2109. {
  2110. if($val['type'] ==3)
  2111. {
  2112. $pingtai_deal = 1;
  2113. }
  2114. }
  2115. $order_refund = M('lionfish_comshop_order_refund')->where( array('order_id' => $order_id ) )->find();
  2116. if(!empty($order_refund))
  2117. {
  2118. $order_refund['addtime'] = date('Y-m-d H:i:s', $order_refund['addtime']);
  2119. }
  2120. $need_data['pick_up'] = $pick_up_info;
  2121. $need_data['pick_order_info'] = $pick_order_info;
  2122. $order_pay_after_share = D('Home/Front')->get_config_by_name('order_pay_after_share');
  2123. if($order_pay_after_share==1){
  2124. $order_pay_after_share_img = D('Home/Front')->get_config_by_name('order_pay_after_share_img');
  2125. $order_pay_after_share_img = $order_pay_after_share_img ? tomedia($order_pay_after_share_img) : '';
  2126. $need_data['share_img'] = $order_pay_after_share_img;
  2127. }
  2128. //$order_info['order_status_id']
  2129. //0开启,1关闭 取消订单
  2130. $order_can_del_cancle = D('Home/Front')->get_config_by_name('order_can_del_cancle');
  2131. $order_can_del_cancle = empty($order_can_del_cancle) || $order_can_del_cancle == 0 ? 1 : 0;
  2132. $is_hidden_orderlist_phone = D('Home/Front')->get_config_by_name('is_hidden_orderlist_phone');
  2133. $is_show_guess_like = D('Home/Front')->get_config_by_name('is_show_order_guess_like');
  2134. $user_service_switch = D('Home/Front')->get_config_by_name('user_service_switch');
  2135. echo json_encode(
  2136. array(
  2137. 'code' => 0,
  2138. 'data' => $need_data,
  2139. 'pingtai_deal' => $pingtai_deal,
  2140. 'order_refund' => $order_refund,
  2141. 'order_can_del_cancle' => $order_can_del_cancle,
  2142. 'order_pay_after_share' => $order_pay_after_share,
  2143. 'is_hidden_orderlist_phone' => $is_hidden_orderlist_phone,
  2144. 'is_show_guess_like' => $is_show_guess_like,
  2145. 'user_service_switch' => $user_service_switch
  2146. )
  2147. );
  2148. die();
  2149. }
  2150. /**
  2151. * 订单确认付款
  2152. */
  2153. public function order_pay(){
  2154. $gpc = I('request.');
  2155. $token = $gpc['token'];
  2156. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2157. $member_id = $weprogram_token['member_id'];
  2158. $order_id = $gpc['order_id'];
  2159. $is_supply = $gpc['is_supply'];
  2160. if( empty($member_id) )
  2161. {
  2162. $result['code'] = 2;
  2163. $result['msg'] = '登录失效';
  2164. echo json_encode($result);
  2165. die();
  2166. }
  2167. $supply_info = array();
  2168. $order_info = array();
  2169. if($is_supply == 1){
  2170. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  2171. if(empty($supply_info)){
  2172. $result['code'] = 1;
  2173. $result['msg'] = '您不是供应商,无法操作';
  2174. echo json_encode($result);
  2175. die();
  2176. }
  2177. $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
  2178. }
  2179. if(empty($order_info)){
  2180. $result['code'] = 1;
  2181. $result['msg'] = '非法操作,供应商不存在该订单';
  2182. echo json_encode($result);
  2183. die();
  2184. }
  2185. //order_status_id == 3
  2186. if($order_info['order_status_id'] != 3)
  2187. {
  2188. $result['code'] = 1;
  2189. $result['msg'] = '订单不是未付款订单,无法确认付款';
  2190. echo json_encode($result);
  2191. die();
  2192. }
  2193. D('Seller/Order')->admin_pay_order($order_id,1);
  2194. $result['code'] = 0;
  2195. echo json_encode($result);
  2196. die();
  2197. }
  2198. /**
  2199. * 订单改价页面
  2200. */
  2201. public function order_change(){
  2202. $gpc = I('request.');
  2203. $token = $gpc['token'];
  2204. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2205. $member_id = $weprogram_token['member_id'];
  2206. $order_id = $gpc['order_id'];
  2207. $is_supply = $gpc['is_supply'];
  2208. if( empty($member_id) )
  2209. {
  2210. $result['code'] = 2;
  2211. $result['msg'] = '登录失效';
  2212. echo json_encode($result);
  2213. die();
  2214. }
  2215. $supply_info = array();
  2216. $order_info = array();
  2217. if($is_supply == 1){
  2218. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  2219. if(empty($supply_info)){
  2220. $result['code'] = 1;
  2221. $result['msg'] = '您不是供应商,无法操作';
  2222. echo json_encode($result);
  2223. die();
  2224. }
  2225. $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
  2226. }
  2227. if(empty($order_info)){
  2228. $result['code'] = 1;
  2229. $result['msg'] = '非法操作,供应商不存在该订单';
  2230. echo json_encode($result);
  2231. die();
  2232. }
  2233. //order_status_id == 3
  2234. if($order_info['order_status_id'] != 3)
  2235. {
  2236. $result['code'] = 1;
  2237. $result['msg'] = '订单不是未付款订单,无法改价';
  2238. echo json_encode($result);
  2239. die();
  2240. }
  2241. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->select();
  2242. $member_youhui = 0;
  2243. foreach($order_goods as $k=>$v){
  2244. $order_goods[$k]['goods_img_url'] = tomedia($v['goods_images']);
  2245. $order_goods[$k]['max_total'] = round($v['total']-$v['fullreduction_money']-$v['voucher_credit']-$v['score_for_money'],2);
  2246. $member_youhui += round(($v['oldprice'] - $v['price'])*$v['quantity'],2);
  2247. $order_goods[$k]['goods_optiontitle'] = D('Seller/Order')->get_order_option_sku($v['order_id'], $v['order_goods_id']);
  2248. $order_goods[$k]['price'] = sprintf("%.2f", $v['price']);
  2249. }
  2250. $youhui_total = round($order_info['voucher_credit']+$order_info['fullreduction_money']+$order_info['score_for_money']+$member_youhui,2);
  2251. $order_info['youhui_total'] = sprintf("%.2f", $youhui_total);
  2252. $order_info['changeprice'] = sprintf("%.2f", $order_info['total'] - $order_info['old_price']);
  2253. $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);
  2254. echo json_encode(
  2255. array(
  2256. 'code' => 0,
  2257. 'order_goods' => $order_goods,
  2258. 'orders' => $order_info
  2259. )
  2260. );
  2261. die();
  2262. }
  2263. /**
  2264. * 订单改价
  2265. */
  2266. public function order_changeprice(){
  2267. $gpc = I('request.');
  2268. $order_id = $gpc['order_id'];
  2269. $order_goods_ids = $gpc['order_goods_id'];
  2270. $change_prices = $gpc['change_price'];
  2271. $is_supply = $gpc['is_supply'];
  2272. $token = $gpc['token'];
  2273. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2274. $member_id = $weprogram_token['member_id'];
  2275. if( empty($member_id) )
  2276. {
  2277. $result['code'] = 2;
  2278. $result['msg'] = '登录失效';
  2279. echo json_encode($result);
  2280. die();
  2281. }
  2282. $supply_info = array();
  2283. $order_info = array();
  2284. if($is_supply == 1){
  2285. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  2286. if(empty($supply_info)){
  2287. $result['code'] = 1;
  2288. $result['msg'] = '您不是供应商,无法操作';
  2289. echo json_encode($result);
  2290. die();
  2291. }
  2292. $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
  2293. }
  2294. if(empty($order_info)){
  2295. $result['code'] = 1;
  2296. $result['msg'] = '非法操作,供应商不存在该订单';
  2297. echo json_encode($result);
  2298. die();
  2299. }
  2300. //order_status_id == 3
  2301. if($order_info['order_status_id'] != 3)
  2302. {
  2303. $result['code'] = 1;
  2304. $result['msg'] = '订单不是未付款订单,无法改价';
  2305. echo json_encode($result);
  2306. die();
  2307. }
  2308. if(empty($order_goods_ids) || empty($change_prices)){
  2309. $result['code'] = 1;
  2310. $result['msg'] = '商品订单号和价格参数不能为空';
  2311. echo json_encode($result);
  2312. die();
  2313. }
  2314. $order_goods_ids = explode(',',$order_goods_ids);
  2315. $change_prices = explode(',',$change_prices);
  2316. if(count($order_goods_ids) != count($change_prices)){
  2317. $result['code'] = 1;
  2318. $result['msg'] = '商品订单号和价格参数不匹配';
  2319. echo json_encode($result);
  2320. die();
  2321. }
  2322. //改价后的商品实付价格不能低于0.1元
  2323. foreach($order_goods_ids as $k=>$order_goods_id){
  2324. $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_id' =>$order_id,'order_goods_id' =>$order_goods_id ) )->find();
  2325. $total = $order_goods_info['total'];
  2326. $fullreduction_money = $order_goods_info['fullreduction_money'];
  2327. $voucher_credit = $order_goods_info['voucher_credit'];
  2328. $score_for_money = $order_goods_info['score_for_money'];
  2329. $total = round($total - $fullreduction_money - $voucher_credit - $score_for_money,2);
  2330. if(!empty($change_prices[$k])){
  2331. $change_price = $change_prices[$k];
  2332. $total = floatval($total) + floatval($change_price);
  2333. if(bccomp($total, '0.1', 2) == -1){
  2334. $result['code'] = 1;
  2335. $result['msg'] = '改价后的商品实付价格不能低于0.1元';
  2336. echo json_encode($result);
  2337. die();
  2338. }
  2339. }
  2340. }
  2341. $change_amount = 0;
  2342. foreach($order_goods_ids as $k=>$order_goods_id){
  2343. $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_id' =>$order_id,'order_goods_id' =>$order_goods_id ) )->find();
  2344. $total = $order_goods_info['total'];
  2345. $update_data = array();
  2346. if(!empty($change_prices[$k])){
  2347. $change_amount = $change_amount + $change_prices[$k];
  2348. $change_price = $change_prices[$k];
  2349. $update_data['total'] = round(floatval($total) + floatval($change_price),2);
  2350. $update_data['is_change_price'] = 1;
  2351. M('lionfish_comshop_order_goods')->where( array('order_id' =>$order_id,'order_goods_id' => $order_goods_id ) )->save( $update_data);
  2352. }
  2353. }
  2354. $order_info = M('lionfish_comshop_order')->where( array('order_id' =>$order_id) )->find();
  2355. $order_total = $order_info['total'];
  2356. $order_data = array();
  2357. $order_data['total'] = round(floatval($order_total) + floatval($change_amount),2);
  2358. $order_data['is_change_price'] = 1;
  2359. M('lionfish_comshop_order')->where( array('order_id' =>$order_id) )->save($order_data);
  2360. $oh = array();
  2361. $oh['order_id'] = $order_id;
  2362. $oh['order_status_id']=15;
  2363. $oh['comment']='订单改价';
  2364. $oh['date_added']=time();
  2365. M('lionfish_comshop_order_history')->add($oh);
  2366. $result['code'] = 0;
  2367. echo json_encode($result);
  2368. die();
  2369. }
  2370. /**
  2371. * 供应商确定配送订单
  2372. */
  2373. public function order_delivery(){
  2374. $gpc = I('request.');
  2375. $token = $gpc['token'];
  2376. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2377. $member_id = $weprogram_token['member_id'];
  2378. $order_id = $gpc['order_id'];
  2379. $is_supply = $gpc['is_supply'];
  2380. if( empty($member_id) )
  2381. {
  2382. $result['code'] = 2;
  2383. $result['msg'] = '登录失效';
  2384. echo json_encode($result);
  2385. die();
  2386. }
  2387. $supply_info = array();
  2388. $order_info = array();
  2389. if($is_supply == 1){
  2390. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  2391. if(empty($supply_info)){
  2392. $result['code'] = 1;
  2393. $result['msg'] = '您不是供应商,无法操作';
  2394. echo json_encode($result);
  2395. die();
  2396. }
  2397. $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
  2398. }
  2399. if(empty($order_info)){
  2400. $result['code'] = 1;
  2401. $result['msg'] = '非法操作,供应商不存在该订单';
  2402. echo json_encode($result);
  2403. die();
  2404. }
  2405. if($order_info['order_status_id'] != 1)
  2406. {
  2407. $result['code'] = 1;
  2408. $result['msg'] = '订单不是待发货订单,无法确认配送';
  2409. echo json_encode($result);
  2410. die();
  2411. }
  2412. D('Seller/Order')->do_send_localtown($order_id,'供应商操作,开始配送货物');
  2413. $result['code'] = 0;
  2414. echo json_encode($result);
  2415. die();
  2416. }
  2417. /**
  2418. * 选择配送员
  2419. */
  2420. public function choosemember()
  2421. {
  2422. $_GPC = I('request.');
  2423. $kwd = trim($_GPC['keyword']);
  2424. $token = $_GPC['token'];
  2425. $order_id = $_GPC['order_id'];
  2426. $is_supply = $_GPC['is_supply'];
  2427. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2428. $member_id = $weprogram_token['member_id'];
  2429. if( empty($member_id) )
  2430. {
  2431. $result['code'] = 2;
  2432. $result['msg'] = '登录失效';
  2433. echo json_encode($result);
  2434. die();
  2435. }
  2436. $supply_info = array();
  2437. $order_info = array();
  2438. if($is_supply == 1){
  2439. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  2440. if(empty($supply_info)){
  2441. $result['code'] = 1;
  2442. $result['msg'] = '您不是供应商,无法操作';
  2443. echo json_encode($result);
  2444. die();
  2445. }
  2446. $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
  2447. }
  2448. if(empty($order_info)){
  2449. $result['code'] = 1;
  2450. $result['msg'] = '非法操作,供应商不存在该订单';
  2451. echo json_encode($result);
  2452. die();
  2453. }
  2454. if($order_info['order_status_id'] != 4)
  2455. {
  2456. $result['code'] = 1;
  2457. $result['msg'] = '订单不是已发货,待收货订单,无法指定配送员';
  2458. echo json_encode($result);
  2459. die();
  2460. }
  2461. $condition = ' 1 ';
  2462. if (!empty($kwd)) {
  2463. $condition .= ' and ( username LIKE "%'.$kwd .'%" or mobile like "%'.$kwd .'%" )';
  2464. }
  2465. $condition .= ' and store_id='.$order_info['store_id'];
  2466. /**
  2467. 分页开始
  2468. **/
  2469. $per_page = 10;
  2470. $page = isset($_GPC['page']) ? $_GPC['page'] : 1;
  2471. $offset = ($page - 1) * $per_page;
  2472. /**
  2473. 分页结束
  2474. **/
  2475. $sql = 'SELECT * FROM ' . C('DB_PREFIX') . 'lionfish_comshop_orderdistribution where '
  2476. . $condition .
  2477. ' order by id asc limit '.$offset.','.$per_page;
  2478. $list = M()->query($sql);
  2479. if( !empty($list) )
  2480. {
  2481. echo json_encode( array('code' => 0, 'data' => $list) );
  2482. die();
  2483. }else{
  2484. echo json_encode( array('code' => 1, 'msg'=>'暂无数据') );
  2485. die();
  2486. }
  2487. }
  2488. public function sub_orderchoose_distribution(){
  2489. $_GPC = I('request.');
  2490. $token = $_GPC['token'];
  2491. $order_id = $_GPC['order_id'];
  2492. $is_supply = $_GPC['is_supply'];
  2493. $distribution_id = $_GPC['distribution_id'];
  2494. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2495. $member_id = $weprogram_token['member_id'];
  2496. if( empty($member_id) )
  2497. {
  2498. $result['code'] = 2;
  2499. $result['msg'] = '登录失效';
  2500. echo json_encode($result);
  2501. die();
  2502. }
  2503. $supply_info = array();
  2504. $order_info = array();
  2505. if($is_supply == 1){
  2506. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  2507. if(empty($supply_info)){
  2508. echo json_encode(array('code' => 1, 'msg' => '您不是供应商,无法操作'));
  2509. die();
  2510. }
  2511. $order_info = M('lionfish_comshop_order')->where( array('store_id' => $supply_info['id'],'order_id' => $order_id) )->find();
  2512. }
  2513. if(empty($order_info)){
  2514. echo json_encode(array('code' => 1, 'msg' => '非法操作,供应商不存在该订单'));
  2515. die();
  2516. }
  2517. if($order_info['order_status_id'] != 4)
  2518. {
  2519. echo json_encode(array('code' => 1, 'msg' => '订单不是已发货,待收货订单,无法指定配送员'));
  2520. die();
  2521. }
  2522. $distribution_info = M('lionfish_comshop_orderdistribution')->where(array('id'=>$distribution_id,'store_id'=>$supply_info['id']))->find();
  2523. if(empty($distribution_info)){
  2524. echo json_encode(array('code' => 1, 'msg' => '配送员不存在'));
  2525. die();
  2526. }
  2527. $res = D('Home/LocaltownDelivery')->distribution_get_order( $distribution_id , $order_id);
  2528. if($res)
  2529. {
  2530. echo json_encode( array('code' => 0, 'msg' => '分配成功') );
  2531. die();
  2532. }else{
  2533. echo json_encode( array('code' => 1, 'msg' => '已被分配,请刷新页面') );
  2534. die();
  2535. }
  2536. }
  2537. public function share_order(){
  2538. $gpc = I('request.');
  2539. $order_id = $gpc['order_id'];
  2540. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->find();
  2541. $head_id = $order_info['head_id'];
  2542. $member_id = $order_info['member_id'];
  2543. if(empty($order_info)){
  2544. echo json_encode( array('code' => 3, 'msg' => '订单信息不存在') );
  2545. die();
  2546. }
  2547. $cart= D('Home/Car');
  2548. $order_array = array();
  2549. $order_status_id = $order_info['order_status_id'];
  2550. $order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id) )->order('order_goods_id asc')->select();
  2551. $order_goods_array = array();
  2552. $goods_quantity = 0;
  2553. foreach($order_goods_list as $k=>$val){
  2554. $goods_common_info = "";
  2555. $where='1=1';
  2556. if( $head_id > 0 )
  2557. {
  2558. $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}) ) ";
  2559. }
  2560. $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 ";
  2561. $goods_common_info = M()->query($sql_pingoods);
  2562. $goods_common_info = $goods_common_info[0];
  2563. $tmp_data = array();
  2564. $order_goods_array[$k]['actId'] = $goods_common_info['id'];
  2565. $order_goods_array[$k]['spuName'] = htmlspecialchars_decode($goods_common_info['goodsname']);
  2566. $order_goods_array[$k]['spuCanBuyNum'] = $goods_common_info['total'];
  2567. $order_goods_array[$k]['spuDescribe'] = $goods_common_info['subtitle'];
  2568. $order_goods_array[$k]['end_time'] = $goods_common_info['end_time'];
  2569. $order_goods_array[$k]['soldNum'] = $goods_common_info['seller_count'] + $goods_common_info['sales'];
  2570. $order_goods_array[$k]['oneday_limit_count'] = $goods_common_info['oneday_limit_count'];
  2571. $order_goods_array[$k]['total_limit_count'] = $goods_common_info['total_limit_count'];
  2572. $order_goods_array[$k]['one_limit_count'] = $goods_common_info['one_limit_count'];
  2573. $order_goods_array[$k]['goods_start_count'] = $goods_common_info['goods_start_count'];
  2574. $productprice = $goods_common_info['productprice'];
  2575. $order_goods_array[$k]['marketPrice'] = explode('.', $productprice);
  2576. if( !empty($goods_common_info['big_img']) )
  2577. {
  2578. $order_goods_array[$k]['bigImg'] = tomedia($goods_common_info['big_img']);
  2579. }
  2580. $good_image = D('Home/Pingoods')->get_goods_images($goods_common_info['id']);
  2581. if( !empty($good_image) )
  2582. {
  2583. $order_goods_array[$k]['skuImage'] = tomedia($good_image['image']);
  2584. }
  2585. $price_arr = D('Home/Pingoods')->get_goods_price($goods_common_info['id'], $member_id);
  2586. $price = $price_arr['price'];
  2587. $order_goods_array[$k]['actPrice'] = explode('.', $price);
  2588. //$tmp_data['skuList']= D('Home/Pingoods')->get_goods_options($val['id'], $member_id);
  2589. $order_goods_array[$k]['skuList']= D('Home/Pingoods')->get_goods_options_carquantity($goods_common_info['id'], $member_id, $head_id ,$token);
  2590. if( !empty($tmp_data['skuList']) )
  2591. {
  2592. $order_goods_array[$k]['car_count'] = 0;
  2593. }else{
  2594. $car_count = $cart->get_wecart_goods($val['id'],"",$head_id ,$token);
  2595. if( empty($car_count) )
  2596. {
  2597. $order_goods_array[$k]['car_count'] = 0;
  2598. }else{
  2599. $order_goods_array[$k]['car_count'] = $car_count;
  2600. }
  2601. }
  2602. $goods_quantity = $goods_quantity + $val['quantity'];
  2603. if($order_status_id != 3 && $order_status_id != 5){//不是未付款和取消订单
  2604. $order_goods_array[$k]['price'] = $val['price'];
  2605. $order_goods_array[$k]['oldprice'] = $val['oldprice'];
  2606. }
  2607. }
  2608. if($order_status_id != 3 && $order_status_id != 5) {//不是未付款和取消订单
  2609. $order_array['goods_quantity'] = $goods_quantity;//商品数量
  2610. $order_array['goods_count'] = count($order_goods_list);//商品种类数
  2611. $order_array['order_total'] = $order_info['total'];//订单总金额
  2612. $order_array['old_order_total'] = $order_info['old_price'];//订单原金额
  2613. $order_array['save_money'] = $order_info['old_price'] - $order_info['total'];//省了多少钱
  2614. }
  2615. //用户信息
  2616. $member_id = $order_info['member_id'];
  2617. $member_info = M('lionfish_comshop_member')->where(array('member_id'=>$member_id))->find();
  2618. $member_array = [];
  2619. $member_array['avatar'] = $member_info['avatar'];//用户头像
  2620. $member_array['username'] = $member_info['username'];//用户昵称
  2621. //团长信息
  2622. if($order_info['delivery'] != 'hexiao'){
  2623. $head_id = $order_info['head_id'];
  2624. $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();
  2625. $head_member_info = M('lionfish_comshop_member')->where(array('member_id'=>$head_info['member_id']))->find();
  2626. $head_info['province_name'] = D('Seller/area')->get_area_info($head_info['province_id']);
  2627. $head_info['city_name'] = D('Seller/area')->get_area_info($head_info['city_id']);
  2628. $head_info['area_name'] = D('Seller/area')->get_area_info($head_info['area_id']);
  2629. $head_info['country_name'] = D('Seller/area')->get_area_info($head_info['country_id']);
  2630. $head_info['fulladdress'] = $head_info['province_name'].$head_info['city_name'].$head_info['area_name'].$head_info['country_name'].$head_info['address'];
  2631. $head_info['head_images'] = $head_member_info['avatar'];
  2632. $order_array['head_info'] = $head_info;
  2633. }else{
  2634. //门店信息
  2635. $salesroom_list = D('Home/Salesroom')->get_order_salesroom($order_id,0);
  2636. $order_array['salesroom_info'] = array();
  2637. if(!empty($salesroom_list)){
  2638. $order_array['salesroom_info'] = $salesroom_list[0];
  2639. }
  2640. }
  2641. $need_data = array();
  2642. $need_data['orders'] = $order_array;
  2643. $need_data['order_goods_list'] = $order_goods_array;
  2644. $need_data['members'] = $member_array;
  2645. echo json_encode(
  2646. array(
  2647. 'code' => 0,
  2648. 'data' => $need_data
  2649. )
  2650. );
  2651. }
  2652. }