Fullordersmt.php 155 KB

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