Fullordersmt.php 155 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601
  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['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'] == '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' ) && $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. if((!in_array($post['express'],[2,63,64,81,85,86,87])) && ($post['type'] == 5)){
  1431. echo json_encode(array('msg'=>'此快递方式不能美仓发货!','success'=>false));exit;
  1432. }
  1433. $express = $this->express->read($post['express']);
  1434. /**
  1435. if($express['ioss'] == 1 && $post['ioss'] == '')
  1436. {
  1437. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1438. }
  1439. **/
  1440. $thisdata = $this->fullordersmt->read($id);
  1441. $warehouse = $this->warehouse->read($thisdata['type']);
  1442. $warehousenew = $this->warehouse->read($post['type']);
  1443. if(($post['express'] == '5' || $post['express'] == '24') && strlen($ud['address']) > 32)
  1444. {
  1445. echo json_encode(array('msg'=>'地址1长度不合格!','success'=>false));exit;
  1446. }
  1447. if($post['express'] == '27' && strlen($post['address']) > 30)
  1448. {
  1449. echo json_encode(array('msg'=>'地址1长度不合格!','success'=>false));exit;
  1450. }
  1451. if($data['type'] != '5' && $post['type'] == '5' && $editstate != '207')
  1452. {
  1453. echo json_encode(array('msg'=>'等待发货状态才可选择美仓!','success'=>false));exit;
  1454. }
  1455. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1456. {
  1457. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1458. }
  1459. if($ud['yhs'] == 1)
  1460. {
  1461. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1462. }
  1463. $expt = $this->express->read($post['express']);
  1464. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1465. {
  1466. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1467. }
  1468. if($expt['province'] != '' && stripos($expt['province'],$ud['province'].'、') !== false)
  1469. {
  1470. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1471. }
  1472. /**
  1473. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1474. {
  1475. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1476. }
  1477. **/
  1478. //开始注释 xyxg
  1479. /**
  1480. $ft = array();
  1481. $ftdata = explode('|',rtrim($fpcount,'|'));
  1482. foreach ($ftdata as $va)
  1483. {
  1484. $ftitle = '';
  1485. $va = explode('-',trim($va,'-'));
  1486. foreach ($va as $v)
  1487. {
  1488. $v = $this->typeclass->read($v);
  1489. $ftitle .= $v['title'].' ';
  1490. }
  1491. $ft[] = rtrim($ftitle,' ');
  1492. }
  1493. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1494. {
  1495. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1496. if($tskcyz['t'] > '0')
  1497. {
  1498. echo $tskcyz['m'];exit;
  1499. }
  1500. }
  1501. $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']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1502. if($kcyz['t'] > '0')
  1503. {
  1504. echo $kcyz['m'];exit;
  1505. }
  1506. else
  1507. {
  1508. if($this->fullordersmt->save($post,$id))
  1509. {
  1510. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  1511. }
  1512. else
  1513. {
  1514. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1515. }
  1516. }
  1517. //结束注释
  1518. **/
  1519. $warehouse = $this->warehouse->read($post['type']);
  1520. if($ud['library'] == 1 || ($ud['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1521. {
  1522. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1523. if($kcyz['t'] > '0')
  1524. {
  1525. echo $kcyz['m'];exit;
  1526. }
  1527. else if($kcyz['fpdata'] != '')
  1528. {
  1529. $post['whlabel'] = $kcyz['whlabel'];
  1530. $post['fpdata'] = $kcyz['fpdata'];
  1531. }
  1532. }
  1533. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1534. $post['sfxh'] = $fl['sfxh'];
  1535. $post['ckfl'] = $fl['ckfl'];
  1536. //查询净重开始
  1537. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1538. //查询净重结束
  1539. if($this->fullordersmt->save($post,$id))
  1540. {
  1541. if($data['printtime'] == '0')
  1542. {
  1543. $xghz = ',该单将自动禁止打印';
  1544. }
  1545. else if($data['printtime'] > '0' && $data['librarytime'] == '0')
  1546. {
  1547. $xghz = ',该单将自动禁止发货';
  1548. }
  1549. else
  1550. {
  1551. $xghz = '';
  1552. }
  1553. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1554. }
  1555. else
  1556. {
  1557. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1558. }
  1559. }
  1560. $arg_array = $arg_array[0];$fpdata = array();
  1561. $fullordersmt = $this->fullordersmt->read($arg_array);
  1562. $returngoods = $this->returngoods->get_orderinfo($fullordersmt['orderinfo']);
  1563. $this->data['returngoods'] = $returngoods?1:0;
  1564. $fullordersmt['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullordersmt['shipremarks']);
  1565. $fullordersmt['parameter'] = str_replace(",","---",$fullordersmt['parameter']);
  1566. $this->data['fullordersmt'] = $fullordersmt;
  1567. if($fullordersmt['express'] == 2)
  1568. {
  1569. $zzhl = 'oz';
  1570. }
  1571. else
  1572. {
  1573. $zzhl = 'kg';
  1574. }
  1575. $this->data['zzhl'] = $zzhl;
  1576. $this->data['countrys'] = $this->country->find_all();
  1577. $this->data['express'] = $this->express->find_all();
  1578. $warehouse = $this->warehouse->read($fullordersmt['type']);
  1579. if(stripos($fullordersmt['fpdata'],';') !== false)
  1580. {
  1581. $fpdata = explode(';',rtrim($fullordersmt['fpdata'],';'));
  1582. foreach ($fpdata as $k=>$v)
  1583. {
  1584. $xxv = explode('|',$v);
  1585. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1586. {
  1587. $xxv['zd'] = "<p>已占单</p>";
  1588. $bdck = $warehouse['bdck'];
  1589. if(stripos($xxv[9],'~') !== false)
  1590. {
  1591. $dxxv = explode('~',trim($xxv[9],'~'));
  1592. foreach ($dxxv as $val)
  1593. {
  1594. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1595. if($wzid['details'] != '')
  1596. {
  1597. if($fullordersmt['type'] == 5){
  1598. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1599. }else{
  1600. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1601. }
  1602. }
  1603. }
  1604. }
  1605. else
  1606. {
  1607. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1608. if($wzid['details'] != '')
  1609. {
  1610. if($fullordersmt['type'] == 5){
  1611. $xxv['zd'] .= '<p>位置:'.$wzid['details'].'</p>';
  1612. }else{
  1613. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1614. }
  1615. }
  1616. }
  1617. }
  1618. $fpdata[$k] = $xxv;
  1619. }
  1620. }
  1621. $this->data['fpdata'] = $fpdata;
  1622. $thfpdataxs = array();
  1623. if($fullordersmt['thfpdata'] != '')
  1624. {
  1625. $thfpdata = explode(';',trim($fullordersmt['thfpdata'],';'));
  1626. foreach ($thfpdata as $k=>$v)
  1627. {
  1628. $thxs = explode('~',trim($v,'~'));
  1629. $thxs[0] = explode('|',trim($thxs[0],'|'));
  1630. $thxs[1] = explode('|',trim($thxs[1],'|'));
  1631. $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]);
  1632. }
  1633. }
  1634. $this->data['thfpdata'] = $thfpdataxs;
  1635. $shop = $this->shop->read($fullordersmt['shop']);
  1636. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  1637. $is = 0;
  1638. if($shop['type'] == 269)//判断是否独立站,269是独立站
  1639. {
  1640. $is = 1;
  1641. }
  1642. $this->data['is'] = $is;
  1643. //单项开始
  1644. $warehouse = $this->warehouse->read($fullordersmt['warehouse']);//发货仓库
  1645. $state = $this->typeclass->read($fullordersmt['state']);//订单状态
  1646. $country = $this->country->read($fullordersmt['country']);//国家
  1647. if($fullordersmt['capital'] == 1)
  1648. {
  1649. $capital = '暂未支付';
  1650. }
  1651. else if($fullordersmt['capital'] == 2)
  1652. {
  1653. $capital = '部分支付';
  1654. }
  1655. else if($fullordersmt['capital'] == 3)
  1656. {
  1657. $capital = '全部支付';
  1658. }
  1659. if($fullordersmt['printtype'] == 1)
  1660. {
  1661. $printtype = '运单';
  1662. }
  1663. else if($fullordersmt['printtype'] == 2)
  1664. {
  1665. $printtype = '发货单';
  1666. }
  1667. else if($fullordersmt['printtype'] == 3)
  1668. {
  1669. $printtype = '不打印单据';
  1670. }
  1671. else
  1672. {
  1673. $printtype = '未选择';
  1674. }
  1675. $this->data['warehouse'] = $warehouse['title'];
  1676. $this->data['state'] = $state['title'];
  1677. $this->data['capital'] = $capital;
  1678. $this->data['country'] = $country['ename'];
  1679. $this->data['printtype'] = $printtype;
  1680. //单项结束
  1681. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  1682. $downwaybill = '';$dwls = array();
  1683. $oldwaybill = explode('-',ltrim($fullordersmt['oldwaybill'],'-'));
  1684. if(isset($oldwaybill[0][1]))
  1685. {
  1686. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  1687. foreach ($oldwaybill as $v)
  1688. {
  1689. $dw = explode('/',$v);
  1690. if(isset($dw[1]))
  1691. {
  1692. $dwls[$dw[1]] = 1;
  1693. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  1694. }
  1695. }
  1696. }
  1697. if($fullordersmt['printtype'] == 1)
  1698. {
  1699. if($fullordersmt['waybill'] != '' && !isset($dwls[$fullordersmt['waybill']]))
  1700. {
  1701. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordersmt['printtime']).'/y-'.$fullordersmt['waybill'].'.pdf" target="_blank">'.$fullordersmt['waybill'].'</a>、'.$downwaybill;
  1702. }
  1703. }
  1704. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  1705. /** 历史打印时间 **/
  1706. $printtime = '';
  1707. if($fullordersmt['oldprinttime'])
  1708. {
  1709. $pte = explode('-',rtrim($fullordersmt['oldprinttime'],'-'));
  1710. foreach ($pte as $v)
  1711. {
  1712. $printtime .= date('Y-m-d H:i:s',$v).'、';
  1713. }
  1714. }
  1715. $this->data['printtime'] = rtrim($printtime,'、');
  1716. $product = '';
  1717. if($fullordersmt['link'] != '' && $fullordersmt['source'] != '1')
  1718. {
  1719. $pt = explode(';',rtrim($fullordersmt['product'],';'));
  1720. $lk = explode(',',$fullordersmt['link']);
  1721. for($i=0;$i<count($pt);$i++)
  1722. {
  1723. if(isset($lk[$i]) && isset($pt[$i]))
  1724. {
  1725. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$pt[$i].'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$pt[$i].'</a>';
  1726. }
  1727. }
  1728. }
  1729. else
  1730. {
  1731. $product = $fullordersmt['product'];
  1732. }
  1733. $this->data['username'] = ($user['shop']=='|9|')?'1':'0';
  1734. $out = $this->systemtransfer->find_all("number = '".$fullordersmt['number']."'");
  1735. $outread = '';
  1736. if($out)
  1737. {
  1738. foreach ($out as $val)
  1739. {
  1740. $list = '';
  1741. $rk = explode('|',trim($val['rk'],'|'));
  1742. $rktime = explode('|',trim($val['rktime'],'|'));
  1743. $zw = array();
  1744. $t = $this->transfer->find_all("1=1");
  1745. foreach ($t as $v)
  1746. {
  1747. $zw[$v['id']] = $v['title'];
  1748. }
  1749. if($val['rk'] != '' && count($rk) > 0)
  1750. {
  1751. for($i=0;$i<count($rk);$i++)
  1752. {
  1753. if(!isset($rktime[$i]))
  1754. {
  1755. $list .= $zw[$cz[$i]];
  1756. }
  1757. else
  1758. {
  1759. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1760. }
  1761. }
  1762. }
  1763. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1764. }
  1765. }
  1766. else
  1767. {
  1768. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordersmt['number']."'");
  1769. $outread = array();
  1770. if($systemwigsout)
  1771. {
  1772. foreach ($systemwigsout as $v)
  1773. {
  1774. if($v['czwarehouse'] == 37)
  1775. {
  1776. $outread[] = '华荣厂';
  1777. }
  1778. else if($v['czwarehouse'] == 0)
  1779. {
  1780. $outread[] = '龙盈厂';
  1781. }
  1782. $cz = explode('|',trim($v['cz'],'|'));
  1783. $cztime = explode('|',trim($v['cztime'],'|'));
  1784. $zw = $this->transfer->get_list();
  1785. if($v['cz'] != '' && count($cz) > 0)
  1786. {
  1787. for($i=0;$i<count($cz);$i++)
  1788. {
  1789. if(!isset($cztime[$i]))
  1790. {
  1791. $outread[] = $zw[$cz[$i]].' -&gt; ';
  1792. }
  1793. else
  1794. {
  1795. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1796. }
  1797. }
  1798. $outread[] = '<br>';
  1799. }
  1800. }
  1801. }
  1802. }
  1803. $this->data['systemwigsout'] = $outread;
  1804. $this->data['user'] = $user;
  1805. $this->_Template('fullordersmt_readonly',$this->data);
  1806. }
  1807. //浏览列表
  1808. public function _readlist()
  1809. {
  1810. $post = $this->input->post(NULL, TRUE);
  1811. if(isset($post['page']))
  1812. {
  1813. $page = $this->input->post('page',true);
  1814. $perpage = $this->input->post('perpage',true);
  1815. $warehouse = $this->input->post('warehouse',true);
  1816. $express = $this->input->post('express',true);
  1817. $state = $this->input->post('state',true);
  1818. $print = $this->input->post('print',true);
  1819. $libraryconfirm = $this->input->post('libraryconfirm',true);
  1820. $orderinfo = $this->input->post('orderinfo',true);
  1821. $client = $this->input->post('name',true);
  1822. $email = $this->input->post('email',true);
  1823. $number = $this->input->post('number',true);
  1824. $waybill = $this->input->post('waybill',true);
  1825. $timetk = $this->input->post('timetk',true);
  1826. $timetj = $this->input->post('timetj',true);
  1827. $timetk = strtotime($timetk);
  1828. $timetj = strtotime($timetj);
  1829. $where = "mergeid = 0";
  1830. if($warehouse)
  1831. {
  1832. $where .= " and type = '$warehouse'";
  1833. }
  1834. if($express)
  1835. {
  1836. $where .= " and express = '$express'";
  1837. }
  1838. if($state)
  1839. {
  1840. $where .= " and state = '$state'";
  1841. }
  1842. if($print)
  1843. {
  1844. $where .= " and print = '$print'";
  1845. }
  1846. if($libraryconfirm)
  1847. {
  1848. $where .= " and libraryconfirm = '$libraryconfirm'";
  1849. }
  1850. if($orderinfo)
  1851. {
  1852. $where .= " and orderinfo = '$orderinfo'";
  1853. }
  1854. if($client)
  1855. {
  1856. $where .= " and client like '%$client%'";
  1857. }
  1858. if($email)
  1859. {
  1860. $where .= " and email = '$email'";
  1861. }
  1862. if($number)
  1863. {
  1864. $where .= " and number = '$number'";
  1865. }
  1866. if($waybill)
  1867. {
  1868. $where .= " and waybill = '$waybill'";
  1869. }
  1870. if($timetk && $timetj)
  1871. {
  1872. $timetj = $timetj+24*3600;
  1873. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  1874. }
  1875. //数据排序
  1876. $order_str = "numberpx desc";
  1877. if(empty($page))
  1878. {
  1879. $start = 0;
  1880. $perpage = 1;
  1881. }
  1882. else
  1883. {
  1884. $start = ($page - 1)*$perpage;
  1885. }
  1886. //取得信息列表
  1887. $info_list = $this->fullordersmt->find_all($where,'id,type,orderinfo,number,client,state,buytime,express,waybill,print,library,orderremarks',$order_str,$start,$perpage);
  1888. //格式化数据
  1889. foreach ($info_list as $key=>$value)
  1890. {
  1891. $ud = $this->fullordersmt->read($value['id']);
  1892. $warehouse = $this->warehouse->read($value['type']);
  1893. $info_list[$key]['type'] = $warehouse['title'];
  1894. $typeclass = $this->typeclass->read($value['state']);
  1895. $info_list[$key]['state'] = $typeclass['spare'];
  1896. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  1897. {
  1898. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
  1899. }
  1900. else
  1901. {
  1902. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  1903. }
  1904. $express = $this->express->read($value['express']);
  1905. $info_list[$key]['express'] = $express['servicename'];
  1906. if($value['print'] == 1)
  1907. {
  1908. $info_list[$key]['print'] = "不可打印";
  1909. }
  1910. else if($value['print'] == 2)
  1911. {
  1912. $info_list[$key]['print'] = "未打印";
  1913. }
  1914. else if($value['print'] == 3)
  1915. {
  1916. $info_list[$key]['print'] = '<p>'.date('Y-m-d',$ud['printtime']).'</p><p>'.date('H:i:s',$ud['printtime']).'</p>';
  1917. }
  1918. if($value['library'] == 1)
  1919. {
  1920. $info_list[$key]['library'] = "未出库";
  1921. }
  1922. else if($value['library'] == 2)
  1923. {
  1924. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'</p>';
  1925. }
  1926. else if($value['library'] == 3)
  1927. {
  1928. $info_list[$key]['library'] = "已退库";
  1929. }
  1930. }
  1931. $total = $this->fullordersmt->find_count($where);
  1932. $pagenum = ceil($total/$perpage);
  1933. $over = $total-($start+$perpage);
  1934. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1935. echo json_encode($rows);exit;
  1936. }
  1937. $this->_Template('fullordersmt_readlist',$this->data);
  1938. }
  1939. //删除
  1940. public function _del()
  1941. {
  1942. echo json_encode(array('msg'=>'不允许执行!','success'=>false));exit;
  1943. $post = $this->input->post(NULL, TRUE);
  1944. if(isset($post['s']))
  1945. {
  1946. $id_arr = $this->input->post('s');
  1947. $id_arr = explode(',',$id_arr);
  1948. if(!$id_arr)
  1949. {
  1950. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  1951. }
  1952. //循环删除记录
  1953. foreach ($id_arr as $v)
  1954. {
  1955. $this->fullordersmt->remove($v);
  1956. }
  1957. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  1958. }
  1959. }
  1960. //查找商品价格
  1961. public function _price()
  1962. {
  1963. $post = $this->input->post(NULL, TRUE);
  1964. if(isset($post['data']))
  1965. {
  1966. $data = $this->input->post('data');
  1967. $data = explode('-',$data);
  1968. $number = '';$num = count($data);
  1969. //循环删除记录
  1970. for($i=0;$i<$num-1;$i++)
  1971. {
  1972. if($data[$i] != 0)
  1973. {
  1974. $number=$number.$data[$i];
  1975. if($i == 2)
  1976. {
  1977. $number=$number.$data[$num-1];
  1978. }
  1979. }
  1980. }
  1981. $list = $this->productdescribe->get_number($number);
  1982. if($list)
  1983. {
  1984. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));
  1985. }
  1986. else
  1987. {
  1988. $list = array('purchase'=>0,'cost'=>0,'salesprice'=>0);
  1989. //echo json_encode(array('msg'=>'此信息没有配置价格!','n'=>$data[$num-1],'success'=>false));exit;
  1990. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));exit;
  1991. }
  1992. }
  1993. }
  1994. public function _customs()
  1995. {
  1996. $post = $this->input->post(NULL, TRUE);
  1997. if(isset($post['e']))
  1998. {
  1999. $e = $this->input->post('e');//快递信息
  2000. $c = $this->input->post('c');//国家信息
  2001. $data = $this->customs->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2002. $list = $this->productdescription->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2003. $rows = array();
  2004. foreach ($data as $key=>$value)
  2005. {
  2006. $detailed = explode('|',trim($value['detailed'],'|'));
  2007. //此处未对比重量选择价值,暂直接选择第一条海关价值
  2008. $detailed = $this->detailed->read($detailed[0]);
  2009. $money = $detailed['customsval'];//找到海关价值
  2010. }
  2011. foreach ($list as $key=>$value)
  2012. {
  2013. $description = $this->typeclass->read($value['description']);
  2014. $list[$key]['title'] = $description['title'];//产品描述名称
  2015. }
  2016. if(!$data && !$list)
  2017. {
  2018. echo json_encode(array('msg'=>'无此快递配置信息!','success'=>false));exit;
  2019. }
  2020. else
  2021. {
  2022. //$list-title -description 取值
  2023. echo json_encode(array('money'=>sprintf("%.2f",$money),'msg'=>$list,'success'=>true));
  2024. }
  2025. }
  2026. }
  2027. public function _express()
  2028. {
  2029. $post = $this->input->post(NULL, TRUE);
  2030. if(isset($post['e']))
  2031. {
  2032. $e = $this->input->post('e');//快递信息
  2033. $c = $this->input->post('c');//国家信息
  2034. $data = $this->logistics->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2035. if(!$data)
  2036. {
  2037. echo json_encode(array('success'=>false));exit;
  2038. }
  2039. else
  2040. {
  2041. echo json_encode(array('money'=>sprintf("%.2f",$data[0]['firstmoney']),'success'=>true));
  2042. }
  2043. }
  2044. }
  2045. public function _hl()
  2046. {
  2047. $post = $this->input->post(NULL, TRUE);
  2048. if(isset($post['cy']))
  2049. {
  2050. $hl = 0;
  2051. $cy = $this->input->post('cy');//币种ID
  2052. $cy = $this->typeclass->read($cy);
  2053. $gethl = $this->hl->get_hl();
  2054. foreach ($gethl as $v)
  2055. {
  2056. $code = str_replace(" ","",$v['code']);
  2057. if($code == $cy['title'])
  2058. {
  2059. $hl = $v['refePrice']/100;
  2060. }
  2061. }
  2062. echo json_encode(array('msg'=>$hl,'success'=>true));
  2063. }
  2064. }
  2065. public function _operation()
  2066. {
  2067. $post = $this->input->post(NULL, TRUE);
  2068. if(isset($post['type']))
  2069. {
  2070. $type = $this->input->post('type');
  2071. $id = $this->input->post('id');
  2072. $msg = $this->input->post('msg');
  2073. if($type == 1)//禁止发货
  2074. {
  2075. $d = $this->fullordersmt->read($id);
  2076. if($d['library'] != 1)
  2077. {
  2078. echo json_encode(array('msg'=>'操作失败,订单非未出库状态!','success'=>false));exit;
  2079. }
  2080. if($msg == "")
  2081. {
  2082. echo json_encode(array('msg'=>'必须填写禁止原因!','success'=>false));exit;
  2083. }
  2084. if($d['print'] < 3)
  2085. {
  2086. $a = "订单未打印,";
  2087. }
  2088. else
  2089. {
  2090. $a = "";
  2091. }
  2092. if($this->fullordersmt->save(array('libraryconfirm'=>1,'librarynot'=>$a.$msg),$id))
  2093. {
  2094. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2095. }
  2096. else
  2097. {
  2098. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2099. }
  2100. }
  2101. if($type == 6)//允许发货
  2102. {
  2103. $d = $this->fullordersmt->read($id);
  2104. if($d['library'] > 1)
  2105. {
  2106. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2107. }
  2108. if($d['print'] < 3)
  2109. {
  2110. $a = "订单未打印,";
  2111. }
  2112. else
  2113. {
  2114. $a = "";
  2115. }
  2116. if($this->fullordersmt->save(array('libraryconfirm'=>2,'librarynot'=>$a.$msg),$id))
  2117. {
  2118. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2119. }
  2120. else
  2121. {
  2122. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2123. }
  2124. }
  2125. if($type == 7)//禁止打印
  2126. {
  2127. $d = $this->fullordersmt->read($id);
  2128. if($d['printtime'] != 0)
  2129. {
  2130. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2131. }
  2132. if($d['library'] > 1)
  2133. {
  2134. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2135. }
  2136. if($d['print'] == 3)
  2137. {
  2138. echo json_encode(array('msg'=>'操作失败,订单已打印!','success'=>false));exit;
  2139. }
  2140. if($d['print'] < 3)
  2141. {
  2142. $a = "订单未打印,";
  2143. }
  2144. else
  2145. {
  2146. $a = "";
  2147. }
  2148. if($this->fullordersmt->save(array('print'=>1),$id))
  2149. {
  2150. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2151. }
  2152. else
  2153. {
  2154. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2155. }
  2156. }
  2157. if($type == 8)//允许打印
  2158. {
  2159. $d = $this->fullordersmt->read($id);
  2160. /**
  2161. if($d['printtime'] != 0)
  2162. {
  2163. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2164. }
  2165. **/
  2166. if($d['library'] > 1)
  2167. {
  2168. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2169. }
  2170. if($d['print'] < 3)
  2171. {
  2172. $a = "订单未打印,";
  2173. }
  2174. else
  2175. {
  2176. $a = "";
  2177. }
  2178. if($d['printtime'] == '0')
  2179. {
  2180. $bcprint = 2;
  2181. }
  2182. else
  2183. {
  2184. $bcprint = 3;
  2185. }
  2186. if($this->fullordersmt->save(array('print'=>$bcprint,'failed'=>'','librarynot'=>$a.$d['librarynot']),$id))
  2187. {
  2188. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2189. }
  2190. else
  2191. {
  2192. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2193. }
  2194. }
  2195. if($type == 9)//关闭
  2196. {
  2197. if($this->fullordersmt->save(array('failed'=>''),$id))
  2198. {
  2199. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2200. }
  2201. else
  2202. {
  2203. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2204. }
  2205. }
  2206. if($type == 10)//允许出库
  2207. {
  2208. if($this->fullordersmt->save(array('failed'=>'','libraryconfirm'=>2),$id))
  2209. {
  2210. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2211. }
  2212. else
  2213. {
  2214. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2215. }
  2216. }
  2217. if($type == 2)//填写运单、修改运单
  2218. {
  2219. $d = $this->fullordersmt->read($id);
  2220. if($d['source'] == 1)
  2221. {
  2222. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>216,'dlz'=>3),$id);
  2223. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2224. }
  2225. $ex = $this->express->read($d['express']);
  2226. $shop = $this->shop->read($d['shop']);
  2227. if($d['express'] == 0)
  2228. {
  2229. echo json_encode(array('msg'=>'操作失败,未选择物流方式!','success'=>false));exit;
  2230. }
  2231. if($d['library'] == 3 || ($d['print'] == 3 && $d['libraryconfirm'] == 1))
  2232. {
  2233. echo json_encode(array('msg'=>'操作失败,不允许填写运单号!','success'=>false));exit;
  2234. }
  2235. if($d['dlz'] == 1 || $d['dlz'] == 2)//如果已经声明过需要操作修改声明
  2236. {
  2237. $msg = trim($msg);
  2238. $obtain = $this->apismt->get_obtain($d['orderinfo'],$shop['code']);//修改声明先查询之前物流信息
  2239. if(isset($obtain['logistics_no']))
  2240. {
  2241. $result = $this->apismt->get_editout($obtain['logistics_no'],$msg,'all',$d['orderinfo'],$obtain['service_name'],$ex['aecode'],$shop['code']);
  2242. }
  2243. if(isset($result['result_success']) && $result['result_success'] == 1)
  2244. {
  2245. $this->fullordersmt->save(array('waybill'=>$msg),$id);
  2246. /** 合并信息处理开始-修改声明 **/
  2247. if($d['merge'] != '0')
  2248. {
  2249. $hdata = $this->fullordersmt->find_all("merge = '".$d['merge']."' and id != '".$d['id']."' and dlz = '0' and source != 1");$i=0;
  2250. foreach ($hdata as $v)
  2251. {
  2252. $obtain = $this->apismt->get_obtain($v['orderinfo'],$shop['code']);//修改声明先查询之前物流信息
  2253. if(isset($obtain['logistics_no']))
  2254. {
  2255. $result = $this->apismt->get_editout($obtain['logistics_no'],$msg,'all',$v['orderinfo'],$obtain['service_name'],$ex['aecode'],$shop['code']);
  2256. }
  2257. if(isset($result['result_success']) && $result['result_success'] == 1)
  2258. {
  2259. $this->fullordersmt->save(array('waybill'=>$msg),$v['id']);
  2260. }
  2261. else
  2262. {
  2263. $this->fullordersmt->save(array('waybill'=>$msg,'dlz'=>4),$v['id']);
  2264. }
  2265. $i++;
  2266. if($i > 10)
  2267. {
  2268. break;
  2269. }
  2270. }
  2271. }
  2272. /** 合并信息处理结束开始 **/
  2273. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2274. }
  2275. else
  2276. {
  2277. $this->fullordersmt->save(array('waybill'=>$msg,'dlz'=>4),$id);
  2278. echo json_encode(array('msg'=>'修改声明失败,请重试','xq'=>$obtain,'success'=>false));exit;
  2279. }
  2280. }
  2281. else if($d['dlz'] == '0')//未发货声明状态
  2282. {
  2283. $msg = trim($msg);
  2284. $result_t = $this->apismt->get_out($msg,'all',$d['orderinfo'],$ex['aecode'],$shop['code']);
  2285. if(isset($result_t['result']))
  2286. {
  2287. $result = $result_t['result'];
  2288. if(isset($result['success']) && $result['success'] == "true"){
  2289. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$id);
  2290. /** 合并信息处理开始-发货声明 **/
  2291. if($d['merge'] != '0')
  2292. {
  2293. $hdata = $this->fullordersmt->find_all("merge = '".$d['merge']."' and id != '".$d['id']."' and dlz = '0' and source != 1");$i=0;
  2294. foreach ($hdata as $v)
  2295. {
  2296. $result_t = $this->apismt->get_out($msg,'all',$v['orderinfo'],$ex['aecode'],$shop['code']);
  2297. if(isset($result_t['result'])){
  2298. $result = $result_t['result'];
  2299. if(isset($result['success']) && $result['success'] == "true")
  2300. {
  2301. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$v['id']);
  2302. }
  2303. else
  2304. {
  2305. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>2),$v['id']);
  2306. }
  2307. }else{
  2308. if(isset($d['result_success']) && $d['result_success'] == "true")
  2309. {
  2310. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$v['id']);
  2311. }
  2312. else
  2313. {
  2314. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>2),$v['id']);
  2315. }
  2316. }
  2317. $i++;
  2318. if($i > 10)
  2319. {
  2320. break;
  2321. }
  2322. }
  2323. }
  2324. /** 合并信息处理结束开始 **/
  2325. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2326. }else{
  2327. echo json_encode(array('msg'=>'操作失败,请联系技术','success'=>false));exit;
  2328. }
  2329. }
  2330. else
  2331. {
  2332. if(isset($result_t['result_success']) && $result_t['result_success'] == "true"){
  2333. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$id);
  2334. /** 合并信息处理开始-发货声明 **/
  2335. if($d['merge'] != '0')
  2336. {
  2337. $hdata = $this->fullordersmt->find_all("merge = '".$d['merge']."' and id != '".$d['id']."' and dlz = '0' and source != 1");$i=0;
  2338. foreach ($hdata as $v)
  2339. {
  2340. $result_t = $this->apismt->get_out($msg,'all',$v['orderinfo'],$ex['aecode'],$shop['code']);
  2341. if(isset($d['result_success']) && $d['result_success'] == "true")
  2342. {
  2343. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>1),$v['id']);
  2344. }
  2345. else
  2346. {
  2347. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>2),$v['id']);
  2348. }
  2349. $i++;
  2350. if($i > 10)
  2351. {
  2352. break;
  2353. }
  2354. }
  2355. }
  2356. echo json_encode(array('msg'=>'操作成功','success'=>false));exit;
  2357. }else{
  2358. $this->fullordersmt->save(array('waybill'=>$msg,'state'=>209,'dlz'=>2),$id);
  2359. echo json_encode(array('msg'=>'声明失败:'.$result_t['error_msg'],'success'=>false));exit;
  2360. }
  2361. }
  2362. }
  2363. else
  2364. {
  2365. if($this->fullordersmt->save(array('waybill'=>$msg),$id))
  2366. {
  2367. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2368. }
  2369. else
  2370. {
  2371. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));
  2372. }
  2373. }
  2374. }
  2375. }
  2376. }
  2377. public function _merge()
  2378. {
  2379. $user = $this->user->get_api($_SESSION['api']);
  2380. if(!$user)
  2381. {
  2382. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2383. }
  2384. $post = $this->input->post(NULL, TRUE);
  2385. if(isset($post['s']))
  2386. {
  2387. $id_arr = $this->input->post('s');
  2388. $id_arr = explode(',',trim( $id_arr,','));
  2389. $id_arr = array_reverse($id_arr);
  2390. if(!$id_arr)
  2391. {
  2392. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2393. }
  2394. if(count($id_arr) < 2)
  2395. {
  2396. echo json_encode(array('msg'=>'缺少可合并单!','success'=>false));exit;
  2397. }
  2398. $tmp_list = $this->db->from('fullordersmt')->where_in('id',$id_arr)->select('id,orderinfo,number,type,express')->get()->result_array();
  2399. $count_warehouse_list = [];
  2400. $count_express_list = [];
  2401. $flag = 0;
  2402. $flag_str = '';
  2403. foreach ($tmp_list as $k => $v) {
  2404. $count_warehouse_list[$v['type']] = $v['type'];
  2405. if(empty($v['express'])){
  2406. $flag = 1;
  2407. $flag_str.= $v['number'].'仓库未选,请先选快递;';
  2408. }
  2409. $count_express_list[$v['express']] = $v['express'];
  2410. }
  2411. if($flag == 1){
  2412. echo json_encode(array('msg'=>$flag_str,'success'=>false));exit;
  2413. }
  2414. if(count($count_warehouse_list) > 1){
  2415. echo json_encode(array('msg'=>'合并单的仓库不一致,无法合并!','success'=>false));exit;
  2416. }
  2417. if(count($count_express_list) > 1){
  2418. echo json_encode(array('msg'=>'合并单的快递不一致,无法合并!','success'=>false));exit;
  2419. }
  2420. $post = array();
  2421. $u = $this->fullordersmt->read($id_arr[0]);
  2422. unset($id_arr[0]);
  2423. $this->db->trans_begin();
  2424. $hd = $this->fullordersmthb->get_orderinfo($u['orderinfo']);
  2425. if(!$hd)
  2426. {
  2427. $this->fullordersmthb->insert($u);
  2428. }
  2429. //相加
  2430. $post['shouldmoney'] = $u['shouldmoney'];//购买应收金额
  2431. $post['budget'] = $u['budget'];//预估到帐金额
  2432. $post['expressmoney']= $u['expressmoney'];//物流金额
  2433. //$post['refundy'] = $u['refundy'];//补/退原额
  2434. //$post['refundj'] = $u['refundj'];//补/退净额
  2435. $post['cost'] = $u['cost'];//成本金额
  2436. //$post['zzl'] = $u['zzl'];//总重量
  2437. //$post['zsbjz'] = $u['zsbjz'];//总申报价值
  2438. $post['ts'] = $u['ts'];//条数
  2439. $post['cost'] = $u['cost'];//成本金额
  2440. //追加
  2441. $post['rpaypal'] = $u['rpaypal'];//补/退交易号
  2442. $post['rtext'] = $u['rtext'];//补/退原因
  2443. $post['pay'] = $u['pay'];//付款方式
  2444. $post['paypal'] = $u['paypal'];//交易号
  2445. $post['clientremarks'] = $u['clientremarks'];//客户留言
  2446. $post['product'] = $u['product'];//商品名称
  2447. //$post['issku'] = $u['issku'];//sku
  2448. //$post['orderremarks'] = $u['orderremarks'];//订单备注
  2449. $post['shipremarks'] = $u['shipremarks'];//仓库品名
  2450. //产品追加
  2451. $post['fpdata'] = $u['fpdata'];//产品内容
  2452. $post['whlabel'] = $u['whlabel'];//产品对应库存码
  2453. $merge = $u['id'];
  2454. $d = array($u['id']);$order = '';
  2455. $zsl = 0;$zccsl = 0;
  2456. foreach ($id_arr as $v)
  2457. {
  2458. $v = $this->fullordersmt->read($v);
  2459. if($u['type'] != $v['type'])
  2460. {
  2461. echo json_encode(array('msg'=>'仓库不一致,无法合并!','success'=>false));exit;
  2462. }
  2463. if($v['shop'] = $u['shop'])
  2464. {
  2465. $hd = $this->fullordersmthb->get_orderinfo($v['orderinfo']);
  2466. if(!$hd)
  2467. {
  2468. $this->fullordersmthb->insert($v);
  2469. }
  2470. // $post['shouldmoney'] += $v['shouldmoney'];//购买应收金额
  2471. // $post['budget'] += $v['budget'];//预估到帐金额
  2472. // $post['expressmoney'] += $v['expressmoney'];//物流金额
  2473. //$post['refundy'] += $v['refundy'];//补/退原额
  2474. //$post['refundj'] += $v['refundj'];//补/退净额
  2475. $post['cost'] += $v['cost'];//成本金额
  2476. //$post['zzl'] += $v['zzl'];//总重量
  2477. //$post['zsbjz'] += $v['zsbjz'];//总申报价值
  2478. $post['ts'] += $v['ts'];//条数
  2479. //$post['rpaypal'] .= $v['rpaypal'];//补/退交易号
  2480. //$post['rtext'] .= $v['rtext'];//补/退原因
  2481. //$post['pay'] .= (stripos($post['pay'],$v['pay']) !== false)?'':';'.$v['pay'];//付款方式
  2482. //$post['paypal'] .= $v['paypal'];//交易号
  2483. $post['clientremarks'] .= $v['clientremarks'];//客户留言
  2484. $post['product'] .= $v['product'];//商品名称
  2485. //$post['issku'] .= $v['issku'];//sku
  2486. //$post['orderremarks'] .= $v['orderremarks'];//订单备注
  2487. $post['shipremarks'] .= $v['shipremarks'];//仓库品名
  2488. $post['fpdata'] .= $v['fpdata'];//产品内容
  2489. $post['whlabel'] .= ltrim($v['whlabel'],'|');//产品对应库存码
  2490. $d[] = $v['id'];
  2491. $order .= $v['orderinfo'].'('.$v['number'].')、';
  2492. $wl = $this->whlabel->find_all("zd = '".$v['number']."'");//查找是否有占用库存情况
  2493. $i = 0;
  2494. if($wl)//如果有那么清除所有占用
  2495. {
  2496. foreach ($wl as $val)
  2497. {
  2498. if($val['sku'] == 'Preset' && $val['state'] == '9')
  2499. {
  2500. $this->whlabel->remove($val['id']);//删除预设
  2501. $i++;
  2502. }
  2503. else
  2504. {
  2505. $this->whlabel->save(array('zd'=>''),$val['id']);//专属
  2506. $i++;
  2507. }
  2508. }
  2509. }
  2510. $zsl += count($wl);
  2511. $zccsl += $i;
  2512. $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']);
  2513. }
  2514. }
  2515. //计算出单条价值
  2516. /**
  2517. if($post['zsbjz'] < 1 || $post['ts'] < 1)
  2518. {
  2519. //$post['dtsbjz'] = 0;
  2520. }
  2521. else
  2522. {
  2523. //$post['dtsbjz'] = $post['zsbjz']/$post['ts'];//单条申报价
  2524. }
  2525. **/
  2526. $post['orderremarks'] = ' 《合并信息》:由'.rtrim($order,'、').'合并而来; '.$u['orderremarks'];;
  2527. $post['merge'] = $u['id'];
  2528. //$post['mergeid'] = 1;
  2529. //合并重复项
  2530. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  2531. $hbcff = explode(';',trim($post['fpdata'],';'));
  2532. $c = 0;
  2533. $hbw = array();
  2534. $hbf = array();
  2535. for($i=0;$i<count($hbcfw);$i++)
  2536. {
  2537. $w = explode('-',$hbcfw[$i]);
  2538. $f = explode('|',$hbcff[$i]);
  2539. if(isset($w[2]))
  2540. {
  2541. $w2 = ($w[2]==0)?0:'';
  2542. }
  2543. else
  2544. {
  2545. $w2 = '';
  2546. }
  2547. if(!isset($hbw[$w[0].$w2]))
  2548. {
  2549. $hbw[$w[0].$w2] = $hbcfw[$i];
  2550. $hbf[$w[0].$w2] = $hbcff[$i];
  2551. }
  2552. else
  2553. {
  2554. $c++;
  2555. $cw = explode('-',$hbw[$w[0].$w2]);
  2556. $cf = explode('|',$hbf[$w[0].$w2]);
  2557. if($cw[2] != 0 && $w[2] != 0)
  2558. {
  2559. $cf[2] += $f[2];
  2560. $cf[9] .= '~'.$f[9];
  2561. $hbf[$w[0].$w2] = implode("|",$cf);
  2562. $cw[1] += $f[2];
  2563. $cw[2] .= '~'.$f[9];
  2564. $hbw[$w[0].$w2] = implode("-",$cw);
  2565. }
  2566. else if($cw[2] == 0 && $w[2] == 0)
  2567. {
  2568. $cf[2] += $f[2];
  2569. $hbf[$w[0].$w2] = implode("|",$cf);
  2570. $cw[1] += $f[2];
  2571. $hbw[$w[0].$w2] = implode("-",$cw);
  2572. }
  2573. else
  2574. {
  2575. $hbw[] = $hbcfw[$i];
  2576. $hbf[] = $hbcff[$i];
  2577. }
  2578. }
  2579. }
  2580. if($c > 0)
  2581. {
  2582. $post['fpdata'] = implode(";",$hbf).';';
  2583. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  2584. }
  2585. //合并重复项结束
  2586. $this->fullordersmt->save($post,$u['id']);
  2587. if ($this->db->trans_status() === FALSE)
  2588. {
  2589. $this->db->trans_commit();
  2590. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2591. }
  2592. else
  2593. {
  2594. $this->db->trans_commit();
  2595. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$u['id'],'success'=>true));
  2596. }
  2597. }
  2598. }
  2599. public function _split()
  2600. {
  2601. $user = $this->user->get_api($_SESSION['api']);
  2602. if($user)
  2603. {
  2604. $fgshop = "";$sid = "";
  2605. $user = explode('|',trim($user['shop'],'|'));
  2606. foreach ($user as $value)
  2607. {
  2608. $fgshop .= " shop = ".$value." or";
  2609. $sid .= " id = ".$value." or";
  2610. }
  2611. }
  2612. $post = $this->input->post(NULL, TRUE);
  2613. if(isset($post['id']))
  2614. {
  2615. $id = $this->input->post('id');
  2616. $data = $this->fullordersmt->find_all("merge = '$id' and print !=3 and library =1 and (".rtrim($fgshop,'or').")");
  2617. $datanum = $this->fullordersmt->find_count("merge = '$id' and (".rtrim($fgshop,'or').")");
  2618. if($data && count($data) == $datanum)
  2619. {
  2620. foreach ($data as $k=>$v)
  2621. {
  2622. unset($data[$k]['id']);
  2623. unset($data[$k]['express']);
  2624. unset($data[$k]['printtype']);
  2625. unset($data[$k]['review']);
  2626. unset($data[$k]['reviewtime']);
  2627. $t = $this->fullordersmt->get_orderinfo($v['orderinfo']);
  2628. $this->fullordersmt->save($v,$t['id']);
  2629. }
  2630. echo json_encode(array('msg'=>'拆分成功!','success'=>true));
  2631. }
  2632. else
  2633. {
  2634. echo json_encode(array('msg'=>'有订单不符合条件,请重试','success'=>false));exit;
  2635. }
  2636. }
  2637. }
  2638. //评价管理
  2639. public function _evaluate()
  2640. {
  2641. $user = $this->user->get_api($_SESSION['api']);
  2642. if($user)
  2643. {
  2644. $fgshop = "";$sid = "";
  2645. $user = explode('|',trim($user['shop'],'|'));
  2646. foreach ($user as $value)
  2647. {
  2648. $fgshop .= " shop = ".$value." or";
  2649. $sid .= " id = ".$value." or";
  2650. }
  2651. }
  2652. $post = $this->input->post(NULL, TRUE);
  2653. if(isset($post['page']))
  2654. {
  2655. $page = $this->input->post('page',true);
  2656. $perpage = $this->input->post('perpage',true);
  2657. $shop = $this->input->post('shop',true);
  2658. $where = "1=1 and evaluate = 0 and (".rtrim($fgshop,'or').")";
  2659. if($shop)
  2660. {
  2661. $where .= " and shop = '$shop'";
  2662. }
  2663. //数据排序
  2664. $order_str = "id desc";
  2665. if(empty($page))
  2666. {
  2667. $start = 0;
  2668. $perpage = 1;
  2669. }
  2670. else
  2671. {
  2672. $start = ($page - 1)*$perpage;
  2673. }
  2674. //取得信息列表
  2675. $info_list = $this->fullordersmt->find_all($where,'id,shop,orderinfo,number,operation',$order_str,$start,$perpage);
  2676. //格式化数据
  2677. foreach ($info_list as $key=>$value)
  2678. {
  2679. $shop = $this->shop->read($value['shop']);
  2680. $info_list[$key]['shop'] = $shop['shopname'];
  2681. $info_list[$key]['operation'] = "评价";
  2682. }
  2683. $total = $this->fullordersmt->find_count($where);
  2684. $pagenum = ceil($total/$perpage);
  2685. $over = $total-($start+$perpage);
  2686. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2687. echo json_encode($rows);exit;
  2688. }
  2689. $this->_Template('fullordersmt_evaluate',$this->data);
  2690. }
  2691. //订单消息
  2692. public function _state()
  2693. {
  2694. $user = $this->user->get_api($_SESSION['api']);
  2695. if($user)
  2696. {
  2697. $fgshop = "";$sid = "";
  2698. $user = explode('|',trim($user['shop'],'|'));
  2699. foreach ($user as $value)
  2700. {
  2701. $fgshop .= " shop = ".$value." or";
  2702. $sid .= " id = ".$value." or";
  2703. }
  2704. }
  2705. $post = $this->input->post(NULL, TRUE);
  2706. if(isset($post['page']))
  2707. {
  2708. $page = $this->input->post('page',true);
  2709. $perpage = $this->input->post('perpage',true);
  2710. $timetk = $this->input->post('timetk',true);
  2711. $timetj = $this->input->post('timetj',true);
  2712. $shop = $this->input->post('shop',true);
  2713. $source = $this->input->post('source',true);
  2714. $state = $this->input->post('state',true);
  2715. $review = $this->input->post('review',true);
  2716. $expressstate = $this->input->post('expressstate',true);
  2717. $express = $this->input->post('express',true);
  2718. $orderinfo = $this->input->post('orderinfo',true);
  2719. $user = $this->input->post('user',true);
  2720. $name = $this->input->post('name',true);
  2721. $waybill = $this->input->post('waybill',true);
  2722. $timetk = strtotime($timetk);
  2723. $timetj = strtotime($timetj);
  2724. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2725. if($timetk && $timetj)
  2726. {
  2727. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2728. }
  2729. if($shop)
  2730. {
  2731. $where .= " and shop = '$shop'";
  2732. }
  2733. if($source)
  2734. {
  2735. $where .= " and source = '$source'";
  2736. }
  2737. if($state)
  2738. {
  2739. $where .= " and state = '$state'";
  2740. }
  2741. if($review)
  2742. {
  2743. $where .= " and review = '$review'";
  2744. }
  2745. if($expressstate != "")
  2746. {
  2747. $where .= " and expressstate = '$expressstate'";
  2748. }
  2749. if($express)
  2750. {
  2751. $where .= " and express = '$express'";
  2752. }
  2753. if($orderinfo)
  2754. {
  2755. $where .= " and orderinfo = '$orderinfo'";
  2756. }
  2757. if($user)
  2758. {
  2759. $where .= " and user = '$user'";
  2760. }
  2761. if($name)
  2762. {
  2763. $where .= " and name = '$name'";
  2764. }
  2765. if($waybill)
  2766. {
  2767. $where .= " and waybill = '$waybill'";
  2768. }
  2769. //数据排序
  2770. $order_str = "id desc";
  2771. if(empty($page))
  2772. {
  2773. $start = 0;
  2774. $perpage = 1;
  2775. }
  2776. else
  2777. {
  2778. $start = ($page - 1)*$perpage;
  2779. }
  2780. //取得信息列表
  2781. $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);
  2782. //格式化数据
  2783. foreach ($info_list as $key=>$value)
  2784. {
  2785. $ud = $this->fullordersmt->read($value['id']);
  2786. $shop = $this->shop->read($value['shop']);
  2787. $info_list[$key]['shop'] = $shop['shopname'];
  2788. $info_list[$key]['user'] = $shop['shopuser'];
  2789. $country = $this->country->read($value['country']);
  2790. $info_list[$key]['country'] = $country['name'];
  2791. $state = $this->typeclass->read($value['state']);
  2792. if($ud['source'] != '1')
  2793. {
  2794. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$state['title']."</a>";
  2795. }
  2796. else
  2797. {
  2798. $info_list[$key]['state'] = $state['title'];
  2799. }
  2800. if($value['library'] == 1)
  2801. {
  2802. $info_list[$key]['library'] = "未出库";
  2803. }
  2804. else if($value['library'] == 2)
  2805. {
  2806. $info_list[$key]['library'] = "已出库";
  2807. }
  2808. else if($value['library'] == 3)
  2809. {
  2810. $info_list[$key]['library'] = "已退库";
  2811. }
  2812. if($value['librarytime'] == '0')
  2813. {
  2814. $info_list[$key]['librarytime'] = '无';
  2815. }
  2816. else
  2817. {
  2818. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2819. }
  2820. if($value['exstate'] == 0)
  2821. {
  2822. $info_list[$key]['exstate'] = "未取件";
  2823. }
  2824. else if($value['exstate'] == 1)
  2825. {
  2826. $info_list[$key]['exstate'] = "已揽收";
  2827. }
  2828. else if($value['exstate'] == 2)
  2829. {
  2830. $info_list[$key]['exstate'] = "在途中";
  2831. }
  2832. else if($value['exstate'] == 3)
  2833. {
  2834. $info_list[$key]['exstate'] = "派送中";
  2835. }
  2836. else if($value['exstate'] == 4)
  2837. {
  2838. $info_list[$key]['exstate'] = "签收";
  2839. }
  2840. if($value['express'])
  2841. {
  2842. $express = $this->express->read($value['express']);
  2843. $info_list[$key]['express'] = $express['servicename'];
  2844. }
  2845. else
  2846. {
  2847. $info_list[$key]['express'] = '';
  2848. }
  2849. }
  2850. $total = $this->fullordersmt->find_count($where);
  2851. $pagenum = ceil($total/$perpage);
  2852. $over = $total-($start+$perpage);
  2853. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2854. echo json_encode($rows);exit;
  2855. }
  2856. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2857. $this->data['wlshop'] = $wlshop;
  2858. $this->data['express'] = $this->express->find_all();
  2859. $this->_Template('fullordersmt_state',$this->data);
  2860. }
  2861. //审核订单
  2862. public function _review()
  2863. {
  2864. $user = $this->user->get_api($_SESSION['api']);
  2865. $fgshop = "";
  2866. if($user)
  2867. {
  2868. $fgshop = "";$sid = "";
  2869. $user = explode('|',trim($user['shop'],'|'));
  2870. foreach ($user as $value)
  2871. {
  2872. $fgshop .= " shop = ".$value." or";
  2873. }
  2874. $fgshop = " and (".rtrim($fgshop,'or').")";
  2875. }
  2876. $post = $this->input->post(NULL, TRUE);
  2877. if(isset($post['page']))
  2878. {
  2879. $page = $this->input->post('page',true);
  2880. $perpage = $this->input->post('perpage',true);
  2881. $source = $this->input->post('source',true);
  2882. $warehouse = $this->input->post('warehouse',true);
  2883. $express = $this->input->post('express',true);
  2884. $user = $this->input->post('user',true);
  2885. $shop = $this->input->post('shop',true);
  2886. $review = $this->input->post('review',true);
  2887. $orderinfo = $this->input->post('orderinfo',true);
  2888. $number = $this->input->post('number',true);
  2889. $timetk = $this->input->post('timetk',true);
  2890. $timetj = $this->input->post('timetj',true);
  2891. $timetk = strtotime($timetk);
  2892. $timetj = strtotime($timetj);
  2893. $where = "mergeid = 0".$fgshop;
  2894. if($timetk && $timetj)
  2895. {
  2896. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2897. }
  2898. if($source)
  2899. {
  2900. $where .= " and source = '$source'";
  2901. }
  2902. if($shop)
  2903. {
  2904. $where .= " and shop = '$shop'";
  2905. }
  2906. if($warehouse)
  2907. {
  2908. $where .= " and type = '$warehouse'";
  2909. }
  2910. if($express)
  2911. {
  2912. $where .= " and express = '$express'";
  2913. }
  2914. if($user)
  2915. {
  2916. $where .= " and user = '$user'";
  2917. }
  2918. if($review)
  2919. {
  2920. $where .= " and review = '$review'";
  2921. }
  2922. if($orderinfo)
  2923. {
  2924. $where .= " and orderinfo = '$orderinfo'";
  2925. }
  2926. if($number)
  2927. {
  2928. $where .= " and number = '$number'";
  2929. }
  2930. //数据排序
  2931. $order_str = "id desc";
  2932. if(empty($page))
  2933. {
  2934. $start = 0;
  2935. $perpage = 1;
  2936. }
  2937. else
  2938. {
  2939. $start = ($page - 1)*$perpage;
  2940. }
  2941. //取得信息列表
  2942. $info_list = $this->fullordersmt->find_all($where,'id,shop,user,type,orderinfo,number,client,express,buytime,shouldmoney,review,currencytitle,library');
  2943. //格式化数据
  2944. foreach ($info_list as $key=>$value)
  2945. {
  2946. $lr = $this->fullordersmt->read($value['id']);
  2947. $shop = $this->shop->read($value['shop']);
  2948. $info_list[$key]['shop'] = $shop['shopname'];
  2949. $info_list[$key]['user'] = $shop['shopuser'];
  2950. $warehouse = $this->warehouse->read($value['type']);
  2951. $info_list[$key]['type'] = $warehouse['title'];
  2952. $express = $this->express->read($value['express']);
  2953. $info_list[$key]['express'] = $express['servicename'];
  2954. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']).'</p><p>'.date('H:i:s',$value['buytime']).'</p>';
  2955. if($value['review'] == 1)
  2956. {
  2957. $info_list[$key]['review'] = "未送审";
  2958. }
  2959. else if($value['review'] == 2)
  2960. {
  2961. $info_list[$key]['review'] = "待审核";
  2962. }
  2963. else if($value['review'] == 3)
  2964. {
  2965. $info_list[$key]['review'] = "不通过";
  2966. }
  2967. else if($value['review'] == 4)
  2968. {
  2969. $info_list[$key]['review'] = "取消重审";
  2970. }
  2971. else if($value['review'] == 5)
  2972. {
  2973. $info_list[$key]['review'] = "审核通过";
  2974. }
  2975. else if($value['review'] == 6)
  2976. {
  2977. $info_list[$key]['review'] = "自动通过";
  2978. }
  2979. if($value['review'] == 2)
  2980. {
  2981. $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>";
  2982. }
  2983. else if($value['review'] == 3)
  2984. {
  2985. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='5' data-id='".$value['id']."'>审核通过</b></p>";
  2986. }
  2987. else if($value['review'] == 5)
  2988. {
  2989. $info_list[$key]['library'] = "<p><b class='fullorderreview' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  2990. }
  2991. else
  2992. {
  2993. $info_list[$key]['library'] = "";
  2994. }
  2995. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$lr['currencytitle'];
  2996. $lr['hl'] = $lr['hl']==0?6.71:$lr['hl'];
  2997. $cost = $lr['cost']/$lr['hl'];
  2998. $currencytitle = $lr['budget']-$lr['refundj']-$cost-$lr['expressmoney'];
  2999. $info_list[$key]['currencytitle'] = sprintf("%.2f",$currencytitle).' '.$lr['currencytitle'];
  3000. }
  3001. $total = $this->fullordersmt->find_count($where);
  3002. $pagenum = ceil($total/$perpage);
  3003. $over = $total-($start+$perpage);
  3004. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3005. echo json_encode($rows);exit;
  3006. }
  3007. $this->_Template('fullordersmt_review',$this->data);
  3008. }
  3009. //导出资金统计excel
  3010. public function _fmexcel()
  3011. {
  3012. $user = $this->user->get_api($_SESSION['api']);
  3013. if($user)
  3014. {
  3015. $fgshop = "";$sid = "";
  3016. $user = explode('|',trim($user['shop'],'|'));
  3017. foreach ($user as $value)
  3018. {
  3019. $fgshop .= " shop = ".$value." or";
  3020. $sid .= " id = ".$value." or";
  3021. }
  3022. }
  3023. if(isset($_GET['excel']))
  3024. {
  3025. $timetk = $this->input->get('timetk',true);
  3026. $timetj = $this->input->get('timetj',true);
  3027. $shop = $this->input->get('shop',true);
  3028. $source = $this->input->get('source',true);
  3029. $state = $this->input->get('state',true);
  3030. $type = $this->input->get('type',true);
  3031. $orderinfo = $this->input->get('orderinfo',true);
  3032. $user = $this->input->get('user',true);
  3033. $name = $this->input->get('name',true);
  3034. $timetk = strtotime($timetk);
  3035. $timetj = strtotime($timetj);
  3036. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3037. if($timetk && $timetj)
  3038. {
  3039. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3040. }
  3041. if($shop)
  3042. {
  3043. $where .= " and shop = '$shop'";
  3044. }
  3045. if($source)
  3046. {
  3047. $where .= " and source = '$source'";
  3048. }
  3049. if($state)
  3050. {
  3051. if($state == 1)
  3052. {
  3053. $where .= " and state = '$state'";
  3054. }
  3055. }
  3056. if($type)
  3057. {
  3058. $where .= " and type = '$type'";
  3059. }
  3060. if($orderinfo)
  3061. {
  3062. $where .= " and orderinfo = '$orderinfo'";
  3063. }
  3064. if($user)
  3065. {
  3066. $where .= " and user = '$user'";
  3067. }
  3068. if($name)
  3069. {
  3070. $where .= " and name = '$name'";
  3071. }
  3072. //取得信息列表
  3073. $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');
  3074. //格式化数据
  3075. $i = 1;$shouldmoney = 0;$refund = 0;$budget = 0;$currency = 0;$hl=1;
  3076. foreach ($info_list as $key=>$value)
  3077. {
  3078. $info_list[$key]['id'] = $i;
  3079. if($value['currencytitle'] != "CNY")
  3080. {
  3081. $hl=$value['hl'];
  3082. }
  3083. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3084. $budget=$budget+($value['budget']*$hl);
  3085. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  3086. $refund=$refund+($value['refund']*$hl);
  3087. $shop = $this->shop->read($value['shop']);
  3088. $info_list[$key]['shop'] = $shop['shopname'];
  3089. $info_list[$key]['user'] = $shop['shopuser'];
  3090. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3091. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  3092. $country = $this->country->read($value['country']);
  3093. $info_list[$key]['country'] = $country['name'];
  3094. $express = $this->express->read($value['express']);
  3095. $info_list[$key]['express'] = $express['servicename'];
  3096. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  3097. $info_list[$key]['refund'] = $value['refund'].' '.$value['currencytitle'];
  3098. $info_list[$key]['budget'] = $value['budget'].' '.$value['currencytitle'];
  3099. $info_list[$key]['currency'] = sprintf("%.2f",$value['shouldmoney']-$value['budget']).' '.$value['currencytitle'];
  3100. $fpdata = array();
  3101. if(stripos($value['fpdata'],';') !== false)
  3102. {
  3103. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  3104. foreach ($fpdata as $ke=>$va)
  3105. {
  3106. $v = explode('|',rtrim($va,'|'));
  3107. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  3108. }
  3109. }
  3110. $info_list[$key]['fpdata'] = $fpdata;
  3111. $i++;
  3112. }
  3113. $data = array($shouldmoney.' CNY',$refund.' CNY',$currency.' CNY',$budget.' CNY');
  3114. $title = "订单资金信息";
  3115. $titlename = "<table border=1>
  3116. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  3117. <tr>
  3118. <td>NO.</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>退款金额</td>
  3131. <td>手续费</td>
  3132. <td>预估金额</td>
  3133. <td>
  3134. <table border=1>
  3135. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  3136. <tr>
  3137. <td>产品</td>
  3138. <td>条数</td>
  3139. <td>数量</td>
  3140. </tr>
  3141. </table>
  3142. </td>
  3143. <td>总条数</td>
  3144. </tr>
  3145. </table>";
  3146. $filename = $title.".xls";
  3147. $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";
  3148. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  3149. }
  3150. }
  3151. //导出订单excel
  3152. public function _fdexcel()
  3153. {
  3154. if(isset($_GET['excel']))
  3155. {
  3156. $page = $this->input->post('page',true);
  3157. $perpage = $this->input->post('perpage',true);
  3158. $timetk = $this->input->post('timetk',true);
  3159. $timetj = $this->input->post('timetj',true);
  3160. $shop = $this->input->post('shop',true);
  3161. $source = $this->input->post('source',true);
  3162. $state = $this->input->post('state',true);
  3163. $review = $this->input->post('review',true);
  3164. $express = $this->input->post('express',true);
  3165. $orderinfo = $this->input->post('orderinfo',true);
  3166. $user = $this->input->post('user',true);
  3167. $name = $this->input->post('name',true);
  3168. $waybill = $this->input->post('waybill',true);
  3169. $timetk = strtotime($timetk);
  3170. $timetj = strtotime($timetj);
  3171. $where = "1=1 and mergeid = 0";
  3172. if($timetk && $timetj)
  3173. {
  3174. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3175. }
  3176. if($shop)
  3177. {
  3178. $where .= " and shop = '$shop'";
  3179. }
  3180. if($source)
  3181. {
  3182. $where .= " and source = '$source'";
  3183. }
  3184. if($state)
  3185. {
  3186. $where .= " and state = '$state'";
  3187. }
  3188. if($review)
  3189. {
  3190. $where .= " and review = '$review'";
  3191. }
  3192. if($express)
  3193. {
  3194. $where .= " and express = '$express'";
  3195. }
  3196. if($orderinfo)
  3197. {
  3198. $where .= " and orderinfo = '$orderinfo'";
  3199. }
  3200. if($user)
  3201. {
  3202. $where .= " and user = '$user'";
  3203. }
  3204. if($name)
  3205. {
  3206. $where .= " and name = '$name'";
  3207. }
  3208. if($waybill)
  3209. {
  3210. $where .= " and waybill = '$waybill'";
  3211. }
  3212. //取得信息列表
  3213. $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');
  3214. //格式化数据
  3215. $i = 1;$shouldmoney = 0;$hl=1;
  3216. foreach ($info_list as $key=>$value)
  3217. {
  3218. $info_list[$key]['id'] = $i;
  3219. if($value['source'] == 1)
  3220. {
  3221. $info_list[$key]['source'] = "线下订单";
  3222. }
  3223. else if($value['source'] == 2)
  3224. {
  3225. $info_list[$key]['source'] = "PC订单";
  3226. }
  3227. else if($value['source'] == 3)
  3228. {
  3229. $info_list[$key]['source'] = "手机订单";
  3230. }
  3231. if($value['currencytitle'] != "CNY")
  3232. {
  3233. $hl=$value['hl'];
  3234. }
  3235. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3236. $shop = $this->shop->read($value['shop']);
  3237. $info_list[$key]['shop'] = $shop['shopname'];
  3238. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3239. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  3240. $state = $this->typeclass->read($value['state']);
  3241. $info_list[$key]['state'] = $state['title'];
  3242. $country = $this->country->read($value['country']);
  3243. $info_list[$key]['country'] = $country['name'];
  3244. $express = $this->express->read($value['express']);
  3245. $info_list[$key]['express'] = $express['servicename'];
  3246. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  3247. $fpdata = array();
  3248. if(stripos($value['fpdata'],';') !== false)
  3249. {
  3250. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  3251. foreach ($fpdata as $ke=>$va)
  3252. {
  3253. $v = explode('|',rtrim($va,'|'));
  3254. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  3255. }
  3256. }
  3257. $info_list[$key]['fpdata'] = $fpdata;
  3258. $i++;
  3259. }
  3260. $data = array($shouldmoney.' CNY');
  3261. $title = "订单信息表";
  3262. $titlename = "<table border=1>
  3263. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  3264. <tr>
  3265. <td>NO.</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>运单号</td>
  3284. <td>订单备注</td>
  3285. <td>客户备注</td>
  3286. <td>
  3287. <table border=1>
  3288. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  3289. <tr>
  3290. <td>产品</td>
  3291. <td>条数</td>
  3292. <td>数量</td>
  3293. </tr>
  3294. </table>
  3295. </td>
  3296. <td>总条数</td>
  3297. </tr>
  3298. </table>";
  3299. $filename = $title.".xls";
  3300. $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";
  3301. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  3302. }
  3303. }
  3304. public function _black()
  3305. {
  3306. $post = $this->input->post(NULL, TRUE);
  3307. if(isset($post['bd']))
  3308. {
  3309. $bd = $this->input->post('bd',true);
  3310. $rows = $this->fullordersmt->read($bd);
  3311. $post['shop'] = $rows['shop'];
  3312. $post['source'] = 1;
  3313. $post['name'] = $rows['client'];
  3314. $post['email'] = $rows['email'];
  3315. $post['phone'] = $rows['phone'];
  3316. $post['country'] = $rows['country'];
  3317. $post['money'] = $rows['shouldmoney'];
  3318. $post['num'] = 1;
  3319. $post['time'] = $rows['dtime'];
  3320. $post['province'] = $rows['province'];
  3321. $post['city'] = $rows['city'];
  3322. $post['street'] = $rows['street'];
  3323. $post['address'] = $rows['address'];
  3324. $post['address2'] = $rows['address2'];
  3325. $post['zipcode'] = $rows['zipcode'];
  3326. $post['type'] = 2;
  3327. if($this->customer->insert($post))
  3328. {
  3329. $this->fullordersmt->save(array('black'=>1),$bd);
  3330. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3331. }
  3332. else
  3333. {
  3334. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3335. }
  3336. }
  3337. }
  3338. public function _ryf()
  3339. {
  3340. $post = $this->input->post(NULL, TRUE);
  3341. if(isset($post['bd']))
  3342. {
  3343. $bd = $this->input->post('bd',true);
  3344. $d = $this->fullordersmt->read($bd);
  3345. if($d['state'] == 207 || $d['state'] == 207)//订单状态为等待发货或等待部分发货才可更改为允许发货
  3346. {
  3347. if($d['print'] < 3)//打印状态为未打印
  3348. {
  3349. $print = 1;//未打印
  3350. $libraryconfirm = 1;//不允许出库
  3351. $a = "订单未打印,";
  3352. }
  3353. else//已打印订单
  3354. {
  3355. $libraryconfirm = 2;//允许出库
  3356. $a = "";
  3357. }
  3358. if($this->fullordersmt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  3359. {
  3360. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  3361. }
  3362. else
  3363. {
  3364. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3365. }
  3366. }
  3367. if($this->fullordersmt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  3368. {
  3369. echo json_encode(array('msg'=>'操作失败!订单未非发货状态','success'=>false));exit;
  3370. }
  3371. else
  3372. {
  3373. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3374. }
  3375. }
  3376. }
  3377. public function _fsstate()
  3378. {
  3379. $post = $this->input->post(NULL, TRUE);
  3380. if(isset($post['s']))
  3381. {
  3382. $id_arr = $this->input->post('s');
  3383. $id_arr = explode(',',$id_arr);
  3384. if(!$id_arr)
  3385. {
  3386. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  3387. }
  3388. foreach ($id_arr as $v)
  3389. {
  3390. $data = $this->fullordersmt->read($v);
  3391. $warehouse = $this->warehouse->read($data['type']);
  3392. $fs = $this->notice->get_ordertatus($data['state']);
  3393. if($fs)
  3394. {
  3395. $ck = $this->_email($fs['content'],$data,$warehouse['company']);
  3396. if($ck == 1)
  3397. {
  3398. $this->fullordersmt->save(array('fscontent'=>date('Y-m-d H:i:s',time()).'已发送:'.$fs['title'].' - '),$v);
  3399. }
  3400. }
  3401. }
  3402. echo json_encode(array('msg'=>'发送完成!','success'=>true));exit;
  3403. }
  3404. }
  3405. public function _power()
  3406. {
  3407. $user = $this->user->get_api($_SESSION['api']);
  3408. $post = $this->input->post(NULL, TRUE);
  3409. if(isset($post['id']))
  3410. {
  3411. $id = $this->input->post('id',true);
  3412. $fullorder = $this->fullordersmt->read($id);
  3413. $express = $this->express->read($fullorder['express']);
  3414. $warehouse = $this->warehouse->read($fullorder['type']);
  3415. if(($warehouse['zd'] == '1' || stripos($fullorder['whlabel'],'z|') !== false) && $fullorder['library'] == '2')
  3416. {
  3417. echo json_encode(array('msg'=>'需要先退库释放库存后才可重置!','success'=>false));exit;
  3418. }
  3419. /**
  3420. if($fullorder['print'] == '3' && isset($express['iscode']) && ($express['iscode'] == 'ARAMEX' || $express['iscode'] == 'TOLL' || $express['iscode'] == 'FEDEX'))
  3421. {
  3422. $lj = $this->ali->get_lj($fullorder['number'],2,'订单修改');
  3423. if($lj != '1' && $lj != '订单不存在')
  3424. {
  3425. echo json_encode(array('msg'=>$lj,'success'=>false));exit;
  3426. }
  3427. }
  3428. **/
  3429. $this->db->trans_begin();
  3430. $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);
  3431. if($fullorder['merge'] != '0')
  3432. {
  3433. $hdata = $this->fullordersmt->find_all("merge = '".$fullorder['merge']."' and id != '".$id."'");
  3434. foreach ($hdata as $v)
  3435. {
  3436. $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']);
  3437. }
  3438. }
  3439. $warehouse = $this->warehouse->read($fullorder['warehouse']);
  3440. $typeclass = $this->typeclass->read($fullorder['state']);
  3441. $express = $this->express->read($fullorder['express']);
  3442. $printtype = array(1=>'运单',2=>'发货单',3=>'不打印单据');
  3443. $teset['number']=$fullorder['number'];
  3444. $teset['orderinfo']=$fullorder['orderinfo'];
  3445. $teset['shop']=$fullorder['shop'];
  3446. $teset['user']=$user['userid'];
  3447. $teset['ip']=$this->input->ip_address();
  3448. $teset['time']=time();
  3449. $teset['warehouse']=(isset($warehouse['title']))?$warehouse['title']:'未选择';
  3450. $teset['state']=(isset($typeclass['title']))?$typeclass['title']:'未选择';
  3451. $teset['express']=(isset($express['title']))?$express['servicename']:'未选择';
  3452. $teset['printtype']=(isset($printtype[$fullorder['printtype']]))?$printtype[$fullorder['printtype']]:'未选择';
  3453. $teset['reviewtime']=($fullorder['reviewtime'] > '0')?date('Y-m-d H:i:s',$fullorder['reviewtime']):'无';
  3454. $teset['printtime']=($fullorder['printtime'] > '0')?date('Y-m-d H:i:s',$fullorder['printtime']):'无';
  3455. $teset['librarytime']=($fullorder['librarytime'] > '0')?date('Y-m-d H:i:s',$fullorder['librarytime']):'无';
  3456. $teset['shipremarks']=$fullorder['shipremarks'];
  3457. $teset['fpdata']=$fullorder['fpdata'];
  3458. if(!$this->fullreset->insert($teset))
  3459. {
  3460. echo json_encode(array('msg'=>'重置失败,请重试','success'=>true));exit;
  3461. }
  3462. if ($this->db->trans_status() === TRUE)
  3463. {
  3464. $this->db->trans_commit();
  3465. $th_info = $this->retreatlogs->getInfoByNumber($fullorder['number']);
  3466. if(!empty($th_info)){
  3467. $this->retreatlogs->save(array('cz_time'=>time()),$th_info['id']);
  3468. }
  3469. echo json_encode(array('msg'=>'重置成功','success'=>true));exit;
  3470. }
  3471. else
  3472. {
  3473. $this->db->trans_rollback();
  3474. echo json_encode(array('msg'=>'重置失败,请重试','success'=>false));exit;
  3475. }
  3476. }
  3477. }
  3478. public function _expresstype()
  3479. {
  3480. $post = $this->input->post(NULL, TRUE);
  3481. if(isset($post['id']))
  3482. {
  3483. $id = $this->input->post('id',true);
  3484. $data = $this->express->read($id);
  3485. echo json_encode(array('msg'=>$data['type'],'success'=>true));exit;
  3486. }
  3487. }
  3488. public function _email($content,$data,$shopname)
  3489. {
  3490. $express = $this->express->read($data['express']);
  3491. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  3492. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  3493. $content = str_replace($t,$h,$content);
  3494. $this->load->library('email');
  3495. $config['protocol'] = 'smtp';
  3496. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  3497. $config['smtp_port'] = 465;
  3498. $config['smtp_user'] = 'service@email.supernovahair.com';
  3499. $config['smtp_pass'] = 'LONGyihair374';
  3500. $config['smtp_crypto'] = 'ssl';
  3501. $config['crlf'] = "\r\n";
  3502. $config['newline'] = "\r\n";
  3503. $this->email->initialize($config);
  3504. $this->email->from('service@email.supernovahair.com',$shopname);
  3505. $this->email->to($data['email']);//收件
  3506. $this->email->subject('The product you purchased has a new progress');//标题
  3507. $this->email->message($content);//内容
  3508. if ( ! $this->email->send())
  3509. {
  3510. return 2;
  3511. }
  3512. else
  3513. {
  3514. return 1;
  3515. }
  3516. }
  3517. public function _error()
  3518. {
  3519. if(isset($_SESSION['api']))
  3520. {
  3521. $user = $this->user->get_api($_SESSION['api']);
  3522. $usp = $user;
  3523. $fgshop = "";$sid = "";
  3524. $user = explode('|',trim($user['shop'],'|'));
  3525. foreach ($user as $value)
  3526. {
  3527. $fgshop .= " shop = ".$value." or";
  3528. $sid .= " id = ".$value." or";
  3529. }
  3530. }
  3531. $post = $this->input->post(NULL, TRUE);
  3532. if(isset($post['page']))
  3533. {
  3534. $page = $this->input->post('page',true);
  3535. $perpage = $this->input->post('perpage',true);
  3536. $orderinfo = $this->input->post('orderinfo',true);
  3537. $waybill = $this->input->post('waybill',true);
  3538. $number = $this->input->post('number',true);
  3539. $timetk = $this->input->post('timetk',true);
  3540. $timetj = $this->input->post('timetj',true);
  3541. $timetk = strtotime($timetk);
  3542. $timetj = strtotime($timetj);
  3543. $where = "failed !='' and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3544. if($orderinfo)
  3545. {
  3546. $where .= " and orderinfo = '$orderinfo'";
  3547. }
  3548. if($waybill)
  3549. {
  3550. $where .= " and waybill = '$waybill'";
  3551. }
  3552. if($number)
  3553. {
  3554. $where .= " and number = '$number'";
  3555. }
  3556. if($timetk && $timetj)
  3557. {
  3558. $timetj = $timetj+24*3600;
  3559. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3560. }
  3561. //数据排序
  3562. $order_str = "dtime desc";
  3563. if(empty($page))
  3564. {
  3565. $start = 0;
  3566. $perpage = 1;
  3567. }
  3568. else
  3569. {
  3570. $start = ($page - 1)*$perpage;
  3571. }
  3572. $info_list = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,express,failed,operation',$order_str,$start,$perpage);
  3573. //格式化数据
  3574. foreach ($info_list as $key=>$value)
  3575. {
  3576. $ud = $this->fullordersmt->read($value['id']);
  3577. $shop = $this->shop->read($value['shop']);
  3578. $info_list[$key]['shop'] = $shop['shopname'];
  3579. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  3580. $warehouse = $this->warehouse->read($value['type']);
  3581. $warehousetitle = $warehouse['title'];
  3582. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  3583. $info_list[$key]['type'] = $warehousetitle;
  3584. if($value['express'] != 0)
  3585. {
  3586. $express = $this->express->read($value['express']);
  3587. $expressservicename = $express['servicename'];
  3588. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  3589. $info_list[$key]['express'] = $expressservicename;
  3590. }
  3591. else
  3592. {
  3593. $info_list[$key]['express'] = "无";
  3594. }
  3595. $x = "";
  3596. if($ud['review'] >4 && $ud['print'] == 1)
  3597. {
  3598. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  3599. }
  3600. else if($ud['review'] >4 && $ud['print'] == 3 && $ud['libraryconfirm'] == 1)
  3601. {
  3602. $x = "<p class='ckn'><b class='fojzof' data-type='10' data-id='".$value['id']."'>清除错误</b></p>";
  3603. }
  3604. else
  3605. {
  3606. $x = "<p class='ckn'><b class='fojzof' data-type='9' data-id='".$value['id']."'>关闭</b></p>";
  3607. }
  3608. $info_list[$key]['operation'] = $x;
  3609. }
  3610. $total = $this->fullordersmt->find_count($where);
  3611. $pagenum = ceil($total/$perpage);
  3612. $over = $total-($start+$perpage);
  3613. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3614. echo json_encode($rows);exit;
  3615. }
  3616. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3617. $this->data['wlshop'] = $wlshop;
  3618. $this->data['express'] = $this->express->find_all();
  3619. $user = $this->user->get_api($_SESSION['api']);
  3620. $powerid = $this->power->read($user['power']);
  3621. $powertext = explode('|',trim($powerid['excelid'],'|'));
  3622. $pid = '';
  3623. foreach ($powertext as $v)
  3624. {
  3625. $pid .= " id = ".$v." or";
  3626. }
  3627. $fullorderexcel = $this->fullorderexcel->find_all("type = '100004' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  3628. $this->data['fullorderexcel'] = $fullorderexcel;
  3629. $this->_Template('fullordersmt_error',$this->data);
  3630. }
  3631. //关闭订单详情时保存备注
  3632. public function _bcbz()
  3633. {
  3634. $post = $this->input->post(NULL, TRUE);
  3635. if(isset($post['id']))
  3636. {
  3637. $fpcount = $this->input->post('fpcount',true);
  3638. if(!$fpcount)
  3639. {
  3640. echo json_encode(array('msg'=>'未设置商品信息!','success'=>false));exit;
  3641. }
  3642. $post['edittime'] = time();
  3643. $fpdata = $this->input->post('fpdata');
  3644. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  3645. $post['fpdata'] = $fpdata;
  3646. $post['state'] = $this->input->post('state');
  3647. $post['type'] = $this->input->post('warehouse');
  3648. $post['ioss'] = $this->input->post('ioss');
  3649. $rtime = $this->input->post('rtime',true);
  3650. if($rtime)
  3651. {
  3652. $post['rtime'] = strtotime($rtime);
  3653. }
  3654. $id = $this->input->post('id',TRUE);
  3655. $whlabel = $this->input->post('whlabel',true);
  3656. $data = $this->fullordersmt->read($id);
  3657. $editstate = $post['state'];
  3658. if($data['library'] == 1)
  3659. {
  3660. if($data['print'] != 3 && $data['review'] < 5)
  3661. {
  3662. $post['libraryconfirm'] = 1;
  3663. $post['librarynot'] = "订单未打印";
  3664. }
  3665. else if($data['print'] != 3 && $data['review'] > 4)
  3666. {
  3667. $post['print'] = 1;
  3668. $post['libraryconfirm'] = 1;
  3669. $post['librarynot'] = "订单未打印,订单审核后修改";
  3670. }
  3671. else
  3672. {
  3673. $post['libraryconfirm'] = 1;
  3674. $post['librarynot'] = "订单打印后修改";
  3675. }
  3676. }
  3677. if($data['yhs'] == 1)
  3678. {
  3679. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  3680. }
  3681. 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))
  3682. {
  3683. echo json_encode(array('msg'=>'此快递方式必须选择美国仓!','success'=>false));exit;
  3684. }
  3685. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '31') && $data['country'] != 192)
  3686. {
  3687. echo json_encode(array('msg'=>'非美国无法选择Fedex!','success'=>false));exit;
  3688. }
  3689. if(($post['express'] == '28' || $post['express'] == '7') && $data['country'] != 191)
  3690. {
  3691. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  3692. }
  3693. $express = $this->express->read($post['express']);
  3694. if($express['ioss'] == 1 && $post['ioss'] == '')
  3695. {
  3696. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  3697. }
  3698. if(isset($post['address']) && (strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize']))
  3699. {
  3700. echo json_encode(array('msg'=>'此快递地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
  3701. }
  3702. if($data['type'] != '5' && $post['type'] == '5' && $editstate != '207')
  3703. {
  3704. echo json_encode(array('msg'=>'等待发货状态才可选择美仓!','success'=>false));exit;
  3705. }
  3706. if($data['library'] == 2 && $data['print'] == 3 && $data['waybill'] != $post['waybill'])
  3707. {
  3708. echo json_encode(array('msg'=>'不允许修改运单号','success'=>true));exit;
  3709. }
  3710. //南非 限制邮箱
  3711. if($post['country'] == 166){
  3712. if(empty($post['email'])){
  3713. echo json_encode(array('msg'=>'惠程安迈世发货需要有邮箱!','success'=>false));exit;
  3714. }else{
  3715. if(!$this->logic_order->checkEmail($post['email'])){
  3716. echo json_encode(array('msg'=>'邮箱格式不正确!','success'=>false));exit;
  3717. }
  3718. }
  3719. }
  3720. if(empty($post['zsbjz']*1)){
  3721. echo json_encode(array('msg'=>'申报金额不可为0!','success'=>false));exit;
  3722. }
  3723. if(empty($post['dtsbjz']*1)){
  3724. echo json_encode(array('msg'=>'单条申报价值不能为0!','success'=>false));exit;
  3725. }
  3726. $thisdata = $data;
  3727. $warehouse = $this->warehouse->read($thisdata['type']);
  3728. $warehousenew = $this->warehouse->read($post['type']);
  3729. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  3730. {
  3731. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  3732. }
  3733. /**
  3734. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  3735. {
  3736. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  3737. }
  3738. **/
  3739. if($data['shop'] == '9' && $post['type'] != '7' && $post['type'] != '8' && $post['type'] != '9')
  3740. {
  3741. echo json_encode(array('msg'=>'仓库选择错误!','success'=>false));exit;
  3742. }
  3743. //减少代码复用吧
  3744. $lo_ret = $this->logic_order->checkEditExpress($post,['plat'=>'fullordersmt']);
  3745. if($lo_ret['code'] != 1){
  3746. echo json_encode(array('msg'=>$lo_ret['msg'],'success'=>false));exit;
  3747. }
  3748. /**
  3749. if($warehousenew['zd'] == '1' && $editstate != $thisdata['state'] && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  3750. {
  3751. echo json_encode(array('msg'=>'如需更改订单状态,请先把仓库选择为非开启库存模式仓库或等待订单出库!','success'=>false));exit;
  3752. }
  3753. if($warehousenew['zd'] == '1' && $editstate != '207' && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  3754. {
  3755. echo json_encode(array('msg'=>'非待发货状态,不允许修改为开启库存模式仓库','success'=>false));exit;
  3756. }
  3757. **/
  3758. //开始注释 xyxg
  3759. /**
  3760. $ft = array();
  3761. $ftdata = explode('|',rtrim($fpcount,'|'));
  3762. foreach ($ftdata as $va)
  3763. {
  3764. $ftitle = '';
  3765. $va = explode('-',trim($va,'-'));
  3766. foreach ($va as $v)
  3767. {
  3768. $v = $this->typeclass->read($v);
  3769. $ftitle .= $v['title'].' ';
  3770. }
  3771. $ft[] = rtrim($ftitle,' ');
  3772. }
  3773. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  3774. {
  3775. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  3776. if($tskcyz['t'] > '0')
  3777. {
  3778. echo $tskcyz['m'];exit;
  3779. }
  3780. }
  3781. $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']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  3782. if($kcyz['t'] > '0')
  3783. {
  3784. echo $kcyz['m'];exit;
  3785. }
  3786. else
  3787. {
  3788. if($this->fullordersmt->save($post,$id))
  3789. {
  3790. echo json_encode(array('msg'=>'保存成功','id'=>$id,'a'=>$kcyz,'success'=>true));exit;
  3791. }
  3792. else
  3793. {
  3794. echo json_encode(array('msg'=>'保存失败,请重试','success'=>false));exit;
  3795. }
  3796. }
  3797. //结束注释
  3798. **/
  3799. $warehouse = $this->warehouse->read($post['type']);
  3800. if($data['library'] == 1 || ($data['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  3801. {
  3802. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  3803. if($kcyz['t'] > '0')
  3804. {
  3805. echo $kcyz['m'];exit;
  3806. }
  3807. else if($kcyz['fpdata'] != '')
  3808. {
  3809. $post['whlabel'] = $kcyz['whlabel'];
  3810. $post['fpdata'] = $kcyz['fpdata'];
  3811. }
  3812. }
  3813. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  3814. $post['sfxh'] = $fl['sfxh'];
  3815. $post['ckfl'] = $fl['ckfl'];
  3816. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  3817. if($this->fullordersmt->save($post,$id))
  3818. {
  3819. echo json_encode(array('msg'=>'保存成功','id'=>$id,'success'=>true));exit;
  3820. }
  3821. else
  3822. {
  3823. echo json_encode(array('msg'=>'保存失败,请重试','success'=>false));exit;
  3824. }
  3825. }
  3826. }
  3827. //验证地址
  3828. public function _yzaddress()
  3829. {
  3830. $post = $this->input->post(NULL, TRUE);
  3831. if(isset($post['address']))
  3832. {
  3833. $address = $this->input->post('address',true);
  3834. $address2 = $this->input->post('address2',true);
  3835. $city = $this->input->post('city',true);
  3836. $province = $this->input->post('province',true);
  3837. $zipcode = $this->input->post('zipcode',true);
  3838. $barcode = $this->usps->get_address(array('address'=>$address,'address2'=>$address2,'city'=>$city,'province'=>$province,'zipcode'=>$zipcode));
  3839. echo $barcode;
  3840. }
  3841. }
  3842. //订单退货
  3843. public function _return()
  3844. {
  3845. $post = $this->input->post(NULL, TRUE);
  3846. if(isset($post['orderinfo']))
  3847. {
  3848. $orderinfo = $this->input->post('orderinfo',true);
  3849. $data = $this->fullordersmt->get_orderinfo($orderinfo);
  3850. $fu = 'fullordersmt';
  3851. $bctime = date('Ymd',time());
  3852. if($data['returndata'] != "")
  3853. {
  3854. echo json_encode(array('msg'=>'请求失败,已有退货信息!','success'=>false));exit;
  3855. }
  3856. if($data['library'] != 2){
  3857. echo json_encode(array('msg'=>'此单不是出库状态,不允许退货','success'=>false));exit;
  3858. }
  3859. $barcode = $this->usps->get_return($data);
  3860. if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  3861. {
  3862. echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  3863. }
  3864. else
  3865. {
  3866. $pdf = $this->_pdf($barcode['ReturnLabel'],'t-'.$barcode['TrackingNumber'],$bctime);
  3867. $read = 'PostalRouting:'.$barcode['PostalRouting'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['TrackingNumber'].'.pdf" target="_blank">'.$barcode['TrackingNumber'].'</a>';
  3868. $this->$fu->save(array('returndata'=>$read),$data['id']);
  3869. echo json_encode(array('msg'=>'退货成功!','data'=>$read,'success'=>true));exit;
  3870. }
  3871. }
  3872. }
  3873. public function _pdf($pdf,$title,$bctime)
  3874. {
  3875. $pdf_path = './data/pdf/'.$bctime.'/';
  3876. $file_base64 = $pdf;
  3877. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  3878. $file_base64 = base64_decode($file_base64);
  3879. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  3880. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  3881. return $bctime;
  3882. }
  3883. //管理
  3884. public function _aaa()
  3885. {
  3886. $dt = 0;
  3887. if(isset($_SESSION['api']))
  3888. {
  3889. $user = $this->user->get_api($_SESSION['api']);
  3890. $usp = $user;
  3891. $fgshop = "";$sid = "";
  3892. $user = explode('|',trim($user['shop'],'|'));
  3893. foreach ($user as $value)
  3894. {
  3895. $fgshop .= " shop = ".$value." or";
  3896. $sid .= " id = ".$value." or";
  3897. }
  3898. }
  3899. $post = $this->input->post(NULL, TRUE);
  3900. if(isset($post['page']))
  3901. {
  3902. $page = $this->input->post('page',true);
  3903. $perpage = $this->input->post('perpage',true);
  3904. $warehouse = $this->input->post('warehouse',true);
  3905. $timetk = $this->input->post('timetkk',true);
  3906. $timetj = $this->input->post('timetjj',true);
  3907. $shop = $this->input->post('shop',true);
  3908. $source = $this->input->post('source',true);
  3909. $state = $this->input->post('state',true);
  3910. $review = $this->input->post('review',true);
  3911. $type = $this->input->post('type',true);
  3912. $express = $this->input->post('express',true);
  3913. $orderinfo = $this->input->post('orderinfo',true);
  3914. $user = $this->input->post('user',true);
  3915. $client = $this->input->post('name',true);
  3916. $fullname = $this->input->post('fullname',true);
  3917. $waybill = $this->input->post('waybill',true);
  3918. $number = $this->input->post('number',true);
  3919. $email = $this->input->post('email',true);
  3920. $dlz = $this->input->post('dlz',true);
  3921. $print = $this->input->post('print',true);
  3922. $library = $this->input->post('library',true);
  3923. $xztime = $this->input->post('xztime',true);
  3924. $timetk = strtotime($timetk)-1;
  3925. $timetj = strtotime($timetj);
  3926. $px = $this->input->post('px',true);
  3927. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3928. if($warehouse)
  3929. {
  3930. $where .= " and type = '$warehouse'";
  3931. }
  3932. if($timetk && $timetj)
  3933. {
  3934. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3935. }
  3936. if($shop)
  3937. {
  3938. $where .= " and shop = '$shop'";
  3939. }
  3940. if($source)
  3941. {
  3942. $where .= " and source = '$source'";
  3943. }
  3944. if($state)
  3945. {
  3946. $where .= " and state = '$state'";
  3947. }
  3948. if($review)
  3949. {
  3950. $where .= " and review = '$review'";
  3951. }
  3952. if($type)
  3953. {
  3954. $where .= " and type = '$type'";
  3955. }
  3956. if($express)
  3957. {
  3958. $where .= " and express = '$express'";
  3959. }
  3960. if($orderinfo)
  3961. {
  3962. $where .= " and orderinfo = '$orderinfo'";
  3963. }
  3964. if($user)
  3965. {
  3966. $where .= " and user = '$user'";
  3967. }
  3968. if($client)
  3969. {
  3970. $where .= " and client like '%$client%'";
  3971. }
  3972. if($waybill)
  3973. {
  3974. $where .= " and waybill = '$waybill'";
  3975. }
  3976. if($number)
  3977. {
  3978. $where .= " and number = '$number'";
  3979. }
  3980. if($email)
  3981. {
  3982. $where .= " and email = '$email'";
  3983. }
  3984. if($library)
  3985. {
  3986. $where .= " and library = '$library'";
  3987. }
  3988. if($print)
  3989. {
  3990. $where .= " and print = '$print'";
  3991. }
  3992. if($dlz != '')
  3993. {
  3994. $where .= " and dlz = '$dlz'";
  3995. }
  3996. if($fullname)
  3997. {
  3998. $where .= " and fullname = '$fullname'";
  3999. }
  4000. //数据排序
  4001. if($px)
  4002. {
  4003. $order_str = $px." desc";
  4004. }
  4005. else
  4006. {
  4007. $order_str = "numberpx desc";
  4008. }
  4009. if(empty($page))
  4010. {
  4011. $start = 0;
  4012. $perpage = 1;
  4013. }
  4014. else
  4015. {
  4016. $start = ($page - 1)*$perpage;
  4017. }
  4018. //取得信息列表id,shop,type,source,user,orderinfo,number,name,state,buytime,clientremarks,review,print,library,libraryconfirm,express,waybill,orderremarks,black
  4019. $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);
  4020. //格式化数据
  4021. foreach ($info_list as $key=>$value)
  4022. {
  4023. $ud = $this->fullordersmt1->read($value['id']);
  4024. $ud['address'] = str_replace("'","’",$ud['address']);
  4025. $ud['name'] = str_replace("'","’",$ud['name']);
  4026. $customer = $ud['source'] != 1?$this->customersmt1->get_fullname($ud['fullname']):$this->customersmt1->get_shopdata($value['shop'],$ud['name'],$ud['address']);
  4027. //$a = array_column($customer, 'email'); //三维找其中健的数组
  4028. //$a = array_flip($a); //键和值调换
  4029. $currency = $this->country->read($ud['country']);
  4030. $name = ($ud['source'] == 1)?$ud['name']:$value['fullname'];
  4031. $lkh = "<p>".$name."</p><p style='color:#8f54fb'>".$currency['ename']."</p>";
  4032. if($customer)
  4033. {
  4034. if($customer['type'] == 1 && $customer['num'] > 1)
  4035. {
  4036. $lkh .= "<p style='color:#FF3333'>老客户</p>";
  4037. }
  4038. else if($customer['type'] == 2)
  4039. {
  4040. $hmsp = $this->shop->read($customer[0]['shop']);
  4041. $lkh .= "<p style='color:#9900CC'>黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  4042. }
  4043. }
  4044. $info_list[$key]['fullname'] = $lkh;
  4045. $shop = $this->shop->read($value['shop']);
  4046. $info_list[$key]['shop'] = $shop['shopname'];
  4047. //$info_list[$key]['user'] = $shop['shopuser'];
  4048. $warehouse = $this->warehouse->read($value['type']);
  4049. $warehousetitle = $warehouse['title'];
  4050. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4051. $info_list[$key]['type'] = $warehousetitle;
  4052. $typeclass = $this->typeclass->read($value['state']);
  4053. if($ud['source'] != 1)
  4054. {
  4055. $info_list[$key]['state'] = "<a href='https://trade.aliexpress.com/order_detail.htm?orderId=".$value['orderinfo']."' target='_blank'>".$typeclass['title']."</a>";
  4056. }
  4057. else
  4058. {
  4059. $info_list[$key]['state'] = $typeclass['title'];
  4060. }
  4061. if(!$value['buytime'])
  4062. {
  4063. $info_list[$key]['buytime'] = '<p>无</p>';
  4064. }
  4065. else
  4066. {
  4067. $info_list[$key]['buytime'] = '<p>'.date('Y-m-d',$value['buytime']-$dt).'</p><p>'.date('H:i:s',$value['buytime']-$dt).'</p>';
  4068. }
  4069. if($value['review'] == 1)
  4070. {
  4071. $info_list[$key]['review'] = "未送审";
  4072. }
  4073. else if($value['review'] == 2)
  4074. {
  4075. $info_list[$key]['review'] = "<font style='color:#555'>待审核</font>";
  4076. }
  4077. else if($value['review'] == 3)
  4078. {
  4079. $info_list[$key]['review'] = "<font style='color:#f90f4b'>不通过</font>";
  4080. }
  4081. else if($value['review'] == 4)
  4082. {
  4083. $info_list[$key]['review'] = "取消重审";
  4084. }
  4085. else if($value['review'] == 5)
  4086. {
  4087. $info_list[$key]['review'] = "<font style='color:#2f80f9'>审核通过</font>";
  4088. }
  4089. else if($value['review'] == 6)
  4090. {
  4091. $info_list[$key]['review'] = "<font style='color:#2f80f9'>自动通过</font>";
  4092. }
  4093. if($ud['dlz'] == 1)
  4094. {
  4095. $dlz = "<p>发货声明成功</p>";
  4096. }
  4097. else if($ud['dlz'] == 3)
  4098. {
  4099. $dlz = "<p>不需要发货声明</p>";
  4100. }
  4101. else if($ud['dlz'] == 2)
  4102. {
  4103. $dlz = "<p style='color:#C3C'>发货声明失败</p>";
  4104. }
  4105. else
  4106. {
  4107. $dlz = "";
  4108. }
  4109. if($value['waybill'] != "")
  4110. {
  4111. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  4112. if( !empty($value['waybillid'])){
  4113. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz."<p>".$value['waybillid']."</p>";
  4114. }
  4115. }
  4116. if($value['express'] != 0)
  4117. {
  4118. $express = $this->express->read($value['express']);
  4119. $expressservicename = $express['servicename'];
  4120. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4121. $info_list[$key]['express'] = $expressservicename;
  4122. }
  4123. else
  4124. {
  4125. $info_list[$key]['express'] = "无";
  4126. }
  4127. $x = "";
  4128. if($value['libraryconfirm'] == 2 && $value['review'] > 4 && $ud['library'] == 1)
  4129. {
  4130. $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
  4131. }
  4132. else if(($value['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
  4133. {
  4134. $x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
  4135. }
  4136. if(($value['review'] > 4) && $ud['print'] == 2)
  4137. {
  4138. $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
  4139. }
  4140. else if($value['review'] >4 && $ud['print'] == 1)
  4141. {
  4142. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  4143. }
  4144. if($value['waybill'] == "" && $value['review'] > 4)
  4145. {
  4146. $x .= "<p><b class='kn' data-type='2'>填写运单号</b></p>";
  4147. }
  4148. else if($value['waybill'] != "" && $value['review'] > 4)
  4149. {
  4150. $x .= "<p><b class='kn' data-type='2'>修改运单</b></p>";
  4151. }
  4152. 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)
  4153. {
  4154. $x .= "<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
  4155. }
  4156. $x .= "<p><b class='window' data-h='/customersmt/edit/".$customer['id']."' data-t='客户信息 - 修改'>客户信息</b></p>";
  4157. $info_list[$key]['black'] = $x;
  4158. $tly = "";
  4159. if($value['clientremarks'] != "")
  4160. {
  4161. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  4162. }
  4163. if($value['review'] > 4 && $usp['vip'] != 1)
  4164. {
  4165. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/readonly/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  4166. }
  4167. else
  4168. {
  4169. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordersmt/b/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  4170. }
  4171. if($value['library'] == 1 && $ud['printtype'] == 3)
  4172. {
  4173. $info_list[$key]['library'] = "不需要";
  4174. }
  4175. else if($value['library'] == 1 && $ud['printtype'] != 3)
  4176. {
  4177. $info_list[$key]['library'] = "未出库";
  4178. }
  4179. else if($value['library'] == 2)
  4180. {
  4181. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  4182. }
  4183. else if($value['library'] == 3)
  4184. {
  4185. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  4186. }
  4187. unset($info_list[$key]['waybillid']);
  4188. }
  4189. $total = $this->fullordersmt1->find_count($where);
  4190. $pagenum = ceil($total/$perpage);
  4191. $over = $total-($start+$perpage);
  4192. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4193. echo json_encode($rows);exit;
  4194. }
  4195. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4196. $this->data['wlshop'] = $wlshop;
  4197. $this->data['express'] = $this->express->find_all();
  4198. $user = $this->user->get_api($_SESSION['api']);
  4199. $powerid = $this->power->read($user['power']);
  4200. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4201. $pid = '';
  4202. foreach ($powertext as $v)
  4203. {
  4204. $pid .= " id = ".$v." or";
  4205. }
  4206. $fullorderexcel = $this->fullorderexcel->find_all("type = '100004' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4207. $this->data['fullorderexcel'] = $fullorderexcel;
  4208. $error = $this->fullordersmt1->find_count("print = 1 and failed !='' and mergeid = 0 and waybill = '' and (".rtrim($fgshop,'or').")");
  4209. $this->data['error'] = $error;
  4210. $this->_Template('fullordersmt_a',$this->data);
  4211. }
  4212. public function _bbb($arg_array)
  4213. {
  4214. $post = $this->input->post(NULL, TRUE);
  4215. if(isset($post['id']))
  4216. {
  4217. $id = $this->input->post('id',true);
  4218. $data = $this->fullordersmt1->read($id);
  4219. $post['type'] = $this->input->post('warehouse',true);
  4220. $post['country'] = $this->input->post('country',true);
  4221. $currency = $this->country->read($post['country']);
  4222. $post['al'] = $currency['lb'];
  4223. $post['freight'] = $this->input->post('freight',true);
  4224. $post['expressmoney'] = $this->input->post('expressmoney',true);
  4225. $post['shouldmoney'] = $this->input->post('shouldmoney',true);
  4226. $post['orderremarks'] = $this->input->post('orderremarks',true);
  4227. $shipremarks = $this->input->post('shipremarks');
  4228. $shipremarks = str_replace(array('%26','%2B'),array('&','+'),$shipremarks);
  4229. $post['shipremarks'] = preg_replace('/( | | |\s)/',' ',$shipremarks);
  4230. $post['email'] = $this->input->post('email',true);
  4231. $name = $this->input->post('name',true);
  4232. $post['name'] = str_replace("'","’",$name);
  4233. $post['phone'] = $this->input->post('phone',true);
  4234. $post['country'] = $this->input->post('country',true);
  4235. $post['province'] = $this->input->post('province',true);
  4236. $post['city'] = $this->input->post('city',true);
  4237. $post['zipcode'] = $this->input->post('zipcode',true);
  4238. $post['street'] = $this->input->post('street',true);
  4239. $address = $this->input->post('address',true);
  4240. $post['address'] = str_replace("'","’",$address);
  4241. $post['express'] = $this->input->post('express',true);
  4242. $post['printtype'] = $this->input->post('printtype',true);
  4243. $post['fpdata'] = $this->input->post('fpdata');
  4244. $post['waybill'] = $this->input->post('waybill',true);
  4245. $post['msg'] = $this->input->post('msg',true);
  4246. $post['zsbjz'] = $this->input->post('zsbjz',true);
  4247. $post['refundy'] = $this->input->post('refundy',true);
  4248. $post['refundj'] = $this->input->post('refundj',true);
  4249. $rtime = $this->input->post('rtime',true);
  4250. $post['rtime'] = strtotime($rtime);
  4251. $post['rpaypal'] = $this->input->post('rpaypal',true);
  4252. $post['rtext'] = $this->input->post('rtext',true);
  4253. $editstate = $this->input->post('state',true);
  4254. $post['review'] = 1;
  4255. if($post['zsbjz'] < '0.01')
  4256. {
  4257. echo json_encode(array('msg'=>'总申报价错误!','success'=>false));exit;
  4258. }
  4259. if($data['library'] == 1)
  4260. {
  4261. if($data['print'] != 3 && $data['review'] < 5)
  4262. {
  4263. $post['libraryconfirm'] = 1;
  4264. $post['librarynot'] = "订单未打印";
  4265. }
  4266. else if($data['print'] != 3 && $data['review'] > 4)
  4267. {
  4268. $post['print'] = 1;
  4269. $post['libraryconfirm'] = 1;
  4270. $post['librarynot'] = "订单未打印,订单审核后修改";
  4271. }
  4272. else
  4273. {
  4274. $post['libraryconfirm'] = 1;
  4275. $post['librarynot'] = "订单打印后修改";
  4276. }
  4277. }
  4278. if($post['printtype'] == 1)//如果是运单
  4279. {
  4280. $post['productdescription'] = $this->input->post('productdescription',true);
  4281. $post['customs'] = $this->input->post('customs',true);
  4282. }
  4283. /**
  4284. if($editstate == 216 && $data['state'] != 216)
  4285. {
  4286. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  4287. }
  4288. **/
  4289. if($editstate == 216 && preg_match('/\d/is',$post['waybill']) != true)
  4290. {
  4291. echo json_encode(array('msg'=>'当前信息不可修改订单状态','success'=>false));exit;
  4292. }
  4293. else
  4294. {
  4295. if($data['review'] == 1 && $data['source'] != 1)
  4296. {
  4297. $review = 6;
  4298. }
  4299. else if($data['review'] == 3 || ($data['review'] == 1 && $data['source'] == 1))
  4300. {
  4301. $review = 2;
  4302. }
  4303. else
  4304. {
  4305. $review = $data['review'];
  4306. }
  4307. $post['review'] = $review;
  4308. $post['state'] = $editstate;
  4309. $post['reviewtime'] = time();
  4310. }
  4311. if($this->fullordersmt1->save($post,$id))
  4312. {
  4313. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  4314. }
  4315. else
  4316. {
  4317. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  4318. }
  4319. }
  4320. $arg_array = $arg_array[0];$fpdata = array();
  4321. $fullordersmt = $this->fullordersmt1->read($arg_array);
  4322. $fullordersmt['parameter'] = str_replace(",","---",$fullordersmt['parameter']);
  4323. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  4324. $express = $this->express->find_all('1=1');//所有快递配置信息
  4325. $this->data['fullordersmt'] = $fullordersmt;
  4326. $this->data['country'] = $country;
  4327. $this->data['express'] = $express;
  4328. $this->data['dtime'] = date('Y-m-d H:i:s',$fullordersmt['dtime']);
  4329. if(stripos($fullordersmt['fpdata'],';') !== false)
  4330. {
  4331. $fpdata = explode(';',rtrim($fullordersmt['fpdata'],';'));
  4332. foreach ($fpdata as $k=>$v)
  4333. {
  4334. $fpdata[$k] = explode('|',$v);
  4335. }
  4336. }
  4337. $this->data['fpdata'] = $fpdata;
  4338. $shop = $this->shop->read($fullordersmt['shop']);
  4339. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  4340. $is = 0;
  4341. if($shop['type'] == 269)//判断是否独立站,269是独立站
  4342. {
  4343. $is = 1;
  4344. }
  4345. $this->data['is'] = $is;
  4346. if(isset($_SESSION['api']))
  4347. {
  4348. $user = $this->user->get_api($_SESSION['api']);
  4349. if($user['vip'] == 1)
  4350. {
  4351. $vip = 1;
  4352. }
  4353. else
  4354. {
  4355. $vip = 0;
  4356. }
  4357. }
  4358. else
  4359. {
  4360. $vip = 0;
  4361. }
  4362. $this->data['power'] = $vip;
  4363. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  4364. $downwaybill = '';
  4365. if($fullordersmt['printtype'] == 1)
  4366. {
  4367. if($fullordersmt['waybill'] != '')
  4368. {
  4369. $downwaybill .= '<a href="/data/pdf/'.date('Ymd',$fullordersmt['printtime']).'/y-'.$fullordersmt['waybill'].'.pdf" target="_blank">'.$fullordersmt['waybill'].'</a>、';
  4370. }
  4371. }
  4372. $oldwaybill = explode('-',ltrim($fullordersmt['oldwaybill'],'-'));
  4373. if(isset($oldwaybill[0][1]))
  4374. {
  4375. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  4376. foreach ($oldwaybill as $v)
  4377. {
  4378. $dw = explode('/',$v);
  4379. if(isset($dw[1]))
  4380. {
  4381. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  4382. }
  4383. }
  4384. }
  4385. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  4386. /** 历史打印时间 **/
  4387. $printtime = '';
  4388. if($fullordersmt['oldprinttime'])
  4389. {
  4390. $pte = explode('-',rtrim($fullordersmt['oldprinttime'],'-'));
  4391. foreach ($pte as $v)
  4392. {
  4393. $printtime .= date('Y-m-d H:i:s',$v).'、';
  4394. }
  4395. }
  4396. $this->data['printtime'] = rtrim($printtime,'、');
  4397. $this->_Template('fullordersmt_b',$this->data);
  4398. }
  4399. public function _cf() //速卖通订单拆分
  4400. {
  4401. $post = $this->input->post(NULL, TRUE);
  4402. if(isset($post['id']))
  4403. {
  4404. $id = $this->input->post('id',true);
  4405. $b = $this->fullordersmt->read($id);
  4406. $order = array();
  4407. if($b['merge'] == $b['id'])
  4408. {
  4409. $data = $this->fullordersmt->find_all("merge = '".$b['merge']."'");
  4410. foreach ($data as $v)
  4411. {
  4412. $a = $this->fullordersmthb->get_orderinfo($v['orderinfo']);
  4413. if($a)
  4414. {
  4415. $this->fullordersmt->save($a,$v['id']);
  4416. }
  4417. $order[] = $v['id'];
  4418. }
  4419. echo json_encode(array('msg'=>'拆分成功!','d'=>$order,'success'=>true));exit;
  4420. }
  4421. else
  4422. {
  4423. echo json_encode(array('msg'=>'拆分条件错误!','success'=>false));exit;
  4424. }
  4425. }
  4426. }
  4427. public function _epod()
  4428. {
  4429. $post = $this->input->post(NULL, TRUE);
  4430. if(isset($post['number']))
  4431. {
  4432. $number = $this->input->post('number',true);
  4433. $data = $this->fullordersmt->get_number($number);
  4434. if(is_file('./data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf'))
  4435. {
  4436. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf','success'=>true));exit;
  4437. }
  4438. else
  4439. {
  4440. $epod = $this->dhl->get_epod($data);
  4441. if($epod['c'] == 1)
  4442. {
  4443. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].$epod['d'],'success'=>true));exit;
  4444. }
  4445. else
  4446. {
  4447. echo json_encode(array('msg'=>$epod['d'],'success'=>false));exit;
  4448. }
  4449. }
  4450. }
  4451. }
  4452. public function _ddcf()
  4453. {
  4454. $post = $this->input->post(NULL, TRUE);
  4455. if(isset($post['number']))
  4456. {
  4457. $number = $this->input->post('number',true);
  4458. $data = $this->fullordersmt->get_number($number);
  4459. if(!$data)
  4460. {
  4461. echo json_encode(array('msg'=>'没有找到此订单','success'=>false));exit;
  4462. }
  4463. if($data['review'] != 1 && $data['review'] != 2)
  4464. {
  4465. echo json_encode(array('msg'=>'必须是 待审核 状态才能拆分','success'=>false));exit;
  4466. }
  4467. $cfnum = explode('-',trim($number,'-'));
  4468. if((count($cfnum)> 3 && stripos($pd[$x],'-PF-') !== false) || (count($cfnum)> 4 && stripos($pd[$x],'-PF-') === false))
  4469. {
  4470. echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  4471. }
  4472. $num = $this->fullordersmt->find_count("number like '".$number."%'");
  4473. $data['number'] = $data['number'].'-'.$num;
  4474. $data['orderinfo'] = $data['shop'].date('ymdHis',time()).rand(0,1);
  4475. $data['shouldmoney'] = 0;
  4476. $data['budget'] = 0;
  4477. $data['shipremarks'] = '';
  4478. $data['source'] = 1;
  4479. unset($data['id']);
  4480. unset($data['jweight']);
  4481. unset($data['fpcount']);
  4482. unset($data['returndata']);
  4483. unset($data['waybill']);
  4484. unset($data['oldwaybill']);
  4485. unset($data['printtime']);
  4486. if($this->fullordersmt->insert($data))
  4487. {
  4488. echo json_encode(array('msg'=>'拆分成功!新订单编号:'.$data['number'],'success'=>true));exit;
  4489. }
  4490. else
  4491. {
  4492. echo json_encode(array('msg'=>'拆分失败,请重试','success'=>false));exit;
  4493. }
  4494. }
  4495. }
  4496. }