Fullordersmt.php 149 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Fullordersmt extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_fullordersmt','fullordersmt');
  7. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  8. $this->load->_model('Model_shop','shop');
  9. $this->load->_model('Model_typeclass','typeclass');
  10. $this->load->_model('Model_express','express');
  11. $this->load->_model('Model_country','country');
  12. $this->load->_model('Model_productdescribe','productdescribe');
  13. $this->load->_model('Model_customs','customs');
  14. $this->load->_model('Model_detailed','detailed');
  15. $this->load->_model('Model_productdescription','productdescription');
  16. $this->load->_model('Model_logistics','logistics');
  17. $this->load->_model('Model_hl','hl');
  18. $this->load->_model('Model_excel','excel');
  19. $this->load->_model('Model_warehouse','warehouse');
  20. $this->load->_model('Model_customersmt','customersmt');
  21. $this->load->_model('Model_user','user');
  22. $this->load->_model('Model_dhl','dhl');
  23. $this->load->_model('Model_ali','ali');
  24. $this->load->_model('Model_notice','notice');
  25. $this->load->_model('Model_api','api');
  26. $this->load->_model('Model_apismt','apismt');
  27. $this->load->_model('Model_usps','usps');
  28. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  29. $this->load->_model('Model_fullordersmthb','fullordersmthb');
  30. $this->load->_model('Model_whlabel','whlabel');
  31. $this->load->_model('Model_specialstock','specialstock');
  32. $this->load->_model('Model_reset','fullreset');
  33. $this->load->_model('Model_systemwigsout','systemwigsout');
  34. $this->load->_model('Model_ck','ck');
  35. $this->load->_model('Model_weight','weight');
  36. $this->load->_model('Model_pay','pay');
  37. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  38. $this->load->_model('Model_transfer','transfer');
  39. $this->load->_model('Model_systemtransfer','systemtransfer');
  40. $this->load->_model('Model_power','power');
  41. $this->load->_model('Model_setting','setting');
  42. $this->load->_model('Model_returngoods','returngoods');
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_fullordererrors","fullordererrors");
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg,$arg_array)
  48. {
  49. if($arg == 'add')//添加
  50. {
  51. $this->_add();
  52. }
  53. else if($arg == 'edit')//修改
  54. {
  55. $this->_edit($arg_array);
  56. }
  57. else if($arg == 'readonly')//修改
  58. {
  59. $this->_readonly($arg_array);
  60. }
  61. else if($arg == 'readlist')
  62. {
  63. $this->_readlist();
  64. }
  65. else if($arg == 'del')//修改
  66. {
  67. $this->_del();
  68. }
  69. else if($arg == 'price')//价格明细
  70. {
  71. $this->_price();
  72. }
  73. else if($arg == 'customs')
  74. {
  75. $this->_customs();
  76. }
  77. else if($arg == 'express')
  78. {
  79. $this->_express();
  80. }
  81. else if($arg == 'hl')
  82. {
  83. $this->_hl();
  84. }
  85. else if($arg == 'repeat')
  86. {
  87. $this->_repeat();
  88. }
  89. else if($arg == 'operation')
  90. {
  91. $this->_operation();
  92. }
  93. else if($arg == 'merge')
  94. {
  95. $this->_merge();
  96. }
  97. else if($arg == 'split')
  98. {
  99. $this->_split();
  100. }
  101. else if($arg == 'fmexcel')
  102. {
  103. $this->_fmexcel();
  104. }
  105. else if($arg == 'fdexcel')
  106. {
  107. $this->_fdexcel();
  108. }
  109. else if($arg == 'fdfexcel')
  110. {
  111. $this->_fdfexcel();
  112. }
  113. else if($arg == 'evaluate')
  114. {
  115. $this->_evaluate();
  116. }
  117. else if($arg == 'state')
  118. {
  119. $this->_state();
  120. }
  121. else if($arg == 'review')
  122. {
  123. $this->_review();
  124. }
  125. else if($arg == 'black')
  126. {
  127. $this->_black();
  128. }
  129. else if($arg == 'ryf')
  130. {
  131. $this->_ryf();
  132. }
  133. else if($arg == 'expresstype')
  134. {
  135. $this->_expresstype();
  136. }
  137. else if($arg == 'fsstate')
  138. {
  139. $this->_fsstate();
  140. }
  141. else if($arg == 'power')
  142. {
  143. $this->_power();
  144. }
  145. else if($arg == 'error')
  146. {
  147. $this->_error();
  148. }
  149. else if($arg == 'yzaddress')
  150. {
  151. $this->_yzaddress();
  152. }
  153. else if($arg == 'return')
  154. {
  155. $this->_return();
  156. }
  157. else if($arg == 'bcbz')
  158. {
  159. $this->_bcbz();
  160. }
  161. else if($arg == 'abc')
  162. {
  163. $this->_aaa();
  164. }
  165. else if($arg == 'b')
  166. {
  167. $this->_bbb($arg_array);
  168. }
  169. else if($arg == 'plcx')
  170. {
  171. $this->_plcx($arg_array);
  172. }
  173. else if($arg == 'cf')
  174. {
  175. $this->_cf();
  176. }
  177. else if($arg == 'epod')
  178. {
  179. $this->_epod();
  180. }
  181. else if($arg == 'ddcf')
  182. {
  183. $this->_ddcf();
  184. }
  185. else
  186. {
  187. $this->_index();
  188. }
  189. }
  190. //管理
  191. public function _index()
  192. {
  193. $dt = 0;
  194. if(isset($_SESSION['api']))
  195. {
  196. $user = $this->user->get_api($_SESSION['api']);
  197. $usp = $user;
  198. $fgshop = "";$sid = "";
  199. $user = explode('|',trim($user['shop'],'|'));
  200. foreach ($user as $value)
  201. {
  202. $fgshop .= " shop = ".$value." or";
  203. $sid .= " id = ".$value." or";
  204. }
  205. }
  206. $post = $this->input->post(NULL, TRUE);
  207. if(isset($post['page']))
  208. {
  209. $page = $this->input->post('page',true);
  210. $perpage = $this->input->post('perpage',true);
  211. $warehouse = $this->input->post('warehouse',true);
  212. $timetk = $this->input->post('timetkk',true);
  213. $timetj = $this->input->post('timetjj',true);
  214. $shop = $this->input->post('shop',true);
  215. $source = $this->input->post('source',true);
  216. $state = $this->input->post('state',true);
  217. $review = $this->input->post('review',true);
  218. $type = $this->input->post('type',true);
  219. $express = $this->input->post('express',true);
  220. $orderinfo = $this->input->post('orderinfo',true);
  221. $user = $this->input->post('user',true);
  222. $client = $this->input->post('name',true);
  223. $fullname = $this->input->post('fullname',true);
  224. $waybill = $this->input->post('waybill',true);
  225. $number = $this->input->post('number',true);
  226. $email = $this->input->post('email',true);
  227. $dlz = $this->input->post('dlz',true);
  228. $print = $this->input->post('print',true);
  229. $library = $this->input->post('library',true);
  230. $country = $this->input->post('country',true);
  231. $paypal = $this->input->post('paypal',true);
  232. $sku = $this->input->post('sku',true);
  233. $xztime = $this->input->post('xztime',true);
  234. $timetk = strtotime($timetk)-1;
  235. $timetj = strtotime($timetj);
  236. $px = $this->input->post('px',true);
  237. $plorder = $this->input->post('pl',true);
  238. $where = "1=1 and (".rtrim($fgshop,'or').")";
  239. if($warehouse)
  240. {
  241. $where .= " and type = '$warehouse'";
  242. }
  243. if($timetk && $timetj)
  244. {
  245. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  246. }
  247. if($shop)
  248. {
  249. $where .= " and shop = '$shop'";
  250. }
  251. if($source)
  252. {
  253. $where .= " and source = '$source'";
  254. }
  255. if($state)
  256. {
  257. $where .= " and state = '$state'";
  258. }
  259. if($review)
  260. {
  261. $where .= " and review = '$review'";
  262. }
  263. if($type)
  264. {
  265. $where .= " and type = '$type'";
  266. }
  267. if($express)
  268. {
  269. $where .= " and express = '$express'";
  270. }
  271. if($orderinfo)
  272. {
  273. $where .= " and orderinfo = '$orderinfo'";
  274. }
  275. if($user)
  276. {
  277. $where .= " and user = '$user'";
  278. }
  279. if($client)
  280. {
  281. $where .= " and client like '%$client%'";
  282. }
  283. if($waybill)
  284. {
  285. $where .= " and waybill = '$waybill'";
  286. }
  287. if($number)
  288. {
  289. $where .= " and number like '$number%'";
  290. }
  291. if($email)
  292. {
  293. $where .= " and email = '$email'";
  294. }
  295. if($library)
  296. {
  297. $where .= " and library = '$library'";
  298. }
  299. if($country)
  300. {
  301. $where .= " and country = '$country'";
  302. }
  303. if($print)
  304. {
  305. $where .= " and print = '$print'";
  306. }
  307. if($paypal)
  308. {
  309. $where .= " and paypal = '$paypal'";
  310. }
  311. if($dlz != '')
  312. {
  313. $where .= " and dlz = '$dlz'";
  314. }
  315. if($sku)
  316. {
  317. $where .= " and sku like '%$sku%'";
  318. }
  319. if($fullname)
  320. {
  321. $where .= " and fullname = '$fullname'";
  322. }
  323. //数据排序
  324. if($px)
  325. {
  326. $order_str = $px." desc";
  327. }
  328. else
  329. {
  330. $order_str = "numberpx desc";
  331. }
  332. if($plorder)
  333. {
  334. $plorderinfo = '';$plnumber = '';$pln = 0;
  335. $plorder = explode(',',trim($plorder,','));
  336. foreach ($plorder as $value)
  337. {
  338. if(is_numeric($value))
  339. {
  340. $plorderinfo .= " orderinfo = ".$value." or";
  341. }
  342. else if($value != '')
  343. {
  344. $plorderinfo .= " number = '".$value."' or";
  345. }
  346. }
  347. if($pln > 0)
  348. {
  349. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  350. }
  351. else
  352. {
  353. $where .= " and (".rtrim($plorderinfo,'or').")";
  354. }
  355. }
  356. if(empty($page))
  357. {
  358. $start = 0;
  359. $perpage = 1;
  360. }
  361. else
  362. {
  363. $start = ($page - 1)*$perpage;
  364. }
  365. //取得信息列表id,shop,type,source,user,orderinfo,number,name,state,buytime,clientremarks,review,print,library,libraryconfirm,express,waybill,orderremarks,black
  366. $info_list = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,fullname,state,buytime,review,libraryconfirm,express,waybill,orderremarks,library,black,clientremarks,waybillid',$order_str,$start,$perpage);
  367. //格式化数据
  368. foreach ($info_list as $key=>$value)
  369. {
  370. $ud = $this->fullordersmt->read($value['id']);
  371. $ud['address'] = str_replace("'","’",$ud['address']);
  372. $ud['name'] = str_replace("'","’",$ud['name']);
  373. //$customer = $ud['source'] != 1?$this->customersmt->get_fullname($ud['fullname']):$this->customersmt->get_shopdata($value['shop'],$ud['name'],$ud['address']);//目前只用地址和收货人判断是否老客户
  374. $customer = $this->customersmt->get_shopdata($value['shop'],$ud['name'],$ud['address']);
  375. //$a = array_column($customer, 'email'); //三维找其中健的数组
  376. //$a = array_flip($a); //键和值调换
  377. $currency = $this->country->read($ud['country']);
  378. $name = ($ud['source'] == 1)?$ud['name']:$value['fullname'];
  379. $lkh = "<p>".$name."</p><p style='color:#8f54fb'>".$currency['ename']."</p>";
  380. if($customer)
  381. {
  382. if($customer['type'] == 1 && $customer['num'] > 1)
  383. {
  384. $lkh .= "<p style='color:#FF3333'>老客户(".$customer['num'].")</p>";
  385. }
  386. else if($customer['type'] == 2)
  387. {
  388. $hmsp = $this->shop->read($customer['shop']);
  389. $lkh .= "<p style='color:#9900CC'>黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  390. }
  391. }
  392. $info_list[$key]['fullname'] = $lkh;
  393. $shop = $this->shop->read($value['shop']);
  394. $info_list[$key]['shop'] = $shop['shopname'];
  395. //$info_list[$key]['user'] = $shop['shopuser'];
  396. $warehouse = $this->warehouse->read($value['type']);
  397. $warehousetitle = $warehouse['title'];
  398. if($value['type'] != 13){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  399. $info_list[$key]['type'] = $warehousetitle;
  400. $typeclass = $this->typeclass->read($value['state']);
  401. if($ud['source'] != 1)
  402. {
  403. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$typeclass['title']."</a></br>";
  404. if($ud['overtime'] > 0 && $ud['state'] == 207)
  405. {
  406. //date_default_timezone_set("US/Pacific-New");
  407. $second = $ud['overtime']-time()+15*3600;
  408. $day = floor($second/(3600*24));
  409. $second = $second%(3600*24);//除去整天之后剩余的时间
  410. $hour = floor($second/3600);
  411. $second = $second%3600;//除去整小时之后剩余的时间
  412. $minute = floor($second/60);
  413. $second = $second%60;//除去整分钟之后剩余的时间
  414. //返回字符串
  415. $info_list[$key]['state'] .= "<p style='color:#555'>".$day." 天 ".$hour." 时 ".$minute." 分</p>";
  416. }
  417. }
  418. else
  419. {
  420. $info_list[$key]['state'] = $typeclass['title'];
  421. }
  422. if(!$value['buytime'])
  423. {
  424. $info_list[$key]['buytime'] = '<p>无</p>';
  425. }
  426. else
  427. {
  428. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']-$dt).'</p><p>'.date('H:i:s',$value['buytime']-$dt).'</p>';
  429. }
  430. if($value['review'] == 1)
  431. {
  432. $info_list[$key]['review'] = "未送审";
  433. }
  434. else if($value['review'] == 2)
  435. {
  436. $info_list[$key]['review'] = "<font style='color:#555'>待审核</font>";
  437. }
  438. else if($value['review'] == 3)
  439. {
  440. $info_list[$key]['review'] = "<font style='color:#f90f4b'>不通过</font>";
  441. }
  442. else if($value['review'] == 4)
  443. {
  444. $info_list[$key]['review'] = "取消重审";
  445. }
  446. else if($value['review'] == 5)
  447. {
  448. $info_list[$key]['review'] = "<font style='color:#2f80f9'>审核通过</font>";
  449. }
  450. else if($value['review'] == 6)
  451. {
  452. $info_list[$key]['review'] = "<font style='color:#2f80f9'>自动通过</font>";
  453. }
  454. if($ud['dlz'] == 1)
  455. {
  456. $dlz = "<p>发货声明成功</p>";
  457. }
  458. else if($ud['dlz'] == 3)
  459. {
  460. $dlz = "<p>不需要发货声明</p>";
  461. }
  462. else if($ud['dlz'] == 2)
  463. {
  464. $dlz = "<p style='color:#C3C'>发货声明失败</p>";
  465. }
  466. else
  467. {
  468. $dlz = "";
  469. }
  470. if($value['waybill'] != "")
  471. {
  472. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  473. if(!empty($value['waybillid'])){
  474. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  475. }
  476. }
  477. if($value['express'] != 0)
  478. {
  479. $express = $this->express->read($value['express']);
  480. $expressservicename = $express['servicename'];
  481. if($value['express'] != 1 && $value['express'] != 63)
  482. {
  483. $expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";
  484. }
  485. else if($value['express'] == 63)
  486. {
  487. $expressservicename = "<font style='color:#a910f8'>".$express['servicename']."</font>";
  488. }
  489. $info_list[$key]['express'] = $expressservicename;
  490. }
  491. else
  492. {
  493. $info_list[$key]['express'] = "无";
  494. }
  495. $x = "";
  496. if($value['libraryconfirm'] == 2 && $value['review'] > 4 && $ud['library'] == 1)
  497. {
  498. $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
  499. }
  500. else if(($value['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
  501. {
  502. $x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
  503. }
  504. if(($value['review'] > 4) && $ud['print'] == 2 && ($ud['merge'] == 0 || $ud['merge'] == $ud['id']))
  505. {
  506. $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
  507. }
  508. else if($value['review'] >4 && $ud['print'] == 1 && ($ud['merge'] == 0 || $ud['merge'] == $ud['id']))
  509. {
  510. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  511. }
  512. else if($value['review'] > 4 && $ud['print'] == 2 && $ud['merge'] != $ud['id'])
  513. {
  514. $x = "<p><b style='background-color:#999'>禁止打印</b></p>";
  515. }
  516. else if($value['review'] > 4 && $ud['print'] == 1 && $ud['merge'] != $ud['id'])
  517. {
  518. $x = "<p><b style='background-color:#999'>允许打印</b></p>";
  519. }
  520. if($value['waybill'] == "" && $value['review'] > 4)
  521. {
  522. $x .= "<p><b class='kn' data-type='2'>填写运单号</b></p>";
  523. }
  524. else if($value['waybill'] != "" && $value['review'] > 4 && $usp['vip'] == 1)
  525. {
  526. $x .= "<p><b class='kn' data-type='2'>修改运单号</b></p>";
  527. }
  528. else if($value['waybill'] != "" && $value['review'] > 4 && $value['library'] == 1 && $usp['vip'] != 1)
  529. {
  530. $x .= "<p><b class='kn' data-type='2'>修改运单号</b></p>";
  531. }
  532. if(($value['review'] == 1 || $value['review'] == 3) && $ud['express'] > 0 && $ud['dtsbjz'] != 0 && $ud['ts'] != 0 && $ud['zsbjz'] != 0 && $ud['zjs'] != 0 && $ud['ts'] != 0 && ($ud['merge'] == 0 || $ud['merge'] != 0 && $ud['merge'] == $ud['id']))
  533. {
  534. $x .= "<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
  535. }
  536. $x .= "<p><b class='window' data-h='/customersmt/edit/".$customer['id']."' data-t='客户信息 - 修改'>客户信息</b></p>";
  537. $info_list[$key]['black'] = $x;
  538. $tly = "";
  539. if($value['clientremarks'] != "")
  540. {
  541. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  542. }
  543. if($value['review'] > 4 && $usp['vip'] != 1 && ($ud['merge'] == 0 || $ud['merge'] == $ud['id']))
  544. {
  545. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/readonly/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  546. }
  547. else if($ud['merge'] == 0 || $ud['merge'] == $ud['id'])
  548. {
  549. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  550. }
  551. else if($ud['merge'] != 0 && $ud['merge'] != $ud['id'])
  552. {
  553. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."' style='color:#000'><p>".$value['orderinfo']."</p>".$tly."</h9>"."<p>合并订单</p>";
  554. }
  555. if($value['library'] == 1 && $ud['printtype'] == 3)
  556. {
  557. $info_list[$key]['library'] = "不需要";
  558. }
  559. else if($value['library'] == 1 && $ud['printtype'] != 3)
  560. {
  561. $info_list[$key]['library'] = "未出库";
  562. }
  563. else if($value['library'] == 2)
  564. {
  565. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  566. }
  567. else if($value['library'] == 3)
  568. {
  569. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  570. }
  571. unset($info_list[$key]['waybillid']);
  572. }
  573. $total = $this->fullordersmt->find_count($where);
  574. $pagenum = ceil($total/$perpage);
  575. $over = $total-($start+$perpage);
  576. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  577. echo json_encode($rows);exit;
  578. }
  579. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  580. $this->data['wlshop'] = $wlshop;
  581. $this->data['express'] = $this->express->find_all();
  582. $user = $this->user->get_api($_SESSION['api']);
  583. $powerid = $this->power->read($user['power']);
  584. $powertext = explode('|',trim($powerid['excelid'],'|'));
  585. $pid = '';
  586. foreach ($powertext as $v)
  587. {
  588. $pid .= " id = ".$v." or";
  589. }
  590. $fullorderexcel = $this->fullorderexcel->find_all("type = '100004' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  591. $this->data['fullorderexcel'] = $fullorderexcel;
  592. $error = $this->fullordersmt->find_count("failed !='' and mergeid = 0 and (".rtrim($fgshop,'or').") and dtime > '".(time()-90*24*3600)."'");
  593. $this->data['error'] = $error;
  594. if(isset($_SESSION['api']))
  595. {
  596. $user = $this->user->get_api($_SESSION['api']);
  597. if($user['vip'] == 1)
  598. {
  599. $vip = 1;
  600. }
  601. else
  602. {
  603. $vip = 0;
  604. }
  605. }
  606. else
  607. {
  608. $vip = 0;
  609. }
  610. $this->data['power'] = $vip;
  611. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  612. $this->data['country'] = $country;
  613. $this->data['user'] = $user;
  614. $cs_num = $this->fullordererrors->find_count( "plat = 'fullordersmt' and error_type = 1 and (".rtrim($fgshop,'or'). " ) and error_time > '".(time()-90*24*3600)."'");
  615. $this->data['cs_num'] = $cs_num;
  616. $this->_Template('fullordersmt',$this->data);
  617. }
  618. //筛选重复订单
  619. public function _repeat()
  620. {
  621. $user = $this->user->get_api($_SESSION['api']);
  622. if($user)
  623. {
  624. $fgshop = "";$sid = "";
  625. $user = explode('|',trim($user['shop'],'|'));
  626. foreach ($user as $value)
  627. {
  628. $fgshop .= " shop = ".$value." or";
  629. $sid .= " id = ".$value." or";
  630. }
  631. }
  632. $post = $this->input->post(NULL, TRUE);
  633. if(isset($post['page']))
  634. {
  635. $page = $this->input->post('page',true);
  636. $perpage = $this->input->post('perpage',true);
  637. $shop = $this->input->post('shop',true);
  638. $timetk = $this->input->post('timetk',true);
  639. $timetj = $this->input->post('timetj',true);
  640. $timetk = strtotime($timetk);
  641. $timetj = strtotime($timetj);
  642. $where = "print != 3 and review = 1 and state = 207 and (".rtrim($fgshop,'or').")";
  643. if($shop)
  644. {
  645. $where .= " and shop = '$shop'";
  646. }
  647. if($timetk && $timetj)
  648. {
  649. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  650. }
  651. //数据排序
  652. $order_str = "numberpx desc";
  653. if(empty($page))
  654. {
  655. $start = 0;
  656. $perpage = 1;
  657. }
  658. else
  659. {
  660. $start = ($page - 1)*$perpage;
  661. }
  662. //取得信息列表
  663. $info_list = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,state,buytime,name,userid,address,merge');
  664. $info = array();
  665. $len = count($info_list);
  666. //格式化数据
  667. foreach ($info_list as $key=>$value)
  668. {
  669. $ud = $this->fullordersmt->read($value['id']);
  670. $shop = $this->shop->read($value['shop']);
  671. $info_list[$key]['shop'] = $shop['shopname'];
  672. $warehouse = $this->warehouse->read($value['type']);
  673. $info_list[$key]['type'] = $warehouse['title'];
  674. $typeclass = $this->typeclass->read($value['state']);
  675. if($ud['source'] != 1)
  676. {
  677. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$typeclass['title']."</a>";
  678. }
  679. else
  680. {
  681. $info_list[$key]['state'] = $typeclass['title'];
  682. }
  683. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  684. $info_list[$key]['userid'] = $value['userid'];
  685. if($value['merge'] == 0)
  686. {
  687. $info_list[$key]['merge'] = "<p><b class='jd' data-type='5'>合并订单</b></p>";
  688. }
  689. else
  690. {
  691. if($value['merge'] == $value['id'])
  692. {
  693. if($ud['print'] < '3' && $ud['library'] == '1')
  694. {
  695. $info_list[$key]['merge'] = "<p><b class='cforder' data-id='".$value['id']."'>拆分订单</b></p>";
  696. }
  697. else
  698. {
  699. $info_list[$key]['merge'] = "已合并";
  700. }
  701. }
  702. else
  703. {
  704. $info_list[$key]['merge'] = "被合并";
  705. }
  706. }
  707. }
  708. for($i=0;$i<$len;$i++)
  709. {
  710. for($j=$i+1;$j<$len;$j++)
  711. {
  712. if ($info_list[$i]['name'] == $info_list[$j]['name'] || $info_list[$i]['address'] == $info_list[$j]['address'] || $info_list[$i]['userid'] == $info_list[$j]['userid'] && ($info_list[$i]['state'] == $info_list[$j]['state'] && $info_list[$i]['type'] == $info_list[$j]['type']))
  713. {
  714. if(!array_key_exists($j,$info))
  715. {
  716. $info[$j] = $info_list[$j];
  717. }
  718. if(!array_key_exists($i,$info))
  719. {
  720. $info[$i] = $info_list[$i];
  721. }
  722. }
  723. }
  724. }
  725. rsort($info);
  726. $total = count($info);
  727. $pagenum = ceil($total/$perpage);
  728. $over = $total-($start+$perpage);
  729. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_slice($info,$start,$perpage)));
  730. echo json_encode($rows);exit;
  731. }
  732. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  733. $this->data['wlshop'] = $wlshop;
  734. $this->_Template('fullordersmt_repeat',$this->data);
  735. }
  736. //修改
  737. public function _edit($arg_array)
  738. {
  739. if(isset($_SESSION['api']))
  740. {
  741. $user = $this->user->get_api($_SESSION['api']);
  742. if($user['vip'] == 1)
  743. {
  744. $vip = 1;
  745. $this->data['userid'] = $user['id'];
  746. }
  747. else
  748. {
  749. $vip = 0;
  750. $this->data['userid'] = 0;
  751. }
  752. $xwtype = '';
  753. $userwh = explode('|',trim($user['warehouse'],'|'));
  754. foreach ($userwh as $v)
  755. {
  756. $xwtype .= " id = ".$v." or";
  757. }
  758. }
  759. else
  760. {
  761. $vip = 0;
  762. $this->data['userid'] = 0;
  763. }
  764. $post = $this->input->post(NULL, TRUE);
  765. if(isset($post['id']))
  766. {
  767. $id = $this->input->post('id',true);
  768. $data = $this->fullordersmt->read($id);
  769. $post['type'] = $this->input->post('warehouse',true);
  770. $post['country'] = $this->input->post('country',true);
  771. $currency = $this->country->read($post['country']);
  772. $post['al'] = $currency['lb'];
  773. $post['freight'] = $this->input->post('freight',true);
  774. $post['expressmoney'] = $this->input->post('expressmoney',true);
  775. $post['shouldmoney'] = $this->input->post('shouldmoney',true);
  776. $orderremarks = $this->input->post('orderremarks');
  777. $orderremarks = str_replace(array('%26','%2B'),array('&','+'),$orderremarks);
  778. $post['orderremarks'] = $orderremarks;
  779. $post['shipremarks'] = $this->input->post('shipremarks');
  780. $post['email'] = $this->input->post('email',true);
  781. $name = $this->input->post('name',true);
  782. $post['name'] = str_replace("'","’",$name);
  783. $post['phone'] = $this->input->post('phone',true);
  784. $post['country'] = $this->input->post('country',true);
  785. $post['province'] = $this->input->post('province',true);
  786. $post['city'] = $this->input->post('city',true);
  787. $post['zipcode'] = $this->input->post('zipcode',true);
  788. $post['street'] = $this->input->post('street',true);
  789. $address = $this->input->post('address',true);
  790. $post['address'] = str_replace("'","’",$address);
  791. $post['express'] = $this->input->post('express',true);
  792. $post['printtype'] = $this->input->post('printtype',true);
  793. $fpdata = $this->input->post('fpdata');
  794. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  795. $post['fpdata'] = $fpdata;
  796. $post['waybill'] = $this->input->post('waybill',true);
  797. $post['msg'] = $this->input->post('msg',true);
  798. $post['zsbjz'] = $this->input->post('zsbjz',true);
  799. $post['refundy'] = $this->input->post('refundy',true);
  800. $post['refundj'] = $this->input->post('refundj',true);
  801. $rtime = $this->input->post('rtime',true);
  802. $post['rtime'] = strtotime($rtime);
  803. $post['rpaypal'] = $this->input->post('rpaypal',true);
  804. $post['rtext'] = $this->input->post('rtext',true);
  805. $post['ioss'] = $this->input->post('ioss',true);
  806. $post['sbpm'] = $this->input->post('sbpm',true);
  807. $post['edittime'] = time();
  808. $post['waybill'] = preg_replace('/( | | | |\s)/','',$post['waybill']);
  809. $pay = $this->pay->get_typeclass($data['pay']);
  810. $yga = $post['shouldmoney'];
  811. $ygc = $data['estimaterate'];
  812. $post['budget'] = 0;
  813. $ifbudget = eval("return $yga*1.$ygc;");
  814. if($ifbudget > 0)
  815. {
  816. $post['budget'] = eval("return $yga*1.$ygc;");
  817. }
  818. $editstate = $this->input->post('state',true);
  819. $whlabel = $this->input->post('whlabel',true);
  820. $fpcount = $this->input->post('fpcount',true);
  821. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  822. foreach ($whlabeldata as $va)
  823. {
  824. if(stripos($va,'z') !== false)
  825. {
  826. $way += 1;
  827. }
  828. }
  829. //如果备注中出现网红的两个字 ,那么在fpdata种的品名中必须有 WH这两个字 且美仓不用
  830. if($post['type'] !=5 ){
  831. if(stripos($post['shipremarks'],'网红') !== false){
  832. if(stripos($post['fpdata'],'-2090-') === false){
  833. echo json_encode(array('msg'=>'网红单请在商品名称中勾选WH!','success'=>false));exit;
  834. }
  835. }
  836. }
  837. if((($post['express'] == 2 || $post['express'] == 63 || $post['express'] == 64) && $post['type'] != 5) || ($post['express'] != 2 && $post['express'] != 63 && $post['express'] != 64 && $post['type'] == 5))
  838. {
  839. echo json_encode(array('msg'=>'此快递方式不可从美仓发货!','success'=>false));exit;
  840. }
  841. if($way == count($whlabeldata) && $post['type'] != 12)
  842. {
  843. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  844. }
  845. // if($post['express'] == 42 && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 ||
  846. // {
  847. // echo json_encode(array('msg'=>'此快递方式必须选择Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  848. // }
  849. //减少代码复用吧
  850. $lo_ret = $this->logic_order->checkEditExpress($post);
  851. if($lo_ret['code'] != 1){
  852. echo json_encode(array('msg'=>$lo_ret['msg'],'success'=>false));exit;
  853. }
  854. if($post['express'] == 24 && $post['sbpm'] != 'Hair Sample' && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods')//$post['express'] == 3 ||
  855. {
  856. echo json_encode(array('msg'=>'此快递方式必须选择Hair Sample/Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  857. }
  858. if($post['country'] != 192 && $post['express'] == 1 && $post['sbpm'] != 'Synthetic Hair Wigs' && $post['sbpm'] != 'Synthetic Hair Goods')//$post['express'] == 3 ||
  859. {
  860. echo json_encode(array('msg'=>'非美国选择官方DHL必须选择Synthetic Hair Wigs/Synthetic Hair Goods','success'=>false));exit;
  861. }
  862. $post['review'] = 1;
  863. if($post['zsbjz'] < '0.01')
  864. {
  865. echo json_encode(array('msg'=>'总申报价错误!','success'=>false));exit;
  866. }
  867. if($data['shop'] == '9' && $post['type'] != '7' && $post['type'] != '8' && $post['type'] != '9')
  868. {
  869. echo json_encode(array('msg'=>'仓库选择错误!','success'=>false));exit;
  870. }
  871. if($data['library'] == 1)
  872. {
  873. if($data['print'] != 3 && $data['review'] < 5)
  874. {
  875. $post['libraryconfirm'] = 1;
  876. $post['librarynot'] = "订单未打印";
  877. }
  878. else if($data['print'] != 3 && $data['review'] > 4)
  879. {
  880. $post['print'] = 1;
  881. $post['libraryconfirm'] = 1;
  882. $post['librarynot'] = "订单未打印,订单审核后修改";
  883. }
  884. else
  885. {
  886. $post['libraryconfirm'] = 1;
  887. $post['librarynot'] = "订单打印后修改";
  888. }
  889. }
  890. if($data['yhs'] == 1)
  891. {
  892. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  893. }
  894. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '31') && $post['country'] != 192)
  895. {
  896. echo json_encode(array('msg'=>'非美国无法选择Fedex!','success'=>false));exit;
  897. }
  898. if(($post['express'] == '28' || $post['express'] == '7') && $post['country'] != 191)
  899. {
  900. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  901. }
  902. if($data['type'] != '5' && $post['type'] == '5' && $editstate != '207')
  903. {
  904. echo json_encode(array('msg'=>'等待发货状态才可选择美仓!','success'=>false));exit;
  905. }
  906. if($post['express'] == 52 && empty($post['email'])){
  907. echo json_encode(array('msg'=>'惠程安迈世发货需要有邮箱!','success'=>false));exit;
  908. }
  909. if($post['express'] == '2' && $post['bx'] > 0)
  910. {
  911. echo json_encode(array('msg'=>'此物流不允许购买保险','success'=>false));exit;
  912. }
  913. if($post['printtype'] == 1)//如果是运单
  914. {
  915. $post['productdescription'] = $this->input->post('productdescription',true);
  916. $post['customs'] = $this->input->post('customs',true);
  917. }
  918. $express = $this->express->read($post['express']);
  919. if($express['ioss'] == 1 && $post['ioss'] == '')
  920. {
  921. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  922. }
  923. if(strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize'])
  924. {
  925. echo json_encode(array('msg'=>'此快递地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
  926. }
  927. if($post['zsbjz'] > $express['sbjz'])
  928. {
  929. echo json_encode(array('msg'=>'总申报价值不可超出'.$express['sbjz'],'success'=>false));exit;
  930. }
  931. if($post['shouldmoney'] > $express['shouldmoney'] && $express['shouldmoney'] != 0)
  932. {
  933. echo json_encode(array('msg'=>'订单金额不可超出'.$express['shouldmoney'],'success'=>false));exit;
  934. }
  935. if($post['express'] == '2' && $post['zzl'] > '16' && $post['js'] == '0')
  936. {
  937. echo json_encode(array('msg'=>'重量大于16不可按Ground Advantage提交!','success'=>false));exit;
  938. }
  939. if($post['express'] == '2' && isset($post['js']) && $post['js'] == '0'&& $post['qm'] == '1')
  940. {
  941. echo json_encode(array('msg'=>'Ground Advantage不可使用签名服务!','success'=>false));exit;
  942. }
  943. if(($post['express'] == '3' || $post['express'] == '42' || $post['express'] == '24' || $post['express'] == '31') && $post['shouldmoney'] < 1)
  944. {
  945. echo json_encode(array('msg'=>'零金额订单不可发 UPS/DHL官方-美国/Fedex(杭州)','success'=>false));exit;
  946. }
  947. if($post['express'] == '6' && $post['province'] == '')
  948. {
  949. echo json_encode(array('msg'=>'选择DPEX必须填写州信息','success'=>false));exit;
  950. }
  951. if(($post['express'] == '24' || $post['express'] == '3') && $post['shouldmoney'] == 0)
  952. {
  953. echo json_encode(array('msg'=>'0金额订单不可发UPS/Fedex(杭州)!!!','success'=>false));exit;
  954. }
  955. if($post['express'] == '42' && $post['zsbjz'] < 1)
  956. {
  957. echo json_encode(array('msg'=>'零申报金额不可发 DHL官方-美国','success'=>false));exit;
  958. }
  959. if($post['country'] == '35' && $post['zsbjz'] > 20)
  960. {
  961. echo json_encode(array('msg'=>'加拿大不可申报超过20美金!!!','success'=>false));exit;
  962. }
  963. if($post['express'] == 2 && strlen($post['zipcode']) != 5)//如果usps 邮编不是5位
  964. {
  965. echo json_encode(array('msg'=>'USPS-USA的邮编需按5位数格式提交!','success'=>false));exit;
  966. }
  967. /**
  968. if($editstate == 216 && $data['state'] != 216)
  969. {
  970. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  971. }
  972. **/
  973. if($editstate == 216 && preg_match('/\d/is',$post['waybill']) != true)
  974. {
  975. echo json_encode(array('msg'=>'当前信息不可修改订单状态','success'=>false));exit;
  976. }
  977. else
  978. {
  979. if($data['review'] == 1 && $data['source'] != 1)
  980. {
  981. $review = 6;
  982. if($data['merge'] != '0')
  983. {
  984. $hdata = $this->fullordersmt->find_all("merge = '".$data['merge']."' and id != '".$data['id']."'");
  985. foreach ($hdata as $v)
  986. {
  987. $this->fullordersmt->save(array('review'=>6),$v['id']);
  988. }
  989. }
  990. }
  991. else if($data['review'] == 3 || ($data['review'] == 1 && $data['source'] == 1))
  992. {
  993. $review = 2;
  994. }
  995. else
  996. {
  997. $review = $data['review'];
  998. }
  999. $post['review'] = $review;
  1000. $post['state'] = $editstate;
  1001. $post['reviewtime'] = time();
  1002. }
  1003. $thisdata = $this->fullordersmt->read($id);
  1004. $warehouse = $this->warehouse->read($thisdata['type']);
  1005. $warehousenew = $this->warehouse->read($post['type']);
  1006. if($warehousenew['bdcountry'] != 0 && $post['country'] != $warehousenew['bdcountry'])
  1007. {
  1008. echo json_encode(array('msg'=>'当前国家无法选择'.$warehousenew['title'].'!','success'=>false));exit;
  1009. }
  1010. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1011. {
  1012. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1013. }
  1014. $expt = $this->express->read($post['express']);
  1015. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1016. {
  1017. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1018. }
  1019. if($expt['province'] != '' && stripos($expt['province'],$post['province'].'、') !== false)
  1020. {
  1021. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1022. }
  1023. /**
  1024. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1025. {
  1026. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1027. }
  1028. **/
  1029. //开始注释 xyxg
  1030. /**
  1031. $ft = array();
  1032. $ftdata = explode('|',rtrim($fpcount,'|'));
  1033. foreach ($ftdata as $va)
  1034. {
  1035. $ftitle = '';
  1036. $va = explode('-',trim($va,'-'));
  1037. foreach ($va as $v)
  1038. {
  1039. $v = $this->typeclass->read($v);
  1040. $ftitle .= $v['title'].' ';
  1041. }
  1042. $ft[] = rtrim($ftitle,' ');
  1043. }
  1044. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1045. {
  1046. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1047. if($tskcyz['t'] > '0')
  1048. {
  1049. echo $tskcyz['m'];exit;
  1050. }
  1051. }
  1052. $kcyz = $this->whlabel->get_kc($data['state'],$post['state'],$warehousenew['zd'],$warehousenew['ys'],$post['type'],$whlabel,$fpcount,$ft,$thisdata['number'],$thisdata['shop'],$thisdata['type'],$thisdata['whlabel']);
  1053. if($kcyz['t'] > '0')
  1054. {
  1055. echo $kcyz['m'];exit;
  1056. }
  1057. else
  1058. {
  1059. if($this->fullordersmt->save($post,$id))
  1060. {
  1061. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  1062. }
  1063. else
  1064. {
  1065. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1066. }
  1067. }
  1068. //结束注释
  1069. **/
  1070. $warehouse = $this->warehouse->read($post['type']);
  1071. if($data['library'] == 1 || ($data['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1072. {
  1073. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1074. if($kcyz['t'] > '0')
  1075. {
  1076. echo $kcyz['m'];exit;
  1077. }
  1078. else if($kcyz['fpdata'] != '')
  1079. {
  1080. $post['whlabel'] = $kcyz['whlabel'];
  1081. $post['fpdata'] = $kcyz['fpdata'];
  1082. }
  1083. }
  1084. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1085. $post['sfxh'] = $fl['sfxh'];
  1086. $post['ckfl'] = $fl['ckfl'];
  1087. //查询净重开始
  1088. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1089. //查询净重结束
  1090. if($this->fullordersmt->save($post,$id))
  1091. {
  1092. if($data['printtime'] == '0')
  1093. {
  1094. $xghz = ',该单将自动禁止打印';
  1095. }
  1096. else if($data['printtime'] > '0' && $data['librarytime'] == '0')
  1097. {
  1098. $xghz = ',该单将自动禁止发货';
  1099. }
  1100. else
  1101. {
  1102. $xghz = '';
  1103. }
  1104. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1105. }
  1106. else
  1107. {
  1108. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1109. }
  1110. }
  1111. $arg_array = $arg_array[0];$fpdata = array();
  1112. $fullordersmt = $this->fullordersmt->read($arg_array);
  1113. $returngoods = $this->returngoods->get_orderinfo($fullordersmt['orderinfo']);
  1114. $this->data['returngoods'] = $returngoods?1:0;
  1115. $fullordersmt['parameter'] = str_replace(",","---",$fullordersmt['parameter']);
  1116. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  1117. $express = $this->express->find_all('1=1');//所有快递配置信息
  1118. $this->data['fullordersmt'] = $fullordersmt;
  1119. if($fullordersmt['express'] == 2)
  1120. {
  1121. $zzhl = 'oz';
  1122. }
  1123. else
  1124. {
  1125. $zzhl = 'kg';
  1126. }
  1127. $this->data['zzhl'] = $zzhl;
  1128. $this->data['country'] = $country;
  1129. $this->data['express'] = $express;
  1130. $this->data['dtime'] = date('Y-m-d H:i:s',$fullordersmt['dtime']);
  1131. $warehouse = $this->warehouse->read($fullordersmt['type']);
  1132. if(stripos($fullordersmt['fpdata'],';') !== false)
  1133. {
  1134. $fpdata = explode(';',rtrim($fullordersmt['fpdata'],';'));
  1135. foreach ($fpdata as $k=>$v)
  1136. {
  1137. $xxv = explode('|',$v);
  1138. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1139. {
  1140. $xxv['zd'] = "<p>已占单</p>";
  1141. $bdck = $warehouse['bdck'];
  1142. if(stripos($xxv[9],'~') !== false)
  1143. {
  1144. $dxxv = explode('~',trim($xxv[9],'~'));
  1145. foreach ($dxxv as $val)
  1146. {
  1147. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1148. if($wzid['details'] != '')
  1149. {
  1150. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1151. }
  1152. }
  1153. }
  1154. else
  1155. {
  1156. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1157. if($wzid['details'] != '')
  1158. {
  1159. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1160. }
  1161. }
  1162. }
  1163. $fpdata[$k] = $xxv;
  1164. }
  1165. }
  1166. $this->data['fpdata'] = $fpdata;
  1167. $thfpdataxs = array();
  1168. if($fullordersmt['thfpdata'] != '')
  1169. {
  1170. $thfpdata = explode(';',trim($fullordersmt['thfpdata'],';'));
  1171. foreach ($thfpdata as $k=>$v)
  1172. {
  1173. $thxs = explode('~',trim($v,'~'));
  1174. $thxs[0] = explode('|',trim($thxs[0],'|'));
  1175. $thxs[1] = explode('|',trim($thxs[1],'|'));
  1176. $thfpdataxs[] = array("<p>".$thxs[0][1]."<i class='fa fa-level-down'></i></p><p>".$thxs[1][1]."</p>","<p>".$thxs[0][2]."</p><p>".$thxs[1][2]."</p>","<p>旧</p><p>新</p>",$thxs[1][0]);
  1177. }
  1178. }
  1179. $this->data['thfpdata'] = $thfpdataxs;
  1180. $shop = $this->shop->read($fullordersmt['shop']);
  1181. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  1182. $is = 0;
  1183. if($shop['type'] == 269)//判断是否独立站,269是独立站
  1184. {
  1185. $is = 1;
  1186. }
  1187. $this->data['is'] = $is;
  1188. $this->data['power'] = $vip;
  1189. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  1190. $downwaybill = '';$dwls = array();
  1191. $oldwaybill = explode('-',ltrim($fullordersmt['oldwaybill'],'-'));
  1192. if(isset($oldwaybill[0][1]))
  1193. {
  1194. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  1195. foreach ($oldwaybill as $v)
  1196. {
  1197. $dw = explode('/',$v);
  1198. if(isset($dw[1]))
  1199. {
  1200. if(stripos($downwaybill,$dw[1]) === false)
  1201. {
  1202. $dwls[$dw[1]] = 1;
  1203. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  1204. }
  1205. }
  1206. }
  1207. }
  1208. if($fullordersmt['printtype'] == 1)
  1209. {
  1210. if($fullordersmt['waybill'] != '' && !isset($dwls[$fullordersmt['waybill']]))
  1211. {
  1212. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordersmt['printtime']).'/y-'.$fullordersmt['waybill'].'.pdf" target="_blank">'.$fullordersmt['waybill'].'</a>、'.$downwaybill;
  1213. }
  1214. }
  1215. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  1216. $product = '';
  1217. if($fullordersmt['link'] != '' && $fullordersmt['source'] != '1')
  1218. {
  1219. $pt = explode(';',rtrim($fullordersmt['product'],';'));
  1220. $lk = explode(',',$fullordersmt['link']);
  1221. for($i=0;$i<count($pt);$i++)
  1222. {
  1223. if(isset($lk[$i]) && isset($pt[$i]))
  1224. {
  1225. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$pt[$i].'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$pt[$i].'</a>';
  1226. }
  1227. }
  1228. }
  1229. else
  1230. {
  1231. $product = $fullordersmt['product'];
  1232. }
  1233. $this->data['product'] = $product;
  1234. $out = $this->systemtransfer->find_all("number = '".$fullordersmt['number']."'");
  1235. $outread = '';
  1236. if($out)
  1237. {
  1238. foreach ($out as $val)
  1239. {
  1240. $list = '';
  1241. $rk = explode('|',trim($val['rk'],'|'));
  1242. $rktime = explode('|',trim($val['rktime'],'|'));
  1243. $zw = array();
  1244. $t = $this->transfer->find_all("1=1");
  1245. foreach ($t as $v)
  1246. {
  1247. $zw[$v['id']] = $v['title'];
  1248. }
  1249. if($val['rk'] != '' && count($rk) > 0)
  1250. {
  1251. for($i=0;$i<count($rk);$i++)
  1252. {
  1253. if(!isset($rktime[$i]))
  1254. {
  1255. $list .= $zw[$cz[$i]];
  1256. }
  1257. else
  1258. {
  1259. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1260. }
  1261. }
  1262. }
  1263. //$outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1264. $outread .= '<span style="color:#f00">'.$val['shipremarks'].'</span>:'.$list.'<br>';
  1265. }
  1266. }
  1267. else
  1268. {
  1269. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordersmt['number']."'");
  1270. $outread = array();
  1271. if($systemwigsout)
  1272. {
  1273. foreach ($systemwigsout as $v)
  1274. {
  1275. if($v['czwarehouse'] == 37)
  1276. {
  1277. $outread[] = '华荣厂';
  1278. }
  1279. else if($v['czwarehouse'] == 0)
  1280. {
  1281. $outread[] = '龙盈厂';
  1282. }
  1283. $cz = explode('|',trim($v['cz'],'|'));
  1284. $cztime = explode('|',trim($v['cztime'],'|'));
  1285. $zw = $this->transfer->get_list();
  1286. if($v['cz'] != '' && count($cz) > 0)
  1287. {
  1288. for($i=0;$i<count($cz);$i++)
  1289. {
  1290. if(!isset($cztime[$i]))
  1291. {
  1292. $outread[] = $zw[$cz[$i]].' -&gt; ';
  1293. }
  1294. else
  1295. {
  1296. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1297. }
  1298. }
  1299. $outread[] = '<br>';
  1300. }
  1301. }
  1302. }
  1303. }
  1304. $this->data['systemwigsout'] = $outread;
  1305. $this->data['xwuser'] = 0;
  1306. if($user['power'] == 47)
  1307. {
  1308. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($xwtype,'or'),"*","px asc");
  1309. $this->data['warehouse'] = $warehouse;
  1310. $this->data['xwuser'] = 1;
  1311. }
  1312. $this->data['user'] = $user;
  1313. $this->_Template('fullordersmt_edit',$this->data);
  1314. }
  1315. //不可修改
  1316. public function _readonly($arg_array)
  1317. {
  1318. $user = $this->user->get_api($_SESSION['api']);
  1319. $post = $this->input->post(NULL, TRUE);
  1320. if(isset($post['id']))
  1321. {
  1322. $id = $this->input->post('id',true);
  1323. $ud = $this->fullordersmt->read($id);$data = $ud;
  1324. $post['type'] = $this->input->post('warehouse',true);
  1325. $post['orderremarks'] = $this->input->post('orderremarks',true);
  1326. $post['state'] = $this->input->post('state',true);
  1327. $post['msg'] = $this->input->post('msg',true);
  1328. $post['refundy'] = $this->input->post('refundy',true);
  1329. $post['refundj'] = $this->input->post('refundj',true);
  1330. $fpdata = $this->input->post('fpdata');
  1331. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  1332. $post['fpdata'] = $fpdata;
  1333. $rtime = $this->input->post('rtime',true);
  1334. $post['rtime'] = strtotime($rtime);
  1335. $post['rpaypal'] = $this->input->post('rpaypal',true);
  1336. $post['rtext'] = $this->input->post('rtext',true);
  1337. //$post['ioss'] = $this->input->post('ioss',true);
  1338. $whlabel = $this->input->post('whlabel',true);
  1339. $post['edittime'] = time();
  1340. $editstate = $post['state'];
  1341. /**
  1342. if($post['state'] == 216 && $ud['state'] != 216)
  1343. {
  1344. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  1345. }
  1346. **/
  1347. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  1348. foreach ($whlabeldata as $va)
  1349. {
  1350. if(stripos($va,'z') !== false)
  1351. {
  1352. $way += 1;
  1353. }
  1354. }
  1355. if($way == count($whlabeldata) && $post['type'] != 12)
  1356. {
  1357. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  1358. }
  1359. $fpcount = $this->input->post('fpcount',true);
  1360. if(!$fpcount)
  1361. {
  1362. echo json_encode(array('msg'=>'需要先清理浏览器缓存,刷新当前页面后再试!','success'=>false));exit;
  1363. }
  1364. if($ud['shop'] == '9' && $post['type'] != '7' && $post['type'] != '8')
  1365. {
  1366. echo json_encode(array('msg'=>'仓库选择错误!','success'=>false));exit;
  1367. }
  1368. if($ud['library'] == 1)
  1369. {
  1370. if($ud['print'] != 3)
  1371. {
  1372. $post['print'] = 1;
  1373. $post['libraryconfirm'] = 1;
  1374. $post['librarynot'] = "订单未打印,未审核或未通过";
  1375. }
  1376. else
  1377. {
  1378. $post['libraryconfirm'] = 1;
  1379. $post['librarynot'] = "未审核或未通过";
  1380. }
  1381. }
  1382. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '31') && $ud['country'] != 192)
  1383. {
  1384. echo json_encode(array('msg'=>'非美国无法选择Fedex!','success'=>false));exit;
  1385. }
  1386. if(($post['express'] == '28' || $post['express'] == '7') && $ud['country'] != 191)
  1387. {
  1388. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  1389. }
  1390. if($post['type'] != 5 && in_array($post['express'],[2,63,64]))
  1391. {
  1392. echo json_encode(array('msg'=>"此快递方式必须从美仓发货!",'success'=>false));exit;
  1393. }
  1394. if($post['type'] == 5 && !in_array($post['express'],[2,63,64]))
  1395. {
  1396. echo json_encode(array('msg'=>"此快递方式不能美仓发货!",'success'=>false));exit;
  1397. }
  1398. $express = $this->express->read($post['express']);
  1399. /**
  1400. if($express['ioss'] == 1 && $post['ioss'] == '')
  1401. {
  1402. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1403. }
  1404. **/
  1405. $thisdata = $this->fullordersmt->read($id);
  1406. $warehouse = $this->warehouse->read($thisdata['type']);
  1407. $warehousenew = $this->warehouse->read($post['type']);
  1408. if(($post['express'] == '5' || $post['express'] == '24') && strlen($ud['address']) > 32)
  1409. {
  1410. echo json_encode(array('msg'=>'地址1长度不合格!','success'=>false));exit;
  1411. }
  1412. if($post['express'] == '27' && strlen($post['address']) > 30)
  1413. {
  1414. echo json_encode(array('msg'=>'地址1长度不合格!','success'=>false));exit;
  1415. }
  1416. if($data['type'] != '5' && $post['type'] == '5' && $editstate != '207')
  1417. {
  1418. echo json_encode(array('msg'=>'等待发货状态才可选择美仓!','success'=>false));exit;
  1419. }
  1420. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1421. {
  1422. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1423. }
  1424. if($ud['yhs'] == 1)
  1425. {
  1426. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1427. }
  1428. $expt = $this->express->read($post['express']);
  1429. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1430. {
  1431. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1432. }
  1433. if($expt['province'] != '' && stripos($expt['province'],$ud['province'].'、') !== false)
  1434. {
  1435. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1436. }
  1437. /**
  1438. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1439. {
  1440. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1441. }
  1442. **/
  1443. //开始注释 xyxg
  1444. /**
  1445. $ft = array();
  1446. $ftdata = explode('|',rtrim($fpcount,'|'));
  1447. foreach ($ftdata as $va)
  1448. {
  1449. $ftitle = '';
  1450. $va = explode('-',trim($va,'-'));
  1451. foreach ($va as $v)
  1452. {
  1453. $v = $this->typeclass->read($v);
  1454. $ftitle .= $v['title'].' ';
  1455. }
  1456. $ft[] = rtrim($ftitle,' ');
  1457. }
  1458. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1459. {
  1460. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1461. if($tskcyz['t'] > '0')
  1462. {
  1463. echo $tskcyz['m'];exit;
  1464. }
  1465. }
  1466. $kcyz = $this->whlabel->get_kc($thisdata['state'],$post['state'],$warehousenew['zd'],$warehousenew['ys'],$post['type'],$whlabel,$fpcount,$ft,$thisdata['number'],$thisdata['shop'],$thisdata['type'],$thisdata['whlabel']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1467. if($kcyz['t'] > '0')
  1468. {
  1469. echo $kcyz['m'];exit;
  1470. }
  1471. else
  1472. {
  1473. if($this->fullordersmt->save($post,$id))
  1474. {
  1475. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  1476. }
  1477. else
  1478. {
  1479. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1480. }
  1481. }
  1482. //结束注释
  1483. **/
  1484. $warehouse = $this->warehouse->read($post['type']);
  1485. if($ud['library'] == 1 || ($ud['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1486. {
  1487. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1488. if($kcyz['t'] > '0')
  1489. {
  1490. echo $kcyz['m'];exit;
  1491. }
  1492. else if($kcyz['fpdata'] != '')
  1493. {
  1494. $post['whlabel'] = $kcyz['whlabel'];
  1495. $post['fpdata'] = $kcyz['fpdata'];
  1496. }
  1497. }
  1498. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1499. $post['sfxh'] = $fl['sfxh'];
  1500. $post['ckfl'] = $fl['ckfl'];
  1501. //查询净重开始
  1502. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1503. //查询净重结束
  1504. if($this->fullordersmt->save($post,$id))
  1505. {
  1506. if($data['printtime'] == '0')
  1507. {
  1508. $xghz = ',该单将自动禁止打印';
  1509. }
  1510. else if($data['printtime'] > '0' && $data['librarytime'] == '0')
  1511. {
  1512. $xghz = ',该单将自动禁止发货';
  1513. }
  1514. else
  1515. {
  1516. $xghz = '';
  1517. }
  1518. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1519. }
  1520. else
  1521. {
  1522. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1523. }
  1524. }
  1525. $arg_array = $arg_array[0];$fpdata = array();
  1526. $fullordersmt = $this->fullordersmt->read($arg_array);
  1527. $returngoods = $this->returngoods->get_orderinfo($fullordersmt['orderinfo']);
  1528. $this->data['returngoods'] = $returngoods?1:0;
  1529. $fullordersmt['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullordersmt['shipremarks']);
  1530. $fullordersmt['parameter'] = str_replace(",","---",$fullordersmt['parameter']);
  1531. $this->data['fullordersmt'] = $fullordersmt;
  1532. if($fullordersmt['express'] == 2)
  1533. {
  1534. $zzhl = 'oz';
  1535. }
  1536. else
  1537. {
  1538. $zzhl = 'kg';
  1539. }
  1540. $this->data['zzhl'] = $zzhl;
  1541. $this->data['countrys'] = $this->country->find_all();
  1542. $this->data['express'] = $this->express->find_all();
  1543. $warehouse = $this->warehouse->read($fullordersmt['type']);
  1544. if(stripos($fullordersmt['fpdata'],';') !== false)
  1545. {
  1546. $fpdata = explode(';',rtrim($fullordersmt['fpdata'],';'));
  1547. foreach ($fpdata as $k=>$v)
  1548. {
  1549. $xxv = explode('|',$v);
  1550. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1551. {
  1552. $xxv['zd'] = "<p>已占单</p>";
  1553. $bdck = $warehouse['bdck'];
  1554. if(stripos($xxv[9],'~') !== false)
  1555. {
  1556. $dxxv = explode('~',trim($xxv[9],'~'));
  1557. foreach ($dxxv as $val)
  1558. {
  1559. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1560. if($wzid['details'] != '')
  1561. {
  1562. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1563. }
  1564. }
  1565. }
  1566. else
  1567. {
  1568. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1569. if($wzid['details'] != '')
  1570. {
  1571. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1572. }
  1573. }
  1574. }
  1575. $fpdata[$k] = $xxv;
  1576. }
  1577. }
  1578. $this->data['fpdata'] = $fpdata;
  1579. $thfpdataxs = array();
  1580. if($fullordersmt['thfpdata'] != '')
  1581. {
  1582. $thfpdata = explode(';',trim($fullordersmt['thfpdata'],';'));
  1583. foreach ($thfpdata as $k=>$v)
  1584. {
  1585. $thxs = explode('~',trim($v,'~'));
  1586. $thxs[0] = explode('|',trim($thxs[0],'|'));
  1587. $thxs[1] = explode('|',trim($thxs[1],'|'));
  1588. $thfpdataxs[] = array("<p>".$thxs[0][1]."<i class='fa fa-level-down'></i></p><p>".$thxs[1][1]."</p>","<p>".$thxs[0][2]."</p><p>".$thxs[1][2]."</p>","<p>旧</p><p>新</p>",$thxs[1][0]);
  1589. }
  1590. }
  1591. $this->data['thfpdata'] = $thfpdataxs;
  1592. $shop = $this->shop->read($fullordersmt['shop']);
  1593. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  1594. $is = 0;
  1595. if($shop['type'] == 269)//判断是否独立站,269是独立站
  1596. {
  1597. $is = 1;
  1598. }
  1599. $this->data['is'] = $is;
  1600. //单项开始
  1601. $warehouse = $this->warehouse->read($fullordersmt['warehouse']);//发货仓库
  1602. $state = $this->typeclass->read($fullordersmt['state']);//订单状态
  1603. $country = $this->country->read($fullordersmt['country']);//国家
  1604. if($fullordersmt['capital'] == 1)
  1605. {
  1606. $capital = '暂未支付';
  1607. }
  1608. else if($fullordersmt['capital'] == 2)
  1609. {
  1610. $capital = '部分支付';
  1611. }
  1612. else if($fullordersmt['capital'] == 3)
  1613. {
  1614. $capital = '全部支付';
  1615. }
  1616. if($fullordersmt['printtype'] == 1)
  1617. {
  1618. $printtype = '运单';
  1619. }
  1620. else if($fullordersmt['printtype'] == 2)
  1621. {
  1622. $printtype = '发货单';
  1623. }
  1624. else if($fullordersmt['printtype'] == 3)
  1625. {
  1626. $printtype = '不打印单据';
  1627. }
  1628. else
  1629. {
  1630. $printtype = '未选择';
  1631. }
  1632. $this->data['warehouse'] = $warehouse['title'];
  1633. $this->data['state'] = $state['title'];
  1634. $this->data['capital'] = $capital;
  1635. $this->data['country'] = $country['ename'];
  1636. $this->data['printtype'] = $printtype;
  1637. //单项结束
  1638. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  1639. $downwaybill = '';$dwls = array();
  1640. $oldwaybill = explode('-',ltrim($fullordersmt['oldwaybill'],'-'));
  1641. if(isset($oldwaybill[0][1]))
  1642. {
  1643. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  1644. foreach ($oldwaybill as $v)
  1645. {
  1646. $dw = explode('/',$v);
  1647. if(isset($dw[1]))
  1648. {
  1649. $dwls[$dw[1]] = 1;
  1650. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  1651. }
  1652. }
  1653. }
  1654. if($fullordersmt['printtype'] == 1)
  1655. {
  1656. if($fullordersmt['waybill'] != '' && !isset($dwls[$fullordersmt['waybill']]))
  1657. {
  1658. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordersmt['printtime']).'/y-'.$fullordersmt['waybill'].'.pdf" target="_blank">'.$fullordersmt['waybill'].'</a>、'.$downwaybill;
  1659. }
  1660. }
  1661. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  1662. /** 历史打印时间 **/
  1663. $printtime = '';
  1664. if($fullordersmt['oldprinttime'])
  1665. {
  1666. $pte = explode('-',rtrim($fullordersmt['oldprinttime'],'-'));
  1667. foreach ($pte as $v)
  1668. {
  1669. $printtime .= date('Y-m-d H:i:s',$v).'、';
  1670. }
  1671. }
  1672. $this->data['printtime'] = rtrim($printtime,'、');
  1673. $product = '';
  1674. if($fullordersmt['link'] != '' && $fullordersmt['source'] != '1')
  1675. {
  1676. $pt = explode(';',rtrim($fullordersmt['product'],';'));
  1677. $lk = explode(',',$fullordersmt['link']);
  1678. for($i=0;$i<count($pt);$i++)
  1679. {
  1680. if(isset($lk[$i]) && isset($pt[$i]))
  1681. {
  1682. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$pt[$i].'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$pt[$i].'</a>';
  1683. }
  1684. }
  1685. }
  1686. else
  1687. {
  1688. $product = $fullordersmt['product'];
  1689. }
  1690. $this->data['username'] = ($user['shop']=='|9|')?'1':'0';
  1691. $out = $this->systemtransfer->find_all("number = '".$fullordersmt['number']."'");
  1692. $outread = '';
  1693. if($out)
  1694. {
  1695. foreach ($out as $val)
  1696. {
  1697. $list = '';
  1698. $rk = explode('|',trim($val['rk'],'|'));
  1699. $rktime = explode('|',trim($val['rktime'],'|'));
  1700. $zw = array();
  1701. $t = $this->transfer->find_all("1=1");
  1702. foreach ($t as $v)
  1703. {
  1704. $zw[$v['id']] = $v['title'];
  1705. }
  1706. if($val['rk'] != '' && count($rk) > 0)
  1707. {
  1708. for($i=0;$i<count($rk);$i++)
  1709. {
  1710. if(!isset($rktime[$i]))
  1711. {
  1712. $list .= $zw[$cz[$i]];
  1713. }
  1714. else
  1715. {
  1716. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1717. }
  1718. }
  1719. }
  1720. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1721. }
  1722. }
  1723. else
  1724. {
  1725. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordersmt['number']."'");
  1726. $outread = array();
  1727. if($systemwigsout)
  1728. {
  1729. foreach ($systemwigsout as $v)
  1730. {
  1731. if($v['czwarehouse'] == 37)
  1732. {
  1733. $outread[] = '华荣厂';
  1734. }
  1735. else if($v['czwarehouse'] == 0)
  1736. {
  1737. $outread[] = '龙盈厂';
  1738. }
  1739. $cz = explode('|',trim($v['cz'],'|'));
  1740. $cztime = explode('|',trim($v['cztime'],'|'));
  1741. $zw = $this->transfer->get_list();
  1742. if($v['cz'] != '' && count($cz) > 0)
  1743. {
  1744. for($i=0;$i<count($cz);$i++)
  1745. {
  1746. if(!isset($cztime[$i]))
  1747. {
  1748. $outread[] = $zw[$cz[$i]].' -&gt; ';
  1749. }
  1750. else
  1751. {
  1752. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1753. }
  1754. }
  1755. $outread[] = '<br>';
  1756. }
  1757. }
  1758. }
  1759. }
  1760. $this->data['systemwigsout'] = $outread;
  1761. $this->data['user'] = $user;
  1762. $this->_Template('fullordersmt_readonly',$this->data);
  1763. }
  1764. //浏览列表
  1765. public function _readlist()
  1766. {
  1767. $post = $this->input->post(NULL, TRUE);
  1768. if(isset($post['page']))
  1769. {
  1770. $page = $this->input->post('page',true);
  1771. $perpage = $this->input->post('perpage',true);
  1772. $warehouse = $this->input->post('warehouse',true);
  1773. $express = $this->input->post('express',true);
  1774. $state = $this->input->post('state',true);
  1775. $print = $this->input->post('print',true);
  1776. $libraryconfirm = $this->input->post('libraryconfirm',true);
  1777. $orderinfo = $this->input->post('orderinfo',true);
  1778. $client = $this->input->post('name',true);
  1779. $email = $this->input->post('email',true);
  1780. $number = $this->input->post('number',true);
  1781. $waybill = $this->input->post('waybill',true);
  1782. $timetk = $this->input->post('timetk',true);
  1783. $timetj = $this->input->post('timetj',true);
  1784. $timetk = strtotime($timetk);
  1785. $timetj = strtotime($timetj);
  1786. $where = "mergeid = 0";
  1787. if($warehouse)
  1788. {
  1789. $where .= " and type = '$warehouse'";
  1790. }
  1791. if($express)
  1792. {
  1793. $where .= " and express = '$express'";
  1794. }
  1795. if($state)
  1796. {
  1797. $where .= " and state = '$state'";
  1798. }
  1799. if($print)
  1800. {
  1801. $where .= " and print = '$print'";
  1802. }
  1803. if($libraryconfirm)
  1804. {
  1805. $where .= " and libraryconfirm = '$libraryconfirm'";
  1806. }
  1807. if($orderinfo)
  1808. {
  1809. $where .= " and orderinfo = '$orderinfo'";
  1810. }
  1811. if($client)
  1812. {
  1813. $where .= " and client like '%$client%'";
  1814. }
  1815. if($email)
  1816. {
  1817. $where .= " and email = '$email'";
  1818. }
  1819. if($number)
  1820. {
  1821. $where .= " and number = '$number'";
  1822. }
  1823. if($waybill)
  1824. {
  1825. $where .= " and waybill = '$waybill'";
  1826. }
  1827. if($timetk && $timetj)
  1828. {
  1829. $timetj = $timetj+24*3600;
  1830. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  1831. }
  1832. //数据排序
  1833. $order_str = "numberpx desc";
  1834. if(empty($page))
  1835. {
  1836. $start = 0;
  1837. $perpage = 1;
  1838. }
  1839. else
  1840. {
  1841. $start = ($page - 1)*$perpage;
  1842. }
  1843. //取得信息列表
  1844. $info_list = $this->fullordersmt->find_all($where,'id,type,orderinfo,number,client,state,buytime,express,waybill,print,library,orderremarks',$order_str,$start,$perpage);
  1845. //格式化数据
  1846. foreach ($info_list as $key=>$value)
  1847. {
  1848. $ud = $this->fullordersmt->read($value['id']);
  1849. $warehouse = $this->warehouse->read($value['type']);
  1850. $info_list[$key]['type'] = $warehouse['title'];
  1851. $typeclass = $this->typeclass->read($value['state']);
  1852. $info_list[$key]['state'] = $typeclass['spare'];
  1853. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  1854. {
  1855. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
  1856. }
  1857. else
  1858. {
  1859. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  1860. }
  1861. $express = $this->express->read($value['express']);
  1862. $info_list[$key]['express'] = $express['servicename'];
  1863. if($value['print'] == 1)
  1864. {
  1865. $info_list[$key]['print'] = "不可打印";
  1866. }
  1867. else if($value['print'] == 2)
  1868. {
  1869. $info_list[$key]['print'] = "未打印";
  1870. }
  1871. else if($value['print'] == 3)
  1872. {
  1873. $info_list[$key]['print'] = '<p>'.date('Y-m-d',$ud['printtime']).'</p><p>'.date('H:i:s',$ud['printtime']).'</p>';
  1874. }
  1875. if($value['library'] == 1)
  1876. {
  1877. $info_list[$key]['library'] = "未出库";
  1878. }
  1879. else if($value['library'] == 2)
  1880. {
  1881. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'</p>';
  1882. }
  1883. else if($value['library'] == 3)
  1884. {
  1885. $info_list[$key]['library'] = "已退库";
  1886. }
  1887. }
  1888. $total = $this->fullordersmt->find_count($where);
  1889. $pagenum = ceil($total/$perpage);
  1890. $over = $total-($start+$perpage);
  1891. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1892. echo json_encode($rows);exit;
  1893. }
  1894. $this->_Template('fullordersmt_readlist',$this->data);
  1895. }
  1896. //删除
  1897. public function _del()
  1898. {
  1899. $post = $this->input->post(NULL, TRUE);
  1900. if(isset($post['s']))
  1901. {
  1902. $id_arr = $this->input->post('s');
  1903. $id_arr = explode(',',$id_arr);
  1904. if(!$id_arr)
  1905. {
  1906. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1907. }
  1908. //循环删除记录
  1909. foreach ($id_arr as $v)
  1910. {
  1911. $this->fullordersmt->remove($v);
  1912. }
  1913. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  1914. }
  1915. }
  1916. //查找商品价格
  1917. public function _price()
  1918. {
  1919. $post = $this->input->post(NULL, TRUE);
  1920. if(isset($post['data']))
  1921. {
  1922. $data = $this->input->post('data');
  1923. $data = explode('-',$data);
  1924. $number = '';$num = count($data);
  1925. //循环删除记录
  1926. for($i=0;$i<$num-1;$i++)
  1927. {
  1928. if($data[$i] != 0)
  1929. {
  1930. $number=$number.$data[$i];
  1931. if($i == 2)
  1932. {
  1933. $number=$number.$data[$num-1];
  1934. }
  1935. }
  1936. }
  1937. $list = $this->productdescribe->get_number($number);
  1938. if($list)
  1939. {
  1940. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));
  1941. }
  1942. else
  1943. {
  1944. $list = array('purchase'=>0,'cost'=>0,'salesprice'=>0);
  1945. //echo json_encode(array('msg'=>'此信息没有配置价格!','n'=>$data[$num-1],'success'=>false));exit;
  1946. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));exit;
  1947. }
  1948. }
  1949. }
  1950. public function _customs()
  1951. {
  1952. $post = $this->input->post(NULL, TRUE);
  1953. if(isset($post['e']))
  1954. {
  1955. $e = $this->input->post('e');//快递信息
  1956. $c = $this->input->post('c');//国家信息
  1957. $data = $this->customs->find_all('express = "'.$e.'" and country = "'.$c.'"');
  1958. $list = $this->productdescription->find_all('express = "'.$e.'" and country = "'.$c.'"');
  1959. $rows = array();
  1960. foreach ($data as $key=>$value)
  1961. {
  1962. $detailed = explode('|',trim($value['detailed'],'|'));
  1963. //此处未对比重量选择价值,暂直接选择第一条海关价值
  1964. $detailed = $this->detailed->read($detailed[0]);
  1965. $money = $detailed['customsval'];//找到海关价值
  1966. }
  1967. foreach ($list as $key=>$value)
  1968. {
  1969. $description = $this->typeclass->read($value['description']);
  1970. $list[$key]['title'] = $description['title'];//产品描述名称
  1971. }
  1972. if(!$data && !$list)
  1973. {
  1974. echo json_encode(array('msg'=>'无此快递配置信息!','success'=>false));exit;
  1975. }
  1976. else
  1977. {
  1978. //$list-title -description 取值
  1979. echo json_encode(array('money'=>sprintf("%.2f",$money),'msg'=>$list,'success'=>true));
  1980. }
  1981. }
  1982. }
  1983. public function _express()
  1984. {
  1985. $post = $this->input->post(NULL, TRUE);
  1986. if(isset($post['e']))
  1987. {
  1988. $e = $this->input->post('e');//快递信息
  1989. $c = $this->input->post('c');//国家信息
  1990. $data = $this->logistics->find_all('express = "'.$e.'" and country = "'.$c.'"');
  1991. if(!$data)
  1992. {
  1993. echo json_encode(array('success'=>false));exit;
  1994. }
  1995. else
  1996. {
  1997. echo json_encode(array('money'=>sprintf("%.2f",$data[0]['firstmoney']),'success'=>true));
  1998. }
  1999. }
  2000. }
  2001. public function _hl()
  2002. {
  2003. $post = $this->input->post(NULL, TRUE);
  2004. if(isset($post['cy']))
  2005. {
  2006. $hl = 0;
  2007. $cy = $this->input->post('cy');//币种ID
  2008. $cy = $this->typeclass->read($cy);
  2009. $gethl = $this->hl->get_hl();
  2010. foreach ($gethl as $v)
  2011. {
  2012. $code = str_replace(" ","",$v['code']);
  2013. if($code == $cy['title'])
  2014. {
  2015. $hl = $v['refePrice']/100;
  2016. }
  2017. }
  2018. echo json_encode(array('msg'=>$hl,'success'=>true));
  2019. }
  2020. }
  2021. public function _operation()
  2022. {
  2023. $post = $this->input->post(NULL, TRUE);
  2024. if(isset($post['type']))
  2025. {
  2026. $type = $this->input->post('type');
  2027. $id = $this->input->post('id');
  2028. $msg = $this->input->post('msg');
  2029. if($type == 1)//禁止发货
  2030. {
  2031. $d = $this->fullordersmt->read($id);
  2032. if($d['library'] != 1)
  2033. {
  2034. echo json_encode(array('msg'=>'操作失败,订单非未出库状态!','success'=>false));exit;
  2035. }
  2036. if($msg == "")
  2037. {
  2038. echo json_encode(array('msg'=>'必须填写禁止原因!','success'=>false));exit;
  2039. }
  2040. if($d['print'] < 3)
  2041. {
  2042. $a = "订单未打印,";
  2043. }
  2044. else
  2045. {
  2046. $a = "";
  2047. }
  2048. if($this->fullordersmt->save(array('libraryconfirm'=>1,'librarynot'=>$a.$msg),$id))
  2049. {
  2050. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2051. }
  2052. else
  2053. {
  2054. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2055. }
  2056. }
  2057. if($type == 6)//允许发货
  2058. {
  2059. $d = $this->fullordersmt->read($id);
  2060. if($d['library'] > 1)
  2061. {
  2062. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2063. }
  2064. if($d['print'] < 3)
  2065. {
  2066. $a = "订单未打印,";
  2067. }
  2068. else
  2069. {
  2070. $a = "";
  2071. }
  2072. if($this->fullordersmt->save(array('libraryconfirm'=>2,'librarynot'=>$a.$msg),$id))
  2073. {
  2074. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2075. }
  2076. else
  2077. {
  2078. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2079. }
  2080. }
  2081. if($type == 7)//禁止打印
  2082. {
  2083. $d = $this->fullordersmt->read($id);
  2084. if($d['printtime'] != 0)
  2085. {
  2086. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2087. }
  2088. if($d['library'] > 1)
  2089. {
  2090. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2091. }
  2092. if($d['print'] == 3)
  2093. {
  2094. echo json_encode(array('msg'=>'操作失败,订单已打印!','success'=>false));exit;
  2095. }
  2096. if($d['print'] < 3)
  2097. {
  2098. $a = "订单未打印,";
  2099. }
  2100. else
  2101. {
  2102. $a = "";
  2103. }
  2104. if($this->fullordersmt->save(array('print'=>1),$id))
  2105. {
  2106. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2107. }
  2108. else
  2109. {
  2110. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2111. }
  2112. }
  2113. if($type == 8)//允许打印
  2114. {
  2115. $d = $this->fullordersmt->read($id);
  2116. /**
  2117. if($d['printtime'] != 0)
  2118. {
  2119. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2120. }
  2121. **/
  2122. if($d['library'] > 1)
  2123. {
  2124. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2125. }
  2126. if($d['print'] < 3)
  2127. {
  2128. $a = "订单未打印,";
  2129. }
  2130. else
  2131. {
  2132. $a = "";
  2133. }
  2134. if($d['printtime'] == '0')
  2135. {
  2136. $bcprint = 2;
  2137. }
  2138. else
  2139. {
  2140. $bcprint = 3;
  2141. }
  2142. if($this->fullordersmt->save(array('print'=>$bcprint,'failed'=>'','librarynot'=>$a.$d['librarynot']),$id))
  2143. {
  2144. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2145. }
  2146. else
  2147. {
  2148. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2149. }
  2150. }
  2151. if($type == 9)//关闭
  2152. {
  2153. if($this->fullordersmt->save(array('failed'=>''),$id))
  2154. {
  2155. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2156. }
  2157. else
  2158. {
  2159. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2160. }
  2161. }
  2162. if($type == 10)//允许出库
  2163. {
  2164. if($this->fullordersmt->save(array('failed'=>'','libraryconfirm'=>2),$id))
  2165. {
  2166. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2167. }
  2168. else
  2169. {
  2170. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2171. }
  2172. }
  2173. if($type == 2)//填写运单、修改运单
  2174. {
  2175. $d = $this->fullordersmt->read($id);
  2176. if($d['source'] == 1)
  2177. {
  2178. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>216,'dlz'=>3),$id);
  2179. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2180. }
  2181. $ex = $this->express->read($d['express']);
  2182. $shop = $this->shop->read($d['shop']);
  2183. if($d['express'] == 0)
  2184. {
  2185. echo json_encode(array('msg'=>'操作失败,未选择物流方式!','success'=>false));exit;
  2186. }
  2187. if($d['library'] == 3 || ($d['print'] == 3 && $d['libraryconfirm'] == 1))
  2188. {
  2189. echo json_encode(array('msg'=>'操作失败,不允许填写运单号!','success'=>false));exit;
  2190. }
  2191. if($d['dlz'] == 1 || $d['dlz'] == 2)//如果已经声明过需要操作修改声明
  2192. {
  2193. $obtain = $this->apismt->get_obtain($d['orderinfo'],$shop['code']);//修改声明先查询之前物流信息
  2194. if(isset($obtain['logistics_no']))
  2195. {
  2196. $result = $this->apismt->get_editout($obtain['logistics_no'],$msg,'all',$d['orderinfo'],$obtain['service_name'],$ex['aecode'],$shop['code']);
  2197. }
  2198. if(isset($result['result_success']) && $result['result_success'] == 1)
  2199. {
  2200. $this->fullordersmt->save(array('waybill'=>$msg),$id);
  2201. /** 合并信息处理开始-修改声明 **/
  2202. if($d['merge'] != '0')
  2203. {
  2204. $hdata = $this->fullordersmt->find_all("merge = '".$d['merge']."' and id != '".$d['id']."' and dlz = '0' and source != 1");$i=0;
  2205. foreach ($hdata as $v)
  2206. {
  2207. $obtain = $this->apismt->get_obtain($v['orderinfo'],$shop['code']);//修改声明先查询之前物流信息
  2208. if(isset($obtain['logistics_no']))
  2209. {
  2210. $result = $this->apismt->get_editout($obtain['logistics_no'],$msg,'all',$v['orderinfo'],$obtain['service_name'],$ex['aecode'],$shop['code']);
  2211. }
  2212. if(isset($result['result_success']) && $result['result_success'] == 1)
  2213. {
  2214. $this->fullordersmt->save(array('waybill'=>$msg),$v['id']);
  2215. }
  2216. else
  2217. {
  2218. $this->fullordersmt->save(array('waybill'=>$msg,'dlz'=>4),$v['id']);
  2219. }
  2220. $i++;
  2221. if($i > 10)
  2222. {
  2223. break;
  2224. }
  2225. }
  2226. }
  2227. /** 合并信息处理结束开始 **/
  2228. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2229. }
  2230. else
  2231. {
  2232. $this->fullordersmt->save(array('waybill'=>$msg,'dlz'=>4),$id);
  2233. echo json_encode(array('msg'=>'修改声明失败,请重试','xq'=>$obtain,'success'=>false));exit;
  2234. }
  2235. }
  2236. else if($d['dlz'] == '0')//未发货声明状态
  2237. {
  2238. $result_t = $this->apismt->get_out($msg,'all',$d['orderinfo'],$ex['aecode'],$shop['code']);
  2239. $result = $result_t['result'];
  2240. if(isset($result['success']) && $result['success'] == "true")
  2241. {
  2242. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$id);
  2243. /** 合并信息处理开始-发货声明 **/
  2244. if($d['merge'] != '0')
  2245. {
  2246. $hdata = $this->fullordersmt->find_all("merge = '".$d['merge']."' and id != '".$d['id']."' and dlz = '0' and source != 1");$i=0;
  2247. foreach ($hdata as $v)
  2248. {
  2249. $result_t = $this->apismt->get_out($msg,'all',$v['orderinfo'],$ex['aecode'],$shop['code']);
  2250. $result = $result_t['result'];
  2251. if(isset($result['success']) && $result['success'] == "true")
  2252. {
  2253. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$v['id']);
  2254. }
  2255. else
  2256. {
  2257. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>2),$v['id']);
  2258. }
  2259. $i++;
  2260. if($i > 10)
  2261. {
  2262. break;
  2263. }
  2264. }
  2265. }
  2266. /** 合并信息处理结束开始 **/
  2267. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2268. }
  2269. else
  2270. {
  2271. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>2),$id);
  2272. echo json_encode(array('msg'=>'声明失败:'.$result['error_msg'],'success'=>false));exit;
  2273. }
  2274. }
  2275. else
  2276. {
  2277. if($this->fullordersmt->save(array('waybill'=>$msg),$id))
  2278. {
  2279. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2280. }
  2281. else
  2282. {
  2283. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));
  2284. }
  2285. }
  2286. }
  2287. }
  2288. }
  2289. public function _merge()
  2290. {
  2291. $user = $this->user->get_api($_SESSION['api']);
  2292. if($user)
  2293. {
  2294. $fgshop = "";$sid = "";
  2295. $user = explode('|',trim($user['shop'],'|'));
  2296. foreach ($user as $value)
  2297. {
  2298. $fgshop .= " shop = ".$value." or";
  2299. $sid .= " id = ".$value." or";
  2300. }
  2301. }
  2302. $post = $this->input->post(NULL, TRUE);
  2303. if(isset($post['type']))
  2304. {
  2305. $post = array();
  2306. $type = $this->input->post('type');
  2307. $id = $this->input->post('id');
  2308. $u = $this->fullordersmt->read($id);
  2309. $rows = $this->fullordersmt->find_all('name = "'.$u['name'].'" and userid = "'.$u['userid'].'" and address = "'.$u['address'].'" and state = "207" and print != "3" and review = "1" and type = "'.$u['type'].'" and merge = "0" and ('.rtrim($fgshop,"or").')','*','id desc');
  2310. if(count($rows)>1)
  2311. {
  2312. $this->db->trans_begin();
  2313. $hd = $this->fullordersmthb->get_orderinfo($u['orderinfo']);
  2314. if(!$hd)
  2315. {
  2316. $this->fullordersmthb->insert($u);
  2317. }
  2318. //相加
  2319. $post['shouldmoney'] = $u['shouldmoney'];//购买应收金额
  2320. $post['budget'] = $u['budget'];//预估到帐金额
  2321. $post['expressmoney']= $u['expressmoney'];//物流金额
  2322. //$post['refundy'] = $u['refundy'];//补/退原额
  2323. //$post['refundj'] = $u['refundj'];//补/退净额
  2324. $post['cost'] = $u['cost'];//成本金额
  2325. //$post['zzl'] = $u['zzl'];//总重量
  2326. //$post['zsbjz'] = $u['zsbjz'];//总申报价值
  2327. $post['ts'] = $u['ts'];//条数
  2328. $post['cost'] = $u['cost'];//成本金额
  2329. //追加
  2330. $post['rpaypal'] = $u['rpaypal'];//补/退交易号
  2331. $post['rtext'] = $u['rtext'];//补/退原因
  2332. $post['pay'] = $u['pay'];//付款方式
  2333. $post['paypal'] = $u['paypal'];//交易号
  2334. $post['clientremarks'] = $u['clientremarks'];//客户留言
  2335. $post['product'] = $u['product'];//商品名称
  2336. //$post['issku'] = $u['issku'];//sku
  2337. //$post['orderremarks'] = $u['orderremarks'];//订单备注
  2338. $post['shipremarks'] = $u['shipremarks'];//仓库品名
  2339. //产品追加
  2340. $post['fpdata'] = $u['fpdata'];//产品内容
  2341. $post['whlabel'] = $u['whlabel'];//产品对应库存码
  2342. $merge = $u['id'];
  2343. $d = array($id);$order = '';
  2344. $zsl = 0;$zccsl = 0;
  2345. foreach ($rows as $v)
  2346. {
  2347. if($v['id'] != $id && $v['shop'] = $u['shop'])
  2348. {
  2349. $hd = $this->fullordersmthb->get_orderinfo($v['orderinfo']);
  2350. if(!$hd)
  2351. {
  2352. $this->fullordersmthb->insert($v);
  2353. }
  2354. $post['shouldmoney'] += $v['shouldmoney'];//购买应收金额
  2355. $post['budget'] += $v['budget'];//预估到帐金额
  2356. $post['expressmoney'] += $v['expressmoney'];//物流金额
  2357. //$post['refundy'] += $v['refundy'];//补/退原额
  2358. //$post['refundj'] += $v['refundj'];//补/退净额
  2359. $post['cost'] += $v['cost'];//成本金额
  2360. //$post['zzl'] += $v['zzl'];//总重量
  2361. //$post['zsbjz'] += $v['zsbjz'];//总申报价值
  2362. $post['ts'] += $v['ts'];//条数
  2363. //$post['rpaypal'] .= $v['rpaypal'];//补/退交易号
  2364. //$post['rtext'] .= $v['rtext'];//补/退原因
  2365. //$post['pay'] .= (stripos($post['pay'],$v['pay']) !== false)?'':';'.$v['pay'];//付款方式
  2366. //$post['paypal'] .= $v['paypal'];//交易号
  2367. $post['clientremarks'] .= $v['clientremarks'];//客户留言
  2368. $post['product'] .= $v['product'];//商品名称
  2369. //$post['issku'] .= $v['issku'];//sku
  2370. //$post['orderremarks'] .= $v['orderremarks'];//订单备注
  2371. $post['shipremarks'] .= $v['shipremarks'];//仓库品名
  2372. $post['fpdata'] .= $v['fpdata'];//产品内容
  2373. $post['whlabel'] .= $v['whlabel'];//产品对应库存码
  2374. $d[] = $v['id'];
  2375. $order .= $v['orderinfo'].'('.$v['number'].')、';
  2376. $wl = $this->whlabel->find_all("zd = '".$v['number']."'");//查找是否有占用库存情况
  2377. $i = 0;
  2378. if($wl)//如果有那么清除所有占用
  2379. {
  2380. foreach ($wl as $v)
  2381. {
  2382. if($v['sku'] == 'Preset' && $v['state'] == '9')
  2383. {
  2384. $this->whlabel->remove($v['id']);//删除预设
  2385. $i++;
  2386. }
  2387. else
  2388. {
  2389. $this->whlabel->save(array('zd'=>''),$v['id']);//专属
  2390. $i++;
  2391. }
  2392. }
  2393. }
  2394. $zsl += count($wl);
  2395. $zccsl += $i;
  2396. $this->fullordersmt->save(array('merge'=>$id,'mergeid'=>1,'orderremarks'=>' 《合并信息》:'.'已合并到'.$u['orderinfo'].'('.$u['number'].')中; '.$v['orderremarks'],'shouldmoney'=>0,'print'=>1,'libraryconfirm'=>1,'shouldmoney'=>0,'budget'=>0,'whlabel'=>'','fpdata'=>'','shipremarks'=>''),$v['id']);
  2397. }
  2398. }
  2399. //计算出单条价值
  2400. /**
  2401. if($post['zsbjz'] < 1 || $post['ts'] < 1)
  2402. {
  2403. $post['dtsbjz'] = 0;
  2404. }
  2405. else
  2406. {
  2407. $post['dtsbjz'] = $post['zsbjz']/$post['ts'];//单条申报价
  2408. }
  2409. **/
  2410. $post['orderremarks'] = ' 《合并信息》:由'.rtrim($order,'、').'合并而来; '.$u['orderremarks'];;
  2411. $post['merge'] = $id;
  2412. //$post['mergeid'] = 1;
  2413. $this->fullordersmt->save($post,$id);
  2414. if ($this->db->trans_status() === FALSE || $zsl != $zccsl)
  2415. {
  2416. $this->db->trans_commit();
  2417. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2418. }
  2419. else
  2420. {
  2421. $this->db->trans_commit();
  2422. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$id,'success'=>true));
  2423. }
  2424. }
  2425. else
  2426. {
  2427. echo json_encode(array('msg'=>'缺少可合并单','success'=>false));exit;
  2428. }
  2429. }
  2430. }
  2431. public function _split()
  2432. {
  2433. $user = $this->user->get_api($_SESSION['api']);
  2434. if($user)
  2435. {
  2436. $fgshop = "";$sid = "";
  2437. $user = explode('|',trim($user['shop'],'|'));
  2438. foreach ($user as $value)
  2439. {
  2440. $fgshop .= " shop = ".$value." or";
  2441. $sid .= " id = ".$value." or";
  2442. }
  2443. }
  2444. $post = $this->input->post(NULL, TRUE);
  2445. if(isset($post['id']))
  2446. {
  2447. $id = $this->input->post('id');
  2448. $data = $this->fullordersmt->find_all("merge = '$id' and print !=3 and library =1 and (".rtrim($fgshop,'or').")");
  2449. $datanum = $this->fullordersmt->find_count("merge = '$id' and (".rtrim($fgshop,'or').")");
  2450. if($data && count($data) == $datanum)
  2451. {
  2452. foreach ($data as $k=>$v)
  2453. {
  2454. unset($data[$k]['id']);
  2455. unset($data[$k]['express']);
  2456. unset($data[$k]['printtype']);
  2457. unset($data[$k]['review']);
  2458. unset($data[$k]['reviewtime']);
  2459. $t = $this->fullordersmt->get_orderinfo($v['orderinfo']);
  2460. $this->fullordersmt->save($v,$t['id']);
  2461. }
  2462. echo json_encode(array('msg'=>'拆分成功!','success'=>true));
  2463. }
  2464. else
  2465. {
  2466. echo json_encode(array('msg'=>'有订单不符合条件,请重试','success'=>false));exit;
  2467. }
  2468. }
  2469. }
  2470. //评价管理
  2471. public function _evaluate()
  2472. {
  2473. $user = $this->user->get_api($_SESSION['api']);
  2474. if($user)
  2475. {
  2476. $fgshop = "";$sid = "";
  2477. $user = explode('|',trim($user['shop'],'|'));
  2478. foreach ($user as $value)
  2479. {
  2480. $fgshop .= " shop = ".$value." or";
  2481. $sid .= " id = ".$value." or";
  2482. }
  2483. }
  2484. $post = $this->input->post(NULL, TRUE);
  2485. if(isset($post['page']))
  2486. {
  2487. $page = $this->input->post('page',true);
  2488. $perpage = $this->input->post('perpage',true);
  2489. $shop = $this->input->post('shop',true);
  2490. $where = "1=1 and evaluate = 0 and (".rtrim($fgshop,'or').")";
  2491. if($shop)
  2492. {
  2493. $where .= " and shop = '$shop'";
  2494. }
  2495. //数据排序
  2496. $order_str = "id desc";
  2497. if(empty($page))
  2498. {
  2499. $start = 0;
  2500. $perpage = 1;
  2501. }
  2502. else
  2503. {
  2504. $start = ($page - 1)*$perpage;
  2505. }
  2506. //取得信息列表
  2507. $info_list = $this->fullordersmt->find_all($where,'id,shop,orderinfo,number,operation',$order_str,$start,$perpage);
  2508. //格式化数据
  2509. foreach ($info_list as $key=>$value)
  2510. {
  2511. $shop = $this->shop->read($value['shop']);
  2512. $info_list[$key]['shop'] = $shop['shopname'];
  2513. $info_list[$key]['operation'] = "评价";
  2514. }
  2515. $total = $this->fullordersmt->find_count($where);
  2516. $pagenum = ceil($total/$perpage);
  2517. $over = $total-($start+$perpage);
  2518. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2519. echo json_encode($rows);exit;
  2520. }
  2521. $this->_Template('fullordersmt_evaluate',$this->data);
  2522. }
  2523. //订单消息
  2524. public function _state()
  2525. {
  2526. $user = $this->user->get_api($_SESSION['api']);
  2527. if($user)
  2528. {
  2529. $fgshop = "";$sid = "";
  2530. $user = explode('|',trim($user['shop'],'|'));
  2531. foreach ($user as $value)
  2532. {
  2533. $fgshop .= " shop = ".$value." or";
  2534. $sid .= " id = ".$value." or";
  2535. }
  2536. }
  2537. $post = $this->input->post(NULL, TRUE);
  2538. if(isset($post['page']))
  2539. {
  2540. $page = $this->input->post('page',true);
  2541. $perpage = $this->input->post('perpage',true);
  2542. $timetk = $this->input->post('timetk',true);
  2543. $timetj = $this->input->post('timetj',true);
  2544. $shop = $this->input->post('shop',true);
  2545. $source = $this->input->post('source',true);
  2546. $state = $this->input->post('state',true);
  2547. $review = $this->input->post('review',true);
  2548. $expressstate = $this->input->post('expressstate',true);
  2549. $express = $this->input->post('express',true);
  2550. $orderinfo = $this->input->post('orderinfo',true);
  2551. $user = $this->input->post('user',true);
  2552. $name = $this->input->post('name',true);
  2553. $waybill = $this->input->post('waybill',true);
  2554. $timetk = strtotime($timetk);
  2555. $timetj = strtotime($timetj);
  2556. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2557. if($timetk && $timetj)
  2558. {
  2559. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2560. }
  2561. if($shop)
  2562. {
  2563. $where .= " and shop = '$shop'";
  2564. }
  2565. if($source)
  2566. {
  2567. $where .= " and source = '$source'";
  2568. }
  2569. if($state)
  2570. {
  2571. $where .= " and state = '$state'";
  2572. }
  2573. if($review)
  2574. {
  2575. $where .= " and review = '$review'";
  2576. }
  2577. if($expressstate != "")
  2578. {
  2579. $where .= " and expressstate = '$expressstate'";
  2580. }
  2581. if($express)
  2582. {
  2583. $where .= " and express = '$express'";
  2584. }
  2585. if($orderinfo)
  2586. {
  2587. $where .= " and orderinfo = '$orderinfo'";
  2588. }
  2589. if($user)
  2590. {
  2591. $where .= " and user = '$user'";
  2592. }
  2593. if($name)
  2594. {
  2595. $where .= " and name = '$name'";
  2596. }
  2597. if($waybill)
  2598. {
  2599. $where .= " and waybill = '$waybill'";
  2600. }
  2601. //数据排序
  2602. $order_str = "id desc";
  2603. if(empty($page))
  2604. {
  2605. $start = 0;
  2606. $perpage = 1;
  2607. }
  2608. else
  2609. {
  2610. $start = ($page - 1)*$perpage;
  2611. }
  2612. //取得信息列表
  2613. $info_list = $this->fullordersmt->find_all($where,'id,shop,user,orderinfo,number,country,state,library,librarytime,exstate,express,waybill,content,exstateerror',$order_str,$start,$perpage);
  2614. //格式化数据
  2615. foreach ($info_list as $key=>$value)
  2616. {
  2617. $ud = $this->fullordersmt->read($value['id']);
  2618. $shop = $this->shop->read($value['shop']);
  2619. $info_list[$key]['shop'] = $shop['shopname'];
  2620. $info_list[$key]['user'] = $shop['shopuser'];
  2621. $country = $this->country->read($value['country']);
  2622. $info_list[$key]['country'] = $country['name'];
  2623. $state = $this->typeclass->read($value['state']);
  2624. if($ud['source'] != '1')
  2625. {
  2626. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$state['title']."</a>";
  2627. }
  2628. else
  2629. {
  2630. $info_list[$key]['state'] = $state['title'];
  2631. }
  2632. if($value['library'] == 1)
  2633. {
  2634. $info_list[$key]['library'] = "未出库";
  2635. }
  2636. else if($value['library'] == 2)
  2637. {
  2638. $info_list[$key]['library'] = "已出库";
  2639. }
  2640. else if($value['library'] == 3)
  2641. {
  2642. $info_list[$key]['library'] = "已退库";
  2643. }
  2644. if($value['librarytime'] == '0')
  2645. {
  2646. $info_list[$key]['librarytime'] = '无';
  2647. }
  2648. else
  2649. {
  2650. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2651. }
  2652. if($value['exstate'] == 0)
  2653. {
  2654. $info_list[$key]['exstate'] = "未取件";
  2655. }
  2656. else if($value['exstate'] == 1)
  2657. {
  2658. $info_list[$key]['exstate'] = "已揽收";
  2659. }
  2660. else if($value['exstate'] == 2)
  2661. {
  2662. $info_list[$key]['exstate'] = "在途中";
  2663. }
  2664. else if($value['exstate'] == 3)
  2665. {
  2666. $info_list[$key]['exstate'] = "派送中";
  2667. }
  2668. else if($value['exstate'] == 4)
  2669. {
  2670. $info_list[$key]['exstate'] = "签收";
  2671. }
  2672. if($value['express'])
  2673. {
  2674. $express = $this->express->read($value['express']);
  2675. $info_list[$key]['express'] = $express['servicename'];
  2676. }
  2677. else
  2678. {
  2679. $info_list[$key]['express'] = '';
  2680. }
  2681. }
  2682. $total = $this->fullordersmt->find_count($where);
  2683. $pagenum = ceil($total/$perpage);
  2684. $over = $total-($start+$perpage);
  2685. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2686. echo json_encode($rows);exit;
  2687. }
  2688. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2689. $this->data['wlshop'] = $wlshop;
  2690. $this->data['express'] = $this->express->find_all();
  2691. $this->_Template('fullordersmt_state',$this->data);
  2692. }
  2693. //审核订单
  2694. public function _review()
  2695. {
  2696. $user = $this->user->get_api($_SESSION['api']);
  2697. $fgshop = "";
  2698. if($user)
  2699. {
  2700. $fgshop = "";$sid = "";
  2701. $user = explode('|',trim($user['shop'],'|'));
  2702. foreach ($user as $value)
  2703. {
  2704. $fgshop .= " shop = ".$value." or";
  2705. }
  2706. $fgshop = " and (".rtrim($fgshop,'or').")";
  2707. }
  2708. $post = $this->input->post(NULL, TRUE);
  2709. if(isset($post['page']))
  2710. {
  2711. $page = $this->input->post('page',true);
  2712. $perpage = $this->input->post('perpage',true);
  2713. $source = $this->input->post('source',true);
  2714. $warehouse = $this->input->post('warehouse',true);
  2715. $express = $this->input->post('express',true);
  2716. $user = $this->input->post('user',true);
  2717. $shop = $this->input->post('shop',true);
  2718. $review = $this->input->post('review',true);
  2719. $orderinfo = $this->input->post('orderinfo',true);
  2720. $number = $this->input->post('number',true);
  2721. $timetk = $this->input->post('timetk',true);
  2722. $timetj = $this->input->post('timetj',true);
  2723. $timetk = strtotime($timetk);
  2724. $timetj = strtotime($timetj);
  2725. $where = "mergeid = 0".$fgshop;
  2726. if($timetk && $timetj)
  2727. {
  2728. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2729. }
  2730. if($source)
  2731. {
  2732. $where .= " and source = '$source'";
  2733. }
  2734. if($shop)
  2735. {
  2736. $where .= " and shop = '$shop'";
  2737. }
  2738. if($warehouse)
  2739. {
  2740. $where .= " and type = '$warehouse'";
  2741. }
  2742. if($express)
  2743. {
  2744. $where .= " and express = '$express'";
  2745. }
  2746. if($user)
  2747. {
  2748. $where .= " and user = '$user'";
  2749. }
  2750. if($review)
  2751. {
  2752. $where .= " and review = '$review'";
  2753. }
  2754. if($orderinfo)
  2755. {
  2756. $where .= " and orderinfo = '$orderinfo'";
  2757. }
  2758. if($number)
  2759. {
  2760. $where .= " and number = '$number'";
  2761. }
  2762. //数据排序
  2763. $order_str = "id desc";
  2764. if(empty($page))
  2765. {
  2766. $start = 0;
  2767. $perpage = 1;
  2768. }
  2769. else
  2770. {
  2771. $start = ($page - 1)*$perpage;
  2772. }
  2773. //取得信息列表
  2774. $info_list = $this->fullordersmt->find_all($where,'id,shop,user,type,orderinfo,number,client,express,buytime,shouldmoney,review,currencytitle,library');
  2775. //格式化数据
  2776. foreach ($info_list as $key=>$value)
  2777. {
  2778. $lr = $this->fullordersmt->read($value['id']);
  2779. $shop = $this->shop->read($value['shop']);
  2780. $info_list[$key]['shop'] = $shop['shopname'];
  2781. $info_list[$key]['user'] = $shop['shopuser'];
  2782. $warehouse = $this->warehouse->read($value['type']);
  2783. $info_list[$key]['type'] = $warehouse['title'];
  2784. $express = $this->express->read($value['express']);
  2785. $info_list[$key]['express'] = $express['servicename'];
  2786. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  2787. if($value['review'] == 1)
  2788. {
  2789. $info_list[$key]['review'] = "未送审";
  2790. }
  2791. else if($value['review'] == 2)
  2792. {
  2793. $info_list[$key]['review'] = "待审核";
  2794. }
  2795. else if($value['review'] == 3)
  2796. {
  2797. $info_list[$key]['review'] = "不通过";
  2798. }
  2799. else if($value['review'] == 4)
  2800. {
  2801. $info_list[$key]['review'] = "取消重审";
  2802. }
  2803. else if($value['review'] == 5)
  2804. {
  2805. $info_list[$key]['review'] = "审核通过";
  2806. }
  2807. else if($value['review'] == 6)
  2808. {
  2809. $info_list[$key]['review'] = "自动通过";
  2810. }
  2811. if($value['review'] == 2)
  2812. {
  2813. $info_list[$key]['library'] = "<p><b class='focz' data-type='5' data-id='".$value['id']."'>审核通过</b></p><p><b class='focz' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  2814. }
  2815. else if($value['review'] == 3)
  2816. {
  2817. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='5' data-id='".$value['id']."'>审核通过</b></p>";
  2818. }
  2819. else if($value['review'] == 5)
  2820. {
  2821. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  2822. }
  2823. else
  2824. {
  2825. $info_list[$key]['library'] = "";
  2826. }
  2827. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$lr['currencytitle'];
  2828. $lr['hl'] = $lr['hl']==0?6.71:$lr['hl'];
  2829. $cost = $lr['cost']/$lr['hl'];
  2830. $currencytitle = $lr['budget']-$lr['refundj']-$cost-$lr['expressmoney'];
  2831. $info_list[$key]['currencytitle'] = sprintf("%.2f",$currencytitle).' '.$lr['currencytitle'];
  2832. }
  2833. $total = $this->fullordersmt->find_count($where);
  2834. $pagenum = ceil($total/$perpage);
  2835. $over = $total-($start+$perpage);
  2836. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2837. echo json_encode($rows);exit;
  2838. }
  2839. $this->_Template('fullordersmt_review',$this->data);
  2840. }
  2841. //导出资金统计excel
  2842. public function _fmexcel()
  2843. {
  2844. $user = $this->user->get_api($_SESSION['api']);
  2845. if($user)
  2846. {
  2847. $fgshop = "";$sid = "";
  2848. $user = explode('|',trim($user['shop'],'|'));
  2849. foreach ($user as $value)
  2850. {
  2851. $fgshop .= " shop = ".$value." or";
  2852. $sid .= " id = ".$value." or";
  2853. }
  2854. }
  2855. if(isset($_GET['excel']))
  2856. {
  2857. $timetk = $this->input->get('timetk',true);
  2858. $timetj = $this->input->get('timetj',true);
  2859. $shop = $this->input->get('shop',true);
  2860. $source = $this->input->get('source',true);
  2861. $state = $this->input->get('state',true);
  2862. $type = $this->input->get('type',true);
  2863. $orderinfo = $this->input->get('orderinfo',true);
  2864. $user = $this->input->get('user',true);
  2865. $name = $this->input->get('name',true);
  2866. $timetk = strtotime($timetk);
  2867. $timetj = strtotime($timetj);
  2868. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2869. if($timetk && $timetj)
  2870. {
  2871. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  2872. }
  2873. if($shop)
  2874. {
  2875. $where .= " and shop = '$shop'";
  2876. }
  2877. if($source)
  2878. {
  2879. $where .= " and source = '$source'";
  2880. }
  2881. if($state)
  2882. {
  2883. if($state == 1)
  2884. {
  2885. $where .= " and state = '$state'";
  2886. }
  2887. }
  2888. if($type)
  2889. {
  2890. $where .= " and type = '$type'";
  2891. }
  2892. if($orderinfo)
  2893. {
  2894. $where .= " and orderinfo = '$orderinfo'";
  2895. }
  2896. if($user)
  2897. {
  2898. $where .= " and user = '$user'";
  2899. }
  2900. if($name)
  2901. {
  2902. $where .= " and name = '$name'";
  2903. }
  2904. //取得信息列表
  2905. $info_list = $this->fullordersmt->find_all($where,'id,shop,user,number,orderinfo,client,country,dtime,ftime,express,waybill,shouldmoney,refund,currency,budget,fpdata,hl,currencytitle');
  2906. //格式化数据
  2907. $i = 1;$shouldmoney = 0;$refund = 0;$budget = 0;$currency = 0;$hl=1;
  2908. foreach ($info_list as $key=>$value)
  2909. {
  2910. $info_list[$key]['id'] = $i;
  2911. if($value['currencytitle'] != "CNY")
  2912. {
  2913. $hl=$value['hl'];
  2914. }
  2915. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  2916. $budget=$budget+($value['budget']*$hl);
  2917. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  2918. $refund=$refund+($value['refund']*$hl);
  2919. $shop = $this->shop->read($value['shop']);
  2920. $info_list[$key]['shop'] = $shop['shopname'];
  2921. $info_list[$key]['user'] = $shop['shopuser'];
  2922. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  2923. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  2924. $country = $this->country->read($value['country']);
  2925. $info_list[$key]['country'] = $country['name'];
  2926. $express = $this->express->read($value['express']);
  2927. $info_list[$key]['express'] = $express['servicename'];
  2928. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  2929. $info_list[$key]['refund'] = $value['refund'].' '.$value['currencytitle'];
  2930. $info_list[$key]['budget'] = $value['budget'].' '.$value['currencytitle'];
  2931. $info_list[$key]['currency'] = sprintf("%.2f",$value['shouldmoney']-$value['budget']).' '.$value['currencytitle'];
  2932. $fpdata = array();
  2933. if(stripos($value['fpdata'],';') !== false)
  2934. {
  2935. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  2936. foreach ($fpdata as $ke=>$va)
  2937. {
  2938. $v = explode('|',rtrim($va,'|'));
  2939. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  2940. }
  2941. }
  2942. $info_list[$key]['fpdata'] = $fpdata;
  2943. $i++;
  2944. }
  2945. $data = array($shouldmoney.' CNY',$refund.' CNY',$currency.' CNY',$budget.' CNY');
  2946. $title = "订单资金信息";
  2947. $titlename = "<table border=1>
  2948. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  2949. <tr>
  2950. <td>NO.</td>
  2951. <td>店铺</td>
  2952. <td>负责人</td>
  2953. <td>编号</td>
  2954. <td>订单号</td>
  2955. <td>客户姓名</td>
  2956. <td>国家</td>
  2957. <td>订单日期</td>
  2958. <td>发货日期</td>
  2959. <td>快递公司</td>
  2960. <td>运单号</td>
  2961. <td>订单金额</td>
  2962. <td>退款金额</td>
  2963. <td>手续费</td>
  2964. <td>预估金额</td>
  2965. <td>
  2966. <table border=1>
  2967. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  2968. <tr>
  2969. <td>产品</td>
  2970. <td>条数</td>
  2971. <td>数量</td>
  2972. </tr>
  2973. </table>
  2974. </td>
  2975. <td>总条数</td>
  2976. </tr>
  2977. </table>";
  2978. $filename = $title.".xls";
  2979. $tail = "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>合计:</td><td>".$data[0]."</td><td>".$data[1]."</td><td>".$data[2]."</td><td>".$data[3]."</td></tr>\n";
  2980. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  2981. }
  2982. }
  2983. //导出订单excel
  2984. public function _fdexcel()
  2985. {
  2986. if(isset($_GET['excel']))
  2987. {
  2988. $page = $this->input->post('page',true);
  2989. $perpage = $this->input->post('perpage',true);
  2990. $timetk = $this->input->post('timetk',true);
  2991. $timetj = $this->input->post('timetj',true);
  2992. $shop = $this->input->post('shop',true);
  2993. $source = $this->input->post('source',true);
  2994. $state = $this->input->post('state',true);
  2995. $review = $this->input->post('review',true);
  2996. $express = $this->input->post('express',true);
  2997. $orderinfo = $this->input->post('orderinfo',true);
  2998. $user = $this->input->post('user',true);
  2999. $name = $this->input->post('name',true);
  3000. $waybill = $this->input->post('waybill',true);
  3001. $timetk = strtotime($timetk);
  3002. $timetj = strtotime($timetj);
  3003. $where = "1=1 and mergeid = 0";
  3004. if($timetk && $timetj)
  3005. {
  3006. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3007. }
  3008. if($shop)
  3009. {
  3010. $where .= " and shop = '$shop'";
  3011. }
  3012. if($source)
  3013. {
  3014. $where .= " and source = '$source'";
  3015. }
  3016. if($state)
  3017. {
  3018. $where .= " and state = '$state'";
  3019. }
  3020. if($review)
  3021. {
  3022. $where .= " and review = '$review'";
  3023. }
  3024. if($express)
  3025. {
  3026. $where .= " and express = '$express'";
  3027. }
  3028. if($orderinfo)
  3029. {
  3030. $where .= " and orderinfo = '$orderinfo'";
  3031. }
  3032. if($user)
  3033. {
  3034. $where .= " and user = '$user'";
  3035. }
  3036. if($name)
  3037. {
  3038. $where .= " and name = '$name'";
  3039. }
  3040. if($waybill)
  3041. {
  3042. $where .= " and waybill = '$waybill'";
  3043. }
  3044. //取得信息列表
  3045. $info_list = $this->fullordersmt->find_all($where,'id,shop,number,orderinfo,source,client,name,address,city,zipcode,province,country,phone,dtime,ftime,state,shouldmoney,express,waybill,orderremarks,clientremarks,fpdata,hl,currencytitle');
  3046. //格式化数据
  3047. $i = 1;$shouldmoney = 0;$hl=1;
  3048. foreach ($info_list as $key=>$value)
  3049. {
  3050. $info_list[$key]['id'] = $i;
  3051. if($value['source'] == 1)
  3052. {
  3053. $info_list[$key]['source'] = "线下订单";
  3054. }
  3055. else if($value['source'] == 2)
  3056. {
  3057. $info_list[$key]['source'] = "PC订单";
  3058. }
  3059. else if($value['source'] == 3)
  3060. {
  3061. $info_list[$key]['source'] = "手机订单";
  3062. }
  3063. if($value['currencytitle'] != "CNY")
  3064. {
  3065. $hl=$value['hl'];
  3066. }
  3067. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3068. $shop = $this->shop->read($value['shop']);
  3069. $info_list[$key]['shop'] = $shop['shopname'];
  3070. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3071. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  3072. $state = $this->typeclass->read($value['state']);
  3073. $info_list[$key]['state'] = $state['title'];
  3074. $country = $this->country->read($value['country']);
  3075. $info_list[$key]['country'] = $country['name'];
  3076. $express = $this->express->read($value['express']);
  3077. $info_list[$key]['express'] = $express['servicename'];
  3078. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  3079. $fpdata = array();
  3080. if(stripos($value['fpdata'],';') !== false)
  3081. {
  3082. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  3083. foreach ($fpdata as $ke=>$va)
  3084. {
  3085. $v = explode('|',rtrim($va,'|'));
  3086. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  3087. }
  3088. }
  3089. $info_list[$key]['fpdata'] = $fpdata;
  3090. $i++;
  3091. }
  3092. $data = array($shouldmoney.' CNY');
  3093. $title = "订单信息表";
  3094. $titlename = "<table border=1>
  3095. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  3096. <tr>
  3097. <td>NO.</td>
  3098. <td>店铺</td>
  3099. <td>编号</td>
  3100. <td>订单号</td>
  3101. <td>订单类型</td>
  3102. <td>客户姓名</td>
  3103. <td>收件人名称</td>
  3104. <td>收货人地址</td>
  3105. <td>城市</td>
  3106. <td>邮编</td>
  3107. <td>州</td>
  3108. <td>国家</td>
  3109. <td>收件电话</td>
  3110. <td>订单日期</td>
  3111. <td>发货日期</td>
  3112. <td>订单状态</td>
  3113. <td>订单金额</td>
  3114. <td>快递公司</td>
  3115. <td>运单号</td>
  3116. <td>订单备注</td>
  3117. <td>客户备注</td>
  3118. <td>
  3119. <table border=1>
  3120. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  3121. <tr>
  3122. <td>产品</td>
  3123. <td>条数</td>
  3124. <td>数量</td>
  3125. </tr>
  3126. </table>
  3127. </td>
  3128. <td>总条数</td>
  3129. </tr>
  3130. </table>";
  3131. $filename = $title.".xls";
  3132. $tail = "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>合计:</td><td>".$data[0]."</td></tr>\n";
  3133. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  3134. }
  3135. }
  3136. public function _black()
  3137. {
  3138. $post = $this->input->post(NULL, TRUE);
  3139. if(isset($post['bd']))
  3140. {
  3141. $bd = $this->input->post('bd',true);
  3142. $rows = $this->fullordersmt->read($bd);
  3143. $post['shop'] = $rows['shop'];
  3144. $post['source'] = 1;
  3145. $post['name'] = $rows['client'];
  3146. $post['email'] = $rows['email'];
  3147. $post['phone'] = $rows['phone'];
  3148. $post['country'] = $rows['country'];
  3149. $post['money'] = $rows['shouldmoney'];
  3150. $post['num'] = 1;
  3151. $post['time'] = $rows['dtime'];
  3152. $post['province'] = $rows['province'];
  3153. $post['city'] = $rows['city'];
  3154. $post['street'] = $rows['street'];
  3155. $post['address'] = $rows['address'];
  3156. $post['address2'] = $rows['address2'];
  3157. $post['zipcode'] = $rows['zipcode'];
  3158. $post['type'] = 2;
  3159. if($this->customer->insert($post))
  3160. {
  3161. $this->fullordersmt->save(array('black'=>1),$bd);
  3162. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3163. }
  3164. else
  3165. {
  3166. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3167. }
  3168. }
  3169. }
  3170. public function _ryf()
  3171. {
  3172. $post = $this->input->post(NULL, TRUE);
  3173. if(isset($post['bd']))
  3174. {
  3175. $bd = $this->input->post('bd',true);
  3176. $d = $this->fullordersmt->read($bd);
  3177. if($d['state'] == 207 || $d['state'] == 207)//订单状态为等待发货或等待部分发货才可更改为允许发货
  3178. {
  3179. if($d['print'] < 3)//打印状态为未打印
  3180. {
  3181. $print = 1;//未打印
  3182. $libraryconfirm = 1;//不允许出库
  3183. $a = "订单未打印,";
  3184. }
  3185. else//已打印订单
  3186. {
  3187. $libraryconfirm = 2;//允许出库
  3188. $a = "";
  3189. }
  3190. if($this->fullordersmt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  3191. {
  3192. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3193. }
  3194. else
  3195. {
  3196. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3197. }
  3198. }
  3199. if($this->fullordersmt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  3200. {
  3201. echo json_encode(array('msg'=>'操作失败!订单未非发货状态','success'=>false));exit;
  3202. }
  3203. else
  3204. {
  3205. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3206. }
  3207. }
  3208. }
  3209. public function _fsstate()
  3210. {
  3211. $post = $this->input->post(NULL, TRUE);
  3212. if(isset($post['s']))
  3213. {
  3214. $id_arr = $this->input->post('s');
  3215. $id_arr = explode(',',$id_arr);
  3216. if(!$id_arr)
  3217. {
  3218. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  3219. }
  3220. foreach ($id_arr as $v)
  3221. {
  3222. $data = $this->fullordersmt->read($v);
  3223. $warehouse = $this->warehouse->read($data['type']);
  3224. $fs = $this->notice->get_ordertatus($data['state']);
  3225. if($fs)
  3226. {
  3227. $ck = $this->_email($fs['content'],$data,$warehouse['company']);
  3228. if($ck == 1)
  3229. {
  3230. $this->fullordersmt->save(array('fscontent'=>date('Y-m-d H:i:s',time()).'已发送:'.$fs['title'].' - '),$v);
  3231. }
  3232. }
  3233. }
  3234. echo json_encode(array('msg'=>'发送完成!','success'=>true));exit;
  3235. }
  3236. }
  3237. public function _power()
  3238. {
  3239. $user = $this->user->get_api($_SESSION['api']);
  3240. $post = $this->input->post(NULL, TRUE);
  3241. if(isset($post['id']))
  3242. {
  3243. $id = $this->input->post('id',true);
  3244. $fullorder = $this->fullordersmt->read($id);
  3245. $express = $this->express->read($fullorder['express']);
  3246. $warehouse = $this->warehouse->read($fullorder['type']);
  3247. if(($warehouse['zd'] == '1' || stripos($fullorder['whlabel'],'z|') !== false) && $fullorder['library'] == '2')
  3248. {
  3249. echo json_encode(array('msg'=>'需要先退库释放库存后才可重置!','success'=>false));exit;
  3250. }
  3251. /**
  3252. if($fullorder['print'] == '3' && isset($express['iscode']) && ($express['iscode'] == 'ARAMEX' || $express['iscode'] == 'TOLL' || $express['iscode'] == 'FEDEX'))
  3253. {
  3254. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  3255. if($lj != '1' && $lj != '订单不存在')
  3256. {
  3257. echo json_encode(array('msg'=>$lj,'success'=>false));exit;
  3258. }
  3259. }
  3260. **/
  3261. $this->db->trans_begin();
  3262. $this->fullordersmt->save(array('library'=>1,'librarytime'=>0,'libraryconfirm'=>2,'print'=>1,'printtime'=>0,'printnumber'=>0,'retreattime'=>0,'librarynot'=>'订单未打印,未审核或未通过','review'=>1,'reviewtime'=>0,'state'=>207,'waybill'=>'','waybill2'=>'','oldwaybill'=>'-'.date('Ymd',$fullorder['printtime']).'/'.$fullorder['waybill']),$id);
  3263. if($fullorder['merge'] != '0')
  3264. {
  3265. $hdata = $this->fullordersmt->find_all("merge = '".$fullorder['merge']."' and id != '".$id."'");
  3266. foreach ($hdata as $v)
  3267. {
  3268. $this->fullordersmt->save(array('library'=>1,'librarytime'=>0,'libraryconfirm'=>2,'print'=>1,'printtime'=>0,'printnumber'=>0,'retreattime'=>0,'librarynot'=>'订单未打印,未审核或未通过','review'=>1,'reviewtime'=>0,'state'=>207,'waybill'=>'','waybill2'=>'','oldwaybill'=>'-'.date('Ymd',$fullorder['printtime']).'/'.$fullorder['waybill'],'yhs'=>0,'failed'=>''),$v['id']);
  3269. }
  3270. }
  3271. $warehouse = $this->warehouse->read($fullorder['warehouse']);
  3272. $typeclass = $this->typeclass->read($fullorder['state']);
  3273. $express = $this->express->read($fullorder['express']);
  3274. $printtype = array(1=>'运单',2=>'发货单',3=>'不打印单据');
  3275. $teset['number']=$fullorder['number'];
  3276. $teset['orderinfo']=$fullorder['orderinfo'];
  3277. $teset['shop']=$fullorder['shop'];
  3278. $teset['user']=$user['userid'];
  3279. $teset['ip']=$this->input->ip_address();
  3280. $teset['time']=time();
  3281. $teset['warehouse']=(isset($warehouse['title']))?$warehouse['title']:'未选择';
  3282. $teset['state']=(isset($typeclass['title']))?$typeclass['title']:'未选择';
  3283. $teset['express']=(isset($express['title']))?$express['servicename']:'未选择';
  3284. $teset['printtype']=(isset($printtype[$fullorder['printtype']]))?$printtype[$fullorder['printtype']]:'未选择';
  3285. $teset['reviewtime']=($fullorder['reviewtime'] > '0')?date('Y-m-d H:i:s',$fullorder['reviewtime']):'无';
  3286. $teset['printtime']=($fullorder['printtime'] > '0')?date('Y-m-d H:i:s',$fullorder['printtime']):'无';
  3287. $teset['librarytime']=($fullorder['librarytime'] > '0')?date('Y-m-d H:i:s',$fullorder['librarytime']):'无';
  3288. $teset['shipremarks']=$fullorder['shipremarks'];
  3289. $teset['fpdata']=$fullorder['fpdata'];
  3290. if(!$this->fullreset->insert($teset))
  3291. {
  3292. echo json_encode(array('msg'=>'重置失败,请重试','success'=>true));exit;
  3293. }
  3294. if ($this->db->trans_status() === TRUE)
  3295. {
  3296. $this->db->trans_commit();
  3297. echo json_encode(array('msg'=>'重置成功','success'=>true));exit;
  3298. }
  3299. else
  3300. {
  3301. $this->db->trans_rollback();
  3302. echo json_encode(array('msg'=>'重置失败,请重试','success'=>false));exit;
  3303. }
  3304. }
  3305. }
  3306. public function _expresstype()
  3307. {
  3308. $post = $this->input->post(NULL, TRUE);
  3309. if(isset($post['id']))
  3310. {
  3311. $id = $this->input->post('id',true);
  3312. $data = $this->express->read($id);
  3313. echo json_encode(array('msg'=>$data['type'],'success'=>true));exit;
  3314. }
  3315. }
  3316. public function _email($content,$data,$shopname)
  3317. {
  3318. $express = $this->express->read($data['express']);
  3319. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  3320. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  3321. $content = str_replace($t,$h,$content);
  3322. $this->load->library('email');
  3323. $config['protocol'] = 'smtp';
  3324. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  3325. $config['smtp_port'] = 465;
  3326. $config['smtp_user'] = 'service@email.supernovahair.com';
  3327. $config['smtp_pass'] = 'LONGyihair374';
  3328. $config['smtp_crypto'] = 'ssl';
  3329. $config['crlf'] = "\r\n";
  3330. $config['newline'] = "\r\n";
  3331. $this->email->initialize($config);
  3332. $this->email->from('service@email.supernovahair.com',$shopname);
  3333. $this->email->to($data['email']);//收件
  3334. $this->email->subject('The product you purchased has a new progress');//标题
  3335. $this->email->message($content);//内容
  3336. if ( ! $this->email->send())
  3337. {
  3338. return 2;
  3339. }
  3340. else
  3341. {
  3342. return 1;
  3343. }
  3344. }
  3345. public function _error()
  3346. {
  3347. if(isset($_SESSION['api']))
  3348. {
  3349. $user = $this->user->get_api($_SESSION['api']);
  3350. $usp = $user;
  3351. $fgshop = "";$sid = "";
  3352. $user = explode('|',trim($user['shop'],'|'));
  3353. foreach ($user as $value)
  3354. {
  3355. $fgshop .= " shop = ".$value." or";
  3356. $sid .= " id = ".$value." or";
  3357. }
  3358. }
  3359. $post = $this->input->post(NULL, TRUE);
  3360. if(isset($post['page']))
  3361. {
  3362. $page = $this->input->post('page',true);
  3363. $perpage = $this->input->post('perpage',true);
  3364. $orderinfo = $this->input->post('orderinfo',true);
  3365. $waybill = $this->input->post('waybill',true);
  3366. $number = $this->input->post('number',true);
  3367. $timetk = $this->input->post('timetk',true);
  3368. $timetj = $this->input->post('timetj',true);
  3369. $timetk = strtotime($timetk);
  3370. $timetj = strtotime($timetj);
  3371. $where = "failed !='' and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3372. if($orderinfo)
  3373. {
  3374. $where .= " and orderinfo = '$orderinfo'";
  3375. }
  3376. if($waybill)
  3377. {
  3378. $where .= " and waybill = '$waybill'";
  3379. }
  3380. if($number)
  3381. {
  3382. $where .= " and number = '$number'";
  3383. }
  3384. if($timetk && $timetj)
  3385. {
  3386. $timetj = $timetj+24*3600;
  3387. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3388. }
  3389. //数据排序
  3390. $order_str = "dtime desc";
  3391. if(empty($page))
  3392. {
  3393. $start = 0;
  3394. $perpage = 1;
  3395. }
  3396. else
  3397. {
  3398. $start = ($page - 1)*$perpage;
  3399. }
  3400. $info_list = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,express,failed,operation',$order_str,$start,$perpage);
  3401. //格式化数据
  3402. foreach ($info_list as $key=>$value)
  3403. {
  3404. $ud = $this->fullordersmt->read($value['id']);
  3405. $shop = $this->shop->read($value['shop']);
  3406. $info_list[$key]['shop'] = $shop['shopname'];
  3407. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  3408. $warehouse = $this->warehouse->read($value['type']);
  3409. $warehousetitle = $warehouse['title'];
  3410. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  3411. $info_list[$key]['type'] = $warehousetitle;
  3412. if($value['express'] != 0)
  3413. {
  3414. $express = $this->express->read($value['express']);
  3415. $expressservicename = $express['servicename'];
  3416. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  3417. $info_list[$key]['express'] = $expressservicename;
  3418. }
  3419. else
  3420. {
  3421. $info_list[$key]['express'] = "无";
  3422. }
  3423. $x = "";
  3424. if($ud['review'] >4 && $ud['print'] == 1)
  3425. {
  3426. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  3427. }
  3428. else if($ud['review'] >4 && $ud['print'] == 3 && $ud['libraryconfirm'] == 1)
  3429. {
  3430. $x = "<p class='ckn'><b class='fojzof' data-type='10' data-id='".$value['id']."'>清除错误</b></p>";
  3431. }
  3432. else
  3433. {
  3434. $x = "<p class='ckn'><b class='fojzof' data-type='9' data-id='".$value['id']."'>关闭</b></p>";
  3435. }
  3436. $info_list[$key]['operation'] = $x;
  3437. }
  3438. $total = $this->fullordersmt->find_count($where);
  3439. $pagenum = ceil($total/$perpage);
  3440. $over = $total-($start+$perpage);
  3441. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3442. echo json_encode($rows);exit;
  3443. }
  3444. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3445. $this->data['wlshop'] = $wlshop;
  3446. $this->data['express'] = $this->express->find_all();
  3447. $user = $this->user->get_api($_SESSION['api']);
  3448. $powerid = $this->power->read($user['power']);
  3449. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3450. $pid = '';
  3451. foreach ($powertext as $v)
  3452. {
  3453. $pid .= " id = ".$v." or";
  3454. }
  3455. $fullorderexcel = $this->fullorderexcel->find_all("type = '100004' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3456. $this->data['fullorderexcel'] = $fullorderexcel;
  3457. $this->_Template('fullordersmt_error',$this->data);
  3458. }
  3459. //关闭订单详情时保存备注
  3460. public function _bcbz()
  3461. {
  3462. $post = $this->input->post(NULL, TRUE);
  3463. if(isset($post['id']))
  3464. {
  3465. $fpcount = $this->input->post('fpcount',true);
  3466. if(!$fpcount)
  3467. {
  3468. echo json_encode(array('msg'=>'未设置商品信息!','success'=>false));exit;
  3469. }
  3470. $post['edittime'] = time();
  3471. $fpdata = $this->input->post('fpdata');
  3472. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  3473. $post['fpdata'] = $fpdata;
  3474. $post['state'] = $this->input->post('state');
  3475. $post['type'] = $this->input->post('warehouse');
  3476. $post['ioss'] = $this->input->post('ioss');
  3477. $rtime = $this->input->post('rtime',true);
  3478. if($rtime)
  3479. {
  3480. $post['rtime'] = strtotime($rtime);
  3481. }
  3482. $id = $this->input->post('id',TRUE);
  3483. $whlabel = $this->input->post('whlabel',true);
  3484. $data = $this->fullordersmt->read($id);
  3485. $editstate = $post['state'];
  3486. if($data['library'] == 1)
  3487. {
  3488. if($data['print'] != 3 && $data['review'] < 5)
  3489. {
  3490. $post['libraryconfirm'] = 1;
  3491. $post['librarynot'] = "订单未打印";
  3492. }
  3493. else if($data['print'] != 3 && $data['review'] > 4)
  3494. {
  3495. $post['print'] = 1;
  3496. $post['libraryconfirm'] = 1;
  3497. $post['librarynot'] = "订单未打印,订单审核后修改";
  3498. }
  3499. else
  3500. {
  3501. $post['libraryconfirm'] = 1;
  3502. $post['librarynot'] = "订单打印后修改";
  3503. }
  3504. }
  3505. if($data['yhs'] == 1)
  3506. {
  3507. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  3508. }
  3509. if((($post['express'] == 2 || $post['express'] == 63 || $post['express'] == 64) && $post['type'] != 5) || ($post['express'] != 2 && $post['express'] != 63 && $post['express'] != 64 && $post['type'] == 5))
  3510. {
  3511. echo json_encode(array('msg'=>'此快递方式必须选择美国仓!','success'=>false));exit;
  3512. }
  3513. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '31') && $data['country'] != 192)
  3514. {
  3515. echo json_encode(array('msg'=>'非美国无法选择Fedex!','success'=>false));exit;
  3516. }
  3517. if(($post['express'] == '28' || $post['express'] == '7') && $data['country'] != 191)
  3518. {
  3519. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  3520. }
  3521. $express = $this->express->read($post['express']);
  3522. if($express['ioss'] == 1 && $post['ioss'] == '')
  3523. {
  3524. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  3525. }
  3526. if(isset($post['address']) && (strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize']))
  3527. {
  3528. echo json_encode(array('msg'=>'此快递地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
  3529. }
  3530. if($data['type'] != '5' && $post['type'] == '5' && $editstate != '207')
  3531. {
  3532. echo json_encode(array('msg'=>'等待发货状态才可选择美仓!','success'=>false));exit;
  3533. }
  3534. if($data['library'] == 2 && $data['print'] == 3 && $data['waybill'] != $post['waybill'])
  3535. {
  3536. echo json_encode(array('msg'=>'不允许修改运单号','success'=>true));exit;
  3537. }
  3538. //南非 限制邮箱
  3539. if($post['country'] == 166){
  3540. if(empty($post['email'])){
  3541. echo json_encode(array('msg'=>'惠程安迈世发货需要有邮箱!','success'=>false));exit;
  3542. }else{
  3543. if(!$this->logic_order->checkEmail($post['email'])){
  3544. echo json_encode(array('msg'=>'邮箱格式不正确!','success'=>false));exit;
  3545. }
  3546. }
  3547. }
  3548. if(empty($post['zsbjz']*1)){
  3549. echo json_encode(array('msg'=>'申报金额不可为0!','success'=>false));exit;
  3550. }
  3551. if(empty($post['dtsbjz']*1)){
  3552. echo json_encode(array('msg'=>'单条申报价值不能为0!','success'=>false));exit;
  3553. }
  3554. $thisdata = $data;
  3555. $warehouse = $this->warehouse->read($thisdata['type']);
  3556. $warehousenew = $this->warehouse->read($post['type']);
  3557. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  3558. {
  3559. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  3560. }
  3561. /**
  3562. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  3563. {
  3564. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  3565. }
  3566. **/
  3567. if($data['shop'] == '9' && $post['type'] != '7' && $post['type'] != '8' && $post['type'] != '9')
  3568. {
  3569. echo json_encode(array('msg'=>'仓库选择错误!','success'=>false));exit;
  3570. }
  3571. /**
  3572. if($warehousenew['zd'] == '1' && $editstate != $thisdata['state'] && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  3573. {
  3574. echo json_encode(array('msg'=>'如需更改订单状态,请先把仓库选择为非开启库存模式仓库或等待订单出库!','success'=>false));exit;
  3575. }
  3576. if($warehousenew['zd'] == '1' && $editstate != '207' && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  3577. {
  3578. echo json_encode(array('msg'=>'非待发货状态,不允许修改为开启库存模式仓库','success'=>false));exit;
  3579. }
  3580. **/
  3581. //开始注释 xyxg
  3582. /**
  3583. $ft = array();
  3584. $ftdata = explode('|',rtrim($fpcount,'|'));
  3585. foreach ($ftdata as $va)
  3586. {
  3587. $ftitle = '';
  3588. $va = explode('-',trim($va,'-'));
  3589. foreach ($va as $v)
  3590. {
  3591. $v = $this->typeclass->read($v);
  3592. $ftitle .= $v['title'].' ';
  3593. }
  3594. $ft[] = rtrim($ftitle,' ');
  3595. }
  3596. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  3597. {
  3598. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  3599. if($tskcyz['t'] > '0')
  3600. {
  3601. echo $tskcyz['m'];exit;
  3602. }
  3603. }
  3604. $kcyz = $this->whlabel->get_kc($thisdata['state'],$post['state'],$warehousenew['zd'],$warehousenew['ys'],$post['type'],$whlabel,$fpcount,$ft,$thisdata['number'],$thisdata['shop'],$thisdata['type'],$thisdata['whlabel']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  3605. if($kcyz['t'] > '0')
  3606. {
  3607. echo $kcyz['m'];exit;
  3608. }
  3609. else
  3610. {
  3611. if($this->fullordersmt->save($post,$id))
  3612. {
  3613. echo json_encode(array('msg'=>'保存成功','id'=>$id,'a'=>$kcyz,'success'=>true));exit;
  3614. }
  3615. else
  3616. {
  3617. echo json_encode(array('msg'=>'保存失败,请重试','success'=>false));exit;
  3618. }
  3619. }
  3620. //结束注释
  3621. **/
  3622. $warehouse = $this->warehouse->read($post['type']);
  3623. if($data['library'] == 1 || ($data['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  3624. {
  3625. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  3626. if($kcyz['t'] > '0')
  3627. {
  3628. echo $kcyz['m'];exit;
  3629. }
  3630. else if($kcyz['fpdata'] != '')
  3631. {
  3632. $post['whlabel'] = $kcyz['whlabel'];
  3633. $post['fpdata'] = $kcyz['fpdata'];
  3634. }
  3635. }
  3636. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  3637. $post['sfxh'] = $fl['sfxh'];
  3638. $post['ckfl'] = $fl['ckfl'];
  3639. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  3640. if($this->fullordersmt->save($post,$id))
  3641. {
  3642. echo json_encode(array('msg'=>'保存成功','id'=>$id,'success'=>true));exit;
  3643. }
  3644. else
  3645. {
  3646. echo json_encode(array('msg'=>'保存失败,请重试','success'=>false));exit;
  3647. }
  3648. }
  3649. }
  3650. //验证地址
  3651. public function _yzaddress()
  3652. {
  3653. $post = $this->input->post(NULL, TRUE);
  3654. if(isset($post['address']))
  3655. {
  3656. $address = $this->input->post('address',true);
  3657. $address2 = $this->input->post('address2',true);
  3658. $city = $this->input->post('city',true);
  3659. $province = $this->input->post('province',true);
  3660. $zipcode = $this->input->post('zipcode',true);
  3661. $barcode = $this->usps->get_address(array('address'=>$address,'address2'=>$address2,'city'=>$city,'province'=>$province,'zipcode'=>$zipcode));
  3662. echo $barcode;
  3663. }
  3664. }
  3665. //订单退货
  3666. public function _return()
  3667. {
  3668. $post = $this->input->post(NULL, TRUE);
  3669. if(isset($post['orderinfo']))
  3670. {
  3671. $orderinfo = $this->input->post('orderinfo',true);
  3672. $data = $this->fullordersmt->get_orderinfo($orderinfo);
  3673. $fu = 'fullordersmt';
  3674. $bctime = date('Ymd',time());
  3675. if($data['returndata'] != "")
  3676. {
  3677. echo json_encode(array('msg'=>'请求失败,已有退货信息!','success'=>false));exit;
  3678. }
  3679. if($data['library'] != 2){
  3680. echo json_encode(array('msg'=>'此单不是出库状态,不允许退货','success'=>false));exit;
  3681. }
  3682. $barcode = $this->usps->get_return($data);
  3683. if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  3684. {
  3685. echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  3686. }
  3687. else
  3688. {
  3689. $pdf = $this->_pdf($barcode['ReturnLabel'],'t-'.$barcode['TrackingNumber'],$bctime);
  3690. $read = 'PostalRouting:'.$barcode['PostalRouting'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['TrackingNumber'].'.pdf" target="_blank">'.$barcode['TrackingNumber'].'</a>';
  3691. $this->$fu->save(array('returndata'=>$read),$data['id']);
  3692. echo json_encode(array('msg'=>'退货成功!','data'=>$read,'success'=>true));exit;
  3693. }
  3694. }
  3695. }
  3696. public function _pdf($pdf,$title,$bctime)
  3697. {
  3698. $pdf_path = './data/pdf/'.$bctime.'/';
  3699. $file_base64 = $pdf;
  3700. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  3701. $file_base64 = base64_decode($file_base64);
  3702. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  3703. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  3704. return $bctime;
  3705. }
  3706. //管理
  3707. public function _aaa()
  3708. {
  3709. $dt = 0;
  3710. if(isset($_SESSION['api']))
  3711. {
  3712. $user = $this->user->get_api($_SESSION['api']);
  3713. $usp = $user;
  3714. $fgshop = "";$sid = "";
  3715. $user = explode('|',trim($user['shop'],'|'));
  3716. foreach ($user as $value)
  3717. {
  3718. $fgshop .= " shop = ".$value." or";
  3719. $sid .= " id = ".$value." or";
  3720. }
  3721. }
  3722. $post = $this->input->post(NULL, TRUE);
  3723. if(isset($post['page']))
  3724. {
  3725. $page = $this->input->post('page',true);
  3726. $perpage = $this->input->post('perpage',true);
  3727. $warehouse = $this->input->post('warehouse',true);
  3728. $timetk = $this->input->post('timetkk',true);
  3729. $timetj = $this->input->post('timetjj',true);
  3730. $shop = $this->input->post('shop',true);
  3731. $source = $this->input->post('source',true);
  3732. $state = $this->input->post('state',true);
  3733. $review = $this->input->post('review',true);
  3734. $type = $this->input->post('type',true);
  3735. $express = $this->input->post('express',true);
  3736. $orderinfo = $this->input->post('orderinfo',true);
  3737. $user = $this->input->post('user',true);
  3738. $client = $this->input->post('name',true);
  3739. $fullname = $this->input->post('fullname',true);
  3740. $waybill = $this->input->post('waybill',true);
  3741. $number = $this->input->post('number',true);
  3742. $email = $this->input->post('email',true);
  3743. $dlz = $this->input->post('dlz',true);
  3744. $print = $this->input->post('print',true);
  3745. $library = $this->input->post('library',true);
  3746. $xztime = $this->input->post('xztime',true);
  3747. $timetk = strtotime($timetk)-1;
  3748. $timetj = strtotime($timetj);
  3749. $px = $this->input->post('px',true);
  3750. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3751. if($warehouse)
  3752. {
  3753. $where .= " and type = '$warehouse'";
  3754. }
  3755. if($timetk && $timetj)
  3756. {
  3757. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3758. }
  3759. if($shop)
  3760. {
  3761. $where .= " and shop = '$shop'";
  3762. }
  3763. if($source)
  3764. {
  3765. $where .= " and source = '$source'";
  3766. }
  3767. if($state)
  3768. {
  3769. $where .= " and state = '$state'";
  3770. }
  3771. if($review)
  3772. {
  3773. $where .= " and review = '$review'";
  3774. }
  3775. if($type)
  3776. {
  3777. $where .= " and type = '$type'";
  3778. }
  3779. if($express)
  3780. {
  3781. $where .= " and express = '$express'";
  3782. }
  3783. if($orderinfo)
  3784. {
  3785. $where .= " and orderinfo = '$orderinfo'";
  3786. }
  3787. if($user)
  3788. {
  3789. $where .= " and user = '$user'";
  3790. }
  3791. if($client)
  3792. {
  3793. $where .= " and client like '%$client%'";
  3794. }
  3795. if($waybill)
  3796. {
  3797. $where .= " and waybill = '$waybill'";
  3798. }
  3799. if($number)
  3800. {
  3801. $where .= " and number = '$number'";
  3802. }
  3803. if($email)
  3804. {
  3805. $where .= " and email = '$email'";
  3806. }
  3807. if($library)
  3808. {
  3809. $where .= " and library = '$library'";
  3810. }
  3811. if($print)
  3812. {
  3813. $where .= " and print = '$print'";
  3814. }
  3815. if($dlz != '')
  3816. {
  3817. $where .= " and dlz = '$dlz'";
  3818. }
  3819. if($fullname)
  3820. {
  3821. $where .= " and fullname = '$fullname'";
  3822. }
  3823. //数据排序
  3824. if($px)
  3825. {
  3826. $order_str = $px." desc";
  3827. }
  3828. else
  3829. {
  3830. $order_str = "numberpx desc";
  3831. }
  3832. if(empty($page))
  3833. {
  3834. $start = 0;
  3835. $perpage = 1;
  3836. }
  3837. else
  3838. {
  3839. $start = ($page - 1)*$perpage;
  3840. }
  3841. //取得信息列表id,shop,type,source,user,orderinfo,number,name,state,buytime,clientremarks,review,print,library,libraryconfirm,express,waybill,orderremarks,black
  3842. $info_list = $this->fullordersmt1->find_all($where,'id,shop,type,orderinfo,number,fullname,state,buytime,review,libraryconfirm,express,waybill,orderremarks,library,black,clientremarks,waybillid',$order_str,$start,$perpage);
  3843. //格式化数据
  3844. foreach ($info_list as $key=>$value)
  3845. {
  3846. $ud = $this->fullordersmt1->read($value['id']);
  3847. $ud['address'] = str_replace("'","’",$ud['address']);
  3848. $ud['name'] = str_replace("'","’",$ud['name']);
  3849. $customer = $ud['source'] != 1?$this->customersmt1->get_fullname($ud['fullname']):$this->customersmt1->get_shopdata($value['shop'],$ud['name'],$ud['address']);
  3850. //$a = array_column($customer, 'email'); //三维找其中健的数组
  3851. //$a = array_flip($a); //键和值调换
  3852. $currency = $this->country->read($ud['country']);
  3853. $name = ($ud['source'] == 1)?$ud['name']:$value['fullname'];
  3854. $lkh = "<p>".$name."</p><p style='color:#8f54fb'>".$currency['ename']."</p>";
  3855. if($customer)
  3856. {
  3857. if($customer['type'] == 1 && $customer['num'] > 1)
  3858. {
  3859. $lkh .= "<p style='color:#FF3333'>老客户</p>";
  3860. }
  3861. else if($customer['type'] == 2)
  3862. {
  3863. $hmsp = $this->shop->read($customer[0]['shop']);
  3864. $lkh .= "<p style='color:#9900CC'>黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  3865. }
  3866. }
  3867. $info_list[$key]['fullname'] = $lkh;
  3868. $shop = $this->shop->read($value['shop']);
  3869. $info_list[$key]['shop'] = $shop['shopname'];
  3870. //$info_list[$key]['user'] = $shop['shopuser'];
  3871. $warehouse = $this->warehouse->read($value['type']);
  3872. $warehousetitle = $warehouse['title'];
  3873. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  3874. $info_list[$key]['type'] = $warehousetitle;
  3875. $typeclass = $this->typeclass->read($value['state']);
  3876. if($ud['source'] != 1)
  3877. {
  3878. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$typeclass['title']."</a>";
  3879. }
  3880. else
  3881. {
  3882. $info_list[$key]['state'] = $typeclass['title'];
  3883. }
  3884. if(!$value['buytime'])
  3885. {
  3886. $info_list[$key]['buytime'] = '<p>无</p>';
  3887. }
  3888. else
  3889. {
  3890. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']-$dt).'</p><p>'.date('H:i:s',$value['buytime']-$dt).'</p>';
  3891. }
  3892. if($value['review'] == 1)
  3893. {
  3894. $info_list[$key]['review'] = "未送审";
  3895. }
  3896. else if($value['review'] == 2)
  3897. {
  3898. $info_list[$key]['review'] = "<font style='color:#555'>待审核</font>";
  3899. }
  3900. else if($value['review'] == 3)
  3901. {
  3902. $info_list[$key]['review'] = "<font style='color:#f90f4b'>不通过</font>";
  3903. }
  3904. else if($value['review'] == 4)
  3905. {
  3906. $info_list[$key]['review'] = "取消重审";
  3907. }
  3908. else if($value['review'] == 5)
  3909. {
  3910. $info_list[$key]['review'] = "<font style='color:#2f80f9'>审核通过</font>";
  3911. }
  3912. else if($value['review'] == 6)
  3913. {
  3914. $info_list[$key]['review'] = "<font style='color:#2f80f9'>自动通过</font>";
  3915. }
  3916. if($ud['dlz'] == 1)
  3917. {
  3918. $dlz = "<p>发货声明成功</p>";
  3919. }
  3920. else if($ud['dlz'] == 3)
  3921. {
  3922. $dlz = "<p>不需要发货声明</p>";
  3923. }
  3924. else if($ud['dlz'] == 2)
  3925. {
  3926. $dlz = "<p style='color:#C3C'>发货声明失败</p>";
  3927. }
  3928. else
  3929. {
  3930. $dlz = "";
  3931. }
  3932. if($value['waybill'] != "")
  3933. {
  3934. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  3935. if( !empty($value['waybillid'])){
  3936. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  3937. }
  3938. }
  3939. if($value['express'] != 0)
  3940. {
  3941. $express = $this->express->read($value['express']);
  3942. $expressservicename = $express['servicename'];
  3943. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  3944. $info_list[$key]['express'] = $expressservicename;
  3945. }
  3946. else
  3947. {
  3948. $info_list[$key]['express'] = "无";
  3949. }
  3950. $x = "";
  3951. if($value['libraryconfirm'] == 2 && $value['review'] > 4 && $ud['library'] == 1)
  3952. {
  3953. $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
  3954. }
  3955. else if(($value['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
  3956. {
  3957. $x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
  3958. }
  3959. if(($value['review'] > 4) && $ud['print'] == 2)
  3960. {
  3961. $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
  3962. }
  3963. else if($value['review'] >4 && $ud['print'] == 1)
  3964. {
  3965. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  3966. }
  3967. if($value['waybill'] == "" && $value['review'] > 4)
  3968. {
  3969. $x .= "<p><b class='kn' data-type='2'>填写运单号</b></p>";
  3970. }
  3971. else if($value['waybill'] != "" && $value['review'] > 4)
  3972. {
  3973. $x .= "<p><b class='kn' data-type='2'>修改运单</b></p>";
  3974. }
  3975. if(($value['review'] == 1 || $value['review'] == 3) && $ud['express'] > 0 && $ud['dtsbjz'] != 0 && $ud['ts'] != 0 && $ud['zsbjz'] != 0 && $ud['zjs'] != 0 && $ud['ts'] != 0)
  3976. {
  3977. $x .= "<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
  3978. }
  3979. $x .= "<p><b class='window' data-h='/customersmt/edit/".$customer['id']."' data-t='客户信息 - 修改'>客户信息</b></p>";
  3980. $info_list[$key]['black'] = $x;
  3981. $tly = "";
  3982. if($value['clientremarks'] != "")
  3983. {
  3984. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  3985. }
  3986. if($value['review'] > 4 && $usp['vip'] != 1)
  3987. {
  3988. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/readonly/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  3989. }
  3990. else
  3991. {
  3992. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/b/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  3993. }
  3994. if($value['library'] == 1 && $ud['printtype'] == 3)
  3995. {
  3996. $info_list[$key]['library'] = "不需要";
  3997. }
  3998. else if($value['library'] == 1 && $ud['printtype'] != 3)
  3999. {
  4000. $info_list[$key]['library'] = "未出库";
  4001. }
  4002. else if($value['library'] == 2)
  4003. {
  4004. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  4005. }
  4006. else if($value['library'] == 3)
  4007. {
  4008. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  4009. }
  4010. unset($info_list[$key]['waybillid']);
  4011. }
  4012. $total = $this->fullordersmt1->find_count($where);
  4013. $pagenum = ceil($total/$perpage);
  4014. $over = $total-($start+$perpage);
  4015. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4016. echo json_encode($rows);exit;
  4017. }
  4018. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4019. $this->data['wlshop'] = $wlshop;
  4020. $this->data['express'] = $this->express->find_all();
  4021. $user = $this->user->get_api($_SESSION['api']);
  4022. $powerid = $this->power->read($user['power']);
  4023. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4024. $pid = '';
  4025. foreach ($powertext as $v)
  4026. {
  4027. $pid .= " id = ".$v." or";
  4028. }
  4029. $fullorderexcel = $this->fullorderexcel->find_all("type = '100004' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4030. $this->data['fullorderexcel'] = $fullorderexcel;
  4031. $error = $this->fullordersmt1->find_count("print = 1 and failed !='' and mergeid = 0 and waybill = '' and (".rtrim($fgshop,'or').")");
  4032. $this->data['error'] = $error;
  4033. $this->_Template('fullordersmt_a',$this->data);
  4034. }
  4035. public function _bbb($arg_array)
  4036. {
  4037. $post = $this->input->post(NULL, TRUE);
  4038. if(isset($post['id']))
  4039. {
  4040. $id = $this->input->post('id',true);
  4041. $data = $this->fullordersmt1->read($id);
  4042. $post['type'] = $this->input->post('warehouse',true);
  4043. $post['country'] = $this->input->post('country',true);
  4044. $currency = $this->country->read($post['country']);
  4045. $post['al'] = $currency['lb'];
  4046. $post['freight'] = $this->input->post('freight',true);
  4047. $post['expressmoney'] = $this->input->post('expressmoney',true);
  4048. $post['shouldmoney'] = $this->input->post('shouldmoney',true);
  4049. $post['orderremarks'] = $this->input->post('orderremarks',true);
  4050. $shipremarks = $this->input->post('shipremarks');
  4051. $shipremarks = str_replace(array('%26','%2B'),array('&','+'),$shipremarks);
  4052. $post['shipremarks'] = preg_replace('/( | | |\s)/',' ',$shipremarks);
  4053. $post['email'] = $this->input->post('email',true);
  4054. $name = $this->input->post('name',true);
  4055. $post['name'] = str_replace("'","’",$name);
  4056. $post['phone'] = $this->input->post('phone',true);
  4057. $post['country'] = $this->input->post('country',true);
  4058. $post['province'] = $this->input->post('province',true);
  4059. $post['city'] = $this->input->post('city',true);
  4060. $post['zipcode'] = $this->input->post('zipcode',true);
  4061. $post['street'] = $this->input->post('street',true);
  4062. $address = $this->input->post('address',true);
  4063. $post['address'] = str_replace("'","’",$address);
  4064. $post['express'] = $this->input->post('express',true);
  4065. $post['printtype'] = $this->input->post('printtype',true);
  4066. $post['fpdata'] = $this->input->post('fpdata');
  4067. $post['waybill'] = $this->input->post('waybill',true);
  4068. $post['msg'] = $this->input->post('msg',true);
  4069. $post['zsbjz'] = $this->input->post('zsbjz',true);
  4070. $post['refundy'] = $this->input->post('refundy',true);
  4071. $post['refundj'] = $this->input->post('refundj',true);
  4072. $rtime = $this->input->post('rtime',true);
  4073. $post['rtime'] = strtotime($rtime);
  4074. $post['rpaypal'] = $this->input->post('rpaypal',true);
  4075. $post['rtext'] = $this->input->post('rtext',true);
  4076. $editstate = $this->input->post('state',true);
  4077. $post['review'] = 1;
  4078. if($post['zsbjz'] < '0.01')
  4079. {
  4080. echo json_encode(array('msg'=>'总申报价错误!','success'=>false));exit;
  4081. }
  4082. if($data['library'] == 1)
  4083. {
  4084. if($data['print'] != 3 && $data['review'] < 5)
  4085. {
  4086. $post['libraryconfirm'] = 1;
  4087. $post['librarynot'] = "订单未打印";
  4088. }
  4089. else if($data['print'] != 3 && $data['review'] > 4)
  4090. {
  4091. $post['print'] = 1;
  4092. $post['libraryconfirm'] = 1;
  4093. $post['librarynot'] = "订单未打印,订单审核后修改";
  4094. }
  4095. else
  4096. {
  4097. $post['libraryconfirm'] = 1;
  4098. $post['librarynot'] = "订单打印后修改";
  4099. }
  4100. }
  4101. if($post['printtype'] == 1)//如果是运单
  4102. {
  4103. $post['productdescription'] = $this->input->post('productdescription',true);
  4104. $post['customs'] = $this->input->post('customs',true);
  4105. }
  4106. /**
  4107. if($editstate == 216 && $data['state'] != 216)
  4108. {
  4109. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  4110. }
  4111. **/
  4112. if($editstate == 216 && preg_match('/\d/is',$post['waybill']) != true)
  4113. {
  4114. echo json_encode(array('msg'=>'当前信息不可修改订单状态','success'=>false));exit;
  4115. }
  4116. else
  4117. {
  4118. if($data['review'] == 1 && $data['source'] != 1)
  4119. {
  4120. $review = 6;
  4121. }
  4122. else if($data['review'] == 3 || ($data['review'] == 1 && $data['source'] == 1))
  4123. {
  4124. $review = 2;
  4125. }
  4126. else
  4127. {
  4128. $review = $data['review'];
  4129. }
  4130. $post['review'] = $review;
  4131. $post['state'] = $editstate;
  4132. $post['reviewtime'] = time();
  4133. }
  4134. if($this->fullordersmt1->save($post,$id))
  4135. {
  4136. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  4137. }
  4138. else
  4139. {
  4140. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  4141. }
  4142. }
  4143. $arg_array = $arg_array[0];$fpdata = array();
  4144. $fullordersmt = $this->fullordersmt1->read($arg_array);
  4145. $fullordersmt['parameter'] = str_replace(",","---",$fullordersmt['parameter']);
  4146. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  4147. $express = $this->express->find_all('1=1');//所有快递配置信息
  4148. $this->data['fullordersmt'] = $fullordersmt;
  4149. $this->data['country'] = $country;
  4150. $this->data['express'] = $express;
  4151. $this->data['dtime'] = date('Y-m-d H:i:s',$fullordersmt['dtime']);
  4152. if(stripos($fullordersmt['fpdata'],';') !== false)
  4153. {
  4154. $fpdata = explode(';',rtrim($fullordersmt['fpdata'],';'));
  4155. foreach ($fpdata as $k=>$v)
  4156. {
  4157. $fpdata[$k] = explode('|',$v);
  4158. }
  4159. }
  4160. $this->data['fpdata'] = $fpdata;
  4161. $shop = $this->shop->read($fullordersmt['shop']);
  4162. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  4163. $is = 0;
  4164. if($shop['type'] == 269)//判断是否独立站,269是独立站
  4165. {
  4166. $is = 1;
  4167. }
  4168. $this->data['is'] = $is;
  4169. if(isset($_SESSION['api']))
  4170. {
  4171. $user = $this->user->get_api($_SESSION['api']);
  4172. if($user['vip'] == 1)
  4173. {
  4174. $vip = 1;
  4175. }
  4176. else
  4177. {
  4178. $vip = 0;
  4179. }
  4180. }
  4181. else
  4182. {
  4183. $vip = 0;
  4184. }
  4185. $this->data['power'] = $vip;
  4186. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  4187. $downwaybill = '';
  4188. if($fullordersmt['printtype'] == 1)
  4189. {
  4190. if($fullordersmt['waybill'] != '')
  4191. {
  4192. $downwaybill .= '<a href="/data/pdf/'.date('Ymd',$fullordersmt['printtime']).'/y-'.$fullordersmt['waybill'].'.pdf" target="_blank">'.$fullordersmt['waybill'].'</a>、';
  4193. }
  4194. }
  4195. $oldwaybill = explode('-',ltrim($fullordersmt['oldwaybill'],'-'));
  4196. if(isset($oldwaybill[0][1]))
  4197. {
  4198. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  4199. foreach ($oldwaybill as $v)
  4200. {
  4201. $dw = explode('/',$v);
  4202. if(isset($dw[1]))
  4203. {
  4204. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  4205. }
  4206. }
  4207. }
  4208. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  4209. /** 历史打印时间 **/
  4210. $printtime = '';
  4211. if($fullordersmt['oldprinttime'])
  4212. {
  4213. $pte = explode('-',rtrim($fullordersmt['oldprinttime'],'-'));
  4214. foreach ($pte as $v)
  4215. {
  4216. $printtime .= date('Y-m-d H:i:s',$v).'、';
  4217. }
  4218. }
  4219. $this->data['printtime'] = rtrim($printtime,'、');
  4220. $this->_Template('fullordersmt_b',$this->data);
  4221. }
  4222. public function _cf() //速卖通订单拆分
  4223. {
  4224. $post = $this->input->post(NULL, TRUE);
  4225. if(isset($post['id']))
  4226. {
  4227. $id = $this->input->post('id',true);
  4228. $b = $this->fullordersmt->read($id);
  4229. $order = array();
  4230. if($b['merge'] == $b['id'])
  4231. {
  4232. $data = $this->fullordersmt->find_all("merge = '".$b['merge']."'");
  4233. foreach ($data as $v)
  4234. {
  4235. $a = $this->fullordersmthb->get_orderinfo($v['orderinfo']);
  4236. if($a)
  4237. {
  4238. $this->fullordersmt->save($a,$v['id']);
  4239. }
  4240. $order[] = $v['id'];
  4241. }
  4242. echo json_encode(array('msg'=>'拆分成功!','d'=>$order,'success'=>true));exit;
  4243. }
  4244. else
  4245. {
  4246. echo json_encode(array('msg'=>'拆分条件错误!','success'=>false));exit;
  4247. }
  4248. }
  4249. }
  4250. public function _epod()
  4251. {
  4252. $post = $this->input->post(NULL, TRUE);
  4253. if(isset($post['number']))
  4254. {
  4255. $number = $this->input->post('number',true);
  4256. $data = $this->fullordersmt->get_number($number);
  4257. if(is_file('./data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf'))
  4258. {
  4259. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf','success'=>true));exit;
  4260. }
  4261. else
  4262. {
  4263. $epod = $this->dhl->get_epod($data);
  4264. if($epod['c'] == 1)
  4265. {
  4266. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].$epod['d'],'success'=>true));exit;
  4267. }
  4268. else
  4269. {
  4270. echo json_encode(array('msg'=>$epod['d'],'success'=>false));exit;
  4271. }
  4272. }
  4273. }
  4274. }
  4275. public function _ddcf()
  4276. {
  4277. $post = $this->input->post(NULL, TRUE);
  4278. if(isset($post['number']))
  4279. {
  4280. $number = $this->input->post('number',true);
  4281. $data = $this->fullordersmt->get_number($number);
  4282. if(!$data)
  4283. {
  4284. echo json_encode(array('msg'=>'没有找到此订单','success'=>false));exit;
  4285. }
  4286. if($data['review'] != 1 && $data['review'] != 2)
  4287. {
  4288. echo json_encode(array('msg'=>'必须是 待审核 状态才能拆分','success'=>false));exit;
  4289. }
  4290. $cfnum = explode('-',trim($number,'-'));
  4291. if((count($cfnum)> 3 && stripos($pd[$x],'-PF-') !== false) || (count($cfnum)> 4 && stripos($pd[$x],'-PF-') === false))
  4292. {
  4293. echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  4294. }
  4295. $num = $this->fullordersmt->find_count("number like '".$number."%'");
  4296. $data['number'] = $data['number'].'-'.$num;
  4297. $data['orderinfo'] = $data['shop'].date('ymdHis',time()).rand(0,1);
  4298. $data['shouldmoney'] = 0;
  4299. $data['budget'] = 0;
  4300. $data['shipremarks'] = '';
  4301. $data['source'] = 1;
  4302. unset($data['id']);
  4303. unset($data['jweight']);
  4304. unset($data['fpcount']);
  4305. unset($data['returndata']);
  4306. unset($data['waybill']);
  4307. unset($data['oldwaybill']);
  4308. unset($data['printtime']);
  4309. if($this->fullordersmt->insert($data))
  4310. {
  4311. echo json_encode(array('msg'=>'拆分成功!新订单编号:'.$data['number'],'success'=>true));exit;
  4312. }
  4313. else
  4314. {
  4315. echo json_encode(array('msg'=>'拆分失败,请重试','success'=>false));exit;
  4316. }
  4317. }
  4318. }
  4319. }