1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707 |
- <?php
- /**
- * 测试
- * Created by PhpStorm.
- * User=> 小威
- * Date=> 2020/05/16
- * Time=> 11=>31
- */
- namespace Jindouyun\Controller\Common;
- use JinDouYun\Cache\SkuCache;
- use JinDouYun\Cache\Stock;
- use JinDouYun\Dao\Customer\DCustomer;
- use JinDouYun\Dao\Goods\DGoods;
- use JinDouYun\Dao\GoodsCategory\DGoodsCategory;
- use JinDouYun\Dao\GoodsManage\DGoodsBasic;
- use JinDouYun\Dao\GoodsManage\DGoodsBrand;
- use JinDouYun\Dao\GoodsManage\DSku;
- use JinDouYun\Dao\GoodsManage\DUnits;
- use JinDouYun\Dao\Market\DUserCoupon;
- use JinDouYun\Model\Customer\MCustomer;
- use JinDouYun\Model\Enterprise\MEnterprise;
- use JinDouYun\Model\Finance\MReceive;
- use Jindouyun\Model\Finance\MPay;
- use JinDouYun\Model\Goods\MGoods;
- use JinDouYun\Model\Goods\MQuickGoods;
- use JinDouYun\Model\MBaseModel;
- use JinDouYun\Model\GoodsManage\MGoodsBasic;
- use JinDouYun\Model\Order\MOrder;
- use JinDouYun\Model\System\MModule;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Cache\Redis;
- use Mall\Framework\Core\ResultWrapper;
- use Mall\Framework\Core\StatusCode;
- use Mall\Framework\Factory;
- use Util\KuaiDi100\Query;
- use Util\WeiXin\Offiaccount;
- use Util\WeiXin\Miniprogram;
- use Util\WeiXin\Pay;
- use Util\KeRuYun\Open;
- use Util\DaDa\Merchant;
- class Test
- {
- public function index()
- {
- $objStock = new Stock(64);
- $a = $objStock->createSerialSn(0, 'Order');
- echo $a;
- die;
- }
- public function getModuleNameByUri()
- {
- $objMModule = new MModule();
- $objMModule->getModuleNameByUri('GoodsManage/GoodsBasic/getGoodsBasicInfoById');
- }
- private $objDGoods;
- /**
- * @var Redis
- */
- private $cache;
- /**
- * @var string
- */
- private $delayQueueCancelOrderKey = 'delay_queue_cancel_order';
- public function test()
- {
- exit(json_encode([
- 'state' => true,
- 'data' => '0.30kg',
- 'errorMsg' => '',
- ]));
- }
- /**
- * Doc: (des="")
- * User: XMing
- * Date: 2020/9/23
- * Time: 5:04 下午
- * @throws \Exception
- */
- public function pushDelay()
- {
- $this->cache = Factory::cache('default');
- $res = $this->cache->zAdd($this->delayQueueCancelOrderKey . '::1', time(), 100);
- //$orderIds = $this->cache->zrangebyscore($this->delayQueueCancelOrderKey.'::1', 0, time()-60, ['withscores' => TRUE]);
- //print_r($orderIds);die;
- //$res = $this->cache->zrem($this->delayQueueCancelOrderKey.'::1', 100);
- var_dump($res);
- }
- /**
- * Doc: (des="注册补发优惠券")
- * User: XMing
- * Date: 2020/9/22
- * Time: 11:57 上午
- */
- public function couponRegister()
- {
- self::coupon([
- 'userCenterId' => '',
- 'customerId' => '',
- 'enterpriseId' => '',
- ], 'MRegisterCoupon');
- }
- public function codeTest()
- {
- $location = 'eyJwcm92aW5jZU5hbWUiOiLlub/kuJznnIEiLCJjaXR5TmFtZSI6IuS4nOiOnuW4giIsImRpc3RyaWN0TmFtZSI6W10sImFkZHJlc3MiOiLkuK3lm73nn7PljJbkuJzojp7luILpobrovr7liqDmsrnnq5npmYTov5EiLCJsYXRpdHVkZSI6MjMuMDIyMTM1LCJsb25naXR1ZGUiOjExMy43MjI5NzR9';
- $areaArr = json_decode(base64_decode($location), true);
- V($areaArr);
- }
- /**
- * 营销活动(领取优惠券)
- * @param $data
- * @param $className
- */
- protected static function coupon($data, $className)
- {
- $i = 1;
- do {
- $postData = [
- 'topicName' => 'MyJob',
- 'topicClass' => "Jobs\Model\MTopic\Market\\" . $className,
- 'topicMethon' => 'push',
- 'topicMethonParams' => [
- 'userCenterId' => $data['userCenterId'],
- 'enterpriseId' => $data['enterpriseId'],
- 'customerId' => $data['customerId'],
- 'payAmount' => isset($data['payAmount']) ? $data['payAmount'] : 0,
- ],
- ];
- $url = QIANNIAO_QUEUE . '/CAddJob/add';
- $result = request($url, $postData);
- print_r($result);
- $i++;
- } while ($result['httpcode'] != 200 && $i <= 3);
- }
- /*******************************
- * @var string
- *
- *
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- * * es-----------------------ip----------------记得换
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- * es-----------------------ip----------------记得换
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- * **/
- private $Authorization;
- private $Token;
- /**
- * 格式化导入数据
- */
- public function formatData()
- {
- //导入数据需要修改以下6处地方 然后把商品信息和商品数组按照key对应
-
- //1.更换请求头token!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- $Authorization = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjI1MTUsImV4cGlyZVRpbWUiOjE2MjU1NjU0MzB9.r1KfvvNgHTTGcFFNNQed22TIB0y0bPLmdwsnh8ksNxg';
- $Token = 'a3af5bf6213ac4bc899c6d0a78d1613e';
- //2.切换config
- //3.切换esip
- //4.修改商品图片(去该企业的图片库复制一个合适的图片)
- $images = ["https://onlineimg.qianniao.vip/162496878735338/a3af5bf6213ac4bc899c6d0a78d1613e/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20210629200937.jpg"];//商品图片
- //5.企业id
- $enterpriseId = 308;
- //6.多单位
- $twoUnit = false;
- //获取数据文件
- $file = file(PROJECT_PATH.'/Public/www/1.txt');
- //引用dao
- $objDGoodsCategory = new DGoodsCategory();
- $objDGoodsCategory->setTable('qianniao_goods_category_' . $enterpriseId);
- $objDGoodsBrand = new DGoodsBrand();
- $objDGoodsBrand->setTable('qianniao_goods_brand_' . $enterpriseId);
- $objDUnits = new DUnits();
- $objDUnits->setTable('qianniao_units_' . $enterpriseId);
- //请求地址
- $apiUrl = 'https://api.qianniao.vip/Goods/QuickGoods/addBasicAndPublishGoods';
- //请求参数
- $curl_option = [
- CURLOPT_HTTPHEADER => [
- 'Content-Type:text/plain',
- 'Authorization:'.$Authorization,
- 'Token:'.$Token,
- ],
- ];
- $i = 0;
- //获取数据
- foreach ($file as $value) {
-
- if(!strpos($value,',')){
- echo '商品数据格式错误';exit;
- }
- $goodsArray = explode(',', $value);
-
- //商品信息
- $categoryName = isset($goodsArray[0]) ? trim($goodsArray[0]) : '';//分类名称
- $brandName = isset($goodsArray[3]) ? trim($goodsArray[3]) : '';//品牌名称
- $goodsName = isset($goodsArray[1]) ? trim($goodsArray[1]) : '';//商品名称
- $describe = isset($goodsArray[6213]) ? trim($goodsArray[6321]) : '';//商品卖点
- $description = isset($goodsArray[110]) ? '<p>' . trim($goodsArray[110]) . '</p>' : '';//商品详情
- //主单位信息
- $skuName = isset($goodsArray[2]) ? trim($goodsArray[2]) : '无';//单位名称
- $barCode = isset($goodsArray[34]) ? trim($goodsArray[43]) : '';//主单位条码
- $salePrice = isset($goodsArray[423]) ? trim($goodsArray[432]) : 1;//商品价格
- $salePriceTrue = isset($goodsArray[52]) ? trim($goodsArray[53]) : bcmul($salePrice, 1.2, 2);//市场价格
- //辅单位信息
- if($twoUnit){
- $skuNameTwo = isset($goodsArray[56]) ? trim($goodsArray[65]) : '';//辅单位
- $barCodeTwo = isset($goodsArray[32]) ? trim($goodsArray[32]) : '';//辅单位条码
- $conversion = isset($goodsArray[56]) ? trim($goodsArray[56]) : 0;//辅单位换算比例
- $salePriceTwo = isset($goodsArray[65]) ? trim($goodsArray[65]) : 1;//辅单位销售价格
- $salePriceTwoTrue = isset($goodsArray[34]) ? trim($goodsArray[34]) : bcmul($salePriceTwo, 1.2, 2);//辅单位市场价格
- }
- if (empty($goodsName)) {
- continue;
- }
- /***分类数据***/
- if (!empty($categoryName)) {
- //查询分类是否存在
- $categorySelect = [
- 'title' => $categoryName,
- ];
- $dbResult = $objDGoodsCategory->get($categorySelect);
- if ($dbResult === false) {
- exit($objDGoodsCategory->error());
- }
- $category = $dbResult;
- unset($dbResult);
- if (empty($category)) {
- $categoryInsert = [
- 'sort' => 0,
- 'title' => $categoryName,
- 'pid' => 0,
- 'enableStatus' => StatusCode::$standard,
- 'deleteStatus' => StatusCode::$standard,
- 'createTime' => time(),
- 'updateTime' => time(),
- ];
- $dbResult = $objDGoodsCategory->insert($categoryInsert);
- if ($dbResult === false) {
- exit($objDGoodsCategory->error());
- }
- $categoryId = $dbResult;
- $categoryPath = $dbResult;
- unset($dbResult);
- } else {
- $categoryId = $category['id'];
- if(!empty($category['link'])){
- $categoryPath = $category['link'] . ',' . $category['id'];
- }else{
- $categoryPath = $category['id'];
- }
-
- }
- } else {
- $categoryId = 1;
- $categoryPath = '1';
- }
- /***品牌数据***/
- if (!empty($brandName)) {
- //查询品牌是否存在
- $brandSelect = [
- 'title' => $brandName
- ];
- $dbResult = $objDGoodsBrand->get($brandSelect);
- if ($dbResult === false) {
- exit($objDGoodsBrand->error());
- }
- $brand = $dbResult;
- unset($dbResult);
- if (empty($brand)) {
- $brandInsert = [
- 'title' => $brandName,
- 'images' => null,
- 'sort' => 0,
- 'enableStatus' => StatusCode::$standard,
- 'createTime' => time(),
- 'updateTime' => time(),
- ];
- $dbResult = $objDGoodsBrand->insert($brandInsert);
- if ($dbResult === false) {
- exit($objDGoodsBrand->error());
- }
- $brandId = $dbResult;
- unset($dbResult);
- } else {
- $brandId = $brand['id'];
- }
- } else {
- $brandId = 1;
- }
- /***单位数据***/
- $skuId = NULL;
- if (!empty($skuName)) {
- //查询单位是否存在
- $skuSelect = [
- 'unitName' => $skuName
- ];
- $dbResult = $objDUnits->get($skuSelect);
- if ($dbResult === false) {
- exit($objDUnits->error());
- }
- $sku = $dbResult;
- unset($dbResult);
- if (empty($sku)) {
- $skuInsert = [
- 'unitName' => $skuName,
- 'enableStatus' => StatusCode::$standard,
- 'createTime' => time(),
- 'updateTime' => time(),
- ];
- $dbResult = $objDUnits->insert($skuInsert);
- if ($dbResult === false) {
- exit($objDUnits->error());
- }
- $skuId = $dbResult;
- unset($dbResult);
- } else {
- $skuId = $sku['id'];
- }
- }
- $skuIdTwo = NULL;
- if (!empty($skuNameTwo)) {
- //查询单位是否存在
- $skuSelect = [
- 'unitName' => $skuNameTwo
- ];
- $dbResult = $objDUnits->get($skuSelect);
- if ($dbResult === false) {
- exit($objDUnits->error());
- }
- $sku = $dbResult;
- unset($dbResult);
- if (empty($sku)) {
- $skuInsert = [
- 'unitName' => $skuNameTwo,
- 'enableStatus' => StatusCode::$standard,
- 'createTime' => time(),
- 'updateTime' => time(),
- ];
- $dbResult = $objDUnits->insert($skuInsert);
- if ($dbResult === false) {
- exit($objDUnits->error());
- }
- $skuIdTwo = $dbResult;
- unset($dbResult);
- } else {
- $skuIdTwo = $sku['id'];
- }
- }
- if($twoUnit){
- $postData = [
- "categoryPath" => $categoryPath,
- "title" => $goodsName,
- "storage" => "",
- "delUnitIds" => [],
- "delSpecSkuIds" => [],
- "specType" => 1,
- "specGroup" => [],
- "specMultiple" => [
- [
- "barCode" => $barCode,
- "weight" => "",
- "isDefault" => 5,
- "unitId" => $skuId,
- "unitName" => $skuName,
- "isMaster" => 5,
- "conversion" => 0,
- "specImage" => "",
- "specGroup" => [],
- "salePrice" => [
- "conversion" => 0,
- "unitName" => $skuName,
- "unitId" => $skuId,
- "isMaster" => 5,
- "deleteStatus" => 5,
- "enabledLadder" => 0,
- "salePriceAreaType" => 1,
- "salePrice" => $salePrice,
- "ladderPrice" => [],
- "marketPrice" => $salePriceTrue,
- "setNum" => 1
- ]
- ],
- [
- "barCode" => $barCodeTwo,
- "isDefault" => 4,
- "unitId" => $skuIdTwo,
- "unitName" => $skuNameTwo,
- "isMaster" => 4,
- "conversion" => $conversion,
- "specImage" => "",
- "specGroup" => [],
- "salePrice" => [
- "conversion" => $conversion,
- "unitName" => $skuNameTwo,
- "unitId" => $skuIdTwo,
- "isMaster" => 4,
- "deleteStatus" => 5,
- "enabledLadder" => 0,
- "salePriceAreaType" => 1,
- "salePrice" => $salePriceTwo,
- "ladderPrice" => [],
- "marketPrice" => $salePriceTwoTrue,
- "setNum" => 1
- ]
- ]
- ],
- "unitData" => [
- [
- "barCode" => "",
- "weight" => "",
- "isMaster" => 5,
- "isDefault" => 5,
- "unitName" => $skuName,
- "unitId" => $skuId
- ],
- [
- "unitName" => $skuNameTwo,
- "isMaster" => 4,
- "unitId" => $skuIdTwo,
- "conversion" => $conversion,
- "isEditSpec" => 5
- ]
- ],
- "describe" => $describe,
- "code" => "",
- "barCode" => "",
- "weight" => "",
- "categoryId" => $categoryId,
- "expireTime" => "",
- "brandId" => $brandId,
- "tag" => "",
- "description" => $description,
- "noSalesShop" => "",
- "images" => $images,
- "enableStatus" => 5,
- "deliverySupIds" => "1,2",
- "expressType" => 1,
- "expressFee" => "",
- "showExpress" => 5,
- "ruleId" => "",
- "isStore" => false
- ];
- }else{
- /***插入商品***/
- $specMultiple = [[
- "barCode" => $barCode,//商品条码
- "isDefault" => 5,
- "unitId" => $skuId,
- "unitName" => $skuName,
- "isMaster" => 5,
- "conversion" => 0,
- "specImage" => "",
- "specGroup" => [],
- "salePrice" => [
- "conversion" => 0,
- "unitName" => $skuName,
- "unitId" => $skuId,
- "isMaster" => 5,
- "deleteStatus" => 5,
- "enabledLadder" => 0,
- "salePriceAreaType" => 1,
- "salePrice" => $salePrice,//商品价格
- "ladderPrice" => [],
- "marketPrice" => $salePriceTrue,
- "setNum" => 1//限定数量
- ]
- ]];
- $postData = [
- 'categoryPath' => $categoryPath,
- 'title' => $goodsName,
- 'storage' => '',
- 'delUnitIds' => [],
- 'delSpecSkuIds' => [],
- 'specType' => 1,//1:无规格
- 'specGroup' => [],//无规格为空
- 'specMultiple' => $specMultiple,
- 'unitData' =>
- [
- [
- 'barCode' => '',
- 'isMaster' => 5,
- 'isDefault' => 5,
- 'unitName' => $skuName,
- 'unitId' => $skuId,
- ],
- ],
- 'describe' => $describe,//商品卖点
- 'code' => '',
- 'barCode' => '',
- 'categoryId' => $categoryId,
- 'expireTime' => '',
- 'brandId' => $brandId,
- 'tag' => '',
- 'description' => $description,//商品详情
- 'noSalesShop' => '',
- 'images' => $images,
- 'enableStatus' => 5,
- ];
- }
- $result = request($apiUrl, json_encode($postData), 10, false, $curl_option);
-
- if ($result['httpcode'] != 200) {
- exit($result['content']);
- }
- $content = json_decode($result['content'], true);
- if ($content['state'] == false) {
- exit($content['data']);
- }
- $i++;
- var_dump('导入成功:'.$goodsName);
- // break;
- }
- exit('执行成功, 共添加' . $i . '条数据');
- }
- /**
- * 导入
- * 批量添加客户
- */
- public function autoAddCustomer()
- {
- $apiUrl = 'http://api.qianniao.vip/Customer/Customer/addCustomer';
- $curl_option = [
- CURLOPT_HTTPHEADER => [
- 'Content-Type:text/plain',
- 'Authorization:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjMxMDEsImV4cGlyZVRpbWUiOjE2MDY0NTMxMjB9.gSDdfi4e0Hx_XIE-mGNRB7Ehk0iOclzpsQCv6P3ysXE',
- 'Token:95619f5cc272439f87d9b0e6b87be3e4',
- ],
- ];
- $file = file('./1.txt');
- foreach ($file as $key => $value) {
- $array = explode(',', $value);
- $customerName = isset($array[0]) ? trim($array[0]) : '';//客户名称
- $mobile = isset($array[1]) ? trim($array[1]) : '';//手机号
- $remark = isset($array[2]) ? trim($array[2]) : '';//备注
- $shopId = '';//商铺id
- $type = 35;//客户类型id
- if (empty($mobile)) {
- continue;
- }
- // if(empty($mobile) || strlen($mobile) != 11){
- // $len = 4 - strlen($key + 1);
- // $str = '';
- // for($i = 1; $i <= $len; $i++){
- // $str .= '0';
- // }
- // $mobile = '1111111'.$str.($key + 1);
- // }
- $postData = array(
- 'tempSave' => '',
- 'latitude' => '',
- 'longitude' => '',
- 'password' => '',
- 'area' => '',
- 'mobile' => $mobile,
- 'enableStatus' => 5,
- 'name' => $customerName,
- 'code' => '',
- 'type' => $type,
- 'provinceCode' => 610000,
- 'cityCode' => 610100,
- 'districtCode' => 610112,
- 'address' => '',
- 'managerMobile' => '',
- 'shopId' => $shopId,
- 'departmentId' => '',
- 'salesManId' => '',
- 'salesManCode' => '',
- 'salesManName' => '',
- 'birthday' => 0,
- 'remark' => $remark,
- 'extend' =>
- array(
- 'license' => '',
- ),
- 'contact' =>
- array(
- 'area' => '',
- 'name' => $customerName,
- 'mobile' => $mobile,
- 'provinceCode' => 610000,
- 'cityCode' => 610100,
- 'districtCode' => 610112,
- 'address' => '大明宫万达',
- ),
- );
- $result = request($apiUrl, json_encode($postData), 10, false, $curl_option);
- if ($result['httpcode'] != 200) {
- exit($result['content']);
- }
- $content = json_decode($result['content'], true);
- if ($content['state'] == false) {
- // exit($content['data']);
- }
- }
- }
- public function enterpriseId97ByTime0907()
- {
- //获取数据
- $file = file('./enterpriseId97ByTime0907.txt');
- //循环数据
- $goodsData = [];
- foreach ($file as $value) {
- //格式化商品数据
- $goodsArray = explode(',', $value);
- $goods['id'] = trim($goodsArray[0]);//商品ID
- $goods['name'] = trim($goodsArray[1]);//商品名称
- $goods['spec'] = [trim($goodsArray[2])];//商品规格
- $goods['category'] = trim($goodsArray[3]);//商品分类
- $goods['price'] = trim($goodsArray[4]);//商品价格
- if (!strripos($goods['category'], " ")) {
- continue;
- }
- if (isset($goodsData[$goods['id']])) {
- $goodsData[$goods['id']]['spec'] = array_merge($goodsData[$goods['id']]['spec'], $goods['spec']);
- } else {
- $goodsData[$goods['id']] = $goods;
- }
- }
- unset($goodsArray);
- unset($goods);
- // V($goodsData);
- //查询所有分类
- $sql = 'select id,link,title from qianniao_goods_category_97';
- $dbResult = $this->objDGoods->query($sql);
- if ($dbResult === false) {
- exit($this->objDGoods->error());
- }
- //格式化分类
- $categoryData = [];
- foreach ($dbResult as $value) {
- $categoryData[$value['title']] = [
- 'id' => $value['id'],
- 'path' => empty($value['link']) ? $value['id'] : $value['link'] . ',' . $value['id']
- ];
- }
- //请求数据
- $apiUrl = 'http://api.qianniao.vip/Goods/QuickGoods/addBasicAndPublishGoods';
- $curl_option = [
- CURLOPT_HTTPHEADER => [
- 'Content-Type:text/plain',
- 'Authorization:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjIxMDgsImV4cGlyZVRpbWUiOjE1OTk0Njc5ODN9.gG5Ike-xmmKqe-_CpE5tVbSIESvU7-2AlfTlK-ouLNI',
- 'Token:4c8574ddcbf69ea23bcf403c0b0830e9'
- ],
- ];
- $specApiUrl = 'http://api.qianniao.vip/GoodsManage/SpecManage/defineSpec';
- $i = 0;
- foreach ($goodsData as $value) {
- //区分有没有规格
- $specType = 1;//无规格
- $specGroup = [];//无规格
- $specMultipleNo = [];
- $specMultipleNo[] = [
- "barCode" => "",
- "isDefault" => 5,
- "unitId" => 1,
- "unitName" => "件",
- "isMaster" => 5,
- "conversion" => 0,
- "specImage" => "",
- "specGroup" => [],
- "salePrice" => [
- "conversion" => 0,
- "unitName" => "件",
- "unitId" => 1,
- "isMaster" => 5,
- "deleteStatus" => 4,
- "enabledLadder" => 0,
- "salePriceAreaType" => 1,
- "salePrice" => $value['price'],
- "ladderPrice" => [],
- "marketPrice" => $value['price'] * 1.2,
- "setNum" => 1
- ]
- ];
- $specMultipleYes = [];
- foreach ($value['spec'] as $specValue) {
- if ($specValue != '999') {
- $specType = 2;//有规格
- $specPostData = [
- 'hidden' => 4,
- 'pid' => 4,
- 'specName' => $specValue,
- ];
- $result = request($specApiUrl, json_encode($specPostData), 10, false, $curl_option);
- if ($result['httpcode'] != 200) {
- exit($result['content']);
- }
- $content = json_decode($result['content'], true);
- $specGroup['groupSpec'] = [
- 'specName' => '默认',
- 'specId' => 4,
- ];
- $specGroup['params'][] = [
- 'specValueId' => $content['data']['id'],
- 'specValueName' => $content['data']['specName'],
- ];
- $specMultipleYes[] = [
- 'unitId' => 1,
- 'unitName' => '件',
- 'isMaster' => 5,
- 'conversion' => 0,
- 'specImage' => '',
- 'isDefault' => 4,
- 'barCode' => '',
- 'specGroup' => [
- [
- 'specId' => '4',
- 'specName' => '默认',
- 'specValueName' => $specValue,
- 'specValueId' => '5',
- ]
- ],
- 'salePrice' =>
- [
- 'conversion' => 0,
- 'unitName' => '件_' . $specValue,
- 'unitId' => 1,
- 'isMaster' => 5,
- 'deleteStatus' => 4,
- 'enabledLadder' => 0,
- 'salePriceAreaType' => 1,
- 'salePrice' => $value['price'],
- 'ladderPrice' => [],
- 'marketPrice' => $value['price'] * 1.2,
- 'setNum' => 1,
- ],
- ];
- }
- }
- $specMultiple = $specMultipleNo;
- if ($specType == 2) {
- $specMultiple = $specMultipleYes;
- }
- if (!strripos($value['category'], " ")) {
- continue;
- }
- $categoryTitle = substr($value['category'], strripos($value['category'], " ") + 1);
- //分类不存在 跳出本次
- if (!isset($categoryData[$categoryTitle])) {
- continue;
- }
- $postData = array(
- 'categoryPath' => $categoryData[$categoryTitle]['path'],
- 'title' => $value['name'],
- 'storage' => '',
- 'delUnitIds' => [],
- 'delSpecSkuIds' => [],
- 'specType' => $specType,
- 'specGroup' => empty($specGroup) ? $specGroup : [$specGroup],
- 'specMultiple' => $specMultiple,
- 'unitData' =>
- array(
- 0 =>
- array(
- 'barCode' => '',
- 'isMaster' => 5,
- 'isDefault' => 5,
- 'unitName' => '件',
- 'unitId' => 1,
- ),
- ),
- 'describe' => '',
- 'code' => '',
- 'barCode' => '',
- 'categoryId' => $categoryData[$categoryTitle]['id'],
- 'expireTime' => '',
- 'brandId' => '',
- 'tag' => '',
- 'description' => '',
- 'noSalesShop' => '',
- 'images' => ["https://onlineimg.qianniao.vip/159929437078955/4c8574ddcbf69ea23bcf403c0b0830e9/logo.jpg"],
- 'enableStatus' => 5,
- );
- $result = request($apiUrl, json_encode($postData), 10, false, $curl_option);
- if ($result['httpcode'] != 200) {
- exit($result['content']);
- }
- $content = json_decode($result['content'], true);
- if ($content['state'] == false) {
- exit($content['data']);
- }
- $i++;
- }
- echo '执行成功, 共添加' . $i . '条商品';
- }
- /**
- * 我的锅系统商品添加
- */
- public function addGuoGoods()
- {
- $apiUrl = 'https://store.qianniaovip.com//app/index.php?i=2&c=entry&do=SaveGoods&m=yb_cy';
- $curl_option = [
- CURLOPT_HTTPHEADER => [
- 'Content-Type:application/json;charset=UTF-8',
- ],
- ];
- $postData = [
- "id" => "",
- "sort" => "1",
- "categoryIds" => [
- "13"
- ],
- "salesNum" => "",
- "minNum" => 0,
- "maxNum" => 0,
- "icon" => "../addons/yb_cy/template/public/img/set/nopic.jpg",
- "media" => [
- "https => //wodeguo-1303051460.cos.ap-chengdu.myqcloud.com/yb_cy/2020/09/14/0353760156390008.png"
- ],
- "item" => 1,
- "spec" => [
- ],
- "attribute" => [
- ],
- "name" => "千鸟云商测试商品",
- "group" => [
- ],
- "boxMoney" => "",
- "body" => "",
- "outSalesPrice" => 1,
- "outPrice" => 0,
- "outStock" => 1,
- "inSalesPrice" => 1,
- "inPrice" => 0,
- "inStock" => 1,
- "isSpec" => "2",
- "isAttribute" => "2",
- "required" => "2",
- "isMaterial" => "2",
- "MaterialIds" => [
- ],
- "unit" => "13",
- "isMember" => "2",
- "details" => ""
- ];
- $result = request($apiUrl, json_encode($postData), 10, false, $curl_option);
- if ($result['httpcode'] != 200) {
- exit($result['content']);
- }
- $content = json_decode($result['content'], true);
- V($content);
- }
- // public function recived()
- // {
- //
- // $i = 1;
- // do {
- // $postData = [
- // 'topicName' => 'MyJob',
- // 'topicClass' => 'Jobs\Model\MTopic\Finance\MReceivable',
- // 'topicMethon' => 'checkExistCreate',
- // 'topicMethonParams' => [
- // 'enterpriseId' => 34,
- // ],
- // ];
- //
- // $url = 'http://queue.qianniao.vip:8080/CAddJob/add';
- // $result = request($url, $postData);
- // print_r($result);
- // $i++;
- // } while ($result['httpcode'] != 200 && $i <= 3);
- // }
- public function log()
- {
- Logger::logs(E_USER_ERROR, '没有错误信息', __CLASS__, __LINE__, '没有错误信息');
- }
- public function formatUpdateEsData()
- {
- $curl_option = [
- CURLOPT_HTTPHEADER => [
- 'Content-Type: application/json'
- ],
- ];
- $postData = [
- 'doc' => [
- 'status' => 2
- ]
- ];
- for ($i = 1; $i <= 170; $i++) {
- if ($i != 19) {
- $enableApiUrl = 'http://49.235.209.106:9200/online_customer_search/customer/EnterpriseId_13_CustomerId_' . $i . '/_update';
- $result = request($enableApiUrl, json_encode($postData), 1000, false, $curl_option);
- var_dump($result['content']);
- var_dump('<br/>');
- }
- }
- }
- public function autoEnterprise()
- {
- $objMEnterprise = new MEnterprise();
- $return = $objMEnterprise->autoCreateData(1112, 71);
- echo $return->getData();
- }
- public function goodsCateGory()
- {
- $sql = 'select * from qianniao_goods_category_48 where deleteStatus = 5 and pid = 0';
- $category = $this->objDGoods->query($sql);
- if ($category === false) {
- return ResultWrapper::fail($this->objDGoods->error(), ErrorCode::$paramError);
- }
- $map = [];
- foreach ($category as $item) {
- //' and find_in_set('.$condition['categoryId'].',b.categoryPath) ';
- $sql_1 = 'select g.id from qianniao_goods_48 as g left join qianniao_goods_basic_48 as b
- on g.basicGoodsId = b.id where find_in_set(' . $item['id'] . ',b.categoryPath) and
- g.deleteStatus = 5 And g.enableStatus = 5';
- $sql_2 = 'select g.id from qianniao_goods_48 as g left join qianniao_goods_basic_48 as b
- on g.basicGoodsId = b.id where find_in_set(' . $item['id'] . ',b.categoryPath) and
- g.deleteStatus = 5 And g.enableStatus = 4';
- $u_count = count($this->objDGoods->query($sql_1));
- $b_count = count($this->objDGoods->query($sql_2));
- $map[] = [
- 'id' => $item['id'],
- 'categoryName' => $item['title'],
- 'u_num' => $u_count,
- 'b_num' => $b_count
- ];
- }
- self::export($map);
- die;
- }
- /**
- * 导出方法
- *
- * @param $allOrderData
- */
- private static function export($allOrderData)
- {
- //导出到本地
- header("Content-type:application/vnd.ms-excel");
- header("Content-Disposition:filename=订单记录.csv");
- header('Cache-Control: max-age=0');
- $fp = fopen('php://output', 'a');
- $head = ['ID', '分类名称', '上架数量', '下架数量']; //定义标题
- foreach ($head as $i => $v) {
- $head[$i] = mb_convert_encoding($v, 'GBK', 'utf-8'); //将中文标题转换编码,否则乱码
- }
- fputcsv($fp, $head);
- $limit = 10000;
- $num = 0;//计数器
- foreach ($allOrderData as $v) {
- //循环数据
- $num++;
- if ($num == $limit) {
- ob_flush();//释放内存
- flush();
- }
- $rows['id'] = $v['id'];
- $rows['categoryName'] = $v['categoryName'];
- $rows['u_num'] = $v['u_num'];
- $rows['b_num'] = $v['b_num'];
- foreach ($rows as $kk => $vv) {
- $rs[$kk] = mb_convert_encoding($vv, 'GBK', 'utf-8'); //转译编码
- }
- fputcsv($fp, $rs);
- $rows = [];
- }
- exit;
- }
- /**
- * 处理文件
- * @throws Exception
- * @throws \Exception
- */
- public function formatFIle()
- {
- $file = file('./1.txt');
- $userCenterId = 969;
- $enterpriseId = 56;
- $objMGoodsBasic = new MGoodsBasic($userCenterId, $enterpriseId);
- $objMQuickGoods = new MQuickGoods($enterpriseId, $userCenterId);
- $objMGoods = new MGoods($enterpriseId, false, $userCenterId);
- $array = [];
- foreach ($file as $key => $value) {
- $goodsArray = explode(',', $value);
- if (empty(trim($goodsArray[0])) || in_array(trim($goodsArray[0]), $array)) continue;
- $title = trim($goodsArray[0]) . trim($goodsArray[3]);//商品名字
- $unitId = trim($goodsArray[1]);
- $unitName = trim($goodsArray[2]);
- $describe = '';//卖点
- $categoryId = 2;
- $categoryPath = '2';
- $shopId = 56;
- $shopName = '品茗苑茶行';
- $brandId = 1;
- $addData = [
- //必填字段
- 'title' => $title,//商品名称
- 'brandId' => $brandId,//品牌id
- 'categoryId' => $categoryId,//分类
- 'categoryPath' => $categoryPath,//分类路径
- 'unitData' => [['unitName' => $unitName, 'isMaster' => 5, 'conversion' => '0.00', 'unitId' => $unitId, 'barCode' => '']],//单位
- 'barCode' => '',//条码
- 'describe' => $describe,//卖点
- 'specType' => 1,//单规格1 多规格2
- 'description' => '',
- 'images' => '[]',//商品图册json
- 'expireTime' => 0,
- 'tag' => '',//关键词
- 'link' => '',
- // 'specMultiple' => [],
- // 'shopId' => 46,//商铺id
- // 'shopName' => '纺物优选',//商铺名称
- //
- // 'barCode' => '',
- // 'noSalesShop' => '',
- // 'specGroup' => [],
- // 'extends' => json_encode(['storage'=>'']),
- // 'enableStatus' => 4,
- // 'createUserName' => '',
- // 'sort' => '',
- ];
- //添加商品基础资料
- $modelResult = $objMGoodsBasic->addGoodsBasic($addData);
- if (!$modelResult->isSuccess()) {
- echo $modelResult->getData();
- }
- $basicId = $modelResult->getData();
- $goodsData = [
- 'basicGoodsId' => $basicId,//基本资料id
- 'goodsName' => $title,//基本资料商品名称
- 'shopId' => $shopId,//商铺id
- 'shopName' => $shopName,//商铺名称
- 'images' => '[]',
- 'specType' => 1,//规格类型
- 'enableStatus' => StatusCode::$delete,
- 'priceData' => '',//接json值
- 'createUserName' => '',//添加商品人名称
- ];
- $goodsData['content'] = '';
- $goodsData['isRecommend'] = 4;
- $goodsData['createTime'] = time();
- $goodsData['updateTime'] = time();
- $goodsData['deleteStatus'] = StatusCode::$standard;
- $goodsData['sort'] = 0;
- //添加商品
- $modelResult = $objMGoods->addGoods($goodsData);
- if (!$modelResult->isSuccess()) {
- echo $modelResult->getData();
- }
- $array[] = $title;
- //单店铺添加商品
- // $modelResult = $objMQuickGoods->addBasicAndPublishGoods($addData);
- // if (!$modelResult->isSuccess()) {
- // echo $modelResult->getData();
- // }
- // if($key > 1){
- // break;
- // }
- }
- echo '成功';
- }
- /**
- * 格式化分类
- * @throws Exception
- */
- public function formatFIleCategory()
- {
- $file = file('./2.txt');
- $objDSku = new DSku();
- foreach ($file as $value) {
- $explodeData = explode(':', $value);
- $goodsBasicData = trim($explodeData[0]);
- $goodsCategoryData = trim($explodeData[1]);
- //判断是一级分类还是多级分类
- if (strstr($goodsCategoryData, ',')) {
- //多级分类
- $categoryData = explode(',', $goodsCategoryData);
- $categoryPath = '';
- $categoryId = 0;
- foreach ($categoryData as $key => $v) {
- $category = trim($v);
- //查询分类表是否有这个分类的名称
- $sql = 'select * from qianniao_goods_category_34 where title = ' . trim($category) . ' and pid = ' . $categoryId;
- $dbResult = $objDSku->query($sql);
- if ($dbResult === false) {
- echo $objDSku->error();
- break;
- }
- //如果不存在 插入一条分类
- if (empty($dbResult)) {
- $sql = 'insert into qianniao_goods_category_34 (pid, title, createTime, updateTime) values(' . $categoryId . ', "' . trim($category) . '", ' . time() . ', ' . time() . ')';
- $insertResult = $objDSku->query($sql);
- if ($insertResult === false) {
- echo $objDSku->error();
- break;
- }
- $id = $insertResult;
- } else {
- $id = $dbResult[0]['id'];
- }
- $categoryId = $id;
- $categoryPath = $categoryId == 0 ? $id : $categoryPath . ',' . $id;
- }
- } else {
- //一级分类
- //查询分类表是否有这个分类的名称
- $sql = 'select * from qianniao_goods_category_34 where title = ' . trim($goodsCategoryData) . ' and pid = 0';
- $dbResult = $objDSku->query($sql);
- if ($dbResult === false) {
- echo $objDSku->error();
- break;
- }
- //如果不存在 插入一条分类
- if (empty($dbResult)) {
- $sql = 'insert into qianniao_goods_category_34 (pid, title, createTime, updateTime) values(0, "' . trim($goodsCategoryData) . '", ' . time() . ', ' . time() . ')';
- $categoryId = $objDSku->query($sql);
- if ($categoryId === false) {
- echo $objDSku->error();
- break;
- }
- } else {
- $categoryId = $dbResult[0]['id'];
- }
- $categoryPath = $categoryId;
- }
- //根据该商品名称修改分类字段
- $sql = 'update qianniao_goods_basic_34 set categoryId = ' . $categoryId . ', categoryPath = ' . $categoryPath . ' where title = "' . $goodsBasicData . '"';
- $dbResult = $objDSku->query($sql);
- if ($dbResult === false) {
- echo $objDSku->error();
- break;
- }
- }
- }
- /**
- * 测试 获取缓存
- * @throws Exception
- */
- public function getCache()
- {
- $objMOrder = new MOrder(1, 1);
- $result = $objMOrder->businessOverview('todayConfirmedOrderNum', '');
- V($result);
- }
- public function test_request()
- {
- $apiUrl = 'http://api.qianniao.vip/Goods/Goods/addGoods';
- $enableApiUrl = 'http://api.qianniao.vip/Goods/Goods/updateEnableStatus';
- $curl_option = [
- CURLOPT_HTTPHEADER => [
- 'Content-Type:text/plain',
- 'Authorization:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjU2OSwiZXhwaXJlVGltZSI6MTU5MTUwMDQ1M30.y5HnUgq7dZ4lgk4bCK_l7FJr_UpelHYtvgLX4Hpa5fs',
- 'Token:8fa553d53f44e33123e4d0d51a0de634'
- ],
- ];
- $objDGoodsBasic = new DGoodsBasic();
- $objSku = new DSku();
- $sql = 'select b.* from qianniao_goods_basic_34 as b left join qianniao_goods_34 as g on b.id = g.basicGoodsId WHERE g.basicGoodsId IS NULL';
- $dbResult = $objDGoodsBasic->query($sql);
- foreach ($dbResult as $row) {
- $skuData = $objSku->query('select * from qianniao_sku_34 where goodsId = ' . $row['id'] . ' and deleteStatus = 5');
- $postData = [
- "createUserName" => "陈民",
- "goodsName" => $row['title'],
- "specType" => $row['specType'],
- "goodsBasicId" => $row['id'],
- "shopId" => 38,
- "shopName" => "万货网",
- "images" => json_decode($row['images'], true),
- "salesArea" => [],
- "serviceInfo" => 1,
- "price" => [
- [
- "id" => $skuData[0]['id'],
- "unitId" => $skuData[0]['unitId'],
- "unitName" => $skuData[0]['unitName'],
- "conversion" => "0.00",
- "isMaster" => 5,
- "enabledLadder" => 0,
- "marketPrice" => 1000,
- "salePrice" => 999,
- "setNum" => 1,
- "salePriceAreaType" => 1,
- "ladderPrice" => []
- ]
- ],
- "specification" => [
- null
- ],
- "content" => "",
- "isRecommend" => 5,
- "sort" => "1"
- ];
- $result = request($apiUrl, json_encode($postData), 10, false, $curl_option);
- if ($result['httpcode'] != 200) {
- return ResultWrapper::fail($result['content'], ErrorCode::$apiNotResult);
- }
- $reponse = json_decode($result['content'], true);
- if (isset($reponse) && $reponse['errorcode'] == 0) {
- $enableData = [
- 'enableStatus' => StatusCode::$standard,
- 'id' => (int)$reponse['data']
- ];
- $enableResponse = request($enableApiUrl, json_encode($enableData), 10, false, $curl_option);
- }
- //V(123);
- }
- return ResultWrapper::success($reponse['data']);
- }
- /**
- * @throws Exception
- */
- public function syncGoodsAndGoodsBasic()
- {
- $objDGoodsBasic = new DGoodsBasic();
- $objDGoods = new DGoods();
- $objDGoods->setTable('qianniao_goods_34');
- $objDGoodsBasic->setTable('qianniao_goods_basic_34');
- $goodsBasicData = $objDGoodsBasic->select([], 'id,images');
- if ($goodsBasicData === false) {
- exit("sql:" . $objDGoodsBasic->error());
- }
- foreach ($goodsBasicData as $row) {
- $update = $objDGoods->update(['images' => $row['images']], ['basicGoodsId' => $row['id']]);
- if ($update === false) {
- exit("sql:" . $objDGoods->error());
- }
- }
- V("操作成功");
- }
- /**
- * Test constructor.
- */
- public function __construct()
- {
- $this->objDGoods = new DGoods();
- // $this->Authorization = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjgyNywiZXhwaXJlVGltZSI6MTU5NTgzMDUzN30.Rua2aBXgwh_hIAkp6M1KHYYtCzcsTgEdLqvD-c8-pmw';
- // $this->Token = 'a946c2ed5c589bfe0f66e48facb32649';
- }
- /**public function addOrder()
- * {
- * echo "start".PHP_EOL;
- * $apiUrl = 'http://api.qianniao.vip/Order/Order/addOrder/613';
- * $curl_option = [
- * CURLOPT_HTTPHEADER => [
- * 'Content-Type:text/plain',
- * 'Authorization:'.$this->Authorization,
- * 'Token:'.$this->Token
- * ],
- * ];
- * //$postData = '{"deliveryType":1,"customerName":"清扬超市","receiveAddressId":141,"source":"3","orderRemark":"新日期","goodsData":{"totalMoney":"406.05","payMoney":"406.05","preferential":"0.00","vipDiscount":0,"vipDoubleDiscount":0,"activityMoney":"0.00","checkNum":5,"cartNum":5,"goodsNum":29,"goodsData":[{"shopId":38,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","totalMoney":"406.05","preferential":"0.00","payMoney":"406.05","shopGoodsData":[{"id":2536,"goodsId":483,"goodsCode":"MATERIEL000483","buyNum":5,"shopId":38,"goodsBasicId":483,"selection":5,"skuId":483,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2536,"brandName":"","categoryName":"膨化食品","barCode":"6924743919242","storageCode":"H1-2-1-3","goodsName":"乐事墨西哥鸡汁番茄味薯片70g","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591509958101乐事墨西哥鸡汁番茄味薯片70g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":99,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"4.65","price":"4.65","preferential":0,"totalMoney":"23.25","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"4.3200","inventoryNum":"17.00000000","conversion":0},{"id":2535,"goodsId":517,"goodsCode":"MATERIEL000517","buyNum":4,"shopId":38,"goodsBasicId":517,"selection":5,"skuId":517,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2535,"brandName":"健力宝","categoryName":"膨化食品","barCode":"6920912341852","storageCode":"A2-1-4-1","goodsName":"盼盼家庭号经济包薯片原味108g","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591509094748盼盼家庭号经济包薯片原味108g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":1,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.45","price":"2.45","preferential":0,"totalMoney":"9.80","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"2.1000","inventoryNum":"54.00000000","conversion":0},{"id":2534,"goodsId":495,"goodsCode":"MATERIEL000495","buyNum":10,"shopId":38,"goodsBasicId":495,"selection":5,"skuId":495,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2534,"brandName":"","categoryName":"膨化食品","barCode":"6909409012802","storageCode":"A1-1-3-4","goodsName":"上好佳草莓味栗米条40g","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591509681566上好佳草莓味栗米条40g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":102,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.70","price":"2.70","preferential":0,"totalMoney":"27.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"2.6000","inventoryNum":"30.00000000","conversion":0},{"id":2533,"goodsId":64,"goodsCode":"MATERIEL000064","buyNum":8,"shopId":38,"goodsBasicId":64,"selection":5,"skuId":64,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2533,"brandName":"","categoryName":"果汁饮料","barCode":"","storageCode":"","goodsName":"康师傅冰红茶1L*12瓶","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591581053066康师傅茉莉蜜茶1l.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":18,"brandId":109,"categoryPath":"18","isActivity":4,"specType":1,"unitName":"件","specGroup":[],"originPrice":"34.50","price":"34.50","preferential":0,"totalMoney":"276.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"34.6660","inventoryNum":"10.00000000","conversion":0},{"id":2532,"goodsId":63,"goodsCode":"MATERIEL000063","buyNum":2,"shopId":38,"goodsBasicId":63,"selection":5,"skuId":63,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2532,"brandName":"","categoryName":"果汁饮料","barCode":"6921317989847","storageCode":"C1-1-15","goodsName":"康师傅蜂蜜绿茶1L*12瓶","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591581068709康师傅绿茶1l.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":18,"brandId":109,"categoryPath":"18","isActivity":4,"specType":1,"unitName":"件","specGroup":[],"originPrice":"35.00","price":"35.00","preferential":0,"totalMoney":"70.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"34.6500","inventoryNum":"5.00000000","conversion":0}]}],"invalidData":[]}}';
- * $postData = '{"deliveryType":1,"customerName":"诚信百货超市","receiveAddressId":7,"source":"3","orderRemark":"","goodsData":{"totalMoney":"420.75","payMoney":"420.75","preferential":"0.00","vipDiscount":0,"vipDoubleDiscount":0,"activityMoney":"0.00","checkNum":15,"cartNum":15,"goodsNum":60,"goodsData":[{"shopId":38,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","totalMoney":"420.75","preferential":"0.00","payMoney":"420.75","shopGoodsData":[{"id":2552,"goodsId":575,"goodsCode":"MATERIEL000575","buyNum":10,"shopId":38,"goodsBasicId":575,"selection":5,"skuId":575,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2552,"brandName":"","categoryName":"坚果炒货","barCode":"6922742001180","storageCode":"A2-3-3-3","goodsName":"沙土原香瓜子200g","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591504718336沙土原香瓜子200g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":118,"brandId":104,"categoryPath":"118","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"3.70","price":"3.70","preferential":0,"totalMoney":"37.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"4.2538","inventoryNum":"61.00000000","conversion":0},{"id":2550,"goodsId":574,"goodsCode":"MATERIEL000574","buyNum":20,"shopId":38,"goodsBasicId":574,"selection":5,"skuId":574,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2550,"brandName":"","categoryName":"坚果炒货","barCode":"6922742000848","storageCode":"A2-3-3-2","goodsName":"沙土香瓜子300g","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591504774300沙土香瓜子300g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":118,"brandId":104,"categoryPath":"118","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"5.95","price":"5.95","preferential":0,"totalMoney":"119.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"5.6200","inventoryNum":"140.00000000","conversion":0},{"id":2549,"goodsId":345,"goodsCode":"MATERIEL000345","buyNum":2,"shopId":38,"goodsBasicId":345,"selection":5,"skuId":345,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2549,"brandName":"","categoryName":"熟食卤味","barCode":"6935284413991","storageCode":"F1-4-3-5","goodsName":"卫龙亲嘴烧选B麦辣鸡汁味28g*20包","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591513223408卫龙亲嘴烧选B麦辣鸡汁味28g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":13,"brandId":89,"categoryPath":"13","isActivity":4,"specType":1,"unitName":"盒","specGroup":[],"originPrice":"14.50","price":"14.50","preferential":0,"totalMoney":"29.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"13.0000","inventoryNum":"2.00000000","conversion":0},{"id":2548,"goodsId":72,"goodsCode":"MATERIEL000072","buyNum":1,"shopId":38,"goodsBasicId":72,"selection":5,"skuId":72,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2548,"brandName":"","categoryName":"茶饮料","barCode":"4891599366839","storageCode":"C1-1-8","goodsName":"加多宝凉茶植物饮料550ML*15瓶","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591580637360主图-1 (1).jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":15,"brandId":72,"categoryPath":"15","isActivity":4,"specType":1,"unitName":"件","specGroup":[],"originPrice":"43.80","price":"43.80","preferential":0,"totalMoney":"43.80","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"42.0000","inventoryNum":"5.00000000","conversion":0},{"id":2547,"goodsId":440,"goodsCode":"MATERIEL000440","buyNum":3,"shopId":38,"goodsBasicId":440,"selection":5,"skuId":440,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2547,"brandName":"","categoryName":"膨化食品","barCode":"6922330265543","storageCode":"F1-9-1-1","goodsName":"运康牛肉口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510887159运康牛肉口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"1.9367","inventoryNum":"51.00000000","conversion":0},{"id":2546,"goodsId":441,"goodsCode":"MATERIEL000441","buyNum":3,"shopId":38,"goodsBasicId":441,"selection":5,"skuId":441,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2546,"brandName":"","categoryName":"膨化食品","barCode":"6922330265529","storageCode":"F1-9-2-1","goodsName":"运康香辣口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510878227运康香辣口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"2.0000","inventoryNum":"44.00000000","conversion":0},{"id":2545,"goodsId":442,"goodsCode":"MATERIEL000442","buyNum":3,"shopId":38,"goodsBasicId":442,"selection":5,"skuId":442,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2545,"brandName":"","categoryName":"膨化食品","barCode":"6922330255001","storageCode":"F1-9-1-2","goodsName":"运康五香口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510880914运康五香口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"2.0000","inventoryNum":"5.00000000","conversion":0},{"id":2544,"goodsId":443,"goodsCode":"MATERIEL000443","buyNum":3,"shopId":38,"goodsBasicId":443,"selection":5,"skuId":443,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2544,"brandName":"","categoryName":"膨化食品","barCode":"6922330265703","storageCode":"F1-9-2-3","goodsName":"运康鸡肉口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510893356运康鸡肉口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"1.9000","inventoryNum":"50.00000000","conversion":0},{"id":2543,"goodsId":444,"goodsCode":"MATERIEL000444","buyNum":3,"shopId":38,"goodsBasicId":444,"selection":5,"skuId":444,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2543,"brandName":"","categoryName":"膨化食品","barCode":"6922330265512","storageCode":"F1-9-2-2","goodsName":"运康烧烤口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510884090运康烧烤口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"1.9166","inventoryNum":"60.00000000","conversion":0},{"id":2542,"goodsId":445,"goodsCode":"MATERIEL000445","buyNum":3,"shopId":38,"goodsBasicId":445,"selection":5,"skuId":445,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2542,"brandName":"","categoryName":"膨化食品","barCode":"6922330265581","storageCode":"F1-9-2-4","goodsName":"运康麻辣口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510890646运康麻辣口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.45","price":"2.45","preferential":0,"totalMoney":"7.35","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"1.9397","inventoryNum":"53.00000000","conversion":0},{"id":2541,"goodsId":446,"goodsCode":"MATERIEL000446","buyNum":3,"shopId":38,"goodsBasicId":446,"selection":5,"skuId":446,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2541,"brandName":"","categoryName":"膨化食品","barCode":"","storageCode":"","goodsName":"运康羊肉串口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510875264运康羊肉串口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"1.9000","inventoryNum":"50.00000000","conversion":0},{"id":2540,"goodsId":349,"goodsCode":"MATERIEL000349","buyNum":2,"shopId":38,"goodsBasicId":349,"selection":5,"skuId":349,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2540,"brandName":"","categoryName":"熟食卤味","barCode":"6935284415162","storageCode":"F1-4-2-1","goodsName":"卫龙魔芋爽酸辣素毛肚18g*20包","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591513176969卫龙魔芋爽酸辣素毛肚18g_20.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":13,"brandId":89,"categoryPath":"13","isActivity":4,"specType":1,"unitName":"盒","specGroup":[],"originPrice":"14.50","price":"14.50","preferential":0,"totalMoney":"29.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"12.7343","inventoryNum":"10.00000000","conversion":0},{"id":2539,"goodsId":347,"goodsCode":"MATERIEL000347","buyNum":2,"shopId":38,"goodsBasicId":347,"selection":5,"skuId":347,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2539,"brandName":"","categoryName":"熟食卤味","barCode":"6935284414011","storageCode":"F1-4-3-4","goodsName":"卫龙亲嘴烧选C川香风味28g*20包","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591513220899卫龙亲嘴烧选C川香风味28g_20.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":13,"brandId":89,"categoryPath":"13","isActivity":4,"specType":1,"unitName":"盒","specGroup":[],"originPrice":"14.50","price":"14.50","preferential":0,"totalMoney":"29.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"13.0000","inventoryNum":"2.00000000","conversion":0},{"id":2538,"goodsId":678,"goodsCode":"MATERIEL000678","buyNum":1,"shopId":38,"goodsBasicId":678,"selection":5,"skuId":678,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2538,"brandName":"","categoryName":"方便面/粉","barCode":"","storageCode":"","goodsName":"康师傅鲜虾鱼板面95g*24袋","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591502015830康师傅鲜虾鱼板面95g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":22,"brandId":109,"categoryPath":"22","isActivity":4,"specType":1,"unitName":"件","specGroup":[],"originPrice":"47.50","price":"47.50","preferential":0,"totalMoney":"47.50","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"46.0000","inventoryNum":"2.00000000","conversion":0},{"id":2537,"goodsId":663,"goodsCode":"MATERIEL000663","buyNum":1,"shopId":38,"goodsBasicId":663,"selection":5,"skuId":663,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2537,"brandName":"","categoryName":"方便面/粉","barCode":"6903252100785","storageCode":"","goodsName":"康师傅红烧牛肉面109g*12桶","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591502332247康师傅红烧牛肉面108g-12桶.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":22,"brandId":109,"categoryPath":"22","isActivity":4,"specType":1,"unitName":"件","specGroup":[],"originPrice":"38.00","price":"38.00","preferential":0,"totalMoney":"38.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"37.0000","inventoryNum":"7.00000000","conversion":0}]}],"invalidData":[]}}';
- * $result = request($apiUrl, $postData, 60, false, $curl_option);
- * if ($result['httpcode'] != 200) {
- * return ResultWrapper::fail($result['content'], ErrorCode::$apiNotResult);
- * }
- * $reponse = json_decode($result['content'], true);
- * V($reponse);
- * }**/
- public function bugCategoryPath()
- {
- $fields = 'b.id,b.title,b.categoryPath,b.categoryId';
- $sql = 'SELECT ' . $fields . ' FROM qianniao_goods_basic_48 as b
- LEFT JOIN qianniao_goods_category_48 as c ON
- c.id = b.categoryId WHERE c.pid != 0';
- $result = $this->objDGoods->query($sql);
- if ($result === false) {
- echo 'sql' . $this->objDGoods->error();
- die;
- }
- $allCategoryIds = [];
- foreach ($result as $item) {
- $allCategoryIds[] = $item['categoryId'];
- }
- //获取这些分类的全路径
- $c_sql = 'SELECT id,pid,title FROM qianniao_goods_category_48 WHERE deleteStatus=5';
- $category = $this->objDGoods->query($c_sql);
- $allCategory = [];
- foreach ($category as $item) {
- $allCategory[$item['id']] = $item;
- }
- foreach ($allCategory as &$item) {
- if ($item['pid'] == 0) {
- $item['categoryPath'] = $item['id'];
- } else {
- $item['categoryPath'] = $item['pid'] . ',' . $item['id'];
- }
- }
- unset($item);
- foreach ($result as $key => $item) {
- $result[$key]['categoryPath'] = $allCategory[$item['categoryId']]['categoryPath'];
- }
- $objDGoodsBasic = new DGoodsBasic();
- $objDGoodsBasic->setTable('qianniao_goods_basic_48');
- foreach ($result as $value) {
- $update = $objDGoodsBasic->update([
- 'categoryPath' => $value['categoryPath']
- ], ['id' => $value['id']]);
- if ($update === true) {
- echo 'sql' . $objDGoodsBasic->error();
- }
- }
- echo 'success';
- }
- /**
- * 基础商品
- * @return ResultWrapper
- */
- public function goodsBasic()
- {
- echo "start" . PHP_EOL;
- $apiUrl = 'http://api.qianniao.vip/GoodsManage/GoodsBasic/fixEsData';
- $curl_option = [
- CURLOPT_HTTPHEADER => [
- 'Content-Type:text/plain',
- 'Authorization:' . $this->Authorization,
- 'Token:' . $this->Token
- ],
- ];
- $postData = [
- "page" => 0,
- "pageSize" => 2000,
- ];
- $result = request($apiUrl, json_encode($postData), 60, false, $curl_option);
- if ($result['httpcode'] != 200) {
- return ResultWrapper::fail($result['content'], ErrorCode::$apiNotResult);
- }
- $reponse = json_decode($result['content'], true);
- V($reponse);
- }
- /**
- * 修补商品es数据
- */
- public function goods_fixEsData()
- {
- echo 'start' . PHP_EOL;
- $apiUrl = 'http://api.qianniao.vip/Goods/Goods/fixEsData';
- $curl_option = [
- CURLOPT_HTTPHEADER => [
- 'Content-Type:text/plain',
- 'Authorization:' . $this->Authorization,
- 'Token:' . $this->Token
- ],
- ];
- $postData = [
- "page" => 0,
- "pageSize" => 2000
- ];
- $result = request($apiUrl, json_encode($postData), 60, false, $curl_option);
- if ($result['httpcode'] != 200) {
- return ResultWrapper::fail($result['content'], ErrorCode::$apiNotResult);
- }
- $reponse = json_decode($result['content'], true);
- V($reponse);
- }
- /**
- * 基础资料
- * @throws Exception
- */
- public function test_replace()
- {
- $objDGoodsBasic = new DGoodsBasic();
- $objDGoodsBasic->setTable('qianniao_goods_basic_1');
- $sql = 'select id,images,description from qianniao_goods_basic_1';
- $dbResult = $objDGoodsBasic->query($sql);
- if ($dbResult === false) {
- exit("获取数据失败" . $objDGoodsBasic->error());
- }
- foreach ($dbResult as $row) {
- if (empty($row['images'])) {
- continue;
- }
- $images = json_decode($row['images'], true);
- foreach ($images as &$item) {
- $item = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $item);
- }
- $images = json_encode($images);
- $description = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $row['description']);
- $updateResult = $objDGoodsBasic->update(['images' => $images, 'description' => $description], ['id' => $row['id']]);
- if ($updateResult === false) {
- exit('更新失败' . $objDGoodsBasic->error());
- }
- }
- exit('操作成功');
- }
- /**
- *
- * @throws Exception
- */
- public function test_replace_goods()
- {
- $objDGoods = new DGoods();
- $objDGoods->setTable('qianniao_goods_1');
- $sql = 'select id,images,content from qianniao_goods_1';
- $dbResult = $objDGoods->query($sql);
- if ($dbResult === false) {
- exit("获取数据失败" . $objDGoods->error());
- }
- foreach ($dbResult as $row) {
- if (empty($row['images'])) {
- continue;
- }
- $images = json_decode($row['images'], true);
- foreach ($images as &$item) {
- $item = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $item);
- }
- $images = json_encode($images);
- $content = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $row['content']);
- $updateResult = $objDGoods->update(['images' => $images, 'content' => $content], ['id' => $row['id']]);
- if ($updateResult === false) {
- exit('更新失败' . $objDGoods->error());
- }
- }
- exit('操作成功');
- }
- /**
- *
- * @throws Exception
- */
- public function test_replace_category()
- {
- $objDGoodsCategory = new DGoodsCategory();
- $objDGoodsCategory->setTable('qianniao_goods_category_1');
- $sql = 'select id,images,adImage from qianniao_goods_category_1';
- $dbResult = $objDGoodsCategory->query($sql);
- if ($dbResult === false) {
- exit("获取数据失败" . $objDGoodsCategory->error());
- }
- foreach ($dbResult as $row) {
- if (empty($row['images'])) {
- continue;
- }
- $images = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $row['images']);
- $adImage = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $row['adImage']);
- $updateResult = $objDGoodsCategory->update(['images' => $images, 'adImage' => $adImage], ['id' => $row['id']]);
- if ($updateResult === false) {
- exit('更新失败' . $objDGoodsCategory->error());
- }
- }
- exit('操作成功');
- }
- public function forApi()
- {
- $objMCustomer = new MCustomer(4, 29);
- $obj = new DCustomer();
- $sql = 'select * from qianniao_customer_4 where deleteStatus = 5';
- $result = $obj->query($sql);
- foreach ($result as $key => $value) {
- $a = $objMCustomer->updateEsData($value['id']);
- }
- }
- /**
- * @throws Exception
- */
- public function syncSku()
- {
- $objSkuCache = new SkuCache(1);
- $objDSku = new DSku();
- $objDSku->setTable('qianniao_sku_1');
- $skuResult = $objDSku->select([]);
- if ($skuResult === false) {
- exit($objDSku->error());
- }
- foreach ($skuResult as $item) {
- $map = self::cacheMappersSku($item);
- $objSkuCache->delSku($item['id']);
- $cacheRes = $objSkuCache->cacheSku($item['id'], $map);
- if (!$cacheRes->isSuccess()) {
- exit("缓存失败");
- }
- }
- exit("缓存成功");
- }
- /**
- * @param array $data
- * @return array
- */
- public static function cacheMappersSku(array $data)
- {
- $map = [];
- if (empty($data)) {
- return $map;
- }
- $map = [
- 'id' => $data['id'],
- 'unitId' => $data['unitId'],
- 'unitName' => $data['unitName'],
- 'isMaster' => $data['isMaster'],
- 'conversion' => $data['conversion'],
- 'specType' => $data['specType'],
- 'specImage' => $data['specImage'],
- 'specData' => $data['specData'],
- 'specGroupHash' => $data['specGroupHash'],
- 'barCode' => $data['barCode'],
- 'goodsId' => $data['goodsId']
- ];
- return $map;
- }
- /**
- * 测试打印
- */
- public function sendMsg()
- {
- $CloudPrint = new CloudPrint();
- $BaseModel = new MBaseModel();
- $data = [
- 'shopName' => '千鸟云商',
- 'title' => '销售单',
- 'code' => '0000000009',
- 'codeName' => '订单编号',
- 'userName' => '海燕',
- 'mobile' => 13626403927,
- 'address' => '西安大明宫万达',
- 'createTime' => time(),
- 'details' => [
- [
- 'title' => '紫苏焖鹅+梅菜肉饼+椒盐虾+北京烤鸭',
- 'skuData' => [
- [
- 'skuName' => '白色;XL',
- 'unitName' => '件',
- 'num' => 11,
- 'unitPrice' => 10.00,
- 'amountPrice' => 110.00
- ],
- [
- 'skuName' => '白色;XL',
- 'unitName' => '件',
- 'num' => 11,
- 'unitPrice' => 10.00,
- 'amountPrice' => 110.00
- ],
- [
- 'skuName' => '白色;XL',
- 'unitName' => '件',
- 'num' => 11,
- 'unitPrice' => 10,
- 'amountPrice' => 110
- ],
- [
- 'skuName' => '白色;XL',
- 'unitName' => '件',
- 'num' => 11,
- 'unitPrice' => 10,
- 'amountPrice' => 110
- ],
- ]
- ],
- [
- 'title' => '紫苏焖鹅+梅菜肉饼+椒盐虾+北京烤鸭',
- 'skuData' => [
- [
- 'skuName' => '橘子味',
- 'unitName' => '瓶',
- 'num' => 1,
- 'unitPrice' => 5,
- 'amountPrice' => 5,
- ]
- ],
- ]
- ],
- 'totalMoney' => 12.00,
- 'preferential' => 0,
- 'payAmount' => 12.00
- ];
- // $data = $BaseModel->formatMsg($data);
- // $result = $CloudPrint->sendMsg($data);
- // $result = $CloudPrint->getStatus();
- // $result = $CloudPrint->setVolume(0);
- //测试飞鹅打印机
- $data = $BaseModel->formatMsg($data, 2);
- $result = $CloudPrint->feieSendMsg($data);
- V($result);
- }
- public function bugCoupon()
- {
- $objDUserCoupon = new DUserCoupon();
- $objDUserCoupon->setTable('qianniao_user_coupon_13');
- $userCenterIds = [];
- $couponIds = [];
- $couponIdsStr = implode(',', $couponIds);
- $sql = 'select * from qianniao_coupon_13 where id in (' . $couponIdsStr . ')';
- $coupon = $this->objDGoods->query($sql);
- if ($coupon === false) {
- echo 'sql' . $this->objDGoods->error();
- }
- $couponMap = [];
- foreach ($coupon as $key => $value) {
- if ($value['receiveNum'] >= $value['totalNum']) {
- unset($coupon[$key]);
- continue;
- }
- $couponMap[$value['id']] = $value;
- }
- $insert = [];
- foreach ($userCenterIds as $item) {
- foreach ($couponMap as $key => $value) {
- $count = $objDUserCoupon->count(['couponId' => $value['id'], 'userId' => $item['uid']]);
- if ($count >= $value['allowNum']) {
- continue;
- }
- //剩余数量不足每人领取数量
- if ($value['receiveNum'] + $value['allowNum'] > $value['totalNum']) {
- $rec = $value['totalNum'] - $value['receiveNum'];
- for ($i = 0; $i < $rec; $i++) {
- $insert[] = [
- 'couponId' => $value['id'],
- 'name' => $value['name'],
- 'remark' => $value['remark'],
- 'couponType' => $value['couponType'],
- 'reducePrice' => $value['reducePrice'],
- 'minPrice' => $value['minPrice'],
- 'startTime' => $value['startTime'],
- 'endTime' => $value['endTime'],
- 'applyRange' => $value['applyRange'],
- 'categoryCollect' => $value['categoryCollect'],
- 'brandCollect' => $value['brandCollect'],
- 'isExpire' => StatusCode::$delete,
- 'isUse' => StatusCode::$standard,
- 'userId' => $item['uid'],
- 'useShop' => $value['useShop'],
- 'customerId' => $item['cId'],
- 'source' => $value['grantType'],
- 'createTime' => time(),
- 'updateTime' => time(),
- 'customerIds' => $value['customerIds'],
- 'isMutex' => isset($value['isMutex']) ? $value['isMutex'] : StatusCode::$standard,
- ];
- }
- continue;
- }
- for ($i = 0; $i < $value['allowNum']; $i++) {
- $insert[] = [
- 'couponId' => $value['id'],
- 'name' => $value['name'],
- 'remark' => $value['remark'],
- 'couponType' => $value['couponType'],
- 'reducePrice' => $value['reducePrice'],
- 'minPrice' => $value['minPrice'],
- 'startTime' => $value['startTime'],
- 'endTime' => $value['endTime'],
- 'applyRange' => $value['applyRange'],
- 'categoryCollect' => $value['categoryCollect'],
- 'brandCollect' => $value['brandCollect'],
- 'isExpire' => StatusCode::$delete,
- 'isUse' => StatusCode::$standard,
- 'userId' => $item['uid'],
- 'useShop' => $value['useShop'],
- 'customerId' => $item['cId'],
- 'source' => $value['grantType'],
- 'createTime' => time(),
- 'updateTime' => time(),
- 'customerIds' => $value['customerIds'],
- 'isMutex' => isset($value['isMutex']) ? $value['isMutex'] : StatusCode::$standard,
- ];
- }
- }
- }
- print_r($insert);
- die;
- }
- public function testKuaiDi100()
- {
- $kuaidi100Config = Factory::config()->get('kuaidi100');
- if (empty($kuaidi100Config) || !isset($kuaidi100Config['customer']) || !isset($kuaidi100Config['key'])) {
- $this->sendOutput('快递100配置错误', ErrorCode::$configEroor);
- }
- $objQuery = new Query($kuaidi100Config['customer'], $kuaidi100Config['key']);
- $kuaidiData = [
- 'com' => 'zhongtong',
- 'num' => '73140775283454',
- 'phone' => 17600105150,
- ];
- $result = $objQuery->pollQuery($kuaidiData);
- if (!$result->isSuccess()) {
- echo $result->getData() . $result->getErrorCode();
- }
- V($result->getData());
- }
- // 快递100查询返回数据内容
- public function msg()
- {
- $str = '{"message":"ok","nu":"3103922659603","ischeck":"1","condition":"D01","com":"yunda","status":"200","state":"3","data":[{"time":"2020-09-01 22:02:08","ftime":"2020-09-01 22:02:08","context":"[陕西西安北郊一公司未央二区寄存点分部]【代收点】您的快件已签收,签收人在【君泰烟酒店(凤城一路锦园君逸西区东门斜对面君泰烟酒店(免费代收))】领取。"},{"time":"2020-09-01 20:36:29","ftime":"2020-09-01 20:36:29","context":"[陕西西安北郊一公司未央二区寄存点分部]【代收点】您的快件已送达 君泰烟酒店 保管,地址:凤城一路锦园君逸西区东门斜对面君泰烟酒店(免费代收),请及时领取,如有疑问请电联快递员:韩生斌【13519168931】。"},{"time":"2020-09-01 18:51:13","ftime":"2020-09-01 18:51:13","context":"[陕西西安北郊一公司未央二区寄存点分部]【西安市】陕西西安北郊一公司未央二区寄存点分部 快递员 韩生斌13519168931 正在为您派件【95114/95121/9501395546为韵达快递员外呼专属号码,请放心接听】"},{"time":"2020-09-01 17:50:26","ftime":"2020-09-01 17:50:26","context":"[陕西西安北郊一公司]【西安市】已离开 陕西西安北郊一公司;发往 陕西西安北郊一公司未央二区寄存点分部"},{"time":"2020-09-01 12:52:14","ftime":"2020-09-01 12:52:14","context":"[陕西西安分拨中心]【西安市】已离开 陕西西安分拨中心;发往 陕西西安北郊一公司"},{"time":"2020-09-01 12:45:28","ftime":"2020-09-01 12:45:28","context":"[陕西西安分拨中心]【西安市】已到达 陕西西安分拨中心"},{"time":"2020-08-31 19:51:10","ftime":"2020-08-31 19:51:10","context":"[山东济南分拨中心]【济南市】已离开 山东济南分拨中心;发往 陕西西安地区包"},{"time":"2020-08-31 19:42:34","ftime":"2020-08-31 19:42:34","context":"[山东济南分拨中心]【济南市】已到达 山东济南分拨中心"},{"time":"2020-08-30 10:37:09","ftime":"2020-08-30 10:37:09","context":"[山东市场部鹏程KH分部]【济南市】山东市场部鹏程KH分部 已揽收"}]}';
- V(json_decode($str, true));
- }
- // public function testKDNiao()
- // {
- // $kdniaoConfig = Factory::config()->get('kdniao');
- // if (empty($kdniaoConfig) || !isset($kdniaoConfig['EBusinessID']) || !isset($kdniaoConfig['key'])) {
- // $this->sendOutput('快递100配置错误', ErrorCode::$configEroor);
- // }
- // $objQuery = new KDNiaoQuery($kdniaoConfig['EBusinessID'], $kdniaoConfig['key']);
- //
- // $kuaidiData = [
- // 'com' => 'HTKY',
- // 'num' => '557021498255630',
- // ];
- // $result = $objQuery->EbusinessOrderHandle($kuaidiData);
- // if (!$result->isSuccess()) {
- // parent::sendOutput($result->getData(), $result->getErrorCode());
- // }
- // parent::sendOutput($result->getData());
- // }
- // 快递鸟查询返回数据内容
- public function msg1()
- {
- $str = '{
- "LogisticCode" : "557021498255630",
- "ShipperCode" : "HTKY",
- "Traces" : [ {
- "AcceptStation" : "【太仓】,【扫描壹/13913775727】已揽收",
- "AcceptTime" : "2020-08-30 17:56:19"
- }, {
- "AcceptStation" : "到【上海转运中心】",
- "AcceptTime" : "2020-08-30 21:44:19"
- }, {
- "AcceptStation" : "【上海转运中心】,正发往【西安转运中心】",
- "AcceptTime" : "2020-08-30 21:46:44"
- }, {
- "AcceptStation" : "到【西安转运中心】",
- "AcceptTime" : "2020-09-01 01:32:36"
- }, {
- "AcceptStation" : "【西安转运中心】,正发往【西安北郊一站】",
- "AcceptTime" : "2020-09-01 02:16:14"
- }, {
- "AcceptStation" : "【陈仕友/15229250633】正在派件,【西安北郊一站/网点电话18821713238 029-68569101】",
- "AcceptTime" : "2020-09-01 08:42:50"
- }, {
- "AcceptStation" : "派件送达【兔喜快递超市】君泰烟酒店,请前往凤城一路锦园君逸西区东门斜对面君泰烟酒店(免费代收)领取您的包裹,联系电话:15309281529",
- "AcceptTime" : "2020-09-01 10:23:10"
- }, {
- "AcceptStation" : "客户已取件,提货点:【兔喜快递超市】 君泰烟酒店(15309281529 凤城一路锦园君逸西区东门斜对面君泰烟酒店(免费代收))",
- "AcceptTime" : "2020-09-01 22:01:48"
- } ],
- "State" : "3",
- "EBusinessID" : "1670600",
- "Success" : true
- }';
- V(json_decode($str, true));
- }
- /**
- * sql执行
- * 该方法只执行需要拼接企业id的表 不要拼接企业id的表请自行手动执行
- */
- public function batchSql()
- {
- $sqlParent = "
- ALTER TABLE `www.qianniao.vip`.`qianniao_staff_1` MODIFY COLUMN `userCenterId` int(11) NULL DEFAULT NULL COMMENT '用户中心id' AFTER `id`, MODIFY COLUMN `departmentId` int(11) NULL DEFAULT NULL COMMENT '部门id' AFTER `userCenterId`, MODIFY COLUMN `balance` decimal(10, 2) NULL COMMENT '余额' AFTER `rule`;
- ";
- //执行语句
- $sql = substr($sqlParent, stripos($sqlParent, "` ") + 2);
- $sqlIndex = $sql;
- //执行语句表所属数据库
- $dbName = substr($sqlParent, stripos($sqlParent, ' `') + 2, stripos($sqlParent, '`.') - stripos($sqlParent, ' `') - 2);
- //企业表所属数据库
- $dbIndexName = 'www.qianniao.vip';
- //库存数据库名
- $stockDbName = 'stock.qianniao.vip';
- //表名
- $sqlTable = substr($sqlParent, stripos($sqlParent, '.`') + 2, stripos($sqlParent, '` ') - stripos($sqlParent, '.`') - 2);
- $tableNameIndex = substr($sqlTable, 0, strripos($sqlTable, '_') + 1);
- //是否执行企业1表
- $oneEnterpriseTable = true;
- //从某个企业执行
- $startEnterpriseId = 0;
- //按照用户人数分表 例:tableName_1_1
- $userByTables = [
- 'qianniao_order_',
- 'qianniao_order_coupon_',
- 'qianniao_order_goods_',
- 'qianniao_order_receive_',
- 'qianniao_goods_collect_',
- ];
- //按照仓库id分表
- $warehouseTable = [
- 'qianniao_inventory_batch_'
- ];
- //按照季度分表 例:tableName_1_2020_3
- $dateByTable = [
- 'qianniao_commission_order_',
- 'qianniao_customerPriceAdjustmentSheet_'
- ];
- //按照季度分表2 例:tableName_1_201
- $dateByTableTwo = [
- 'qianniao_inventory_locking_',
- ];
- //按照仓库id和季度分表 例:tableName_1_1_194
- $warehouseAndDateByTable = [
- 'qianniao_inventory_details_'
- ];
- $runTrue = 0;
- $runFalse = 0;
- $runTrueTableName = [];
- $runFalseTableName = [];
- $tableNum = 0;
- $existNum = 0;
- $existTable = [];
- if (empty($sqlIndex)) {
- exit('请输入sql语句');
- }
- if (empty($dbIndexName)) {
- exit('请输入数据库名');
- }
- if (empty($tableNameIndex)) {
- exit('请输入表名');
- }
- //查询所有企业
- $whereSql = '';
- if ($startEnterpriseId) {
- $whereSql = ' where id >= ' . $startEnterpriseId;
- }
- $sql = 'select id from `' . $dbIndexName . '`.`qianniao_enterprise_1`' . $whereSql;
- $dbResult = $this->objDGoods->query($sql);
- if ($dbResult === false) {
- exit($this->objDGoods->error());
- }
- $enterpriseResult = $dbResult;
- unset($dbResult);
- unset($sql);
- if (empty($enterpriseResult)) {
- self::prompt('企业数据为空', 0, $enterpriseResult, 0, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
- }
- //按人数分表 因为用户数据量小 所以统一后缀加_1
- $tableSuffix = [];
- foreach ($userByTables as $value) {
- if ($tableNameIndex == $value) {
- $tableSuffix[] = '_1';
- break;
- }
- }
- $start = 2020;
- $end = (int)date('Y', time());
- //按日期季度分表
- foreach ($dateByTable as $value) {
- if ($tableNameIndex == $value) {
- for ($ii = $start; $ii <= $end; $ii++) {
- for ($i = 1; $i <= 4; $i++) {
- $tableSuffix[] = '_' . $ii . '_' . $i;
- }
- }
- break;
- }
- }
- //按照季度分表2
- foreach ($dateByTableTwo as $value) {
- if ($tableNameIndex == $value) {
- for ($ii = $start; $ii <= $end; $ii++) {
- for ($i = 1; $i <= 4; $i++) {
- $tableSuffix[] = '_' . substr($ii, -2) . $i;
- }
- }
- break;
- }
- }
- //按日期季度分表 拼接仓库id
- $isWarehouseId = false;
- foreach ($warehouseAndDateByTable as $value) {
- if ($tableNameIndex == $value) {
- $isWarehouseId = true;
- for ($ii = $start; $ii <= $end; $ii++) {
- for ($i = 1; $i <= 4; $i++) {
- $tableSuffix[] = '_' . substr($ii, -2) . $i;
- }
- }
- break;
- }
- }
- //按照仓库id分表
- foreach ($warehouseTable as $value) {
- if ($tableNameIndex == $value) {
- $isWarehouseId = true;
- break;
- }
- }
- if ($isWarehouseId && empty($stockDbName)) {
- exit($tableNameIndex . '按照仓库分表, 请输入仓库表对应数据库名称');
- }
- $enterpriseFormat = array_column($enterpriseResult, null, 'id');
- if (!isset($enterpriseFormat[1])) {
- $enterprise1 = [
- 'id' => 1,
- ];
- array_unshift($enterpriseResult, $enterprise1);
- }
- $enterpriseData = [];
- $emptyTable = [];
- foreach ($enterpriseResult as $value) {
- $tableList = [];
- //拿出企业id
- $enterpriseId = $value['id'];
- //判断是否执行1企业
- if ($enterpriseId == 1) {
- if ($oneEnterpriseTable == false) {
- continue;
- } else {
- if (!empty($tableSuffix)) {
- $tableList[] = $tableNameIndex . $enterpriseId;
- }
- }
- }
- if ($isWarehouseId) {
- //查询仓库的商铺
- $sql = 'select id from `' . $stockDbName . '`.`qianniao_warehouse_' . $enterpriseId . '`';
- $dbResult = $this->objDGoods->query($sql);
- if ($dbResult === false) {
- self::prompt($this->objDGoods->error(), $enterpriseId, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
- }
- $warehouseResult = $dbResult;
- unset($dbResult);
- //循环仓库数据
- foreach ($warehouseResult as $warehouse) {
- $warehouseId = $warehouse['id'];
- //判断是否有日期后缀
- if (!empty($tableSuffix)) {
- foreach ($tableSuffix as $suffix) {
- //拼接表名
- $tableList[] = $tableNameIndex . $enterpriseId . '_' . $warehouseId . $suffix;
- }
- } else {
- $tableList[] = $tableNameIndex . $enterpriseId . '_' . $warehouseId;
- }
- }
- } else {
- //判断是否有日期后缀
- if (!empty($tableSuffix)) {
- foreach ($tableSuffix as $suffix) {
- //拼接表名
- $tableList[] = $tableNameIndex . $enterpriseId . $suffix;
- }
- } else {
- $tableList[] = $tableNameIndex . $enterpriseId;
- }
- }
- foreach ($tableList as $tableName) {
- $tableNum++;
- //查询表是否存在
- $sql = 'select count(TABLE_NAME) as isTable from information_schema.TABLES where TABLE_SCHEMA = "' . $dbName . '" and TABLE_NAME = "' . $tableName . '"';
- $dbResult = $this->objDGoods->query($sql);
- if ($dbResult === false) {
- self::prompt($this->objDGoods->error(), $enterpriseId, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
- }
- $isTable = 0;
- if (!empty($dbResult)) {
- if (isset($dbResult[0]['isTable']) && $dbResult[0]['isTable'] == 1) {
- $isTable = 1;
- }
- }
- unset($dbResult);
- //判断表是否存在
- if ($isTable) {
- $existNum++;
- $existTable[] = $tableName;
- $enterpriseData[$enterpriseId][] = ['enterpriseId' => $enterpriseId, 'tableName' => $tableName];
- } else {
- $emptyTable[] = $tableName;
- }
- }
- }
- // V($existTable);
- // self::prompt('', 0, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
- //执行语句
- foreach ($enterpriseData as $enterpriseId => $value) {
- foreach ($value as $enterprise) {
- $enterpriseId = $enterprise['enterpriseId'];
- $tableName = $enterprise['tableName'];
- //拼接修改sql语句
- $sql = "ALTER TABLE `" . $dbName . "`.`" . $tableName . "` " . $sqlIndex;
- $dbResult = $this->objDGoods->query($sql);
- if ($dbResult === false) {
- $runFalse++;
- $runFalseTableName[] = $tableName;
- self::prompt($this->objDGoods->error(), $enterpriseId, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
- }
- $runTrue++;
- $runTrueTableName[] = $tableName;
- unset($dbResult);
- }
- }
- self::prompt('', 0, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
- }
- public function prompt($info = '', $enterpriseId = 0, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName)
- {
- $title = '';
- if (!empty($info)) {
- $title = '执行到企业' . $enterpriseId . '时有报错:
- ' . $info . '
- ';
- }
- $title .= '一共' . count($enterpriseResult) . '个企业, 需要修改' . $tableNum . '个表, 存在的表有' . $existNum . '个, 修改成功的表' . $runTrue . '个, 修改失败的表' . $runFalse . '个, 成功的有:' . implode(',', $runTrueTableName) . '; 失败的有:' . implode(',', $runFalseTableName);
- exit($title);
- }
- /**
- * 批量删除某个企业的表
- */
- public function dropEnterpriseTable()
- {
- $date = [];
- for ($i = 2; $i <= 100; $i++) {
- $date[] = $i;
- }
- $sql = 'select id from `www.qianniao.vip`.`qianniao_enterprise_1`';
- $dbResult = $this->objDGoods->query($sql);
- $aa = [];
- foreach ($dbResult as $value) {
- $aa[] = $value['id'];
- }
- $dbResult = array_diff($date, $aa);
- // V($dbResult);
- // $sql = 'select id from `www.qianniao.vip`.`qianniao_enterprise_1` where expireTime <= '.time();
- // $dbResult = $this->objDGoods->query($sql);
- if (empty($dbResult)) {
- exit('没有过期企业');
- }
- $i = 0;
- foreach ($dbResult as $value) {
- $enterpriseId = $value;
- // $enterpriseId = $value['id'];
- $sql = 'DROP TABLE `www.qianniao.vip`.`qianniao_activity_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_activity_goods_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_cart_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_businessman_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_coupon_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_customer_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_customer_contact_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_customer_shipping_address_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_department_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_department_role_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_goods_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_goods_basic_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_goods_brand_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_goods_category_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_goods_collect_' . $enterpriseId . '_1`, `www.qianniao.vip`.`qianniao_material_content_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_message_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_order_' . $enterpriseId . '_1`, `www.qianniao.vip`.`qianniao_order_coupon_' . $enterpriseId . '_1`, `www.qianniao.vip`.`qianniao_order_goods_' . $enterpriseId . '_1`, `www.qianniao.vip`.`qianniao_order_index_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_order_receive_' . $enterpriseId . '_1`, `www.qianniao.vip`.`qianniao_order_return_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_order_return_details_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_order_statistics_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_page_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_role_acl_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_sku_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_spec_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_staff_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_units_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_user_coupon_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_vip_card_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_vip_card_order_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_allocate_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_allocate_details_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_inventory_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_inventory_batch_' . $enterpriseId . '_1`, `stock.qianniao.vip`.`qianniao_inventory_details_' . $enterpriseId . '_1_203`, `stock.qianniao.vip`.`qianniao_inventory_in_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_inventory_in_details_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_inventory_locking_' . $enterpriseId . '_203`, `stock.qianniao.vip`.`qianniao_inventory_out_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_inventory_out_details_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_purchase_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_purchase_goods_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_purchase_out_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_purchase_out_goods_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_stocktaking_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_stocktaking_details_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_supplier_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_warehouse_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_warehouse_beginning_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_customerPriceAdjustmentSheet_' . $enterpriseId . '_2020_3`, `price.qianniao.vip`.`qianniao_customerPriceEffective_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_customerTypePriceAdjustmentSheet_' . $enterpriseId . '_2020_3`, `price.qianniao.vip`.`qianniao_customerTypePriceEffective_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_lastEffectiveSalePriceAreaType_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_nationalUnifiedPrice_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_priceAdjustmentSheet_' . $enterpriseId . '_2020_3`, `price.qianniao.vip`.`qianniao_priceRangeSheet_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_account_transfer_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_customer_balance_' . $enterpriseId . '_1`, `finance.qianniao.vip`.`qianniao_customer_balance_detail_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_customer_balance_detail_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_customer_balance_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_paid_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_paid_account_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_paid_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_pay_receipt_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_pay_receipt_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_receive_receipt_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_receive_receipt_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_received_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_received_account_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_received_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_supplier_balance_' . $enterpriseId . '_1`, `finance.qianniao.vip`.`qianniao_supplier_balance_detail_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_supplier_balance_detail_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_supplier_balance_index_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_flow_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_goods_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_goods_statistics_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_order_' . $enterpriseId . '_2020_3`, `www.qianniao.vip`.`qianniao_commission_order_index_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_withdrawals_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_priceAdjustmentSheet_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_customer_balance_detail_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_pay_receipt_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_receive_receipt_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_received_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_received_account_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_supplier_balance_detail_' . $enterpriseId . '_2020_2`, `www.qianniao.vip`.`qianniao_common_app_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_delivery_rule_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_delivery_self_rule_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_customer_balance_detail_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_account_detail_' . $enterpriseId . '_1`, `finance.qianniao.vip`.`qianniao_paid_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_paid_account_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_pay_receipt_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_receive_receipt_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_received_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_received_account_' . $enterpriseId . '_2020_1`, `www.qianniao.vip`.`qianniao_enterprise_template_module_' . $enterpriseId . '`';
- // $enterpriseSql = 'DELETE FROM `www.qianniao.vip`.`qianniao_enterprise_1` WHERE `id` = '.$enterpriseId;
- // $this->objDGoods->query($enterpriseSql);
- $enterpriseBandUserCenterSql = 'DELETE FROM `www.qianniao.vip`.`qianniao_user_bind_enterprise` WHERE `enterpriseId` = ' . $enterpriseId;
- $this->objDGoods->query($enterpriseBandUserCenterSql);
- $this->objDGoods->query($sql);
- $i++;
- }
- exit('执行成功, 共删除' . $i . '个企业');
- }
- // 客如云
- public function keruyun()
- {
- $keruyunConfig = Factory::config()->get('keruyun');
- if (empty($keruyunConfig)) {
- $this->sendOutput('客如云配置错误', ErrorCode::$configEroor);
- }
- $objOpen = new Open($keruyunConfig['shopIdenty'], $keruyunConfig['appKey'], $keruyunConfig['secretKey']);
- $result = $objOpen->getToken();
- if (!$result->isSuccess()) {
- echo($result->getData() . $result->getErrorCode());
- }
- $token = $result->getData();
- /*
- unset($result);
- $result = $objOpen->dishMenu($token['token'],1,1);
- if(!$result->isSuccess()){
- echo($result->getData().$result->getErrorCode());
- }
- $goodsData = $result->getData();*/
- /*
- unset($result);
- $result = $objOpen->dishMenuByIds($token['token'], ['245842575890634752']);
- if(!$result->isSuccess()){
- echo($result->getData().$result->getErrorCode());
- }
- $goodsData = $result->getData();V($goodsData);*/
- /*
- $customerData = [
- 'birthday' => time(), // 生日时间戳
- 'loginId' => '17600105150', // 手机号或者微信id
- 'loginType' => 0,
- 'name' => '刘鑫',
- 'sex' => -1,
- ];
- unset($result);
- $result = $objOpen->createCustomer($token['token'], $customerData);
- if(!$result->isSuccess()){
- echo($result->getData().$result->getErrorCode());
- }
- $customerInfo = $result->getData(); V($customerInfo);*/
- /*
- $customerData = [
- 'birthday' => time(), // 生日时间戳
- 'loginId' => '17600105150', // 手机号或者微信id
- 'loginType' => 0,
- 'name' => '刘鑫',
- 'sex' => -1,
- ];
- unset($result);
- $result = $objOpen->createOrUpgradeMember($token['token'], $customerData);
- if(!$result->isSuccess()){
- echo($result->getData().$result->getErrorCode());
- }
- $customerInfo = $result->getData(); V($customerInfo); */
- unset($result);
- $result = $objOpen->login($token['token'], '18992853313');
- if (!$result->isSuccess()) {
- echo($result->getData() . $result->getErrorCode());
- }
- $customerInfo = $result->getData();
- V($customerInfo);
- /*
- unset($result);
- $result = $objOpen->getCustomerDetailById($token['token'], 402153925286827008);
- if(!$result->isSuccess()){
- echo($result->getData().$result->getErrorCode());
- }
- $customerInfo = $result->getData(); V($customerInfo);*/
- /*
- unset($result);
- $result = $objOpen->recharge($token['token'], ['customerId'=>'402153925286827008','amount'=>10000,'tpOrderId'=>'3120200910727']);
- if(!$result->isSuccess()){
- echo($result->getData().$result->getErrorCode());
- }
- $customerInfo = $result->getData(); V($customerInfo);*/
- /*
- unset($result);
- $result = $objOpen->orderExportDetail($token['token'], ['401332262188390400']);
- if(!$result->isSuccess()){
- echo($result->getData().$result->getErrorCode());
- }
- $customerInfo = $result->getData(); V($customerInfo);*/
- /*
- unset($result);
- $result = $objOpen->dinnerOrderDetail($token['token'], 'b28e5f7529ac4c64b04a39104429ef26');
- if(!$result->isSuccess()){
- echo($result->getData().$result->getErrorCode());
- }
- $customerInfo = $result->getData(); V($customerInfo);*/
- /*
- unset($result);
- $result = $objOpen->cancel($token['token'], 'f52b36b49c304823b6fcb3b8f3a934df');
- if(!$result->isSuccess()){
- echo($result->getData().$result->getErrorCode());
- }
- $customerInfo = $result->getData(); V($customerInfo);*/
- /*
- $orderData = [
- 'tpOrderId' => '31202009107241774406',
- 'createTime' => time(),
- 'updateTime' => time(),
- 'payment' => [
- 'memberId' => 402153925286827008,
- 'memberPassword' => md5('105150'),
- 'payType' => 1, //支付方式 1:会员卡余额 2:优惠券 3:订单来源支付
- 'platformDiscountFee' => 0,
- 'serviceFee' => 0,
- 'shopDiscountFee' => 0,
- 'shopFee' => 1,
- 'totalDiscountFee' => 0,
- 'totalFee' => 1,
- 'userFee' => 1
- ],
- 'peopleCount' => 1, // 就餐人数
- 'print' => 1, // 打印
- 'remark' => '小程序订单', // 备注
- 'status' => 2, // 已经确认
- 'shopIdenty' => $keruyunConfig['shopIdenty'],
- 'shopName' => '千鸟云商',
- 'products' => [[
- 'tpId' => 40740829341443072,
- 'name' => '水煮牛肉',
- 'price' => 1,
- 'type' => 0,
- 'unit' => '件',
- 'quantity' => 1,
- 'totalFee' => 1
- ]],
- 'customers' => [
- 'phoneNumber' => '17600105150',
- 'name' => '刘鑫',
- 'gender' => 1,
- ],
- 'totalPrice' => 1,
- ];
- unset($result);
- $result = $objOpen->createSnackOrder($token['token'], $orderData);
- if(!$result->isSuccess()){
- echo($result->getData().$result->getErrorCode());
- }
- $customerInfo = $result->getData(); V($customerInfo); */
- $orderData = [
- 'tpOrderId' => '31202009107241774406',
- 'tpShopId' => 100,
- 'createTime' => time(),
- 'shopName' => '千鸟云商',
- 'products' => [[
- 'name' => '水煮牛肉',
- 'type' => 0,
- 'tpId' => 40740829341443072,
- 'quantity' => 1, // 商品数量
- 'price' => 1, // 商品单价
- 'unit' => '件',
- 'packagePrice' => 0, // 餐盒单价
- 'packageQuantity' => 0, // 餐盒数量
- 'totalFee' => 1 // 商品总金额
- ]],
- 'delivery' => [
- 'expectTime' => 0, // 期望送达时间
- 'deliveryParty' => 1, // 配送方式
- 'receiverName' => '刘鑫', // 收货人姓名
- 'receiverPhone' => 17600105150, // 收货人电话
- ],
- 'payment' => [
- 'totalFee' => 1, // 订单总价=商品总金额+餐盒费+配送费
- 'deliveryFee' => 0, // 配送费
- 'packageFee' => 0, // 餐盒费=餐盒数量 * 餐盒单价
- 'discountFee' => 0, // 优惠总金额=平台优惠总金额+商户优惠总金额
- 'platformDiscountFee' => 0, // 平台优惠总金额
- 'shopDiscountFee' => 0, // 商家优惠
- 'shopFee' => 1, // 商户实收总价
- 'userFee' => 1, // 用户实付=订单总价-优惠总金额
- 'serviceFee' => 0, // 服务费(商户向平台支付的佣金等)
- 'subsidies' => 0, // 平台补贴
- 'payType' => 3, // 支付方式 1:线下支付/货到付款 2:在线支付 4:优惠券 3:会员卡余额
- 'memberId' => 402153925286827008,
- 'memberPassword' => md5('105150'),
- ],
- 'customers' => [
- 'phoneNumber' => '17600105150', // 会员电话
- 'name' => '刘鑫', // 会员名字
- 'gender' => 1, // 会员性别
- ]
- ];
- unset($result);
- $result = $objOpen->createTakeoutOrder($token['token'], $orderData);
- if (!$result->isSuccess()) {
- echo($result->getData() . $result->getErrorCode());
- }
- $customerInfo = $result->getData();
- V($customerInfo);
- }
- /**
- * 客如云菜品变更通知
- */
- public function dishChaangeNotify()
- {
- $postStr = file_get_contents('php://input');
- file_put_contents('/www/wwwroot/logs/api.junhailan.com/keruyun.log', date('Y-m-d H:i:s') . '回调数据' . var_export($postStr, true) . PHP_EOL, FILE_APPEND);
- }
- /**
- * 测试发布订阅消息
- */
- public function subscribeMessageSend()
- {
- $miniprogramConfigData = Factory::config()->getAppoint('weixin', 'miniprogram');
- if (empty($miniprogramConfigData)) {
- echo('小程序配置项错误');
- exit();
- }
- // 获取access_token
- $objOffiaccount = new Offiaccount($miniprogramConfigData['appid'], $miniprogramConfigData['appSecret']);
- $result = $objOffiaccount->token();
- if (!$result->isSuccess()) {
- echo $result->getData(), $result->getErrorCode();
- }
- $access_token = $result->getData();
- unset($result);
- // 发送订阅消息
- $data = [
- 'name1' => [
- 'value' => '千鸟云商店铺',
- ],
- 'date2' => [
- 'value' => '2020年10月27日',
- ],
- 'amount3' => [
- 'value' => '¥100元',
- ],
- 'character_string4' => [
- 'value' => '31202010273559779663',
- ],
- ];
- $objMiniprogram = new Miniprogram($miniprogramConfigData['appid'], $miniprogramConfigData['appSecret']);
- $result = $objMiniprogram->subscribeMessageSend($access_token, '7h2cBfuDxPPxovL3xGj9SLojcrVJGNHEzd8OcCUukq4', 'oISU64zx81Uq4oc_kzz1wg4PSNs8', '/pages/index/index', $data);
- V($result);
- }
- /**
- * 添加模板
- */
- public function addtemplate()
- {
- $miniprogramConfigData = Factory::config()->getAppoint('weixin', 'miniprogram');
- if (empty($miniprogramConfigData)) {
- echo('小程序配置项错误');
- exit();
- }
- // 获取access_token
- $objOffiaccount = new Offiaccount($miniprogramConfigData['appid'], $miniprogramConfigData['appSecret']);
- $result = $objOffiaccount->token();
- if (!$result->isSuccess()) {
- echo $result->getData(), $result->getErrorCode();
- }
- $access_token = $result->getData();
- unset($result);
- $objMiniprogram = new Miniprogram($miniprogramConfigData['appid'], $miniprogramConfigData['appSecret']);
- $result = $objMiniprogram->addtemplate($access_token, '3637', [2, 3, 8, 10], '发货通知');
- V($result);
- }
- public function webstockConnect()
- {
- $swooleServerConfigData = Factory::config()->getAppoint('swooleServer', 'order');
- if (empty($swooleServerConfigData)) {
- echo('swoole服务端链接信息配置项错误');
- exit();
- }
- $swooleClient = Factory::swoole($swooleServerConfigData, 'WebsocketClient');
- // 触发商家新订单通知
- $data = [
- 'controller' => 'NewOrder',
- 'action' => 'createConnect',
- 'params' => [
- 'platfrom' => 'qianniaoSAAS',
- 'shop_id' => 1,
- 'userId' => 200,
- ]
- ];
- $swooleClient->sendJson($data);
- V($swooleClient->recv());
- }
- public function test1()
- {
- $obj = new MBaseModel(1, 1);
- V($obj->sendMessage(1, 'NewOrder', 'order'));
- }
- /**
- * 测试下webstock
- * @throws \Exception
- */
- public function webstock()
- {
- $swooleServerConfigData = Factory::config()->getAppoint('swooleServer', 'order');
-
-
- if (empty($swooleServerConfigData)) {
- echo('swoole服务端链接信息配置项错误');
- exit();
- }
- $swooleClient = Factory::swoole($swooleServerConfigData, 'WebsocketClient');
- // 触发商家新订单通知
- $data = [
- 'controller' => 'NewOrder',
- 'action' => 'autoSend',
- 'params' => [
- 'platfrom' => 'qianniaoSAAS',
- 'shop_id' => 9,
- ]
- ];
- $swooleClient->sendJson($data);
- V($swooleClient->recv());
- }
- /**
- * 达达配送接口
- */
- public function dada()
- {
- $dataConfigData = Factory::config()->get('dada');
- if (empty($dataConfigData)) {
- echo('达达配送配置项错误');
- exit();
- }
- $objMerchant = new Merchant($dataConfigData['app_key'], $dataConfigData['app_secret'], 73753);
- $reuslt = $objMerchant->cityCodeList();
- V($reuslt->getData());
- }
- /**
- * 测试退款
- */
- public function refund()
- {
- $miniprogramConfigData = Factory::config()->get('weixin');
- if (empty($miniprogramConfigData)) {
- echo('小程序配置项错误');
- exit();
- }
- $objPay =new Pay($miniprogramConfigData['miniprogram']['appid'], $miniprogramConfigData['pay']['mch_id'],$miniprogramConfigData['pay']['apiPartnerKey'] );
- V($objPay->transfers('4200000989202104119581846831', '20210411-0009','0.01','0.01'));
- }
- /**
- * 临时财务脚本解决应收单索引表id重复问题
- */
- public function tmp()
- {
- $objMReceive = new MReceive(64, 1);
- $result = $objMReceive->tmp();
- if ($result->isSuccess()) {
- V($result->getData());
- } else {
- V($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 临时财务脚本解决应付表索引表id重复问题
- */
- public function tmp1()
- {
- $objMPay = new MPay(64, 1);
- $result = $objMPay->tmp1();
- if ($result->isSuccess()) {
- V($result->getData());
- } else {
- V($result->getData(), $result->getErrorCode());
- }
- }
- }
|