Fullordersmt.php 150 KB

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