Fullordersmt.php 153 KB

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