| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552 |
- <?php
- namespace ghs\controllers;
- use biz\common\classes\GhsNotifyClass;
- use biz\common\classes\HdNotifyClass;
- use biz\shop\classes\ShopExtClass;
- use bizGhs\custom\classes\CustomDebtChangeClass;
- use bizGhs\express\classes\GhsDeliveryOrderClass;
- use bizGhs\express\services\DadaExpressServices;
- use bizGhs\ghs\classes\GhsClass;
- use bizGhs\order\classes\OrderItemClass;
- use bizGhs\order\classes\RefundOrderClass;
- use bizHd\purchase\classes\PurchaseClass;
- use bizHd\purchase\classes\PurchaseItemClass;
- use bizHd\purchase\services\PurchaseService;
- use bizHd\wx\classes\WxOpenClass;
- use bizGhs\custom\classes\CustomClass;
- use bizGhs\order\classes\OrderClass;
- use bizGhs\order\classes\OrderMergeClass;
- use bizGhs\order\classes\OrderMergeSnClass;
- use bizGhs\order\services\OrderService;
- use bizHd\saas\services\RegionService;
- use bizGhs\product\classes\ProductClass;
- use common\components\baiduAip;
- use common\components\dict;
- use common\components\dateUtil;
- use common\components\dirUtil;
- use common\components\freight;
- use common\components\httpUtil;
- use common\components\noticeUtil;
- use common\components\orderSn;
- use common\components\oss;
- use common\components\payUtil;
- use common\components\qrCodeUtil;
- use common\components\stringUtil;
- use Yii;
- use common\components\util;
- use biz\shop\classes\ShopAdminClass;
- use biz\shop\classes\ShopClass;
- use common\components\lakala\Lakala;
- use ghs\models\order\CreateOrderForm;
- class OrderController extends BaseController
- {
- public $guestAccess = ['create-order', 'order-relate', 'fast-pay', 'info'];
- //打印物流列表 ssh 20250712
- public function actionPrintWlList()
- {
- $get = Yii::$app->request->get();
- $begin = $get['begin'] ?? 1;
- $hour = $get['hour'] ?? 0;
- if ($hour > 24 || $hour < 0) {
- util::fail('必须0到24点');
- }
- if ($begin == 0) {
- $date = date('Y-m-d', strtotime('-1 day'));
- } else {
- $date = date('Y-m-d');
- }
- $beginGroup = $date . " {$hour}:00:00";
- $newTime = strtotime($beginGroup);
- $beginTime = date('Y-m-d H:i:s', $newTime);
- $endTime = date("Y-m-d H:i:s");
- $shop = $this->shop;
- OrderClass::printMyWlList($shop, $beginTime, $endTime);
- util::complete('打印成功');
- }
- //修改平账标识状态 ssh 20240405
- public function actionModifyClearSign()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? '';
- $order = OrderClass::getById($id, true);
- if (empty($order)) {
- util::fail('没有找到订单');
- }
- if ($order->mainId != $this->mainId) {
- util::fail('不是你的订单');
- }
- if (!in_array($order->status, [3, 4])) {
- util::fail('订单没有发货');
- }
- if ($order->clearSign == 1) {
- util::fail('不需要重复操作');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $order->clearSign = 1;
- $order->save();
- $cgId = $order->purchaseId;
- $cg = PurchaseClass::getById($cgId, true);
- if (empty($cg)) {
- util::fail('没有找到采购信息');
- }
- $cg->clearSign = 1;
- $cg->save();
- $transaction->commit();
- util::complete();
- } catch (\Exception $e) {
- $transaction->rollBack();
- Yii::error("操作失败原因:" . $e->getMessage());
- util::fail('操作失败');
- }
- }
- //下载图片版订单 ssh 20240321
- public function actionDown()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? '';
- $all = $get['all'] ?? 0;
- $order = OrderClass::getById($id, true);
- if (empty($order)) {
- util::fail('没有找到订单');
- }
- if ($order->mainId != $this->mainId) {
- util::fail('不是你的订单');
- }
- $customName = $order->customName ?? '';
- $date = date("Ymd", strtotime($order->addTime));
- $orderSn = $order->orderSn ?? '';
- $name = $customName . '_' . $date . '_' . $orderSn;
- $shop = $this->shop;
- $staff = $this->shopAdmin;
- $respond = OrderClass::createImgOrder($order, $shop, $staff, $all);
- $imgUrl = $respond['imgFile'] ?? '';
- $file = fopen($imgUrl, "rb");
- Header("Content-type: application/octet-stream ");
- Header("Accept-Ranges: bytes ");
- Header("Content-Disposition: attachment;filename={$name}.png");
- $contents = "";
- while (!feof($file)) {
- $contents .= fread($file, 8192);
- }
- echo $contents;
- fclose($file);
- }
- //确认送达
- public function actionConfirmReach()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? '';
- $order = OrderClass::getById($id, true);
- if (empty($order)) {
- util::fail('没有找到订单');
- }
- if ($order->mainId != $this->mainId) {
- util::fail('不是你的订单');
- }
- if ($order->status == 1) {
- util::fail('订单待付款');
- }
- if ($order->status == 4) {
- util::fail('订单已完成');
- }
- if ($order->status == 5) {
- util::fail('订单已取消');
- }
- if (!in_array($order->sendStatus, [-1, -4, -2])) {
- util::fail('已经叫跑腿了');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $staff = $this->shopAdmin;
- $staffId = $staff->id ?? 0;
- $staffName = $staff->name ?? '';
- $params = ['staffId' => $staffId, 'staffName' => $staffName];
- OrderClass::confirmReach($order, $params);
- $transaction->commit();
- util::complete('操作成功');
- } catch (\Exception $e) {
- $transaction->rollBack();
- Yii::error("操作失败原因:" . $e->getMessage());
- util::fail('确认失败');
- }
- }
- //发货 ssh 20230613
- public function actionFh()
- {
- $post = Yii::$app->request->post();
- $id = $post['id'] ?? '';
- $order = OrderClass::getById($id, true);
- OrderClass::valid($order, $this->shopId);
- $staff = $this->shopAdmin;
- $staffId = $staff->id ?? 0;
- $staffName = $staff->name ?? '';
- $fhWl = $post['fhWl'] ?? '';
- $fhWlNo = $post['fhWlNo'] ?? '';
- $fhType = $post['fhType'] ?? '';
- $params = [
- 'fhType' => $fhType,
- 'fhWl' => $fhWl,
- 'fhWlNo' => $fhWlNo,
- 'staffId' => $staffId,
- 'staffName' => $staffName,
- ];
- if ($order->book == 1) {
- util::fail('预订单不能直接发货');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- //花店会增加路上库存
- OrderClass::orderSend($order, $params);
- $transaction->commit();
- util::complete();
- } catch (\Exception $e) {
- $transaction->rollBack();
- Yii::error("操作失败原因:" . $e->getMessage());
- util::fail('操作失败');
- }
- }
- public function actionAllFh()
- {
- $post = Yii::$app->request->post();
- $ids = $post['ids'] ?? '';
- $mergeId = $post['mergeId'] ?? 0;
- if (empty($ids)) {
- if (empty($mergeId)) {
- util::fail('请选择要合并发货的订单');
- }
- $mergeInfo = OrderMergeSnClass::getById($mergeId, true);
- if (empty($mergeInfo)) {
- util::fail('请选择要合并发货的订单呢');
- }
- if ($mergeInfo->mainId != $this->mainId) {
- util::fail('不是你的订单呢');
- }
- $mergeRows = OrderMergeClass::getAllByCondition(['mergeId' => $mergeId], null, 'orderId');
- $ids = !empty($mergeRows) ? implode(',', array_column($mergeRows, 'orderId')) : '';
- if (empty($ids)) {
- util::fail('请选择要合并发货的订单哈');
- }
- }
- $arr = explode(',', $ids);
- if (empty($arr)) {
- util::fail('请选择要合并发货的订单哦');
- }
- $fhWl = $post['fhWl'] ?? '';
- $fhWlNo = $post['fhWlNo'] ?? '';
- $fhType = 0;
- $params = [
- 'fhType' => $fhType,
- 'fhWl' => $fhWl,
- 'fhWlNo' => $fhWlNo,
- ];
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $all = OrderClass::getAllByCondition(['id' => ['in', $arr]], null, '*', null, true);
- foreach ($all as $order) {
- if ($order->book == 1) {
- util::fail('有预订单,不能一起发货');
- }
- if ($order->mainId != $this->mainId) {
- util::fail('不是你的订单哦');
- }
- OrderClass::orderSend($order, $params, true);
- }
- $transaction->commit();
- util::complete();
- } catch (\Exception $e) {
- $transaction->rollBack();
- Yii::error("操作失败原因:" . $e->getMessage());
- util::fail('操作失败');
- }
- }
- //合并打印 ssh 20230929
- public function actionMergePrint()
- {
- $post = Yii::$app->request->post();
- $ids = $post['ids'] ?? '';
- $mergeId = $post['mergeId'] ?? 0;
- if (empty($ids)) {
- if (empty($mergeId)) {
- util::fail('请选择要合并打印的订单');
- }
- $mergeInfo = OrderMergeSnClass::getById($mergeId, true);
- if (empty($mergeInfo)) {
- util::fail('请选择要合并打印的订单呢');
- }
- if ($mergeInfo->mainId != $this->mainId) {
- util::fail('不是你的订单呢');
- }
- $mergeRows = OrderMergeClass::getAllByCondition(['mergeId' => $mergeId], null, 'orderId');
- $ids = !empty($mergeRows) ? implode(',', array_column($mergeRows, 'orderId')) : '';
- if (empty($ids)) {
- util::fail('请选择要合并打印的订单哈');
- }
- }
- $arr = explode(',', $ids);
- if (empty($arr)) {
- util::fail('请选择要合并打印的订单哦');
- }
- if (getenv('YII_ENV') == 'production') {
- if ($this->mainId != 10536 && $this->mainId != 50) {
- //util::fail('功能开发中');
- }
- } else {
- if ($this->mainId != 11) {
- //util::fail('功能开发中');
- }
- }
- OrderClass::mergePrintOrder($arr, $this->mainId);
- util::complete('打印成功');
- }
- //获取合并订单列表 ssh 20260518
- public function actionMergeOrderList()
- {
- //同个人当天订单不可能超过9999
- Yii::$app->params['pageSize'] = 9999;
- $get = Yii::$app->request->get();
- $mergeId = $get['mergeId'] ?? '';
- $mergeInfo = OrderMergeSnClass::getById($mergeId, true);
- if (empty($mergeInfo)) {
- util::fail('请选择订单');
- }
- if ($mergeInfo->mainId != $this->mainId) {
- util::fail('不是你的订单');
- }
- $mergeRows = OrderMergeClass::getAllByCondition(['mergeId' => $mergeId], null, 'orderId');
- $ids = !empty($mergeRows) ? implode(',', array_column($mergeRows, 'orderId')) : '';
- if (empty($ids)) {
- util::fail('请选择订单哈');
- }
- $where['mainId'] = $this->mainId;
- $newIds = explode(',', $ids);
- if (empty($newIds)) {
- util::fail('请选订单哈');
- }
- $where['id'] = ['in', $newIds];
- $respond = OrderClass::getOrderList($where);
- $respond['shop'] = $this->shop;
- $respond['shopExt'] = $this->shopExt;
- $totalPrice = 0;
- if (!empty($respond['list'])) {
- foreach ($respond['list'] as $order) {
- $actPrice = $order['actPrice'] ?? 0;
- $totalPrice = bcadd($totalPrice, $actPrice, 2);
- }
- }
- $totalPrice = floatval($totalPrice);
- $respond['shareInfo'] = [
- 'id' => $mergeInfo->cgMergeId ?? 0,
- 'mergeId' => $mergeInfo->cgMergeId ?? 0,
- 'salt' => $mergeInfo->cgSalt ?? '',
- 'totalPrice' => $totalPrice,
- ];
- util::success($respond);
- }
- //修改分工 ssh 20221129
- public function actionChangeWorker()
- {
- $post = Yii::$app->request->post();
- $id = $post['id'] ?? 0;
- $shopAdminId = $post['shopAdminId'] ?? 0;
- $shopAdminName = $post['shopAdminName'] ?? '';
- $order = OrderClass::getById($id, true);
- OrderClass::valid($order, $this->shopId);
- $preShopAdminId = $order->shopAdminId ?? 0;
- if (!empty($preShopAdminId)) {
- $shopAdmin = $this->shopAdmin;
- if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
- util::fail('管理员才能操作');
- }
- }
- $order->shopAdminId = $shopAdminId;
- $order->shopAdminName = $shopAdminName;
- $order->save();
- util::complete();
- }
- //预订单到货 ssh 20220321
- public function actionArrival()
- {
- //避免重复提交
- $adminId = $this->adminId;
- util::checkRepeatCommit($adminId, 6);
- $post = Yii::$app->request->post();
- $id = $post['id'] ?? 0;
- $todayBill = $post['todayBill'] ?? 1;
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $order = OrderClass::getById($id, true);
- OrderClass::valid($order, $this->shopId);
- $post['shopAdminId'] = $this->shopAdminId;
- $post['shopAdminName'] = $this->shopAdmin ? $this->shopAdmin->name : '';
- $shop = $this->shop;
- $bookSn = $shop->bookSn ?? 0;
- if (!empty($bookSn)) {
- if ($order->bookSn == $bookSn) {
- util::fail('预订结束了才能确认');
- }
- }
- OrderService::arrival($order, $post);
- if ($todayBill == 0) {
- $lastTime = time() - 86400;
- $payTime = date("Y-m-d H:i:s", $lastTime);
- $order->payTime = $payTime;
- $order->save();
- $purchaseId = $order->purchaseId ?? 0;
- $cg = PurchaseClass::getById($purchaseId, true);
- if (!empty($cg)) {
- $cg->payTime = $payTime;
- $cg->save();
- }
- }
- $transaction->commit();
- util::success($order);
- } catch (\Exception $e) {
- $transaction->rollBack();
- Yii::error("操作失败原因:" . $e->getMessage());
- util::fail('操作失败');
- }
- }
- //到货获取订单详情 ssh 20220323
- public function actionArrivalDetail()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $info = OrderClass::getById($id);
- OrderClass::valid($info, $this->shopId);
- $showItemData = OrderClass::getOriginalShowItem(true, $info);
- $itemList = $showItemData['list'] ?? [];
- $info['product'] = $itemList;
- $kiloFee = $this->shop->kiloFee ?? 0;
- $miniKilo = $this->shop->miniKilo ?? 0;
- $info['kiloFee'] = $kiloFee;
- $info['miniKilo'] = $miniKilo;
- util::success($info);
- }
- //支付宝扫码支付 ssh 20210103
- public function actionScanPayCheck()
- {
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $order = OrderClass::getById($id, true);
- if ($order->status != OrderClass::ORDER_STATUS_UN_PAY && $order->status != OrderClass::ORDER_STATUS_CANCEL) {
- util::success(['returnStatus' => 'SUCCESS']);
- }
- $deadline = $order->deadline ?? '';
- $deadTime = strtotime($deadline);
- $current = time();
- $diff = bcsub($deadTime, $current);
- if ($diff <= 60) {
- util::success(['returnStatus' => 'EXPIRE']);
- }
- util::success(['returnStatus' => 'FAILURE']);
- }
- //微信和支付宝扫码支付 ssh 20210103
- public function actionScanPay()
- {
- ini_set('date.timezone', 'Asia/Shanghai');
- header("Content-type: text/html; charset=utf-8");
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $order = OrderClass::getById($id, true);
- if (isset($order->status) == false || $order->status != 1) {
- util::success(['returnStatus' => 'FAILURE'], '不是待付款订单');
- }
- OrderClass::valid($order, $this->shopId);
- $cgId = $order->purchaseId ?? 0;
- $cg = PurchaseClass::getById($cgId, true);
- $orderSn = $cg->orderSn ?? '';
- if (empty($orderSn)) {
- util::success(['returnStatus' => 'FAILURE'], '没有找到采购单');
- }
- $deadline = $cg->deadline;
- $current = date("Y-m-d H:i:s");
- if ((strtotime($deadline) + 20) < strtotime($current)) {
- util::success(['returnStatus' => 'FAILURE'], '订单已经失效');
- }
- $totalFee = $cg->actPrice ?? 0;
- $subject = '购买鲜花';
- $totalAmount = $totalFee;
- $body = "到店订单";
- //标记为扫码支付 和 自取订单
- $order->codePay = 2;
- $order->sendType = OrderClass::SEND_TYPE_NO;
- $order->save();
- $cg->getType = PurchaseClass::GET_TYPE_SELF_GET;
- $cg->codePay = 2;
- $cg->save();
- $shop = $this->shop;
- $currentCapitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
- $wxPayWay = dict::getDict('payWay', 'wxPay');
- $aliPayWay = dict::getDict('payWay', 'alipay');
- $payWay = Yii::$app->request->get('payWay', $wxPayWay);
- if ($payWay == $wxPayWay) {
- if (isset($order->wxPayUrl) && !empty($order->wxPayUrl)) {
- $url = $order->wxPayUrl;
- } else {
- util::fail('暂不支持');
- $merchantExtend = WxOpenClass::getWxInfo();
- $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
- $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
- $params = [
- 'appid' => 'OP00002119',
- 'serial_no' => '018b08cfddbd',
- 'merchant_no' => $shop->lklSjNo,
- 'term_no' => $shop->lklScanTermNo,
- 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
- 'lklCertificatePath' => $lklCertificatePath,
- ];
- $laResource = new Lakala($params);
- $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
- $wxParams = [
- 'orderSn' => $orderSn,
- 'amount' => $totalFee,
- 'capitalType' => $currentCapitalType,
- 'notifyUrl' => $notifyUrl,
- 'subject' => $subject,
- 'couponId' => 0,
- 'wxAppId' => $merchantExtend['miniAppId'],
- ];
- $response = $laResource->driveNativeWxPay($wxParams);
- if (isset($response['code']) == false || $response['code'] != 'BBS00000') {
- $msg = $response['msg'] ?? '';
- noticeUtil::push($msg, '15280215347');
- util::fail('二维码生成失败');
- }
- $url = isset($response['resp_data']['acc_resp_fields']['code']) ? $response['resp_data']['acc_resp_fields']['code'] : '';
- if (empty($url)) {
- util::fail('二维码生成失败..');
- }
- $order->wxPayUrl = $url;
- $order->save();
- }
- $suffixUrl = qrCodeUtil::generateShortTimeGatheringQrCode($url, $this->sjId, $this->shopId, $payWay);
- $payUrl = Yii::$app->params['ghsImgHost'] . $suffixUrl;
- util::success(['url' => $payUrl, 'returnStatus' => 'SUCCESS']);
- }
- if ($payWay == $aliPayWay) {
- if (isset($order->aliPayUrl) && !empty($order->aliPayUrl)) {
- $url = $order->aliPayUrl;
- } else {
- $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
- $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
- $params = [
- 'appid' => 'OP00002119',
- 'serial_no' => '018b08cfddbd',
- 'merchant_no' => $shop->lklSjNo,
- 'term_no' => $shop->lklScanTermNo,
- 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
- 'lklCertificatePath' => $lklCertificatePath,
- ];
- $laResource = new Lakala($params);
- $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
- $aliParams = [
- 'orderSn' => $orderSn,
- 'amount' => $totalFee,
- 'capitalType' => $currentCapitalType,
- 'notifyUrl' => $notifyUrl,
- 'subject' => $subject,
- ];
- $response = $laResource->driveAliPay($aliParams);
- if (isset($response['code']) == false || $response['code'] != 'BBS00000') {
- util::fail('二维码生成失败');
- }
- $url = isset($response['resp_data']['acc_resp_fields']['code']) ? $response['resp_data']['acc_resp_fields']['code'] : '';
- if (empty($url)) {
- util::fail('二维码生成失败..');
- }
- $order->aliPayUrl = $url;
- $order->save();
- }
- $suffixUrl = qrCodeUtil::generateShortTimeGatheringQrCode($url, $this->sjId, $this->shopId, $payWay);
- $payUrl = Yii::$app->params['ghsImgHost'] . $suffixUrl;
- util::success(['url' => $payUrl, 'returnStatus' => 'SUCCESS']);
- }
- util::success(['returnStatus' => 'FAILURE'], '不支持的收款方式');
- }
- //微信和支付宝付款码支付复查 ssh 20211231
- public function actionCodePayCheck()
- {
- ini_set('date.timezone', 'Asia/Shanghai');
- header("Content-type: text/html; charset=utf-8");
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- util::checkRepeatCommit($id, 3);
- $order = OrderClass::getById($id, true);
- OrderClass::valid($order, $this->shopId);
- if ($order->payStatus == 1) {
- util::success(['returnStatus' => 'SUCCESS']);
- }
- if ($order->status == 5) {
- util::success(['returnStatus' => 'CANCEL']);
- }
- $cgId = $order->purchaseId ?? 0;
- $cg = PurchaseClass::getById($cgId, true);
- $orderSn = $cg->orderSn ?? '';
- $totalFee = $cg->actPrice ?? 0;
- if (empty($orderSn)) {
- util::complete('没有找到采购单');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
- $shop = $this->shop;
- $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
- $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
- $params = [
- 'appid' => 'OP00002119',
- 'serial_no' => '018b08cfddbd',
- 'merchant_no' => $shop->lklSjNo,
- 'term_no' => $shop->lklScanTermNo,
- 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
- 'lklCertificatePath' => $lklCertificatePath,
- ];
- $laResource = new Lakala($params);
- $scanParams = ['orderSn' => $orderSn,];
- $response = $laResource->query($scanParams);
- if (isset($response['code']) && $response['code'] == 'BBS00000') {
- if (isset($response['resp_data']['trade_state']) && $response['resp_data']['trade_state'] == 'SUCCESS') {
- //支付成功
- $transactionId = $response['resp_data']['trade_no'] ?? '';
- $openId = '';
- $aliUserId = '';
- $cg->onlinePay = dict::getDict('onlinePay', 'yes');
- $cg->codePay = 1;
- $cg->payOpenId = $openId;
- $cg->aliUserId = $aliUserId;
- //自取订单
- $cg->getType = PurchaseClass::GET_TYPE_SELF_GET;
- $cg->save();
- $order->onlinePay = dict::getDict('onlinePay', 'yes');
- $order->codePay = 1;
- //自取订单
- $order->sendType = OrderClass::SEND_TYPE_NO;
- $order->save();
- $payWayType = dict::getDict('payWay', 'wxPay');
- $account_type = $response['resp_data']['account_type'] ?? '';
- if ($account_type == 'WECHAT') {
- $payWayType = dict::getDict('payWay', 'wxPay');
- }
- if ($account_type == 'ALIPAY') {
- $payWayType = dict::getDict('payWay', 'alipay');
- }
- $order->payWay = $payWayType;
- $order->save();
- $cg->payWay = $payWayType;
- $cg->save();
- $attach = '';
- payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
- $transaction->commit();
- $saleId = $order->id ?? 0;
- $order = OrderClass::getById($saleId, true);
- if (!empty($order)) {
- //解决付款成功后重复通知打印问题
- $cacheKey = 'pay_success_notice_' . $orderSn;
- $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- if (!empty($has)) {
- return false;
- }
- Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 1, 'has']);
- //订单生成时唤起在线打印
- if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
- if ($order->status != 1 && $order->status != 5) {
- OrderClass::onlinePrint($order);
- $ext = $this->shopExt;
- if (isset($ext->printSn) && !empty($ext->printSn)) {
- $order->printNum += 1;
- $order->save();
- }
- }
- }
- //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
- GhsDeliveryOrderClass::payAfter($order);
- ShopExtClass::ghsGatheringReport($order);
- }
- util::success(['returnStatus' => 'SUCCESS']);
- } else {
- util::complete('未知状态..');
- }
- } else {
- util::complete('未知状态....');
- }
- } catch (\Exception $e) {
- $transaction->rollBack();
- noticeUtil::push('查询订单状态失败:' . $e->getMessage(), '15280215347');
- util::fail('支付失败');
- }
- }
- //微信和支付宝付款码支付复查 ssh 20260716
- public function actionCodePayVerify()
- {
- ini_set('date.timezone', 'Asia/Shanghai');
- header("Content-type: text/html; charset=utf-8");
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- util::checkRepeatCommit($id, 3);
- $order = OrderClass::getById($id, true);
- if (empty($order)) {
- util::complete('没有找到订单呢');
- }
- OrderClass::valid($order, $this->shopId);
- if ($order->payStatus == 1) {
- util::success(['returnStatus' => 'SUCCESS']);
- }
- if ($order->status == 5) {
- util::success(['returnStatus' => 'CANCEL']);
- }
- $cgId = $order->purchaseId ?? 0;
- $cg = PurchaseClass::getById($cgId, true);
- $orderSn = $cg->orderSn ?? '';
- $totalFee = $cg->actPrice ?? 0;
- if (empty($orderSn)) {
- util::complete('没有找到采购单');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
- $shop = $this->shop;
- $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
- $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
- $params = [
- 'appid' => 'OP00002119',
- 'serial_no' => '018b08cfddbd',
- 'merchant_no' => $shop->lklSjNo,
- 'term_no' => $shop->lklScanTermNo,
- 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
- 'lklCertificatePath' => $lklCertificatePath,
- ];
- $laResource = new Lakala($params);
- $scanParams = ['orderSn' => $orderSn,];
- $response = $laResource->query($scanParams);
- if (isset($response['code']) && $response['code'] == 'BBS00000') {
- if (isset($response['resp_data']['trade_state']) && $response['resp_data']['trade_state'] == 'SUCCESS') {
- //支付成功
- $transactionId = $response['resp_data']['trade_no'] ?? '';
- $openId = '';
- $aliUserId = '';
- $cg->onlinePay = dict::getDict('onlinePay', 'yes');
- $cg->codePay = 1;
- $cg->payOpenId = $openId;
- $cg->aliUserId = $aliUserId;
- //自取订单
- $cg->getType = PurchaseClass::GET_TYPE_SELF_GET;
- $cg->save();
- $order->onlinePay = dict::getDict('onlinePay', 'yes');
- $order->codePay = 1;
- //自取订单
- $order->sendType = OrderClass::SEND_TYPE_NO;
- $order->save();
- $payWayType = dict::getDict('payWay', 'wxPay');
- $account_type = $response['resp_data']['account_type'] ?? '';
- if ($account_type == 'WECHAT') {
- $payWayType = dict::getDict('payWay', 'wxPay');
- }
- if ($account_type == 'ALIPAY') {
- $payWayType = dict::getDict('payWay', 'alipay');
- }
- $order->payWay = $payWayType;
- $order->save();
- $cg->payWay = $payWayType;
- $cg->save();
- $attach = '';
- payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
- $transaction->commit();
- $saleId = $order->id ?? 0;
- $order = OrderClass::getById($saleId, true);
- if (!empty($order)) {
- //解决付款成功后重复通知打印问题
- $cacheKey = 'pay_success_notice_' . $orderSn;
- $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- if (!empty($has)) {
- return false;
- }
- Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 1, 'has']);
- //订单生成时唤起在线打印
- if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
- if ($order->status != 1 && $order->status != 5) {
- OrderClass::onlinePrint($order);
- $ext = $this->shopExt;
- if (isset($ext->printSn) && !empty($ext->printSn)) {
- $order->printNum += 1;
- $order->save();
- }
- }
- }
- //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
- GhsDeliveryOrderClass::payAfter($order);
- ShopExtClass::ghsGatheringReport($order);
- }
- util::success(['returnStatus' => 'SUCCESS']);
- } else {
- util::success(['returnStatus' => 'PENDING'], '等待支付中...');
- }
- } else {
- util::success(['returnStatus' => 'PENDING'], '等待支付中...');
- }
- } catch (\Exception $e) {
- $transaction->rollBack();
- noticeUtil::push('查询订单状态失败:' . $e->getMessage(), '15280215347');
- util::fail('支付失败');
- }
- }
- /**
- * 微信和支付宝付款码支付
- * 职责:处理商户扫描客户付款码(被扫支付)的请求,调用拉卡拉支付接口并更新本地订单状态
- * 入参:GET 传参 id (订单ID), authCode (付款码)
- * 返回:JSON 格式的支付结果(SUCCESS/FAILURE)
- * 副作用:更新订单及采购单的支付状态、支付方式,记录支付日志,触发云打印、跑腿呼叫及语音播报
- * 关键边界:
- * 1. 验证订单及采购单的有效性与时效性
- * 2. 校验付款码格式(微信/支付宝)
- * 3. 优化:将拉卡拉外部网络请求移出数据库事务,避免因网络延迟长时间占用数据库连接和行锁
- */
- public function actionCodePay()
- {
- ini_set('date.timezone', 'Asia/Shanghai');
- header("Content-type: text/html; charset=utf-8");
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- util::checkRepeatCommit($id, 3);
- $order = OrderClass::getById($id, true);
- if (empty($order)) {
- $msg = '没有找到订单';
- util::success(['returnStatus' => 'FAILURE'], $msg);
- }
- if ($order->status == 5) {
- $msg = '订单已取消';
- util::success(['returnStatus' => 'FAILURE'], $msg);
- }
- if ($order->status != 1) {
- $msg = '不是待付款订单';
- util::success(['returnStatus' => 'FAILURE'], $msg);
- }
- OrderClass::valid($order, $this->shopId);
- $cgId = $order->purchaseId ?? 0;
- $cg = PurchaseClass::getById($cgId, true);
- $orderSn = $cg->orderSn ?? '';
- if (empty($orderSn)) {
- $msg = '没有找到采购单';
- util::success(['returnStatus' => 'FAILURE'], $msg);
- }
- $codePayErrorKey = 'code_pay_error_' . $id;
- $hasFailPay = Yii::$app->redis->executeCommand('GET', [$codePayErrorKey]);
- //前面有付失败过,要重新生成单号
- if (!empty($hasFailPay)) {
- $oldOrderSn = $orderSn;
- $shopId = $cg->shopId ?? 0;
- $mainId = $cg->mainId ?? 0;
- $ghsId = $cg->ghsId ?? 0;
- $customId = $cg->customId ?? 0;
- $snData = ['shopId' => $shopId, 'mainId' => $mainId, 'ghsId' => $ghsId, 'customId' => $customId];
- $orderSn = orderSn::getPurchaseSn($snData);
- $cg->orderSn = $orderSn;
- $cg->save();
- //noticeUtil::push("重新扫码,成功更换单号 {$oldOrderSn} {$orderSn}", '15280215347');
- PurchaseItemClass::updateByCondition(['orderSn' => $oldOrderSn], ['orderSn' => $orderSn]);
- }
- $shop = $this->shop;
- $sj = $shop->merchantName;
- $shopName = $shop->shopName;
- $name = $shopName == '首店' ? $sj : $sj . '-' . $shopName;
- //付款码
- $authCode = (string)$get['authCode'] ?? '';
- $authCode = trim($authCode);
- if (empty($authCode)) {
- $msg = '没有扫到付款码';
- $remind = $msg . "(付款码:{$authCode})" . '(' . $name . ')';
- noticeUtil::push($remind . ' 编号001', '15280215347');
- util::success(['returnStatus' => 'FAILURE'], $msg);
- }
- //微信文档说明 https://pay.weixin.qq.com/doc/v2/merchant/4011936234
- $wxPattern = '/^(10|11|12|13|14|15)\d{16}$/';
- //支付宝文档说明 https://opendocs.alipay.com/open/194/106039/
- $aliPattern = '/^(25|26|27|28|29|30)\d{14,22}$/';
- if (!preg_match($wxPattern, $authCode) && !preg_match($aliPattern, $authCode)) {
- $msg = '付款码错误,请使用微信或支付宝付款码';
- $remind = $msg . "(付款码:{$authCode})" . '(' . $name . ')';
- //noticeUtil::push($remind . ' 编号002', '15280215347');
- util::success(['returnStatus' => 'FAILURE'], $msg);
- }
- $deadline = $cg->deadline;
- $current = date("Y-m-d H:i:s");
- if ((strtotime($deadline) + 20) < strtotime($current)) {
- $msg = '订单已经失效';
- util::success(['returnStatus' => 'FAILURE'], $msg);
- }
- $totalFee = $cg->actPrice ?? 0;
- try {
- $subject = '购买花材 ' . $orderSn;
- $capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
- $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
- $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
- $params = [
- 'appid' => 'OP00002119',
- 'serial_no' => '018b08cfddbd',
- 'merchant_no' => $shop->lklSjNo,
- 'term_no' => $shop->lklScanTermNo,
- 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
- 'lklCertificatePath' => $lklCertificatePath,
- ];
- $laResource = new Lakala($params);
- $notifyUrl = Yii::$app->params['hdHost'] . "/notice/pay-callback";
- $scanParams = [
- 'orderSn' => $orderSn,
- 'amount' => $totalFee,
- 'capitalType' => $capitalType,
- 'notifyUrl' => $notifyUrl,
- 'subject' => $subject,
- 'authCode' => $authCode,
- ];
- // 复杂分支/关键逻辑:在调用外部支付接口前不开启事务,防止网络延迟卡死数据库连接
- $response = $laResource->scanPay($scanParams);
- if (isset($response['code']) && $response['code'] == 'BBS00000') {
- // 复杂分支/关键逻辑:支付成功后,开启数据库事务,确保本地订单状态更新的原子性
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $account_type = $response['resp_data']['account_type'] ?? '';
- $payWayType = dict::getDict('payWay', 'wxPay');
- if ($account_type == 'WECHAT') {
- $payWayType = dict::getDict('payWay', 'wxPay');
- }
- if ($account_type == 'ALIPAY') {
- $payWayType = dict::getDict('payWay', 'alipay');
- }
- $order->payWay = $payWayType;
- $order->save();
- $cg->payWay = $payWayType;
- $cg->save();
- $transactionId = $response['resp_data']['trade_no'] ?? '';
- $openId = '';
- $aliUserId = '';
- $cg->onlinePay = dict::getDict('onlinePay', 'yes');
- $cg->codePay = 1;
- $cg->payOpenId = $openId;
- $cg->aliUserId = $aliUserId;
- $cg->save();
- $order->onlinePay = dict::getDict('onlinePay', 'yes');
- $order->codePay = 1;
- $order->save();
- $attach = '';
- payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
- $transaction->commit();
- } catch (\Exception $e) {
- $transaction->rollBack();
- throw $e;
- }
- $saleId = $order->id ?? 0;
- $order = OrderClass::getById($saleId, true);
- if (!empty($order)) {
- //解决付款成功后重复通知打印问题
- $cacheKey = 'pay_success_notice_' . $orderSn;
- $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- if (!empty($has)) {
- return false;
- }
- Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 1, 'has']);
- //订单生成时唤起在线打印
- if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
- if ($order->status != 1 && $order->status != 5) {
- OrderClass::onlinePrint($order);
- $ext = $this->shopExt;
- if (isset($ext->printSn) && !empty($ext->printSn)) {
- $order->printNum += 1;
- $order->save();
- }
- }
- }
- //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
- GhsDeliveryOrderClass::payAfter($order);
- ShopExtClass::ghsGatheringReport($order);
- }
- util::success(['returnStatus' => 'SUCCESS']);
- } else {
- //标记有没付成功的次数,原因有可能是余额不足等
- Yii::$app->redis->executeCommand('SETEX', [$codePayErrorKey, 1200, 'hasFail']);
- $msg = $response['msg'] ?? '';
- $retCode = $response['code'] ?? '';
- if ($retCode == 'BBS10000' || $retCode == 'BBS11105') {
- $shopId = $order->shopId;
- ShopExtClass::remindInputPassword($shopId);
- }
- $fullMsg = $msg . "(付款码:{$authCode})" . '(' . $name . ')';
- //noticeUtil::push($fullMsg . ' ' . $retCode . ' 编号007', '15280215347');
- util::success(['returnStatus' => 'FAILURE', 'returnCode' => $retCode], $msg);
- }
- } catch (\Exception $e) {
- Yii::error("支付失败原因:" . $e->getMessage());
- util::fail('支付失败');
- }
- }
- //订单列表 ssh 2021.1.20
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $export = $get['export'] ?? 0;
- $onlySend = $get['onlySend'] ?? 0;
- ini_set('memory_limit', '5045M');
- set_time_limit(0);
- $staff = $this->shopAdmin;
- if (isset($staff->identity) && $staff->identity == 2) {
- //如果用于确认发货时要显出订单
- if ($onlySend == 0) {
- util::success(['list' => []]);
- }
- }
- $where['mainId'] = $this->mainId;
- $status = $get['status'] ?? 0;
- if (!empty($status)) {
- $where['status'] = $status;
- }
- $clearSign = $get['clearSign'] ?? -1;
- if ($clearSign > -1) {
- $where['clearSign'] = $clearSign;
- }
- $book = $get['book'] ?? -1;
- if ($book > -1) {
- $where['book'] = $book;
- }
- $searchTime = $get['searchTime'] ?? '';
- //0搜索的addTime 1搜索的payTime
- $searchTimeType = $get['searchTimeType'] ?? 0;
- if (!empty($searchTime)) {
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
- if ($searchTimeType == 0) {
- $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
- } else {
- $where['payTime'] = ['between', [$period['startTime'], $period['endTime']]];
- }
- }
- if ($export == 1) {
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- if (!isset($where['payTime'])) {
- util::fail('请选 账单日期 和 时间段');
- }
- $start = $where['payTime'][1][0];
- $end = $where['payTime'][1][1];
- $monthTime = bcmul(31, 86400);
- $startArea = strtotime($start);
- $endArea = strtotime($end);
- $diff = bcsub($endArea, $startArea);
- if ($diff > $monthTime) {
- util::fail('最长可导出一个月');
- }
- }
- $name = $get['name'] ?? '';
- if (!empty($name)) {
- $searchType = $get['searchType'] ?? 0;
- if (empty($searchType)) {
- //订单编号
- if (strpos($name, 'XSD') === 0) {
- $where['orderSn'] = $name;
- } elseif (preg_match("/^[a-zA-Z\s]+$/", $name)) {
- $where['customNamePy'] = ['like', $name];
- } else {
- $where['customName'] = ['like', $name];
- }
- } elseif ($searchType == 1) {
- $where['sendNum'] = $name;
- } else {
- }
- }
- if (!empty($get['customId'])) {
- $where['customId'] = (int)$get['customId'];
- }
- $customDistId = $get['customDistId'] ?? ($get['distId'] ?? 0);
- if (!empty($customDistId)) {
- $where['customDistId'] = (int)$customDistId;
- }
- $debt = isset($get['debt']) && is_numeric($get['debt']) ? (int)$get['debt'] : -1;
- if ($debt > -1) {
- $where['debt'] = $debt;
- }
- if (!empty($get['ids'])) {
- $stringIds = $get['ids'];
- $newIds = explode(',', $stringIds);
- $where['id'] = ['in', $newIds];
- }
- //选择开单人
- $shopAdminId = $get['shopAdminId'] ?? 0;
- if (!empty($shopAdminId)) {
- $where['shopAdminId'] = (int)$shopAdminId;
- }
- $onlinePay = $get['onlinePay'] ?? -1;
- if ($onlinePay > -1) {
- $where['onlinePay'] = $onlinePay;
- }
- $sendType = $get['sendType'] ?? -1;
- if ($sendType > -1) {
- $where['sendType'] = $sendType;
- }
- $respond = OrderClass::getOrderList($where);
- if ($export == 1) {
- OrderClass::exportOrderData($respond, $this->mainId);
- }
- $respond['shop'] = $this->shop;
- $respond['shopExt'] = $this->shopExt;
- util::success($respond);
- }
- //按片区排列的订单列表
- public function actionListByDist()
- {
- $get = Yii::$app->request->get();
- $where = [];
- $where['o.mainId'] = $this->mainId;
- $searchTime = $get['searchTime'] ?? '';
- if (!empty($searchTime)) {
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- // 时间跨度不能超过7天
- if (strtotime($endTime) - strtotime($startTime) > 7 * 24 * 3600) {
- util::fail('最多查询7天的订单');
- }
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
- $where['payTime'] = ['between', [$period['startTime'], $period['endTime']]];
- }
- $respond = OrderClass::getDistOrderList($where);
- util::success($respond);
- }
- // 新订单列表详情 -- 可能与 actionList 很相似,但为不影响 actionList,重新创建个方法 shizhongqi 2022.06.23
- public function actionNewOrderList()
- {
- $get = Yii::$app->request->get();
- $where['shopId'] = $this->shopId;
- /*$status = $get['status'] ?? 0;
- if (!empty($status)) {
- $where['status'] = $status;
- }*/
- // 按类别生成查询条件:1.今日实收 2.今日欠款 3.总欠款(所有历史欠款)
- if (isset($get['type'])) {
- $type = $get['type'];
- if ($type == 1) { // 今日实收
- $get['searchTime'] = 'today';
- $where['debt'] = 0;
- $where['debtPrice'] = '0.00';
- $where['status'] = ['in', [OrderClass::ORDER_STATUS_UN_SEND, OrderClass::ORDER_STATUS_SENDING, OrderClass::ORDER_STATUS_COMPLETE]];
- } elseif ($type == 2) { // 今日欠款
- $get['searchTime'] = 'today';
- $where['debt'] = 1;
- } elseif ($type == 3) { // 总欠款
- $where['debt'] = 1;
- } else {
- util::fail('查询的订单类别不存在');
- }
- }
- $searchTime = $get['searchTime'] ?? '';
- if (!empty($searchTime)) {
- $startTime = '';
- $endTime = '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
- $where['addTime'] = ['between', [$period['startTime'], $period['endTime']]];
- }
- $name = $get['name'] ?? '';
- if (!empty($name)) {
- $searchType = $get['searchType'] ?? 0;
- if (empty($searchType)) {
- //订单编号
- if (strpos($name, 'XSD') === 0) {
- $where['orderSn'] = $name;
- } elseif (preg_match("/^[a-zA-Z\s]+$/", $name)) {
- $where['customNamePy'] = ['like', $name];
- } else {
- $where['customName'] = ['like', $name];
- }
- } elseif ($searchType == 1) {
- $where['sendNum'] = $name;
- } else {
- util::fail('搜索的订单类别不存在');
- }
- }
- $respond = OrderClass::getOrderList($where);
- $respond['shop'] = $this->shop;
- $respond['shopExt'] = $this->shopExt;
- $respond['type'] = $type; //把查询类别返回
- util::success($respond);
- }
- //商城下单操作 ssh 2021.1.14
- public function actionCreateOrder()
- {
- $post = Yii::$app->request->post();
- $shopId = $this->shopId;
- $customId = $post['customId'] ?? 0;
- $post['customId'] = $customId;
- //开单必须选客户
- if (empty($customId)) {
- util::fail('请选择客户');
- }
- $modifyPrice = $post['modifyPrice'] ?? 0;
- $pattern = '/^\d+(\.\d{1,2})?$/';
- if ($modifyPrice > 0) {
- if (!preg_match($pattern, $modifyPrice)) {
- //容错前端
- util::fail('金额不能超2位小数');
- }
- }
- $custom = CustomClass::getCustom($customId);
- if (empty($custom)) {
- util::fail('请选客户哦');
- }
- $shopAdmin = $this->shopAdmin;
- $shopAdminId = $this->shopAdminId;
- $shopAdminName = $shopAdmin->name ?? '';
- //解决开单提交订单时,别人修改价格,造成提交价格不是真实卖价问题!!
- $dealPrice = $post['dealPrice'] ?? 0;
- //解决重复提交:同店铺 + 同操作人 + 同客户 + 同成交价,短时间内只允许一次(防连点 / 双请求)
- util::checkRepeatCommit($shopId . '_' . $this->adminId . '_' . $customId . '_' . $dealPrice, 3);
- CustomClass::valid($custom, $this->shopId);
- if (!empty($custom['mainId']) && $custom['mainId'] == $custom['ownMainId']) {
- util::fail('不能给自己开单');
- }
- $post['ghsId'] = $custom['ghsId'] ?? 0;
- $post['customMobile'] = $custom['mobile'] ?? '';
- $customName = $custom['name'] ?? '';
- $post['customName'] = $customName;
- $post['customNamePy'] = $custom['py'] ?? '';
- $post['customAvatar'] = $custom['shortSmallAvatar'] ?? '';
- $post['province'] = $custom['province'] ?? '';
- $post['city'] = $custom['city'] ?? '';
- $post['dist'] = $custom['dist'] ?? '';
- $post['address'] = $custom['address'] ?? '';
- $post['floor'] = $custom['floor'] ?? '';
- $post['fullAddress'] = $custom['fullAddress'] ?? '';
- $post['showAddress'] = $custom['showAddress'] ?? '';
- $post['long'] = $custom['long'] ?? '';
- $post['lat'] = $custom['lat'] ?? '';
- if (!empty($post['getStaffId'])) {
- if (getenv('YII_ENV') == 'production') {
- $tbMainId = 44171;
- } else {
- $tbMainId = 0;
- }
- if ($this->mainId == $tbMainId) {
- //平潭花天下,就算选了收款人,也不要给改变开单人,临时解决方案 ssh 2250314
- if (!empty($post['shopAdminId'])) {
- $getStaffName = $post['shopAdminName'] ?? '';
- $shopAdminId = $post['shopAdminId'];
- $shopAdminName = $getStaffName;
- }
- } else {
- $getStaffName = $post['getStaffName'] ?? '';
- $shopAdminId = $post['getStaffId'];
- $shopAdminName = $getStaffName;
- }
- } else {
- if (getenv('YII_ENV') == 'production') {
- //鹏诚需要选择开单人
- if (in_array($this->mainId, [19606])) {
- util::fail('请选择开单人');
- }
- } else {
- if (in_array($this->mainId, [])) {
- util::fail('请选择开单人');
- }
- }
- }
- if (getenv('YII_ENV') == 'production') {
- //小向花卉开单权限
- if ($this->mainId == 23390) {
- if (!in_array($this->adminId, [24043, 24585, 24586, 24654, 24115, 23960, 28456, 31105, 28456, 31105, 52528, 25011, 61449, 77951, 24655])) {
- util::fail('你不能开单哦');
- }
- }
- }
- //开单人和收款人必定是同个人
- $post['shopAdminId'] = $shopAdminId;
- $post['shopAdminName'] = $shopAdminName;
- $post['getStaffId'] = $shopAdminId;
- $post['getStaffName'] = $shopAdminName;
- if (getenv('YII_ENV') == 'production') {
- //南粤选了别的开单人,也只能变成本人开单
- if ($this->mainId == 22388) {
- $post['shopAdminName'] = $shopAdmin->name;
- $post['shopAdminId'] = $shopAdmin->id;
- $post['getStaffId'] = $shopAdmin->id;
- $post['getStaffName'] = $shopAdmin->name;
- }
- } else {
- if ($this->mainId == 644) {
- $post['shopAdminName'] = $shopAdmin->name;
- $post['shopAdminId'] = $shopAdmin->id;
- $post['getStaffId'] = $shopAdmin->id;
- $post['getStaffName'] = $shopAdmin->name;
- }
- }
- $post['sjId'] = $this->sjId;
- $post['shopId'] = $shopId;
- $post['mainId'] = $this->mainId;
- $post['fromType'] = 1;
- $post['expressId'] = $post['expressId'] ?? 0;
- $book = $post['book'] ?? 0;
- $post['book'] = $book;
- $sendType = $post['sendType'] ?? 0;
- $transType = $post['transType'] ?? 0;
- $shop = $this->shop;
- //过期不支持开单
- $deadline = $shop->deadline;
- $deadTime = strtotime($deadline);
- $myCurrentTime = time();
- $myCurrentDeadline = $deadTime;
- if ($myCurrentTime > $myCurrentDeadline) {
- util::fail('系统已到期,请续费哦');
- }
- if (isset($shop->pfLevel) && $shop->pfLevel == 1) {
- //昆明发往全国
- $sendCost = isset($post['sendCost']) && $post['sendCost'] > 0 ? $post['sendCost'] : 0;
- $post['sendCost'] = $sendCost;
- $packCost = isset($post['packCost']) && $post['packCost'] > 0 ? $post['packCost'] : 0;
- $post['packCost'] = $packCost;
- $post['transType'] = $transType;
- $post['localOrder'] = 1;
- } else {
- //同步配送
- $sendCost = isset($post['sendCost']) && $post['sendCost'] > 0 ? $post['sendCost'] : 0;
- if ($sendType != dict::getDict('sendType', 'thirdSend') && $sendCost > 0) {
- util::fail('填了运费,请选择跑腿');
- }
- $post['sendCost'] = $sendCost;
- $post['packCost'] = isset($post['packCost']) && $post['packCost'] > 0 ? $post['packCost'] : 0;
- }
- if ($book == 1) {
- $bookSn = $shop->bookSn ?? 0;
- if (empty($bookSn)) {
- util::fail('请开启预订');
- }
- $post['bookSn'] = $bookSn;
- }
- $hasPay = $post['hasPay'] ?? dict::getDict('hasPay', 'unPay'); //收款方式 0:扫码付 1:线下(已付款) 2:赊账(欠款)3:现金 4:余额
- $post['debt'] = OrderClass::DEBT_NO;
- if ($hasPay == dict::getDict('hasPay', 'debt')) {
- $post['debt'] = OrderClass::DEBT_YES;
- }
- if (!isset($shopAdmin->super) || $shopAdmin->super != 1) {
- if ($hasPay == dict::getDict('hasPay', 'payed')) {
- //util::fail('没有权限');
- }
- }
- if (getenv('YII_ENV') == 'production') {
- if ($this->mainId == 1082) {
- //泉城鲜花批发的出车,只能开收现金方式,多处要修改,关键词qc_cash
- if ($hasPay != 0) {
- util::fail('只能使用扫码付款,编号193');
- }
- }
- //小齐鲜花出车,源花汇,不能使用线下收款
- if ($this->mainId == 42680 || $this->mainId == 10536) {
- if ($hasPay == 1) {
- util::fail('线下收款暂时无法使用');
- }
- }
- } else {
- if ($this->mainId == 644) {
- if ($hasPay == 1) {
- //util::fail('线下收款暂时无法使用');
- }
- }
- }
- //多颜色数据整理
- $colorItem = $post['xj'] ?? [];
- $newXj = [];
- if (!empty($colorItem)) {
- $colorData = json_decode($colorItem, true);
- if (!empty($colorData) && is_array($colorData)) {
- foreach ($colorData as $colorInfo) {
- $ptItemId = $colorInfo['ptItemId'] ?? 0;
- $colorList = $colorInfo['list'] ?? [];
- if (!empty($colorList)) {
- foreach ($colorList as $colorItemKey => $colorItem) {
- $newXj[$ptItemId][] = $colorItem;
- }
- }
- }
- }
- }
- $post['xj'] = $newXj;
- $treeData = $post['treeData'] ?? [];
- $newTree = [];
- if (!empty($treeData)) {
- $treeArr = json_decode($treeData, true);
- if (!empty($treeArr) && is_array($treeArr)) {
- foreach ($treeArr as $treeInfo) {
- $ptItemId = $treeInfo['ptItemId'] ?? 0;
- $treeList = $treeInfo['list'] ?? [];
- if (!empty($treeList)) {
- foreach ($treeList as $treeItem) {
- $newTree[$ptItemId][] = $treeItem;
- }
- }
- }
- }
- }
- $post['treeData'] = $newTree;
- $productJson = $post['product'] ?? '';
- if (empty($productJson)) {
- //直接收款
- $zjGathering = $post['zjGathering'] ?? 0;
- if ($zjGathering == 1) {
- $gatheringPrice = $post['gatheringPrice'] ?? 0;
- if (!is_numeric($gatheringPrice) || $gatheringPrice <= 0) {
- util::fail('请填写价格');
- }
- //直接收款不需要打印小票
- $post['needPrint'] = 2;
- $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
- $zjGatheringItem = !empty($ext) ? $ext->zjGatheringItem : 0;
- if (empty($zjGatheringItem)) {
- util::fail('请设置收款的商品');
- }
- $zjGatheringItemInfo = ProductClass::getById($zjGatheringItem, true);
- if (empty($zjGatheringItemInfo)) {
- util::fail('请设置收款的商品呢');
- }
- $zjPtItemId = $zjGatheringItemInfo->itemId ?? 0;
- $productList = [['productId' => $zjGatheringItem, 'itemId' => $zjPtItemId, 'bigNum' => 1, 'smallNum' => 0, 'classId' => 0, 'price' => $gatheringPrice]];
- }
- } else {
- $productList = json_decode($productJson, true);
- }
- if (empty($productList)) {
- util::fail('请选择花材');
- }
- $ids = array_unique(array_filter(array_column($productList, 'productId')));
- $itemInfo = ProductClass::getByIds($ids, null, 'id');
- if (empty($itemInfo)) {
- util::fail('请选择花材哦');
- }
- //判断花材有效性
- foreach ($itemInfo as $itemData) {
- if (!isset($itemData['mainId']) || $itemData['mainId'] != $this->mainId) {
- util::fail('只能选一家的商品哈,请清空重选');
- }
- }
- $diff = [];
- $priceMap = CustomClass::$levelPriceKeyMap;
- //这个参数应该是要作废的,但下面加的参数是有用的,多处要同步修改,关键词 abandon_add_price_map ,ssh 20260116
- $addPriceMap = CustomClass::$levelAddPriceKeyMap;
- //但这边加的参数是有用的,给指定客户涨价的
- $addPriceMap['risePercent'] = $custom['risePercent'] ?? 0;
- $level = $custom['level'] ?? 1;
- foreach ($productList as $ptKey => $currentProduct) {
- $currentPrice = $currentProduct['price'] ?? 0;
- $currentId = $currentProduct['productId'] ?? 0;
- $systemInfo = $itemInfo[$currentId] ?? [];
- $name = $systemInfo['name'] ?? '';
- $systemPrice = ProductClass::getFinalPrice($systemInfo, $level, $priceMap, $addPriceMap);
- if (getenv('YII_ENV') == 'production') {
- //苏州小蔡鲜花,几个出车,不能低于原价卖,但可以高于原价卖的
- if (in_array($shopId, [38231, 38143, 29163, 29161])) {
- if ($currentPrice < $systemPrice) {
- util::fail('不能低于原价卖');
- }
- }
- } else {
- if (in_array($shopId, [36544])) {
- if ($currentPrice < $systemPrice) {
- util::fail('不能低于原价卖');
- }
- }
- }
- //后端开单,涉及花材满减,关键词 back_order_reach_discount_price
- $post['reachDiscountPrice'] = 0;
- if (floatval($currentPrice) != floatval($systemPrice)) {
- $diff[] = [
- 'name' => $name,
- 'price' => $systemPrice,
- 'kdPrice' => $currentPrice,
- ];
- } else {
- //后端开单,如果没有改价格,并且数量达到花材满减要求,则自动给减价格,关键词 back_order_reach_discount_price
- $bigNum = $currentProduct['bigNum'] ?? 0;
- $reachNum = $systemInfo['reachNum'] ?? 0;
- if ($reachNum > 0 && $bigNum >= $reachNum) {
- $reachNumDiscount = $systemInfo['reachNumDiscount'] ?? 0;
- $unitPrice = $currentProduct['price'] ?? 0;
- if ($unitPrice > $reachNumDiscount) {
- $newUnitPrice = bcsub($unitPrice, $reachNumDiscount, 2);
- $calcPrice = bcmul($reachNumDiscount, $bigNum, 2);
- if ($calcPrice > 0 && isset($post['modifyPrice']) && $post['modifyPrice'] > $calcPrice) {
- $productList[$ptKey]['price'] = $newUnitPrice;
- //提交给后端的总金额也要减掉,否则会有问题
- $post['modifyPrice'] = bcsub($post['modifyPrice'], $calcPrice, 2);
- $post['reachDiscountPrice'] = bcadd($post['reachDiscountPrice'], $calcPrice, 2);
- }
- }
- }
- }
- }
- //解决开单提交订单时,别人修改价格,造成提交价格不是真实卖价问题!!
- if ($dealPrice == 0) {
- if (!empty($diff)) {
- util::success(['diff' => $diff, 'respondType' => 'priceError']);
- }
- } else {
- if (!empty($diff)) {
- $mainId = $this->mainId;
- //花样年华,除了老板,只能按原价开单,不能改价格
- if (getenv('YII_ENV') == 'production') {
- if (in_array($mainId, [1553, 1563])) {
- if ($this->adminId != 2876) {
- util::fail('请按花材原价格开单');
- }
- }
- } else {
- if (in_array($mainId, [0, 1])) {
- util::fail('请按花材原价格开单');
- }
- }
- }
- }
- if ($book == 1) {
- $post['hasPay'] = 2;
- $post['payWay'] = 0;
- }
- $historyDate = $post['historyDate'] ?? '';
- if (!empty($historyDate)) {
- if ($book == 1) {
- util::fail('预订单不能选订单日期');
- }
- if ($hasPay == 0) {
- util::fail('扫码付不能选订单日期');
- }
- }
- $callErrand = $post['callErrand'] ?? 0;
- if ($callErrand == 1) {
- $shopExt = $this->shopExt;
- if ($shopExt->orderFlow == 0) {
- util::fail('下单后要变待发货,才能直接发跑腿');
- }
- }
- $post['product'] = $productList;
- //商家开单到时间会自动标记为欠款,所以360天内不过期,以保证足够时间标记欠款,具体参数查看dict local_gys_kd_auto_set_debt_time
- $time = time();
- $hasTime = dict::getDict('order_pay_has_time');
- $totalTime = bcadd($time, $hasTime);
- $post['deadline'] = date("Y-m-d H:i:s", $totalTime);
- $connection = Yii::$app->db;
- try {
- // 复杂分支/关键逻辑:优化。去除了并发重试机制 runWithDbConcurrencyRetry,降低锁等待和额外重试带来的性能瓶颈
- // 底层在发货和收货扣减库存时,使用商品 ID 升序排序加锁(SELECT FOR UPDATE)策略,100% 杜绝交叉死锁,因此这里无需再做重试。
- $transaction = $connection->beginTransaction();
- try {
- $return = OrderService::createNewOrder($post, $custom, $hasPay);
- $transaction->commit();
- } catch (\Exception $exception) {
- if ($transaction->isActive) {
- $transaction->rollBack();
- }
- throw $exception;
- }
- // 复杂分支/关键逻辑:优化。直接将创建成功的 $return 赋值给 $order,避免重复 SELECT 销售单
- $order = $return;
- if (!empty($order)) {
- //订单发跑腿流程
- GhsDeliveryOrderClass::prepareAskData($post, $order);
- $saleId = $order->id ?? 0;
- $shopId = $order->shopId ?? 0;
- $customId = $order->customId ?? 0;
- $ghsId = $order->ghsId ?? 0;
- $date = date("Y-m-d H:i:s");
- // 复杂分支/关键逻辑:优化。使用 updateByCondition 直接更新最后下单时间,避免先 SELECT 再 UPDATE 的性能开销
- if ($customId > 0) {
- CustomClass::updateByCondition(['id' => $customId], ['recentExpend' => $date]);
- }
- if ($ghsId > 0) {
- GhsClass::updateByCondition(['id' => $ghsId], ['recentExpend' => $date]);
- }
- $shop = ShopClass::getById($shopId, true);
- if (isset($order->payStatus) && $order->payStatus == 1) {
- if (!empty($shop)) {
- GhsNotifyClass::newOrderNotify($saleId);
- HdNotifyClass::newCgNotify($order->purchaseId);
- }
- }
- //订单生成时唤起在线打印
- if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
- //预订单开单不打小票,小向花卉不需要打小票
- $mainId = $order->mainId ?? 0;
- if ($order->book == 0 && !in_array($mainId, [23390])) {
- if ($order->status != 1 && $order->status != 5) {
- OrderClass::onlinePrint($order);
- $ext = $this->shopExt;
- if (isset($ext->printSn) && !empty($ext->printSn)) {
- $order->printNum += 1;
- $order->save();
- }
- //花镜 自己开单要打二次,有多处要修改搜索关键词 tow_print
- if (in_array($mainId, [76796])) {
- OrderClass::onlinePrint($order);
- $ext = $this->shopExt;
- if (isset($ext->printSn) && !empty($ext->printSn)) {
- $order->printNum += 1;
- $order->save();
- }
- }
- }
- }
- }
- //前台提醒出示付款码
- if (isset($order->status) && $order->status == 1) {
- if (isset($post['isCashier']) && $post['isCashier'] == 1) {
- ShopExtClass::ghsPleasePayReport($order);
- }
- }
- }
- util::success($return);
- } catch (\Exception $e) {
- Yii::error("下单失败原因:" . $e->getMessage());
- noticeUtil::push("批发线下开单失败,原因:" . $e->getMessage(), '15280215347');
- if (util::isDbConcurrencyException($e)) {
- util::fail('系统繁忙中,请稍后再试');
- } else {
- util::fail('下单失败');
- }
- }
- }
- //修改订单 ssh 20210810
- public function actionUpdateOrder()
- {
- $post = Yii::$app->request->post();
- util::fail('订单不可修改');
- //PC端开单
- if (isset($post['clearType'])) {
- $clearType = $post['clearType'];
- if ($clearType == OrderClass::CLEAR_DEBT) {
- $post['debt'] = OrderClass::DEBT_YES;
- $post['payWay'] = dict::getDict('payWay', 'debtPay');
- } else {
- $post['debt'] = OrderClass::DEBT_NO;
- }
- }
- //员工不能开已收款订单
- $debt = $post['debt'] ?? OrderClass::DEBT_YES;
- if ($debt == OrderClass::DEBT_NO) {
- $shopAdmin = $this->shopAdmin;
- if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
- util::fail('不能开已收款订单');
- }
- }
- //PC端开单
- if (isset($post['getType'])) {
- util::fail('暂不支持PC端修改订单');
- $getType = $post['getType'];
- //自取
- if ($getType == 1) {
- $post['sendType'] = OrderClass::SEND_TYPE_NO;
- } else {
- //选择配送时,在发货时让商家自己再确认一下用什么方式
- $post['sendType'] = OrderClass::SEND_TYPE_UNKNOWN;
- }
- }
- //商家开非自取订单,默认订单是待收款的,debt字段为非欠款
- if (isset($post['sendType']) && $post['sendType'] != OrderClass::SEND_TYPE_NO) {
- $post['debt'] = OrderClass::DEBT_NO;
- }
- $id = $post['id'] ?? 0;
- $order = OrderClass::getLockById($id);
- if (empty($order)) {
- util::fail('没有找到订单');
- }
- OrderClass::valid($order, $this->shopId);
- unset($post['id']);
- $shopAdmin = $this->shopAdmin;
- $post['shopAdminId'] = $this->shopAdminId;
- $post['shopAdminName'] = $shopAdmin->name ?? '';
- $post['fromType'] = 1;
- $post['sendCost'] = $post['sendCost'] ?? '0.00';
- $productJson = $post['product'] ?? '';
- if (empty($productJson)) {
- util::fail('请选择花材');
- }
- $productList = json_decode($productJson, true);
- if (empty($productList)) {
- util::fail('请选择花材');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- //判断花材有效性
- ProductClass::valid($productList, $this->mainId);
- $post['product'] = $productList;
- //商家开单订单有效期,到期记欠款
- $validTime = dict::getDict('order_pay_has_time');
- $current = time() + $validTime;
- $post['deadline'] = date("Y-m-d H:i:s", $current);
- $upData = [
- 'payWay' => $post['payWay'],
- 'sendType' => $post['sendType'],
- 'debt' => $post['debt'],
- 'needPrint' => $post['needPrint'],
- 'modifyPrice' => $post['modifyPrice'],
- 'shopAdminId' => $post['shopAdminId'],
- 'shopAdminName' => $post['shopAdminName'],
- 'fromType' => 1,
- 'sendCost' => $post['sendCost'],
- 'product' => $post['product'],
- 'deadline' => $post['deadline'],
- 'debt' => $post['debt'],
- ];
- $return = OrderService::updateOrder($order, $upData);
- $transaction->commit();
- util::success($return);
- } catch (\Exception $e) {
- $transaction->rollBack();
- Yii::error("下单失败原因:" . $e->getMessage());
- util::fail('下单失败');
- }
- }
- //取消预订单 ssh 20240503
- public function actionCancelBookOrder()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- if (empty($id)) {
- util::fail('请选择订单');
- }
- $order = OrderClass::getById($id, true);
- if (empty($order)) {
- util::fail('没有找到订单');
- }
- OrderClass::valid($order, $this->shopId);
- if ($order->book == 0) {
- util::fail('不是预订单');
- }
- if ($order->status != 2) {
- util::fail('当前订单状态不能取消');
- }
- $purchaseId = $order->purchaseId ?? 0;
- $purchase = PurchaseClass::getById($purchaseId, true);
- if (empty($purchase)) {
- util::fail('没有找到采购单');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $order->status = 5;
- $order->save();
- $purchase->status = 5;
- $purchase->save();
- $transaction->commit();
- util::complete('取消成功');
- } catch (\Exception $e) {
- $transaction->rollBack();
- $msg = $e->getMessage();
- $orderSn = $order->orderSn ?? '';
- noticeUtil::push("预订单{$orderSn}取消失败:{$msg}", '15280215347');
- }
- }
- //取消订单 shizhongqi 20220619
- public function actionCancelOrder()
- {
- $post = Yii::$app->request->post();
- $id = $post['orderId'] ?? 0;
- if (empty($id)) {
- util::fail('请选择订单');
- }
- $order = OrderClass::getById($id, true);
- if (empty($order)) {
- util::fail('请选择订单...');
- }
- OrderClass::valid($order, $this->shopId);
- if (isset($order->status) == false || $order->status != 1) {
- util::fail('不是待付款状态,无法取消');
- }
- $purchaseId = $order->purchaseId ?? 0;
- $purchase = PurchaseClass::getById($purchaseId);
- if (empty($purchase)) {
- util::fail('没有找到采购单');
- }
- $deadLineTime = strtotime($purchase['deadline']);
- $diff = $deadLineTime - time();
- if ($diff <= 60) {
- util::fail('1分钟后订单将自动取消');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- $orderSn = $purchase['orderSn'];
- try {
- $current = PurchaseClass::getById($purchaseId, true);
- PurchaseService::expire($current);
- $transaction->commit();
- //noticeUtil::push("采购单过期未付款,库存已回滚,单号:{$orderSn}");
- } catch (\Exception $e) {
- $transaction->rollBack();
- $msg = $e->getMessage();
- noticeUtil::push("采购单过期处理报错了!订单号:{$orderSn},错误信息:{$msg}", '15280215347');
- }
- util::complete();
- }
- //延期支付 ssh 2021.1.19
- public function actionDebt()
- {
- $id = Yii::$app->request->get('id');
- //4秒内不允许重复提交
- $cacheKey = 'ghs_set_order_debt_' . $id;
- $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
- if (!empty($has)) {
- util::fail('请稍等');
- }
- Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']);
- if (getenv('YII_ENV') == 'production') {
- if ($this->mainId == 1082) {
- //泉城鲜花批发的出车,只能开收现金方式,多处要修改,关键词qc_cash
- util::fail('只能使用扫码付款,编号293');
- }
- } else {
- }
- $order = OrderClass::getById($id, true);
- OrderClass::valid($order, $this->shopId);
- $payWay = dict::getDict('payWay', 'debtPay');
- $cgId = $order->purchaseId ?? 0;
- $cg = PurchaseClass::getById($cgId, true);
- if (empty($cg)) {
- util::fail('没有找到采购单');
- }
- if ($order->book == 1) {
- util::fail('预订单不能记欠款');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- PurchaseService::payAfter($cg, $payWay);
- OrderService::payAfter($order, $payWay);
- $transaction->commit();
- } catch (\Exception $exception) {
- $transaction->rollBack();
- Yii::info("延期支付报错:" . $exception->getMessage());
- util::fail('操作失败');
- }
- $order = OrderClass::getById($id, true);
- if (!empty($order)) {
- $shopId = $order->shopId ?? 0;
- $shop = ShopClass::getById($shopId, true);
- if (!empty($shop)) {
- //花店采购供货商端微信收到通知
- //WxMessageClass::ghsHasNewOrderInform($shop, $order);
- $noticeText = json_encode(['orderId' => $id]);
- $noticeKey = "hdCgNoticeGhs";
- Yii::$app->redis->executeCommand('LPUSH', [$noticeKey, $noticeText]);
- }
- //订单生成时唤起在线打印
- if (isset($order->needPrint) && $order->needPrint == dict::getDict('needPrint', 'need')) {
- if ($order->status != 1 && $order->status != 5) {
- OrderClass::onlinePrint($order);
- $ext = $this->shopExt;
- if (isset($ext->printSn) && !empty($ext->printSn)) {
- $order->printNum += 1;
- $order->save();
- }
- }
- }
- //付款成功之后呼叫跑腿,关键词 pay_after_call_pt,多处要同步修改
- GhsDeliveryOrderClass::payAfter($order);
- if ($order->status != 1 && $order->status != 5) {
- //花店采购供货商端APP收到通知
- //NoticeClass::ghsNewOrderNotice($order);
- //向供货商APP发通知
- // $cgShop = ShopClass::getById($cg->shopId, true, 'shopName, merchantName');
- // $push = new push('ghs', push::MSG_TYPE_ORDER);
- // $push->ghsOrderMessage($shop, $cgShop, $order);
- }
- }
- util::complete();
- }
- //获取商城下单要用的微信支付和小程序支付参数 ssh 2019.21.3
- public function actionWxPay()
- {
- ini_set('date.timezone', 'Asia/Shanghai');
- $post = Yii::$app->request->post();
- $couponId = $post['couponId'] ?? 0;
- $orderSn = isset($post['orderSn']) ? $post['orderSn'] : 0;
- $order = OrderClass::getByOrderSn($orderSn);
- if (empty($order)) {
- util::fail('订单号无效');
- }
- $id = $order['id'];
- //支付前验证订单有效性
- if (isset($order['adminId']) == false || $order['adminId'] != $this->adminId) {
- util::fail('无法操作');
- }
- $name = $order['orderName'] ?? '购买商品';
- $totalFee = $order['actPrice'];
- //强制使用小程序的miniOpenId
- $openId = isset($this->admin) && !empty($this->admin) ? $this->admin->miniOpenId : '';
- if (empty($openId)) {
- util::fail('没有找到openId');
- }
- $capitalType = dict::getDict('capitalType', 'xhGhsOrder', 'id');
- //流水类型、优惠卷、微信支付(h5还是小程序支付)类型 带到回调
- $wxPayType = 0;
- if (httpUtil::isMiniProgram()) {
- $wxPayType = 1;
- }
- $attach = "couponId=" . $couponId . "&capitalType=" . $capitalType . '&wxPayType=' . $wxPayType;
- //订单30分钟后过期
- $now = time();
- $expireTime = $now + 1800;
- $wx = Yii::getAlias("@vendor/weixin");
- require_once($wx . '/lib/WxPay.Api.php');
- require_once($wx . '/example/WxPay.JsApiPay.php');
- $input = new \WxPayUnifiedOrder();
- $input->SetBody($name);
- $input->SetOut_trade_no($orderSn);
- $input->SetTotal_fee($totalFee * 100);
- $input->SetTime_start(date("YmdHis", $now));
- $input->SetAttach($attach);//将流水类型、代金劵等传给微信再回传
- $input->SetTime_expire(date("YmdHis", $expireTime));
- $input->SetNotify_url(Yii::$app->params['ghsHost'] . '/notice/wx-callback/');
- $input->SetTrade_type("JSAPI");
- //花卉宝代为申请的微信支付
- //$sjExtend = $this->sjExtend->attributes;
- $sjExtend = WxOpenClass::getGhsWxInfo();
- if (isset($sjExtend['wxPayApply']) && $sjExtend['wxPayApply'] == 1) {
- $input->SetSub_openid($openId);
- } else {
- $input->SetOpenid($openId);
- }
- //强制使用小程序的miniAppId
- $sjExtend['wxAppId'] = $sjExtend['miniAppId'];
- $wxOrder = \WxPayApi::unifiedOrder($input, 6, $sjExtend);
- $tools = new \JsApiPay();
- $jsApiParameters = $tools->GetJsApiParameters($wxOrder, $sjExtend);
- $newParams = json_decode($jsApiParameters, true);
- //微信不能修改价格
- $current = date("Y-m-d H:i:s");
- $updateData = ['deadline' => $current, 'modPrice' => 0];
- OrderClass::updateById($id, $updateData);
- util::success($newParams);
- }
- //获取订单详情 ssh 2021.1.21
- public function actionDetail()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $info = OrderService::getOrderInfo($id, true, true, true, false);
- OrderClass::valid($info, $this->shopId);
- //A4打印需要用到的数据
- $customId = $info['customId'] ?? 0;
- $remark = $info['remark'] ?? '';
- $sendCost = $info['sendCost'] ?? 0;
- $sendNum = $info['sendNum'] ?? '';
- $packCost = $info['packCost'] ?? 0;
- $staffName = $info['shopAdminName'] ?? '';
- $ysName = '';
- if (isset($info['localOrder']) && $info['localOrder'] == 1) {
- if ($info['transType'] == 0) {
- $ysName = '德邦空运';
- }
- if ($info['transType'] == 1) {
- $ysName = '顺丰空运';
- }
- if ($info['transType'] == 2) {
- $ysName = '冷链物流';
- }
- if ($info['transType'] == 3) {
- $ysName = '航空物流';
- }
- if ($info['transType'] == 4) {
- $ysName = '同城配送';
- }
- if ($info['transType'] == 5) {
- $ysName = '到店自取';
- }
- } else {
- $sendType = $info['sendType'] ?? 0;
- $ysName = '送货上门';
- if ($sendType == 1) {
- $ysName = '到店自取';
- }
- if ($sendType == 2) {
- $ysName = '发跑腿';
- }
- if ($sendType == 3) {
- $wlName = $info['wlName'] ?? '';
- $ysName = '发物流';
- if (!empty($wlName)) {
- $ysName = $ysName . '-' . $wlName;
- }
- }
- }
- $fullAddress = '';
- if (getenv('YII_ENV') == 'production') {
- //老油的要显示地址
- if ($this->mainId == 20528) {
- $fullAddress = $info['fullAddress'] ?? '';
- }
- } else {
- if ($this->mainId == 644) {
- $fullAddress = $info['fullAddress'] ?? '';
- }
- }
- $custom = CustomClass::getById($customId, true);
- if (empty($custom)) {
- util::fail('没有找到客户');
- }
- $customName = $custom->name ?? '';
- $customMobile = $custom->customMobile ?? '';
- if (empty($customMobile)) {
- $customShopId = $custom->shopId ?? 0;
- $customShop = ShopClass::getById($customShopId, true);
- if (!empty($customShop)) {
- $customMobile = $customShop->mobile ?? '';
- }
- }
- if (!empty($customMobile)) {
- $customMobile = substr_replace($customMobile, '****', 3, 4);
- }
- $fullCustom = $customName . ' ' . $customMobile;
- if ($this->mainId == 8164) {
- //花大苪不显示客户名称
- $fullCustom = '';
- }
- $seatSn = isset($custom->seatSn) && !empty($custom->seatSn) ? $custom->seatSn : '无';
- $sendTimeWant = $info['sendTimeWant'] ?? '';
- $shortSendTimeWant = !empty($sendTimeWant) ? substr($sendTimeWant, 5, 5) : '';
- $totalItemNum = 0;
- $totalSmallItemNum = 0;
- $table = [];
- if (isset($info['product']) && !empty($info['product'])) {
- foreach ($info['product'] as $key => $val) {
- $currentName = $val['name'] ?? '';
- $num = $val['xhNum'] ?? 0;
- $refundNum = $val['refundNum'] ?? 0;
- $num = bcsub($num, $refundNum);
- $totalItemNum = bcadd($totalItemNum, $num);
- $ratio = $val['ratio'] ?? 0;
- $currentSmallNum = bcmul($num, $ratio);
- $totalSmallItemNum = bcadd($totalSmallItemNum, $currentSmallNum);
- $itemRemark = $val['remark'] ?? '';
- $unitPrice = $val['xhUnitPrice'] ?? 0;
- $unitPrice = floatval($unitPrice);
- $price = bcmul($unitPrice, $num, 2);
- $price = floatval($price);
- $table[] = [
- 'name' => $currentName,
- 'num' => $num,
- 'confirmNum' => '',
- 'remark' => $itemRemark,
- 'wxNumber' => 'shish3508',
- 'unitPrice' => $unitPrice,
- 'price' => $price,
- ];
- }
- }
- $shop = $this->shop;
- $sjName = $shop->merchantName ?? '';
- $shopName = $shop->shopName ?? '';
- $sjShopName = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
- $a4Print = [
- 'customName' => $fullCustom,
- 'staffName' => $staffName,
- 'seatSn' => $seatSn,
- 'shortSendTimeWant' => $shortSendTimeWant,
- 'table' => $table,
- 'remark' => $remark,
- 'fullAddress' => $fullAddress,
- 'sendNum' => $sendNum,
- 'sendCost' => $sendCost,
- 'ysName' => $ysName,
- 'packCost' => $packCost,
- 'totalItemNum' => $totalItemNum,
- 'totalSmallItemNum' => $totalSmallItemNum,
- 'shopName' => $sjShopName . ' 销售单',
- ];
- $info['printData'] = $a4Print;
- //常规模板
- //有用的历史备份
- $template = '{"panels":[{"index":0,"name":1,"height":297,"width":210,"paperHeader":49.5,"paperFooter":780,"printElements":[{"options":{"left":30,"top":53,"height":52,"width":538,"field":"table","coordinateSync":false,"widthHeightSync":false,"tableBorder":"border","tableHeaderBorder":"border","tableHeaderCellBorder":"border","tableHeaderFontWeight":"bold","right":567.25,"bottom":110.24609375,"vCenter":298.25,"hCenter":82.24609375,"textAlign":"center","columns":[[{"width":134.33608169277167,"title":"名称","field":"name","checked":true,"columnId":"name","fixed":false,"rowspan":1,"colspan":1,"align":"center","halign":"center","vAlign":"middle","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":74.77209598393634,"title":"预订数","field":"num","checked":true,"columnId":"num","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":73.30462681205907,"title":"确认数","field":"confirmNum","checked":true,"columnId":"confirmNum","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":71.10877448138285,"title":"单价","field":"unitPrice","checked":true,"columnId":"unitPrice","fixed":false,"rowspan":1,"colspan":1},{"width":84.32601880877743,"title":"金额","field":"price","checked":true,"columnId":"price","fixed":false,"rowspan":1,"colspan":1},{"width":100.15240222107263,"title":"备注","field":"remark","checked":true,"columnId":"remark","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""}]]},"printElementType":{"title":"空白表格","type":"table","editable":true,"columnDisplayEditable":true,"columnDisplayIndexEditable":true,"columnTitleEditable":true,"columnResizable":true,"columnAlignEditable":true,"isEnableEditField":true,"isEnableContextMenu":true,"isEnableInsertRow":true,"isEnableDeleteRow":true,"isEnableInsertColumn":true,"isEnableDeleteColumn":true,"isEnableMergeCell":true}},{"options":{"left":12,"top":786,"height":49,"width":49},"printElementType":{"title":"html","type":"html"}},{"options":{"left":382.5,"top":785,"height":13,"width":136,"title":"销花宝提供技术支持","textAlign":"center","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":518.74609375,"bottom":801.49609375,"vCenter":450.74609375,"hCenter":794.99609375},"printElementType":{"title":"自定义文本","type":"text"}},{"options":{"left":332.5,"top":35,"height":19,"width":233,"title":"货号","field":"seatSn","testData":"60","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"fontWeight":"bold","textAlign":"right","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":567.9921875,"bottom":51.2421875,"vCenter":451.4921875,"hCenter":29.2421875},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":32.5,"height":19,"width":128,"title":"12-16","right":147.75,"bottom":49.49609375,"vCenter":87.75,"hCenter":28.99609375,"field":"shortSendTimeWant","testData":"12-16","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":12,"fontWeight":"bold","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":92.5,"top":32.5,"height":19,"width":411,"title":"文本","right":469,"bottom":52.49609375,"vCenter":282.5,"hCenter":34.99609375,"field":"customName","testData":"纯彩 15280215347","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":11,"fontWeight":"bold","textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":150,"height":45,"width":535,"title":"备注","right":565.75,"bottom":195,"vCenter":298.25,"hCenter":172.5,"field":"remark","testData":"箱子上要写上姓名和电话,到货时要拆箱,检查里面的花材","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"fontWeight":"bold","lineHeight":30,"qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":107.5,"height":25,"width":536,"title":"地址","field":"fullAddress","testData":"福建省厦门市集美区前山路147号中华人民共和国福建省厦门市集美区前山路147号中华人民共和国","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":561.2421875,"bottom":616.75,"vCenter":293.2421875,"hCenter":581.75,"lineHeight":32.25,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":135,"height":15,"width":52,"title":"编号","field":"sendNum","testData":"39","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":241.99609375,"bottom":182.49609375,"vCenter":215.99609375,"hCenter":174.99609375,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":90,"top":135,"height":15,"width":79,"title":"德邦物流","right":173.9921875,"bottom":150,"vCenter":134.4921875,"hCenter":142.5,"field":"ysName","testData":"德邦物流","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"qrCodeLevel":0,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":174,"top":135,"height":15,"width":120,"title":"开单人","field":"staffName","testData":"石头","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":298.9921875,"bottom":154.74609375,"vCenter":238.9921875,"hCenter":149.87109375,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":297.5,"top":135,"height":15,"width":120,"title":"打包人","field":"packName","testData":"小林","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":417.4921875,"bottom":147.24609375,"vCenter":357.4921875,"hCenter":142.37109375,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":92.5,"top":7.5,"height":25,"width":411,"title":"文本","right":509.74609375,"bottom":35.99609375,"vCenter":309.74609375,"hCenter":24.49609375,"field":"shopName","testData":"小向花卉 销售单","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":16,"fontWeight":"bold","textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}}],"paperNumberLeft":552.5,"paperNumberTop":785,"paperNumberContinue":true,"fontFamily":"Microsoft YaHei","watermarkOptions":{"content":"","rotate":25,"timestamp":false,"format":"YYYY-MM-DD HH:mm","fillStyle":"rgba(184, 184, 184, 0.3)","fontSize":"14px","width":200,"height":200},"panelLayoutOptions":{"layoutType":"column","layoutRowGap":0,"layoutColumnGap":0}}]}';
- //$template = '{"panels":[{"index":0,"name":1,"height":297,"width":210,"paperHeader":49.5,"paperFooter":780,"printElements":[{"options":{"left":30,"top":53,"height":52,"width":538,"field":"table","coordinateSync":false,"widthHeightSync":false,"tableBorder":"border","tableHeaderBorder":"border","tableHeaderCellBorder":"border","tableHeaderFontWeight":"bold","right":567.25,"bottom":110.24609375,"vCenter":298.25,"hCenter":82.24609375,"textAlign":"center","columns":[[{"width":134.33608169277167,"title":"名称","field":"name","checked":true,"columnId":"name","fixed":false,"rowspan":1,"colspan":1,"align":"center","halign":"center","vAlign":"middle","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":74.77209598393634,"title":"预订数","field":"num","checked":true,"columnId":"num","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":73.30462681205907,"title":"确认数","field":"confirmNum","checked":true,"columnId":"confirmNum","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":71.10877448138285,"title":"单价","field":"unitPrice","checked":true,"columnId":"unitPrice","fixed":false,"rowspan":1,"colspan":1},{"width":84.32601880877743,"title":"金额","field":"price","checked":true,"columnId":"price","fixed":false,"rowspan":1,"colspan":1},{"width":100.15240222107263,"title":"备注","field":"remark","checked":true,"columnId":"remark","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""}]]},"printElementType":{"title":"空白表格","type":"table","editable":true,"columnDisplayEditable":true,"columnDisplayIndexEditable":true,"columnTitleEditable":true,"columnResizable":true,"columnAlignEditable":true,"isEnableEditField":true,"isEnableContextMenu":true,"isEnableInsertRow":true,"isEnableDeleteRow":true,"isEnableInsertColumn":true,"isEnableDeleteColumn":true,"isEnableMergeCell":true}},{"options":{"left":12,"top":786,"height":49,"width":49},"printElementType":{"title":"html","type":"html"}},{"options":{"left":382.5,"top":785,"height":13,"width":136,"title":"销花宝提供技术支持","textAlign":"center","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":518.74609375,"bottom":801.49609375,"vCenter":450.74609375,"hCenter":794.99609375},"printElementType":{"title":"自定义文本","type":"text"}},{"options":{"left":332.5,"top":35,"height":19,"width":233,"title":"货号","field":"seatSn","testData":"60","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"fontWeight":"bold","textAlign":"right","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":567.9921875,"bottom":51.2421875,"vCenter":451.4921875,"hCenter":29.2421875},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":32.5,"height":19,"width":128,"title":"12-16","right":147.75,"bottom":49.49609375,"vCenter":87.75,"hCenter":28.99609375,"field":"shortSendTimeWant","testData":"12-16","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":12,"fontWeight":"bold","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":92.5,"top":32.5,"height":19,"width":411,"title":"文本","right":469,"bottom":52.49609375,"vCenter":282.5,"hCenter":34.99609375,"field":"customName","testData":"纯彩 15280215347","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":11,"fontWeight":"bold","textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":145,"height":45,"width":535,"title":"备注","right":559.24609375,"bottom":207.99609375,"vCenter":291.74609375,"hCenter":185.49609375,"field":"remark","testData":"箱子上要写上姓名和电话,到货时要拆箱,检查里面的花材","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"fontWeight":"bold","lineHeight":30,"qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":107.5,"height":30,"width":536,"title":"地址","field":"fullAddress","testData":"福建省厦门市集美区前山路147号中华人民共和国福建省厦门市集美区前山路147号中华人民共和国","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":561.2421875,"bottom":616.75,"vCenter":293.2421875,"hCenter":581.75,"lineHeight":32.25},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":135,"height":15,"width":52,"title":"编号","field":"sendNum","testData":"39","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":241.99609375,"bottom":182.49609375,"vCenter":215.99609375,"hCenter":174.99609375},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":95,"top":135,"height":15,"width":79,"title":"德邦物流","right":174.25,"bottom":159.24609375,"vCenter":134.75,"hCenter":151.74609375,"field":"ysName","testData":"德邦物流","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":177.5,"top":137.5,"height":9.75,"width":120,"title":"开单人","field":"staffName","testData":"石头","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":298.9921875,"bottom":154.74609375,"vCenter":238.9921875,"hCenter":149.87109375},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":297.5,"top":137.5,"height":9.75,"width":120,"title":"打包人","field":"packName","testData":"小林","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":417.4921875,"bottom":147.24609375,"vCenter":357.4921875,"hCenter":142.37109375},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":92.5,"top":7.5,"height":25,"width":411,"title":"文本","right":509.74609375,"bottom":35.99609375,"vCenter":309.74609375,"hCenter":24.49609375,"field":"shopName","testData":"小向花卉 销售单","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":16,"fontWeight":"bold","textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}}],"paperNumberLeft":552.5,"paperNumberTop":785,"paperNumberContinue":true,"fontFamily":"Microsoft YaHei","watermarkOptions":{"content":"","rotate":25,"timestamp":false,"format":"YYYY-MM-DD HH:mm","fillStyle":"rgba(184, 184, 184, 0.3)","fontSize":"14px","width":200,"height":200},"panelLayoutOptions":{"layoutType":"column","layoutRowGap":0,"layoutColumnGap":0}}]}';
- if (getenv('YII_ENV') == 'production') {
- //花大苪模板
- if (in_array($this->mainId, [8164])) {
- $template = '{"panels":[{"index":0,"name":1,"height":297,"width":210,"paperHeader":49.5,"paperFooter":780,"printElements":[{"options":{"left":30,"top":53,"height":52,"width":538,"field":"table","coordinateSync":false,"widthHeightSync":false,"fontSize":16,"lineHeight":30,"tableBorder":"border","tableHeaderBorder":"border","tableHeaderCellBorder":"border","tableHeaderFontWeight":"bold","right":567.25,"bottom":110.24609375,"vCenter":298.25,"hCenter":82.24609375,"textAlign":"center","columns":[[{"width":188.91632245461145,"title":"名称","field":"name","checked":true,"columnId":"name","fixed":false,"rowspan":1,"colspan":1,"align":"center","halign":"center","vAlign":"middle","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":105.15171514242958,"title":"预订数","field":"num","checked":true,"columnId":"num","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":103.08801880877742,"title":"确认数","field":"confirmNum","checked":true,"columnId":"confirmNum","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":140.84394359418155,"title":"备注","field":"remark","checked":true,"columnId":"remark","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":93.32065807548679,"title":"日期","field":"shortTime","checked":false,"columnId":"shortTime","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":74.09275968851016,"title":"库存","field":"stock","checked":false,"columnId":"stock","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":276,"title":"金额\n","field":"amount","checked":false,"columnId":"amount","fixed":false,"rowspan":1,"colspan":1,"tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":100,"title":"","field":"","checked":false,"columnId":"","fixed":false,"rowspan":1,"colspan":1},{"width":100,"title":"","field":"","checked":false,"columnId":"","fixed":false,"rowspan":1,"colspan":1}]]},"printElementType":{"title":"空白表格","type":"table","editable":true,"columnDisplayEditable":true,"columnDisplayIndexEditable":true,"columnTitleEditable":true,"columnResizable":true,"columnAlignEditable":true,"isEnableEditField":true,"isEnableContextMenu":true,"isEnableInsertRow":true,"isEnableDeleteRow":true,"isEnableInsertColumn":true,"isEnableDeleteColumn":true,"isEnableMergeCell":true}},{"options":{"left":12,"top":786,"height":49,"width":49},"printElementType":{"title":"html","type":"html"}},{"options":{"left":392.5,"top":785,"height":13,"width":199,"title":"销花宝提供技术支持","textAlign":"center","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":590.74609375,"bottom":801.25,"vCenter":491.24609375,"hCenter":794.75},"printElementType":{"title":"自定义文本","type":"text"}},{"options":{"left":335,"top":12.5,"height":44,"width":233,"title":"货号","field":"seatSn","testData":"60","coordinateSync":false,"widthHeightSync":false,"fontSize":20,"fontWeight":"bold","textAlign":"right","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":567.9921875,"bottom":51.2421875,"vCenter":451.4921875,"hCenter":29.2421875},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":12.5,"height":46,"width":128,"title":"12-16","right":147.75,"bottom":49.49609375,"vCenter":87.75,"hCenter":28.99609375,"field":"shortSendTimeWant","testData":"12-16","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":20,"fontWeight":"bold","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":95,"top":17.5,"height":35,"width":373,"title":"文本","right":469,"bottom":52.49609375,"vCenter":282.5,"hCenter":34.99609375,"field":"customName","testData":"纯彩 15280215347","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":14,"fontWeight":"bold","textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":32.5,"top":377.5,"height":200,"width":535,"title":"备注","right":571.4921875,"bottom":550.25,"vCenter":303.9921875,"hCenter":450.25,"field":"remark","testData":"箱子上要写上姓名和电话,到货时要拆箱,检查里面的花材","coordinateSync":false,"widthHeightSync":false,"fontSize":20,"fontWeight":"bold","lineHeight":30,"qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":32.5,"top":302.5,"height":70,"width":536,"title":"地址","field":"fullAddress","testData":"福建省厦门市集美区前山路147号中华人民共和国福建省厦门市集美区前山路147号中华人民共和国","coordinateSync":false,"widthHeightSync":false,"fontSize":18,"fontWeight":"bold","qrCodeLevel":0,"right":561.2421875,"bottom":616.75,"vCenter":293.2421875,"hCenter":581.75,"lineHeight":32.25},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":200,"height":50,"width":400,"title":"编号","field":"sendNum","testData":"39","coordinateSync":false,"widthHeightSync":false,"fontSize":20,"lineHeight":36,"qrCodeLevel":0,"right":430,"bottom":284.99609375,"vCenter":230,"hCenter":259.99609375},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":32.5,"top":257.5,"height":39,"width":240,"title":"运费","field":"sendCost","testData":"0","coordinateSync":false,"widthHeightSync":false,"fontSize":20,"lineHeight":28.5,"qrCodeLevel":0,"right":526.7421875,"bottom":415.74609375,"vCenter":276.7421875,"hCenter":400.74609375},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":295,"top":202.5,"height":43,"width":270,"title":"德邦物流","right":565.74609375,"bottom":280.99609375,"vCenter":430.74609375,"hCenter":259.49609375,"field":"ysName","testData":"德邦物流","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":20,"lineHeight":36,"qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":297.5,"top":260,"height":41,"width":260,"title":"打包费","field":"packCost","testData":"30","coordinateSync":false,"widthHeightSync":false,"fontSize":20,"lineHeight":24,"qrCodeLevel":0,"right":555.74609375,"bottom":332.99609375,"vCenter":425.74609375,"hCenter":312.49609375},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":160,"height":36,"width":189,"title":"花材数量","field":"totalItemNum","testData":"20","coordinateSync":false,"widthHeightSync":false,"fontFamily":"cursive","fontSize":24,"fontWeight":"bold","lineHeight":32.25,"qrCodeLevel":0,"right":219,"bottom":158.49609375,"vCenter":124.5,"hCenter":140.49609375},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":295,"top":160,"height":36,"width":189,"title":"支数","field":"totalSmallItemNum","testData":"600","coordinateSync":false,"widthHeightSync":false,"fontFamily":"cursive","fontSize":24,"fontWeight":"bold","lineHeight":32.25,"qrCodeLevel":0,"right":482.25,"bottom":195.24609375,"vCenter":387.75,"hCenter":177.24609375},"printElementType":{"title":"文本","type":"text"}}],"paperNumberLeft":565.5,"paperNumberTop":819,"paperNumberContinue":true,"watermarkOptions":{"content":"vue-plugin-hiprint","rotate":25,"timestamp":true,"format":"YYYY-MM-DD HH:mm"},"panelLayoutOptions":{}}]}';
- }
- if (in_array($this->mainId, [44282])) {
- //$template = '{"panels":[{"index":0,"name":1,"height":297,"width":210,"paperHeader":73.5,"paperFooter":780,"printElements":[{"options":{"left":30,"top":77,"height":52,"width":538,"field":"table","coordinateSync":false,"widthHeightSync":false,"tableBorder":"border","tableHeaderBorder":"border","tableHeaderCellBorder":"border","tableHeaderFontWeight":"bold","right":567.25,"bottom":110.24609375,"vCenter":298.25,"hCenter":82.24609375,"textAlign":"center","columns":[[{"width":134.33608169277167,"title":"名称","field":"name","checked":true,"columnId":"name","fixed":false,"rowspan":1,"colspan":1,"align":"center","halign":"center","vAlign":"middle","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":74.77209598393634,"title":"预订数","field":"num","checked":true,"columnId":"num","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":73.30462681205907,"title":"确认数","field":"confirmNum","checked":true,"columnId":"confirmNum","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":71.10877448138285,"title":"单价","field":"unitPrice","checked":true,"columnId":"unitPrice","fixed":false,"rowspan":1,"colspan":1},{"width":84.32601880877743,"title":"金额","field":"price","checked":true,"columnId":"price","fixed":false,"rowspan":1,"colspan":1},{"width":100.15240222107263,"title":"备注","field":"remark","checked":true,"columnId":"remark","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""}]]},"printElementType":{"title":"空白表格","type":"table","editable":true,"columnDisplayEditable":true,"columnDisplayIndexEditable":true,"columnTitleEditable":true,"columnResizable":true,"columnAlignEditable":true,"isEnableEditField":true,"isEnableContextMenu":true,"isEnableInsertRow":true,"isEnableDeleteRow":true,"isEnableInsertColumn":true,"isEnableDeleteColumn":true,"isEnableMergeCell":true}},{"options":{"left":12,"top":786,"height":49,"width":49},"printElementType":{"title":"html","type":"html"}},{"options":{"left":382.5,"top":785,"height":13,"width":136,"title":"销花宝提供技术支持","textAlign":"center","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":518.74609375,"bottom":801.49609375,"vCenter":450.74609375,"hCenter":794.99609375},"printElementType":{"title":"自定义文本","type":"text"}},{"options":{"left":332.5,"top":53,"height":19,"width":233,"title":"货号","field":"seatSn","testData":"60","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"fontWeight":"bold","textAlign":"right","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":567.9921875,"bottom":51.2421875,"vCenter":451.4921875,"hCenter":29.2421875},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":50.5,"height":19,"width":128,"title":"12-16","right":147.75,"bottom":49.49609375,"vCenter":87.75,"hCenter":28.99609375,"field":"shortSendTimeWant","testData":"12-16","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":12,"fontWeight":"bold","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":92.5,"top":50.5,"height":19,"width":411,"title":"文本","right":469,"bottom":52.49609375,"vCenter":282.5,"hCenter":34.99609375,"field":"customName","testData":"纯彩 15280215347","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":11,"fontWeight":"bold","textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":181.5,"height":45,"width":535,"title":"备注","right":565.75,"bottom":195,"vCenter":298.25,"hCenter":172.5,"field":"remark","testData":"箱子上要写上姓名和电话,到货时要拆箱,检查里面的花材","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"fontWeight":"bold","lineHeight":30,"qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":137.5,"height":25,"width":536,"title":"地址","field":"fullAddress","testData":"福建省厦门市集美区前山路147号中华人民共和国福建省厦门市集美区前山路147号中华人民共和国","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":561.2421875,"bottom":616.75,"vCenter":293.2421875,"hCenter":581.75,"lineHeight":32.25,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":165,"height":15,"width":52,"title":"编号","field":"sendNum","testData":"39","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":241.99609375,"bottom":182.49609375,"vCenter":215.99609375,"hCenter":174.99609375,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":90,"top":165,"height":15,"width":79,"title":"德邦物流","right":173.9921875,"bottom":150,"vCenter":134.4921875,"hCenter":142.5,"field":"ysName","testData":"德邦物流","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"qrCodeLevel":0,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":174,"top":165,"height":15,"width":120,"title":"开单人","field":"staffName","testData":"石头","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":298.9921875,"bottom":154.74609375,"vCenter":238.9921875,"hCenter":149.87109375,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":297.5,"top":165,"height":15,"width":120,"title":"打包人","field":"packName","testData":"小林","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":417.4921875,"bottom":147.24609375,"vCenter":357.4921875,"hCenter":142.37109375,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":92.5,"top":25.5,"height":25,"width":411,"title":"文本","right":509.74609375,"bottom":35.99609375,"vCenter":309.74609375,"hCenter":24.49609375,"field":"shopName","testData":"小向花卉 销售单","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":16,"fontWeight":"bold","textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}}],"paperNumberLeft":552.5,"paperNumberTop":785,"paperNumberContinue":true,"fontFamily":"Microsoft YaHei","watermarkOptions":{"content":"","rotate":25,"timestamp":false,"format":"YYYY-MM-DD HH:mm","fillStyle":"rgba(184, 184, 184, 0.3)","fontSize":"14px","width":200,"height":200},"panelLayoutOptions":{"layoutType":"column","layoutRowGap":0,"layoutColumnGap":0}}]}';
- $template = '{"panels":[{"index":0,"name":1,"height":297,"width":210,"paperHeader":73.5,"paperFooter":780,"printElements":[{"options":{"left":30,"top":77,"height":52,"width":538,"field":"table","coordinateSync":false,"widthHeightSync":false,"tableBorder":"border","tableHeaderBorder":"border","tableHeaderCellBorder":"border","tableHeaderFontWeight":"bold","right":567.25,"bottom":110.24609375,"vCenter":298.25,"hCenter":82.24609375,"textAlign":"center","fontSize":11.25,"columns":[[{"width":134.33608169277167,"title":"名称","field":"name","checked":true,"columnId":"name","fixed":false,"rowspan":1,"colspan":1,"align":"center","halign":"center","vAlign":"middle","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":74.77209598393634,"title":"预订数","field":"num","checked":true,"columnId":"num","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":73.30462681205907,"title":"确认数","field":"confirmNum","checked":true,"columnId":"confirmNum","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""},{"width":71.10877448138285,"title":"单价","field":"unitPrice","checked":true,"columnId":"unitPrice","fixed":false,"rowspan":1,"colspan":1},{"width":84.32601880877743,"title":"金额","field":"price","checked":true,"columnId":"price","fixed":false,"rowspan":1,"colspan":1},{"width":100.15240222107263,"title":"备注","field":"remark","checked":true,"columnId":"remark","fixed":false,"rowspan":1,"colspan":1,"align":"center","tableQRCodeLevel":0,"tableSummaryTitle":true,"tableSummary":""}]]},"printElementType":{"title":"空白表格","type":"table","editable":true,"columnDisplayEditable":true,"columnDisplayIndexEditable":true,"columnTitleEditable":true,"columnResizable":true,"columnAlignEditable":true,"isEnableEditField":true,"isEnableContextMenu":true,"isEnableInsertRow":true,"isEnableDeleteRow":true,"isEnableInsertColumn":true,"isEnableDeleteColumn":true,"isEnableMergeCell":true}},{"options":{"left":12,"top":786,"height":49,"width":49},"printElementType":{"title":"html","type":"html"}},{"options":{"left":382.5,"top":785,"height":13,"width":136,"title":"销花宝提供技术支持","textAlign":"center","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":518.74609375,"bottom":801.49609375,"vCenter":450.74609375,"hCenter":794.99609375},"printElementType":{"title":"自定义文本","type":"text"}},{"options":{"left":332.5,"top":53,"height":19,"width":233,"title":"货号","field":"seatSn","testData":"60","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"fontWeight":"bold","textAlign":"right","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":567.9921875,"bottom":51.2421875,"vCenter":451.4921875,"hCenter":29.2421875},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":50.5,"height":19,"width":128,"title":"12-16","right":147.75,"bottom":49.49609375,"vCenter":87.75,"hCenter":28.99609375,"field":"shortSendTimeWant","testData":"12-16","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":12,"fontWeight":"bold","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":93,"top":51,"height":19,"width":411,"title":"文本","right":503.49609375,"bottom":69.49609375,"vCenter":297.99609375,"hCenter":59.99609375,"field":"customName","testData":"纯彩 15280215347","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":11,"fontWeight":"bold","textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":181.5,"height":45,"width":535,"title":"备注","right":565.75,"bottom":195,"vCenter":298.25,"hCenter":172.5,"field":"remark","testData":"箱子上要写上姓名和电话,到货时要拆箱,检查里面的花材","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"fontWeight":"bold","lineHeight":30,"qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":137.5,"height":25,"width":536,"title":"地址","field":"fullAddress","testData":"福建省厦门市集美区前山路147号中华人民共和国福建省厦门市集美区前山路147号中华人民共和国","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":561.2421875,"bottom":616.75,"vCenter":293.2421875,"hCenter":581.75,"lineHeight":32.25,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":165,"height":15,"width":52,"title":"编号","field":"sendNum","testData":"39","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":241.99609375,"bottom":182.49609375,"vCenter":215.99609375,"hCenter":174.99609375,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":90,"top":165,"height":15,"width":79,"title":"德邦物流","right":173.9921875,"bottom":150,"vCenter":134.4921875,"hCenter":142.5,"field":"ysName","testData":"德邦物流","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"qrCodeLevel":0,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":174,"top":165,"height":15,"width":120,"title":"开单人","field":"staffName","testData":"石头","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":298.9921875,"bottom":154.74609375,"vCenter":238.9921875,"hCenter":149.87109375,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":297.5,"top":165,"height":15,"width":120,"title":"打包人","field":"packName","testData":"小林","coordinateSync":false,"widthHeightSync":false,"qrCodeLevel":0,"right":417.4921875,"bottom":147.24609375,"vCenter":357.4921875,"hCenter":142.37109375,"textContentVerticalAlign":"middle"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":92.5,"top":25.5,"height":25,"width":411,"title":"文本","right":509.74609375,"bottom":35.99609375,"vCenter":309.74609375,"hCenter":24.49609375,"field":"shopName","testData":"小向花卉 销售单","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":16,"fontWeight":"bold","textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}}],"paperNumberLeft":552.5,"paperNumberTop":785,"paperNumberContinue":true,"fontFamily":"Microsoft YaHei","watermarkOptions":{"content":"","rotate":25,"timestamp":false,"format":"YYYY-MM-DD HH:mm","fillStyle":"rgba(184, 184, 184, 0.3)","fontSize":"14px","width":200,"height":200},"panelLayoutOptions":{"layoutType":"column","layoutRowGap":0,"layoutColumnGap":0}}]}';
- }
- }
- $info['template'] = $template;
- $printType = $get['printType'] ?? 0;
- if ($printType == 1) {
- //打多联的模板
- $table = [];
- if (isset($info['product']) && !empty($info['product'])) {
- foreach ($info['product'] as $key => $val) {
- $currentName = $val['name'] ?? '';
- $num = $val['xhNum'] ?? 0;
- $refundNum = $val['refundNum'] ?? 0;
- $num = bcsub($num, $refundNum);
- $totalItemNum = bcadd($totalItemNum, $num);
- $ratio = $val['ratio'] ?? 0;
- $currentSmallNum = bcmul($num, $ratio);
- $totalSmallItemNum = bcadd($totalSmallItemNum, $currentSmallNum);
- $itemRemark = $val['remark'] ?? '';
- $unitPrice = $val['xhUnitPrice'] ?? 0;
- $unitPrice = floatval($unitPrice);
- $price = bcmul($unitPrice, $num, 2);
- $price = floatval($price);
- $table[] = [
- 'name' => $currentName,
- 'num' => $num,
- 'orderNum' => '',
- 'remark' => $itemRemark,
- 'wxNumber' => 'shish3508',
- 'unitPrice' => '¥' . $unitPrice,
- 'price' => '¥' . $price,
- 'refundNum' => $refundNum == 0 ? '' : 0,
- ];
- }
- }
- $orderSn = $info['orderSn'] ?? '';
- $kind = $info['productStat'] && $info['productStat']['kind'] ?? 0;
- $totalItemNum = $info['productStat'] && $info['productStat']['bigNum'] ?? 0;
- $addTime = $info['addTime'] ?? '';
- $actPrice = $info['actPrice'] ?? 0;
- $tkPrice = $info['tkPrice'] ?? 0;
- $prePrice = $info['prePrice'] ?? 0;
- $customMobile = $info['customMobile'] ?? '';
- $address = '';
- if (isset($info['address']) && !empty($info['address'])) {
- $address .= $info['fullAddress'];
- if (isset($info['showAddress']) && !empty($info['showAddress']) && $info['showAddress'] != $info['fullAddress']) {
- $address .= '(' . $info['showAddress'] . ')<BR>';
- }
- }
- $printData = [
- 'table' => $table,
- 'addTime' => '',
- 'entryTime' => $addTime,
- 'ghsName' => $customName,
- 'clearCode' => '',
- 'staffName' => '',
- 'telephone' => $customMobile,
- 'kind' => $kind,
- 'orderSn' => $orderSn,
- 'sjShopName' => $sjShopName . ' 销售单',
- 'sjShopName2' => $sjShopName,
- 'prePrice' => '¥' . $prePrice,
- 'tkPrice' => '¥' . $tkPrice,
- 'realPrice' => '¥' . $actPrice,
- 'totalItemNum' => $totalItemNum,
- 'numKind' => "共" . $kind . "种,数量:" . $totalItemNum,
- 'address' => $address,
- 'saleName' => '销售单',
- ];
- $info['printData'] = $printData;
- $template = '{"panels":[{"index":0,"name":1,"height":140,"width":210,"paperHeader":49.5,"paperFooter":383.4343434343434,"printElements":[{"options":{"left":115,"top":20,"height":25,"width":374,"title":"文本","right":488.99609375,"bottom":44.9921875,"vCenter":301.99609375,"hCenter":32.4921875,"field":"sjShopName","testData":"小向花卉 采购单","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":14,"fontWeight":"bold","textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":27.5,"top":22.5,"height":21,"width":145,"title":"单号","field":"orderSn","testData":"PC563961","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":148.9921875,"bottom":43.9921875,"vCenter":85.9921875,"hCenter":33.4921875,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":445,"top":25,"height":22,"width":122,"title":"核销码","field":"clearCode","testData":"3961","coordinateSync":false,"widthHeightSync":false,"fontSize":12,"textAlign":"right","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":571.25,"bottom":46.75,"vCenter":510.25,"hCenter":35.75,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":22.5,"top":55,"height":36,"width":550,"field":"table","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textAlign":"center","tableHeaderFontWeight":"bold","right":572.5,"bottom":90.99609375,"vCenter":297.5,"hCenter":72.99609375,"fontFamily":"SimSun","columns":[[{"width":54.223705213537556,"title":"序号","field":"orderNum","checked":true,"columnId":"orderNum","fixed":false,"rowspan":1,"colspan":1},{"width":175.72632876030514,"title":"花材名称","field":"name","checked":true,"columnId":"name","fixed":false,"rowspan":1,"colspan":1},{"width":69.07232544378695,"title":"单价","field":"unitPrice","checked":true,"columnId":"unitPrice","fixed":false,"rowspan":1,"colspan":1},{"width":72.10486265361865,"title":"数量","field":"num","checked":true,"columnId":"num","fixed":false,"rowspan":1,"colspan":1},{"width":67.11113461538461,"title":"金额","field":"price","checked":true,"columnId":"price","fixed":false,"rowspan":1,"colspan":1},{"width":57.08931639029012,"title":"已退","field":"refundNum","checked":true,"columnId":"refundNum","fixed":false,"rowspan":1,"colspan":1},{"width":54.67232692307692,"title":"备注","field":"remark","checked":true,"columnId":"remark","fixed":false,"rowspan":1,"colspan":1},{"width":100,"title":"","field":"","checked":false,"columnId":"","fixed":false,"rowspan":1,"colspan":1},{"width":100,"title":"","field":"","checked":false,"columnId":"","fixed":false,"rowspan":1,"colspan":1}]]},"printElementType":{"title":"空白表格","type":"table","editable":true,"columnDisplayEditable":true,"columnDisplayIndexEditable":true,"columnTitleEditable":true,"columnResizable":true,"columnAlignEditable":true,"isEnableEditField":true,"isEnableContextMenu":true,"isEnableInsertRow":true,"isEnableDeleteRow":true,"isEnableInsertColumn":true,"isEnableDeleteColumn":true,"isEnableMergeCell":true}},{"options":{"left":200,"top":120,"height":16,"width":178,"title":"账单日期","field":"addTime","testData":"2024-12-28 11:00","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":359.49609375,"bottom":146.9921875,"vCenter":276.99609375,"hCenter":138.9921875,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":372,"top":120,"height":16,"width":178,"title":"客户","field":"ghsName","testData":"石头花艺","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":573.49609375,"bottom":145.99609375,"vCenter":484.49609375,"hCenter":137.99609375,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":27.5,"top":120,"height":16,"width":175,"title":"创建时间","right":141.75,"bottom":139.5,"vCenter":81.75,"hCenter":134.625,"field":"entryTime","testData":"2024-12-29 12:10","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":132.5,"top":145,"height":16,"width":90,"title":"售后","right":262.74609375,"bottom":161.2421875,"vCenter":202.74609375,"hCenter":153.2421875,"field":"tkPrice","testData":"63","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":222.5,"top":145,"height":16,"width":114,"title":"实际金额","field":"realPrice","testData":"23","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":358.9921875,"bottom":160.99609375,"vCenter":301.9921875,"hCenter":152.99609375,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":347.5,"top":145,"height":16,"width":120,"title":"电话","field":"telephone","testData":"15280215347","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":467.7421875,"bottom":161.2421875,"vCenter":407.7421875,"hCenter":153.2421875,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":425,"top":145,"height":16,"width":148,"title":"录单人","field":"staffName","testData":"小石","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textAlign":"right","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":574.4921875,"bottom":161.2421875,"vCenter":500.4921875,"hCenter":153.2421875,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":27.5,"top":145,"height":16,"width":105,"title":"合计","field":"prePrice","testData":"693","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":144,"bottom":160.24609375,"vCenter":85.5,"hCenter":152.24609375,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":169.5,"height":16,"width":120,"field":"numKind","testData":"共3种,数量:9","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"title":"文本","fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":169.5,"top":169.5,"height":16,"width":400,"title":"地址","field":"address","testData":"厦门前山路147号","coordinateSync":false,"widthHeightSync":false,"fontSize":10.5,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":569.5,"bottom":185.5,"vCenter":369.5,"hCenter":177.5},"printElementType":{"title":"文本","type":"text"}}],"paperNumberLeft":565.5,"paperNumberTop":389,"paperNumberDisabled":true,"paperNumberContinue":true,"orient":1,"watermarkOptions":{"content":"","rotate":25,"timestamp":false,"format":"YYYY-MM-DD HH:mm","fillStyle":"rgba(184, 184, 184, 0.3)","fontSize":"14px","width":200,"height":200},"panelLayoutOptions":{"layoutType":"column","layoutRowGap":0,"layoutColumnGap":0}}]}';
- if (in_array($this->mainId, [91452])) {
- //绿科花卉种苗
- $template = '{"panels":[{"index":0,"name":1,"height":140,"width":210,"paperHeader":76.5,"paperFooter":383.4343434343434,"printElements":[{"options":{"left":115.5,"top":21,"height":25,"width":374,"title":"文本","right":488.99609375,"bottom":44.9921875,"vCenter":301.99609375,"hCenter":32.4921875,"field":"sjShopName2","testData":"小向花卉","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":21,"fontWeight":"bold","textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":18.5,"top":22.5,"height":21,"width":165,"title":"单号","field":"orderSn","testData":"PC563961","coordinateSync":false,"widthHeightSync":false,"fontSize":14.25,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":148.9921875,"bottom":43.9921875,"vCenter":85.9921875,"hCenter":33.4921875,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":448,"top":25,"height":22,"width":122,"title":"核销码","field":"clearCode","testData":"3961","coordinateSync":false,"widthHeightSync":false,"fontSize":14.25,"textAlign":"right","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":571.25,"bottom":46.75,"vCenter":510.25,"hCenter":35.75,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":22.5,"top":82,"height":36,"width":550,"field":"table","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textAlign":"center","tableHeaderFontWeight":"bold","right":572.5,"bottom":90.99609375,"vCenter":297.5,"hCenter":72.99609375,"fontFamily":"SimSun","columns":[[{"width":54.696355213537544,"title":"序号","field":"orderNum","checked":true,"columnId":"orderNum","fixed":false,"rowspan":1,"colspan":1},{"width":175.25367876030515,"title":"花材名称","field":"name","checked":true,"columnId":"name","fixed":false,"rowspan":1,"colspan":1},{"width":69.07232544378695,"title":"单价","field":"unitPrice","checked":true,"columnId":"unitPrice","fixed":false,"rowspan":1,"colspan":1},{"width":72.10486265361865,"title":"数量","field":"num","checked":true,"columnId":"num","fixed":false,"rowspan":1,"colspan":1},{"width":67.11113461538461,"title":"金额","field":"price","checked":true,"columnId":"price","fixed":false,"rowspan":1,"colspan":1},{"width":57.08931639029012,"title":"已退","field":"refundNum","checked":true,"columnId":"refundNum","fixed":false,"rowspan":1,"colspan":1},{"width":54.67232692307692,"title":"备注","field":"remark","checked":true,"columnId":"remark","fixed":false,"rowspan":1,"colspan":1},{"width":100,"title":"","field":"","checked":false,"columnId":"","fixed":false,"rowspan":1,"colspan":1},{"width":100,"title":"","field":"","checked":false,"columnId":"","fixed":false,"rowspan":1,"colspan":1}]]},"printElementType":{"title":"空白表格","type":"table","editable":true,"columnDisplayEditable":true,"columnDisplayIndexEditable":true,"columnTitleEditable":true,"columnResizable":true,"columnAlignEditable":true,"isEnableEditField":true,"isEnableContextMenu":true,"isEnableInsertRow":true,"isEnableDeleteRow":true,"isEnableInsertColumn":true,"isEnableDeleteColumn":true,"isEnableMergeCell":true}},{"options":{"left":200,"top":150,"height":16,"width":178,"title":"账单日期","field":"addTime","testData":"2024-12-28 11:00","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":359.49609375,"bottom":146.9921875,"vCenter":276.99609375,"hCenter":138.9921875,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":372,"top":150,"height":16,"width":178,"title":"客户","field":"ghsName","testData":"石头花艺","coordinateSync":false,"widthHeightSync":false,"fontSize":15,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":573.49609375,"bottom":145.99609375,"vCenter":484.49609375,"hCenter":137.99609375,"fontFamily":"SimSun","fontWeight":"bold"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":27.5,"top":150,"height":16,"width":175,"title":"创建时间","right":141.75,"bottom":139.5,"vCenter":81.75,"hCenter":134.625,"field":"entryTime","testData":"2024-12-29 12:10","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":132.5,"top":175,"height":16,"width":90,"title":"售后","right":262.74609375,"bottom":161.2421875,"vCenter":202.74609375,"hCenter":153.2421875,"field":"tkPrice","testData":"63","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":222.5,"top":175,"height":16,"width":114,"title":"实际金额","field":"realPrice","testData":"23","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":358.9921875,"bottom":160.99609375,"vCenter":301.9921875,"hCenter":152.99609375,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":347.5,"top":175,"height":16,"width":120,"title":"电话","field":"telephone","testData":"15280215347","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":467.7421875,"bottom":161.2421875,"vCenter":407.7421875,"hCenter":153.2421875,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":425,"top":175,"height":16,"width":148,"title":"录单人","field":"staffName","testData":"小石","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textAlign":"right","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":574.4921875,"bottom":161.2421875,"vCenter":500.4921875,"hCenter":153.2421875,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":27.5,"top":175,"height":16,"width":105,"title":"合计","field":"prePrice","testData":"693","coordinateSync":false,"widthHeightSync":false,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":144,"bottom":160.24609375,"vCenter":85.5,"hCenter":152.24609375,"fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":30,"top":199.5,"height":16,"width":120,"field":"numKind","testData":"共3种,数量:9","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":11,"textContentVerticalAlign":"middle","qrCodeLevel":0,"title":"文本","fontFamily":"SimSun"},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":169.5,"top":199.5,"height":16,"width":400,"title":"地址","field":"address","testData":"厦门前山路147号","coordinateSync":false,"widthHeightSync":false,"fontSize":10.5,"textContentVerticalAlign":"middle","qrCodeLevel":0,"right":569.5,"bottom":185.5,"vCenter":369.5,"hCenter":177.5},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":238.5,"top":48,"height":28,"width":120,"title":"自定义文本","field":"saleName","testData":"销售单","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":19.5,"textAlign":"center","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":372.75,"bottom":69.25,"vCenter":312.75,"hCenter":55.25},"printElementType":{"title":"自定义文本","type":"text"}}],"paperNumberLeft":565.5,"paperNumberTop":389,"paperNumberDisabled":true,"paperNumberContinue":true,"orient":1,"watermarkOptions":{"content":"","rotate":25,"timestamp":false,"format":"YYYY-MM-DD HH:mm","fillStyle":"rgba(184, 184, 184, 0.3)","fontSize":"14px","width":200,"height":200},"panelLayoutOptions":{"layoutType":"column","layoutRowGap":0,"layoutColumnGap":0}}]}';
- }
- $info['template'] = $template;
- }
- //是否有云打印判断
- $hasCloudPrint = 0;
- $shopExt = $this->shopExt;
- if (isset($shopExt->printSn) && !empty($shopExt->printSn) && isset($shopExt->printKey) && !empty($shopExt->printKey)) {
- $hasCloudPrint = 1;
- }
- $info['hasCloudPrint'] = $hasCloudPrint;
- $purchaseId = $info['purchaseId'] ?? 0;
- $cg = PurchaseClass::getById($purchaseId);
- $info['cgInfo'] = $cg;
- //店长信息
- $mainId = $cg['mainId'] ?? 0;
- $superInfo = ShopAdminClass::getManager($mainId);
- $info['customSuper'] = $superInfo;
- //员工是否有财务权限 ssh 20251117
- $staff = $this->shopAdmin;
- $staffFinance = $staff->finance ?? 0;
- $info['staffFinance'] = $staffFinance;
- $shopBusiness = $shop->business ?? 0;
- $info['shopBusiness'] = $shopBusiness;
- util::success($info);
- }
- //获取订单信息 ssh 20240102
- public function actionGetInfoByOrderSn()
- {
- $get = Yii::$app->request->get();
- $orderSn = $get['orderSn'] ?? '';
- $info = OrderService::getByCondition(['orderSn' => $orderSn], true);
- if (empty($info)) {
- util::fail('没有找到订单');
- }
- if ($info->mainId != $this->mainId) {
- util::fail('不是你的订单哦');
- }
- util::success(['info' => $info]);
- }
- //获取订单详情,不需要登录可以访问,后面要删除此方法 ssh 20220819
- public function actionInfo()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $info = OrderService::getOrderInfo($id, true, true, true, false);
- if (empty($info)) {
- util::fail('没有找到订单');
- }
- //是否有云打印判断
- $hasCloudPrint = 0;
- $shopExt = $this->shopExt;
- if (isset($shopExt->printSn) && !empty($shopExt->printSn) && isset($shopExt->printKey) && !empty($shopExt->printKey)) {
- $hasCloudPrint = 1;
- }
- $info['hasCloudPrint'] = $hasCloudPrint;
- $purchaseId = $info['purchaseId'] ?? 0;
- $cg = PurchaseClass::getById($purchaseId);
- $info['cgInfo'] = $cg;
- //店长信息
- $mainId = $cg['mainId'] ?? 0;
- $superInfo = ShopAdminClass::getManager($mainId);
- $info['customSuper'] = $superInfo;
- util::success($info);
- }
- //自取免发货流程处理 ssh 2021.1.22
- public function actionWithoutSend()
- {
- util::complete();
- }
- //本店送 ssh 2021.1.24
- public function actionSelfSend()
- {
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $info = OrderClass::getById($id, true);
- OrderClass::valid($info->attributes, $this->shopId);
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- OrderClass::selfSend($info);
- $transaction->commit();
- } catch (\Exception $exception) {
- $transaction->rollBack();
- Yii::info("本店送操作报错:" . $exception->getMessage());
- util::fail('操作失败');
- }
- util::complete();
- }
- //运费计算 ssh 2021.1.24
- public function actionFreight()
- {
- //2021.3.28 接入达达
- $get = Yii::$app->request->get();
- $post = Yii::$app->request->post();
- if (empty($get)) {
- $get = $post;
- }
- $orderId = $get['id'] ?? 0; //订单ID
- $customId = $get['customId'] ?? 0;
- if (empty($orderId)) {
- //自定义运费
- //freight::getCost();
- if (empty($customId)) {
- util::fail("请选择客户");
- }
- $customInfo = CustomClass::getById($customId);
- if (empty($customInfo)) {
- util::fail('没有找到客户');
- }
- $shop = $this->shop;
- //花材信息
- $productJson = $get['product'] ?? '';
- // $productJson = '[{"productId":31993,"bigNum":1,"smallNum":0}]';
- if (empty($productJson)) {
- util::fail('请选择花材');
- }
- $productList = json_decode($productJson, true);
- if (empty($productList)) {
- util::fail('请选择花材');
- }
- $productList = ProductClass::mergeItemInfo($productList);
- $weight = 0;
- $price = 0;
- $productData = ProductClass::getProductMapData($productList);
- $bigNum = 0;
- foreach ($productList as $key => $val) {
- $productId = $val['productId'];
- $w = ProductClass::getWeight($val['productId'], $val['bigNum'], $val['smallNum']);
- $bigNum += $val['bigNum'];
- $weight = bcadd($w, $weight, 2);
- $ratio = $productData[$productId]['ratio'] ?? 0;
- //大小数量合并多少扎
- $itemNum = ProductClass::mergeItemNum($val['bigNum'], $val['smallNum'], $ratio);
- //售卖价格
- $itemPrice = $productData[$productId]['price'] ?? 0;
- //合计价格
- $price = bcadd($price, bcmul($itemNum, $itemPrice, 2), 2);
- }
- //没有经纬度的客户运费直接返回空 ssh 20210612
- if (empty($customInfo['lat']) || empty($customInfo['long'])) {
- util::success(['sedCost' => '']);
- }
- $cost = freight::getCost($shop->lat, $shop->long, $customInfo['lat'], $customInfo['long'], $weight);
- util::success(['sedCost' => $cost]);
- }
- $province = $get['province'] ?? '';
- $city = $get['city'] ?? '';
- $address = $get['address'] ?? '';
- $floor = $get['floor'] ?? '';
- $customName = $get['customName'] ?? '';
- $customMobile = $get['customMobile'] ?? '';
- $fullAddress = $province . $city . $address . $floor;
- $sendTime = $get['sendTime'] ?? '';
- $lat = $get['lat'] ?? '';
- $lng = $get['long'] ?? '';
- if (empty($lat) || empty($lng) || empty($fullAddress)) {
- util::fail('请填写客户地址');
- }
- ini_set('date.timezone', 'Asia/Shanghai');
- if (!empty($sendTime)) {
- //配送时间不为空
- // 预约发单时间(预约时间unix时间戳(10位),精确到分;整分钟为间隔,并且需要至少提前5分钟预约
- $sendTimeInt = strtotime($sendTime);
- $now = time();
- $diff = $sendTimeInt - $now;
- //因服务器写入时间,改为至少提前6分钟
- if ($diff <= 360) {
- util::fail('配送时间至少提前6分钟');
- }
- } else {
- //默认立即发送
- $sendTime = 0;
- }
- //更新订单表
- $info = OrderService::getOrderInfo($orderId);
- OrderClass::valid($info, $this->shopId);
- if ($sendTime) {
- $sendTime = date('Y-m-d H:i', strtotime($sendTime));
- } else {
- $sendTime = '0000-00-00 00:00:00';
- }
- $expressAddInfo = [
- 'customName' => $customName,
- 'customMobile' => $customMobile,
- 'province' => $province,
- 'city' => $city,
- 'address' => $address,
- 'floor' => $floor,
- 'lat' => $lat,
- 'long' => $lng,
- 'sendTime' => $sendTime,
- ];
- OrderClass::updateCustomExpressInfo($orderId, $expressAddInfo);
- //计算运费
- $info['province'] = $province;
- $info['city'] = $city;
- $info['address'] = $address;
- $info['floor'] = $floor;
- $info['fullAddress'] = $fullAddress;
- $info['lat'] = $lat;
- $info['long'] = $lng;
- $info['sendTime'] = $expressAddInfo['sendTime'];
- $res = DadaExpressServices::queryDeliverFee($info);
- util::success(['sedCost' => $res['fee']]);
- }
- //发快递和第三方配送 ssh 2021.1.24
- public function actionThirdSend()
- {
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $info = OrderService::getById($id, true);
- OrderClass::valid($info->attributes, $this->shopId);
- if (empty($info->lat) || empty($info->long) || empty($info->fullAddress)) {
- util::fail('请填写客户地址');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $respond = OrderClass::thirdSend($info, $get);
- $transaction->commit();
- util::success($respond);
- } catch (\Exception $exception) {
- $transaction->rollBack();
- Yii::info("发快递操作报错:" . $exception->getMessage());
- util::fail('操作失败' . $exception->getMessage());
- }
- }
- //确认送达 ssh 2021.1.24
- public function actionReach()
- {
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $info = OrderClass::getById($id, true);
- OrderClass::valid($info->attributes, $this->shopId);
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- OrderService::reach($info);
- $transaction->commit();
- } catch (\Exception $exception) {
- $transaction->rollBack();
- Yii::info("送达操作报错:" . $exception->getMessage());
- util::fail('操作失败');
- }
- util::complete();
- }
- //下单要用到的相关信息 ssh 2019.12.6
- public function actionOrderRelate()
- {
- $regionTree = RegionService::tree();
- $shop = $this->shop->attributes;
- $freight = ['first' => 5, 'add' => 2];
- $mapKey = 'OFWBZ-2NTHP-EHNDD-LKWQY-GANM7-PXBJH';
- $out = ['freight' => $freight, 'shop' => $shop, 'region' => $regionTree, 'thirdMapKey' => $mapKey, 'merchant' => $shop];
- util::success($out);
- }
- //客户欠款的订单 ssh 2021.2.4
- public function actionDebtList()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $info = CustomClass::getCustom($id);
- CustomClass::valid($info, $this->shopId);
- $mainId = $this->mainId;
- $where = ['mainId' => $mainId, 'customId' => $id, 'debt' => 1];
- $searchTime = $get['searchTime'] ?? '';
- if (!empty($searchTime)) {
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime);
- $where['payTime'] = ['between', [$period['startTime'], $period['endTime']]];
- } else {
- if ($mainId == 33447 && $id == 51031) {
- util::fail('请选时间');
- }
- }
- $allowedPageSizes = [100, 200, 300];
- $pageSize = isset($get['pageSize']) && in_array((int)$get['pageSize'], $allowedPageSizes, true)
- ? (int)$get['pageSize'] : 100;
- $page = max(1, (int)($get['page'] ?? 1));
- $fields = ['id', 'orderSn', 'actPrice', 'addTime', 'remainDebtPrice', 'debtPrice', 'payTime', 'remark'];
- Yii::$app->request->setQueryParams(array_merge($get, ['page' => $page, 'pageSize' => $pageSize]));
- $result = OrderClass::getList($fields, $where, 'addTime DESC');
- if (!empty($result['list'])) {
- foreach ($result['list'] as $key => $value) {
- $debtPrice = $value['debtPrice'] ?? 0;
- $remainDebtPrice = $value['remainDebtPrice'] ?? 0;
- $hasPayDebt = '0.00';
- if (bccomp((string)$debtPrice, (string)$remainDebtPrice, 2) > 0) {
- $hasPayDebt = bcsub((string)$debtPrice, (string)$remainDebtPrice, 2);
- }
- $result['list'][$key]['hasPayDebt'] = floatval($hasPayDebt);
- }
- }
- $result['customInfo'] = $info;
- util::success($result);
- }
- //更新打印次数
- public function actionAddPrintNum()
- {
- $id = Yii::$app->request->get('id', 0);
- $order = OrderClass::getById($id, true);
- OrderClass::valid($order, $this->shopId);
- $order->printNum += 1;
- $order->save();
- util::complete();
- }
- //打印订单 ssh 20210714
- public function actionCloudPrintOrder()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $showPrice = $get['showPrice'] ?? 1;
- $order = OrderClass::getById($id, true);
- OrderClass::valid($order, $this->shopId);
- if ($order->status == OrderClass::ORDER_STATUS_UN_PAY) {
- util::fail('订单还没有付款');
- }
- if ($order->status == OrderClass::ORDER_STATUS_CANCEL) {
- util::fail('订单已取消');
- }
- $ext = $this->shopExt;
- if (isset($ext->printSn) == false || isset($ext->printKey) == false || empty($ext->printSn) || empty($ext->printKey)) {
- util::success(['hasNoPrint' => 1]);
- }
- OrderClass::onlinePrint($order, $showPrice);
- $order->printNum += 1;
- $order->save();
- util::complete();
- }
- //订单确认完成 ssh 20210809
- public function actionConfirmFinish()
- {
- $payWay = Yii::$app->request->get('payWay', -1);
- $id = Yii::$app->request->get('id', 0);
- $clearType = Yii::$app->request->get('clearType', 0);
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $order = OrderClass::getById($id, true);
- OrderClass::valid($order, $this->shopId);
- $purchaseId = $order->purchaseId ?? 0;
- $purchase = PurchaseClass::getById($purchaseId, true);
- if (empty($purchase)) {
- util::fail('没有采购信息');
- }
- if ($clearType == 1) {
- //欠款
- $payWay = dict::getDict('payWay', 'debtPay');
- } elseif ($clearType == 2) {
- //已收款
- if ($payWay == -1) {
- util::fail('请选择收款方式');
- }
- $shopAdmin = $this->shopAdmin;
- if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
- util::fail('超管才能发起已收款');
- }
- } else {
- util::fail('请选择结算方式');
- }
- //不需要打印
- $order->needPrint = dict::getDict('needPrint', 'noNeed');
- $order->save();
- //支付
- PurchaseService::payAfter($purchase, $payWay);
- OrderService::payAfter($order, $payWay);
- //自己送
- $info = OrderClass::getById($id, true);
- OrderClass::selfSend($info);
- //确认送达,并且不需要微信通知
- Yii::$app->params['noNeedWxNotice'] = 1;
- $info = OrderClass::getById($id, true);
- OrderService::reach($info);
- $transaction->commit();
- util::complete('操作成功');
- } catch (\Exception $exception) {
- $transaction->rollBack();
- Yii::info("确认完成订单报错:" . $exception->getMessage());
- util::fail('操作失败');
- }
- }
- //取消订单 ssh 20220110
- public function actionCancel()
- {
- $shopAdmin = $this->shopAdmin;
- if (!isset($shopAdmin->super) || $shopAdmin->super != 1) {
- util::fail('超管才能取消订单');
- }
- //避免重复提交
- $adminId = $this->adminId;
- util::checkRepeatCommit($adminId, 3);
- $get = Yii::$app->request->get();
- $cashier = $get['cashier'] ?? 0;
- //是否强制取消订单 0不要强制 1强制,没有关单成功也要取消
- $forceCancel = $get['forceCancel'] ?? 0;
- $id = $get['id'] ?? 0;
- $order = OrderClass::getById($id, true);
- OrderClass::valid($order, $this->shopId);
- if ($order->orderType == 2) {
- util::fail('客户下单,不能主动取消');
- }
- //如果收银台的订单,取消时要关闭拉卡拉的订单
- if ($cashier == 1) {
- //已取消,不需要再走下面的流程
- if ($order->status == 5) {
- util::complete('已取消');
- }
- $cgId = $order->purchaseId ?? 0;
- $cg = PurchaseClass::getById($cgId, true);
- $orderSn = $cg->orderSn ?? '';
- $shop = $this->shop;
- $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
- $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
- $params = [
- 'appid' => 'OP00002119',
- 'serial_no' => '018b08cfddbd',
- 'merchant_no' => $shop->lklSjNo,
- 'term_no' => $shop->lklScanTermNo,
- 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
- 'lklCertificatePath' => $lklCertificatePath,
- ];
- $laResource = new Lakala($params);
- // 1. 先查询拉卡拉侧订单状态
- $queryResponse = $laResource->query(['orderSn' => $orderSn]);
- //响应CODE为BBS00000,仅表示查到了这笔交易。交易本身的成功与否状态,要查看响应报文中的trade_state这个值
- if (isset($queryResponse['code']) && $queryResponse['code'] == 'BBS00000') {
- $tradeState = $queryResponse['resp_data']['trade_state'] ?? '';
- // 订单已支付,拦截取消操作
- if ($tradeState == 'SUCCESS') {
- util::fail('已付款,不能取消');
- }
- // 根据拉卡拉聚合支付文档(id=116)及实际情况,判断是否为非终态
- // INIT:初始化, CREATE:下单成功, DEAL:交易处理中, USERPAYING:支付中, NOTPAY:未支付
- $pendingStates = ['INIT', 'CREATE', 'DEAL', 'USERPAYING', 'NOTPAY'];
- if (in_array($tradeState, $pendingStates)) {
- $closeParams = ['orderSn' => $orderSn];
- $closeResponse = $laResource->close($closeParams);
- if (!isset($closeResponse['code']) || $closeResponse['code'] != 'BBS00000') {
- $msg = $closeResponse['msg'] ?? '关闭失败';
- noticeUtil::push("拉卡拉聚合支付关单失败:{$orderSn},原因:{$msg} 原单状态:{$tradeState}", '15280215347');
- if ($forceCancel == 0) {
- //返回禁止关单
- util::fail('取消失败,如必要请强制取消');
- }
- }else{
- noticeUtil::push("关单成功,订单号:{$orderSn} 原单状态:{$tradeState}", '15280215347');
- }
- }
- // 如果状态是 CLOSED 或 CANCELED,则视为已关单,直接继续本地流程
- }
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- OrderService::expire($order);
- $transaction->commit();
- util::complete('已取消');
- } catch (\Exception $exception) {
- $transaction->rollBack();
- Yii::info("取消原因:" . $exception->getMessage());
- util::fail('取消失败');
- }
- }
- //获取收款语音播报地址 ssh 20211231
- public function actionGetPayVoice()
- {
- $id = Yii::$app->request->get('id');
- $order = OrderClass::getById($id, true);
- $payWay = $order->payWay ?? 0;
- $money = floatval($order->actPrice);
- $payment = $payWay == dict::getDict('payWay', 'alipay') ? '支付宝' : '微信';
- $msg = $payment . '收款' . $money . '元';
- $audio = baiduAip::transfer($msg, 4, 0);
- //上传到oss
- $file = time() . rand(10000, 999999) . '.mp3';
- $filePath = 'tmp/arrival/money/' . $file;
- oss::uploadTmpAudio($filePath, $audio);
- $url = Yii::$app->params['ghsImgHost'] . $filePath;
- util::success(['url' => $url]);
- }
- //修改备注
- public function actionModifyRemark()
- {
- $post = Yii::$app->request->post();
- $id = $post['id'] ?? 0;
- $remark = $post['remark'] ?? '';
- $order = OrderClass::getById($id, true);
- if (empty($order)) {
- util::fail('没有找到订单');
- }
- if ($order->mainId != $this->mainId) {
- util::fail('不是你的订单');
- }
- $cgId = $order->purchaseId ?? 0;
- $cg = PurchaseClass::getById($cgId, true);
- if (empty($cg)) {
- util::fail('采购单没有找到');
- }
- $order->remark = $remark;
- $order->save();
- $cg->remark = $remark;
- $cg->save();
- util::complete('修改成功');
- }
- //修改订单的确认时间 ssh 20240511
- public function actionModifyOrderConfirmTime()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $date = $get['date'] ?? '';
- if (empty($date)) {
- util::fail('请选择日期');
- }
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();//开启事务
- try {
- $order = OrderClass::getById($id, true);
- if (empty($order)) {
- util::fail('没有找到订单');
- }
- if ($order->mainId != $this->mainId) {
- util::fail('不是你的订单');
- }
- if ($order->payStatus == 0) {
- util::fail('没有确认的订单');
- }
- $mainId = $this->mainId;
- //超管或者约定的人可以修改日期
- if (getenv('YII_ENV') == 'production') {
- if (in_array($mainId, [23390])) {
- if (!in_array($this->adminId, [24586, 23960, 24043])) {
- util::fail('你不能修改哦');
- }
- }
- }
- $payTime = $order->payTime;
- $timeArr = explode(' ', $payTime);
- $dateStr = $timeArr[0];
- if ($dateStr == $date) {
- util::fail('日期没变');
- }
- $after = $timeArr[1];
- $new = $date . ' ' . $after;
- $cgId = $order->purchaseId ?? 0;
- $cg = PurchaseClass::getById($cgId, true);
- if (empty($cg)) {
- util::fail('没有找到订单信息');
- }
- $order->payTime = $new;
- $order->save();
- $cg->payTime = $new;
- $cg->save();
- //有修改账单日期需要更新到欠款变动明细,财务好对账,多个地方要同步修改,关键词 to_change_custom_debt_pay_time
- CustomDebtChangeClass::updateByCondition(['capitalType' => 10, 'relateId' => $id], ['payTime' => $new]);
- //找到当前订单客户的账单日期为 $date 的所有订单,然后更新同天内的所有订单的 sameTimeIds(加此次要改变的订单的订单号$id),有多处调用,关键词 update_same_ids
- OrderClass::updateSameTimeIds($order, $date);
- PurchaseClass::updateMergeCg($cg, 1);
- OrderClass::updateMergeOrder($order, 1);
- $transaction->commit();
- util::complete('修改成功');
- } catch (\Exception $e) {
- $transaction->rollBack();
- util::fail('修改失败');
- }
- }
- //应收款统计 ssh 20240528
- public function actionAccountList()
- {
- $get = Yii::$app->request->get();
- $mainId = $this->mainId;
- $export = $get['export'] ?? 0;
- $debt = isset($get['debt']) && is_numeric($get['debt']) ? $get['debt'] : -1;
- $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today';
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
- $start = $period['startTime'];
- $end = $period['endTime'];
- $customList = CustomClass::getAllByCondition(['ownMainId' => $this->mainId], null, 'id,name', 'id');
- $currentStartDate = date('Y-m-d', strtotime($start));
- $currentEndDate = date('Y-m-d', strtotime($end));
- $currentStartTime = $currentStartDate . ' 00:00:00';
- $currentEndTime = $currentEndDate . ' 23:59:59';
- $where = ['mainId' => $mainId];
- if ($debt > -1) {
- $where['debt'] = $debt;
- }
- $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
- $orderList = OrderClass::getAllByCondition($where, null, '*');
- $list = [];
- $totalAmount = 0;
- if (!empty($orderList)) {
- foreach ($orderList as $orderInfo) {
- $actPrice = $orderInfo['actPrice'] ?? 0;
- $customId = $orderInfo['customId'] ?? 0;
- $status = $orderInfo['status'] ?? 0;
- $book = $orderInfo['book'] ?? 0;
- if ($status == 1 || $status == 5) {
- continue;
- }
- if ($book == 1 && $status == 2) {
- continue;
- }
- if (isset($list[$customId])) {
- $list[$customId]['amount'] = bcadd($list[$customId]['amount'], $actPrice, 2);
- $list[$customId]['num'] = bcadd($list[$customId]['num'], 1);
- } else {
- $name = $customList[$customId] && $customList[$customId]['name'] ? $customList[$customId]['name'] : '未命名';
- $list[$customId] = ['id' => $customId, 'name' => $name, 'amount' => $actPrice, 'num' => 1];
- }
- $totalAmount = bcadd($totalAmount, $actPrice, 2);
- }
- $list = array_values($list);
- }
- if ($export == 1) {
- if (empty($list)) {
- util::fail('没有数据需要导出');
- }
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- OrderClass::exportAccountList($list, $mainId);
- util::stop();
- }
- util::success(['list' => $list, 'totalAmount' => $totalAmount]);
- }
- //应收款统计 ssh 20240528
- public function actionPastList()
- {
- $get = Yii::$app->request->get();
- $export = $get['export'] ?? 0;
- $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today';
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
- $end = $period['endTime'];
- $customList = CustomClass::getAllByCondition(['ownMainId' => $this->mainId], null, 'id,name,mobile', 'id');
- $currentDate = date('Y-m-d 00:00:00', bcadd(strtotime($end), 86400));
- $totalAmount = 0;
- if (!empty($customList)) {
- foreach ($customList as $key => $custom) {
- $customId = $custom['id'] ?? 0;
- $change = CustomDebtChangeClass::getByCondition(['customId' => $customId, 'addTime<' => $currentDate], true, 'addTime DESC');
- $amount = $change->balance ?? 0;
- $totalAmount = bcadd($totalAmount, $amount, 2);
- $customList[$key]['currentDebAmount'] = $amount;
- }
- $customList = array_values($customList);
- }
- if ($export == 1) {
- $mainId = $this->mainId;
- if (empty($customList)) {
- util::fail('没有数据需要导出');
- }
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- OrderClass::exportPastList($customList, $mainId);
- util::stop();
- }
- util::success(['list' => $customList, 'totalAmount' => $totalAmount]);
- }
- //客户业绩,有多个地方,需要同步,搜索关键词 customYj ssh 20240628
- public function actionYj()
- {
- $get = Yii::$app->request->get();
- $mainId = $this->mainId;
- $export = $get['export'] ?? 0;
- $debt = isset($get['debt']) && is_numeric($get['debt']) ? $get['debt'] : -1;
- $searchTime = isset($get['searchTime']) && !empty($get['searchTime']) ? $get['searchTime'] : 'today';
- $startTime = $get['startTime'] ?? '';
- $endTime = $get['endTime'] ?? '';
- $period = dateUtil::formatTime($searchTime, $startTime, $endTime, true);
- $start = $period['startTime'];
- $end = $period['endTime'];
- $customList = CustomClass::getAllByCondition(['ownMainId' => $mainId], null, '*', 'id');
- $currentStartDate = date('Y-m-d', strtotime($start));
- $currentEndDate = date('Y-m-d', strtotime($end));
- $currentStartTime = $currentStartDate . ' 00:00:00';
- $currentEndTime = $currentEndDate . ' 23:59:59';
- $where = ['mainId' => $mainId];
- if ($debt > -1) {
- $where['debt'] = $debt;
- }
- $where['payTime'] = ['between', [$currentStartTime, $currentEndTime]];
- $orderList = OrderClass::getAllByCondition($where, null, '*');
- $list = [];
- $totalActPrice = 0;
- $totalOrderPrice = 0;
- $totalCarton = 0;
- $totalCartonNum = 0;
- $totalPack = 0;
- $totalFreight = 0;
- $totalTkPrice = 0;
- //增加项
- $totalOnlyTkPrice = 0;
- $totalNum = 0;
- if (!empty($orderList)) {
- foreach ($orderList as $orderInfo) {
- $actPrice = $orderInfo['actPrice'] ?? 0;
- $orderPrice = $orderInfo['orderPrice'] ?? 0;
- $customId = $orderInfo['customId'] ?? 0;
- $status = $orderInfo['status'] ?? 0;
- $book = $orderInfo['book'] ?? 0;
- $orderSn = $orderInfo['orderSn'] ?? '';
- $tkPrice = $orderInfo['tkPrice'] ?? 0;
- if ($status == 1 || $status == 5) {
- continue;
- }
- if ($book == 1 && $status == 2) {
- continue;
- }
- $carton = 0;
- $cartonNum = 0;
- $pack = 0;
- $freight = 0;
- $orderItemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*');
- if ($actPrice > 0) {
- if (!empty($orderItemList)) {
- foreach ($orderItemList as $orderItem) {
- $num = $orderItem['xhNum'] ?? 0;
- $unitPrice = $orderItem['xhUnitPrice'] ?? 0;
- $refundNum = $orderItem['refundNum'] ?? 0;
- $classId = $orderItem['classId'] ?? 0;
- if (getenv('YII_ENV') == 'production') {
- //小向算打包纸箱费用
- if ($mainId == 23390) {
- $remainNum = bcsub($num, $refundNum);
- $amount = bcmul($remainNum, $unitPrice, 2);
- if ($classId == 72106) {
- $carton = bcadd($carton, $amount, 2);
- $cartonNum = bcadd($cartonNum, $remainNum);
- }
- if ($classId == 72108) {
- $pack = bcadd($pack, $amount, 2);
- }
- if ($classId == 73118) {
- $freight = bcadd($freight, $amount, 2);
- }
- }
- //花大苪
- if ($mainId == 8164) {
- $remainNum = bcsub($num, $refundNum);
- $amount = bcmul($remainNum, $unitPrice, 2);
- if ($classId == 90497) {
- $carton = bcadd($carton, $amount, 2);
- $cartonNum = bcadd($cartonNum, $remainNum);
- }
- if ($classId == 90501) {
- $freight = bcadd($freight, $amount, 2);
- }
- }
- //石头花艺
- if ($mainId == 50) {
- $remainNum = bcsub($num, $refundNum);
- $amount = bcmul($remainNum, $unitPrice, 2);
- if ($classId == 71495) {
- $carton = bcadd($carton, $amount, 2);
- $cartonNum = bcadd($cartonNum, $remainNum);
- }
- if ($classId == 91009) {
- $freight = bcadd($freight, $amount, 2);
- }
- }
- }
- }
- }
- }
- //增加项
- if ($tkPrice > 0) {
- $refundList = RefundOrderClass::getAllByCondition(['relateOrderSn' => $orderSn], null, '*', null, true);
- if (!empty($refundList)) {
- foreach ($refundList as $refundInfo) {
- if ($refundInfo->status == 1) {
- if ($refundInfo->refundType == 2) {
- $refundPrice = $refundInfo->refundPrice ?? 0;
- $totalOnlyTkPrice = bcadd($totalOnlyTkPrice, $refundPrice, 2);
- }
- }
- }
- }
- }
- $totalCarton = bcadd($totalCarton, $carton, 2);
- $totalCartonNum = bcadd($totalCartonNum, $cartonNum);
- $totalPack = bcadd($totalPack, $pack, 2);
- $totalFreight = bcadd($totalFreight, $freight, 2);
- $totalTkPrice = bcadd($totalTkPrice, $tkPrice, 2);
- $totalActPrice = bcadd($totalActPrice, $actPrice, 2);
- $totalOrderPrice = bcadd($totalOrderPrice, $orderPrice, 2);
- $totalNum++;
- if (isset($list[$customId])) {
- $list[$customId]['actPrice'] = bcadd($list[$customId]['actPrice'], $actPrice, 2);
- $list[$customId]['orderPrice'] = bcadd($list[$customId]['orderPrice'], $orderPrice, 2);
- $list[$customId]['num'] = bcadd($list[$customId]['num'], 1);
- $list[$customId]['carton'] = bcadd($list[$customId]['carton'], $carton, 2);
- $list[$customId]['cartonNum'] = bcadd($list[$customId]['cartonNum'], $cartonNum);
- $list[$customId]['pack'] = bcadd($list[$customId]['pack'], $pack, 2);
- $list[$customId]['freight'] = bcadd($list[$customId]['freight'], $freight, 2);
- $list[$customId]['tkPrice'] = bcadd($list[$customId]['tkPrice'], $tkPrice, 2);
- } else {
- $name = $customList[$customId] && $customList[$customId]['name'] ? $customList[$customId]['name'] : '未命名';
- $mobile = $customList[$customId] && $customList[$customId]['mobile'] ? $customList[$customId]['mobile'] : '0';
- $list[$customId] = [
- 'id' => $customId,
- 'name' => $name,
- 'mobile' => $mobile,
- 'orderPrice' => $orderPrice,
- 'actPrice' => $actPrice,
- 'num' => 1,
- 'carton' => $carton,
- 'cartonNum' => $cartonNum,
- 'pack' => $pack,
- 'freight' => $freight,
- 'tkPrice' => $tkPrice,
- ];
- }
- }
- foreach ($customList as $key => $custom) {
- $customId = $custom['id'] ?? 0;
- if (isset($list[$customId]) == false) {
- $list[$customId] = [
- 'id' => $customId,
- 'name' => $custom['name'],
- 'mobile' => $custom['mobile'],
- 'actPrice' => 0,
- 'num' => 0,
- 'carton' => 0,
- 'pack' => 0,
- 'freight' => 0,
- 'tkPrice' => 0,
- 'orderPrice' => 0,
- ];
- }
- }
- $list = array_values($list);
- }
- if ($export == 1) {
- if (empty($list)) {
- util::fail('没有数据需要导出');
- }
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- OrderClass::exportYj($list, $mainId);
- util::stop();
- }
- util::success([
- 'list' => $list,
- 'totalActPrice' => $totalActPrice,
- 'totalOrderPrice' => $totalOrderPrice,
- 'totalCarton' => $totalCarton,
- 'totalCartonNum' => $totalCartonNum,
- 'totalNum' => $totalNum,
- 'totalPack' => $totalPack,
- 'totalFreight' => $totalFreight,
- 'totalTkPrice' => $totalTkPrice,
- //增加项
- 'totalOnlyTkPrice' => $totalOnlyTkPrice,
- ]);
- }
- //修改配送人 ssh 20240824
- public function actionChangeSendStaff()
- {
- $staff = $this->shopAdmin;
- if (isset($staff->finance) == false || $staff->finance == 0) {
- util::fail('请有财务权限的人修改');
- }
- $get = Yii::$app->request->get();
- $staffId = $get['staffId'] ?? 0;
- $orderId = $get['orderId'] ?? 0;
- $order = OrderClass::getById($orderId, true);
- if (empty($order)) {
- util::fail('没有找到订单');
- }
- if ($order->mainId != $this->mainId) {
- util::fail('不是你的');
- }
- $staff = ShopAdminClass::getById($staffId, true);
- if (empty($staff)) {
- util::fail('没有找到员工');
- }
- if ($staff->mainId != $this->mainId) {
- util::fail('不是你的员工');
- }
- $staffName = $staff->name ?? '';
- $order->sendStaffId = $staffId;
- $order->sendStaffName = $staffName;
- $order->save();
- util::complete('修改成功');
- }
- //导入开单 ssh 20241126
- public function actionImportCreate()
- {
- ini_set('memory_limit', '2045M');
- set_time_limit(0);
- $connection = Yii::$app->db;
- try {
- $get = Yii::$app->request->get();
- $customId = $get['id'] ?? '';
- $customRes = CustomClass::getById($customId, true);
- if (empty($customRes)) {
- util::fail('没有找到客户');
- }
- if ($customRes->ownMainId != $this->mainId) {
- util::fail('不是你的客户');
- }
- if (isset($customRes->mainId) && !empty($customRes->mainId) && $customRes->mainId == $customRes->ownMainId) {
- util::fail('不能给自己开单');
- }
- $file = $_FILES['file'];
- if (!is_uploaded_file($file['tmp_name'])) {
- util::fail('please upload img');
- }
- $mainId = $this->mainId;
- $sjId = $this->sjId;
- $shopId = $this->shopId;
- $month = date("Ym");
- $date = date("d");
- $path = dirUtil::getImgUploadDir() . "/{$mainId}/kd/{$shopId}/{$month}/{$date}/";
- if (!file_exists($path)) {
- //检查是否有该文件夹,如果没有就创建,并给予最高权限
- mkdir($path, 0700, true);
- }
- $preFileName = stringUtil::uniqueFileName();
- $newFile = $preFileName . ".xls";
- $fullPathFile = $path . $newFile;
- if (move_uploaded_file($file['tmp_name'], $fullPathFile)) {
- $arr = [];
- $phpExcelFile = Yii::getAlias("@vendor/phpoffice/phpexcel/");
- require_once($phpExcelFile . 'Classes/PHPExcel/IOFactory.php');
- $spreadsheet = \PHPExcel_IOFactory::load($fullPathFile);
- // 获取活动工作表
- $worksheet = $spreadsheet->getActiveSheet();
- // 遍历每一行
- foreach ($worksheet->getRowIterator() as $key => $row) {
- $cellIterator = $row->getCellIterator();
- // 这里设置为迭代所有单元格,包括空单元格
- $cellIterator->setIterateOnlyExistingCells(FALSE);
- // 遍历每列
- $rowData = [];
- foreach ($cellIterator as $cell) {
- $option = $cell->getValue();
- $rowData[] = trim($option);
- }
- $arr[] = $rowData;
- }
- array_shift($arr);
- $productIds = [];
- foreach ($arr as $k => $v) {
- $productId = $v[0] ?? 0;
- $productId = trim($productId);
- if (is_numeric($productId) && $productId > 0) {
- $productIds[] = $productId;
- }
- }
- if (empty($productIds)) {
- util::fail('没有识别出花材');
- }
- $productInfo = ProductClass::getByIds($productIds, null, 'id');
- if (empty($productInfo)) {
- util::fail('没有找到有效花材');
- }
- $mat = [];
- foreach ($arr as $k => $v) {
- $productId = $v[0] ?? 0;
- $productId = trim($productId);
- $num = $v[2] ?? 0;
- $num = trim($num);
- $unitPrice = $v[3] ?? 0;
- $unitPrice = trim($unitPrice);
- $remark = $v['5'] ?? '';
- $remark = trim($remark);
- if (is_numeric($productId) && $productId > 0 && $num > 0 && $unitPrice > 0) {
- $product = $productInfo[$productId] ?? [];
- $ptItemId = $product['itemId'] ?? 0;
- $mat[] = [
- 'productId' => $productId,
- 'bigNum' => $num,
- 'itemId' => $ptItemId,
- 'smallNum' => 0,
- 'price' => $unitPrice,
- 'remark' => $remark,
- ];
- }
- }
- $modifyPrice = 0;
- foreach ($mat as $ma) {
- $cNum = $ma['bigNum'] ?? 0;
- $cPrice = $ma['price'] ?? 0;
- $cTotal = bcmul($cNum, $cPrice, 2);
- $modifyPrice = bcadd($modifyPrice, $cTotal, 2);
- }
- $customName = $customRes->name ?? '';
- $customMobile = $customRes->mobile ?? '';
- $customPy = $customRes->py ?? '';
- $ghsId = $customRes->ghsId ?? 0;
- $hasPay = 2;
- $custom = CustomClass::getCustom($customId);
- $post = [];
- $post['modifyPrice'] = $modifyPrice;
- $post['shopId'] = $shopId;
- $post['sendType'] = 0;
- $post['transType'] = 0;
- $post['sendSide'] = 0;
- $post['sendCost'] = 0;
- $post['packCost'] = 0;
- $post['customId'] = $customId;
- $post['customName'] = $customName;
- $post['payWay'] = 0;
- $post['needPrint'] = 2;
- $post['hasPay'] = 2;
- $post['product'] = $mat;
- $post['deadline'] = date("Y-m-d H:i:s", time() + 86400);
- $post['debt'] = 1;
- $post['mainId'] = $mainId;
- $post['fromType'] = 1;
- $post['expressId'] = 0;
- $post['sjId'] = $sjId;
- $staff = $this->shopAdmin;
- $staffId = $staff->id ?? 0;
- $staffName = $staff->name ?? '';
- $post['shopAdminId'] = $staffId;
- $post['shopAdminName'] = $staffName;
- $post['getStaffId'] = $staffId;
- $post['getStaffName'] = $staffName;
- $post['customMobile'] = $customMobile;
- $post['customNamePy'] = $customPy;
- $post['customAvatar'] = '';
- $post['newVersion'] = 1;
- $post['book'] = 1;
- $post['wlName'] = '';
- $post['dealPrice'] = 1;
- $post['ghsId'] = $ghsId;
- $shop = $this->shop;
- $bookSn = $shop->bookSn ?? 0;
- $post['bookSn'] = $bookSn;
- // 复杂分支/关键逻辑:优化。去除了并发重试机制 runWithDbConcurrencyRetry,降低锁等待和额外重试带来的性能瓶颈
- // 底层在发货和收货扣减库存时,使用商品 ID 升序排序加锁(SELECT FOR UPDATE)策略,100% 杜绝交叉死锁,因此这里无需再做重试。
- $transaction = $connection->beginTransaction();
- try {
- OrderService::createNewOrder($post, $custom, $hasPay);
- $transaction->commit();
- } catch (\Exception $exception) {
- if ($transaction->isActive) {
- $transaction->rollBack();
- }
- throw $exception;
- }
- util::complete('提交成功');
- } else {
- util::fail('上传失败了,出错了哦');
- }
- } catch (\Exception $e) {
- Yii::info("导入失败了," . $e->getMessage());
- noticeUtil::push('导入失败,失败原因:' . $e->getMessage(), '15280215347');
- $msg = $e->getMessage();
- util::fail('导入失败:' . $msg);
- }
- }
- //打印发物流用和标签 ssh 20250312
- public function actionPrintWlLabel()
- {
- $get = Yii::$app->request->get();
- $id = $get['id'] ?? 0;
- $order = OrderClass::getById($id, true);
- if (empty($order)) {
- util::fail('没有找到订单');
- }
- if ($order->payStatus == 0) {
- util::fail('订单没有付款');
- }
- $ext = $this->shopExt;
- $shop = $this->shop;
- OrderClass::printLogisticsLabel($order, $shop, $ext);
- util::complete('打印成功');
- }
- //修改地址 ssh 20251123
- public function actionModifyAddress()
- {
- $post = Yii::$app->request->post();
- $id = $post['id'] ?? 0;
- $order = OrderClass::getById($id, true);
- if (empty($order)) {
- util::fail('没有找到订单');
- }
- if ($order->mainId != $this->mainId) {
- util::fail('不是你的订单,不能修改地址');
- }
- if ($order->status == 3) {
- util::fail('订单已经在配送了,不能修改地址');
- }
- if ($order->status == 4) {
- util::fail('订单已完成,不能修改地址');
- }
- $province = $post['province'] ?? '';
- $city = $post['city'] ?? '';
- $dist = $post['dist'] ?? '';
- $address = $post['address'] ?? '';
- $floor = $post['floor'] ?? '';
- $fullAddress = $city . $dist . $address . $floor;
- $lat = $post['lat'] ?? '';
- $long = $post['long'] ?? '';
- $showAddress = $post['showAddress'] ?? '';
- $order->province = $province;
- $order->city = $city;
- $order->dist = $dist;
- $order->address = $address;
- $order->floor = $floor;
- $order->showAddress = $showAddress;
- $order->fullAddress = $fullAddress;
- $order->lat = $lat;
- $order->long = $long;
- $order->save();
- $syncDefaultAddress = $post['syncDefaultAddress'] ?? 0;
- if ($syncDefaultAddress == 1) {
- $customId = $order->customId ?? 0;
- $custom = CustomClass::getById($customId, true);
- if (!empty($custom)) {
- $custom->province = $province;
- $custom->city = $city;
- $custom->dist = $dist;
- $custom->address = $address;
- $custom->floor = $floor;
- $custom->showAddress = $showAddress;
- $custom->fullAddress = $fullAddress;
- $custom->lat = $lat;
- $custom->long = $long;
- $custom->save();
- }
- }
- util::complete('修改成功');
- }
- }
|