Fullordersmt.php 147 KB

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