Fullordersmt.php 150 KB

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