| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- <?php
- /**
- * ----------------------------------------------------------------------------
- * 行到水穷处,坐看云起时
- * 开发软件,找贵阳云起信息科技,官网地址:https://www.56q7.com/
- * ----------------------------------------------------------------------------
- * Author: 老成
- * email:85556713@qq.com
- */
- declare(strict_types=1);
- namespace app\admin\command;
- use app\common\model\FengsuShip;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use GuzzleHttp\Client;
- use app\common\model\CrontabLog;
- use app\common\model\FengsuSku;
- use app\common\model\ShopList;
- use app\common\model\ProductConfig;
- use app\common\model\ShopDelivery;
- use app\common\model\CustomerSpec;
- use app\admin\service\FengsuService;
- use GuzzleHttp\Psr7\Request;
- //抖音
- class JuShuiTan extends Command
- {
- //抖音请求地址
- protected $url = 'https://innerapi.scm121.com/api/inner/supOrder/getErpNormalOrders';
- //抖音请求头部
- protected $headers = [
- //'Host' => 'fsdy2.fengsutb.com',
- 'Accept' => 'application/json, text/plain, */*',
- 'Authorization' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIyMTk0MzA5MSIsInJvbGVJZHMiOltdLCJ1c2VyX25hbWUiOiIxODE4MjY2OTkzNSIsImNvSWQiOiIxNDc5MjIyMiIsImV4cGlyYXRpb24iOjE3NjYyMTg0NDM1MzQsInVzZXIiOnsiY29JZCI6IjE0NzkyMjIyIiwiY29OYW1lIjoi5LqR5Y2X5LmQ55Wq55Sw5L6b5bqU6ZO-5pyJ6ZmQ5YWs5Y-4IiwibG9naW5OYW1lIjoiMTgxODI2Njk5MzUiLCJsb2dpbldheSI6IlVTRVJOQU1FIiwibmlja05hbWUiOiLmnY4iLCJyb2xlSWRzIjoiMTEsMTIsMTMsMTQsMTUsMTYsMTcsMTgsMjIsMjMsMjcsMjgsMjksMzAsMzEsMzIsMzMsMzQsMzUsMzYsMzksNDAsNDEsNTIsNTMsNTQsNjEsNjIsNjMsNjQsNjUsNjYsNjcsNzAsNzEsNzIsNzMsNzYsOTAsMTAxLDEwMiwxMDMsMTA0LDEwNSwxMDYsMTA3LDEwOCwxMDkiLCJ1aWQiOiIyMTk0MzA5MSJ9LCJhdXRob3JpdGllcyI6WyJKU1QtY2hhbm5lbCIsIm11bHRpTG9naW4iLCJKU1Qtc3VwcGxpZXIiXSwiY2xpZW50X2lkIjoicGMiLCJqdGkiOiIxYjNhZjA4OC04ZDhiLTRhNzMtYjcwNC1lYzhhY2QwNzU1ODUiLCJleHAiOjE3NjYyMTg0NDN9.fXIP-yUlJDIfd49QgxjTQXUlRka2gpw0NrfY7lB50sU',
- 'Content-Type' => 'application/json',
- //'platform' => 'dy',
- ];
- // 指令配置
- protected function configure()
- {
- $this->setName('ju_shui_tan')->setDescription('the task command');
- }
- //根据shop_id
- protected function execute(Input $input, Output $output)
- {
- $output->writeln('开始同步聚水潭订单');
- $resquet = $this->getOrderList('dy');
- dump($resquet);
- if($resquet['success']){
- if($resquet['data']['total'] > 0){
- $list = $resquet['data'];
- $this->insertOrder($list);
- //dump($resquet);
- }else{
- $output->writeln('没有数据');
- }
- }else{
- $output->writeln('接口错误: ' .$resquet['message']);
- }
- $output->writeln('ok');
- }
- public function getOrderList($platform = 'dy')
- {
- $client = new \GuzzleHttp\Client([
- 'verify' => false,
- // 或指定证书路径
- // 'verify' => '/path/to/cacert.pem'
- ]);
- $headers = [
- 'Accept' => ' application/json, text/plain, */*',
- 'Authorization' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiIyMTk0MzA5MSIsInJvbGVJZHMiOltdLCJ1c2VyX25hbWUiOiIxODE4MjY2OTkzNSIsImNvSWQiOiIxNDc5MjIyMiIsImV4cGlyYXRpb24iOjE3NjYyMTg0NDM1MzQsInVzZXIiOnsiY29JZCI6IjE0NzkyMjIyIiwiY29OYW1lIjoi5LqR5Y2X5LmQ55Wq55Sw5L6b5bqU6ZO-5pyJ6ZmQ5YWs5Y-4IiwibG9naW5OYW1lIjoiMTgxODI2Njk5MzUiLCJsb2dpbldheSI6IlVTRVJOQU1FIiwibmlja05hbWUiOiLmnY4iLCJyb2xlSWRzIjoiMTEsMTIsMTMsMTQsMTUsMTYsMTcsMTgsMjIsMjMsMjcsMjgsMjksMzAsMzEsMzIsMzMsMzQsMzUsMzYsMzksNDAsNDEsNTIsNTMsNTQsNjEsNjIsNjMsNjQsNjUsNjYsNjcsNzAsNzEsNzIsNzMsNzYsOTAsMTAxLDEwMiwxMDMsMTA0LDEwNSwxMDYsMTA3LDEwOCwxMDkiLCJ1aWQiOiIyMTk0MzA5MSJ9LCJhdXRob3JpdGllcyI6WyJKU1QtY2hhbm5lbCIsIm11bHRpTG9naW4iLCJKU1Qtc3VwcGxpZXIiXSwiY2xpZW50X2lkIjoicGMiLCJqdGkiOiIxYjNhZjA4OC04ZDhiLTRhNzMtYjcwNC1lYzhhY2QwNzU1ODUiLCJleHAiOjE3NjYyMTg0NDN9.fXIP-yUlJDIfd49QgxjTQXUlRka2gpw0NrfY7lB50sU',
- 'Content-Type' => ' application/json'
- ];
- $body = '{
- "startTime": "2025-11-28 00:00:00",
- "endTime": "2025-11-28 23:59:59",
- "dateQueryType": "DeliveryDate",
- "coId": "14792222",
- "uid": "21943091",
- "upSendFailed": false,
- "isExceptAddress": "Except",
- "pageNum": 1,
- "pageSize": 50,
- "searchType": 1,
- "orderStatus": [
- "Sent"
- ]
- }';
- $request = new Request('POST', 'https://innerapi.scm121.com/api/inner/supOrder/getErpNormalOrders', $headers, $body);
- $res = $client->sendAsync($request)->wait();
- $json = [];
- if($res->getStatusCode() == 200) {
- $json = json_decode($res->getBody()->getContents(), true);
- }else{
- dump($res->getStatusCode(), '接口返回结果');
- }
- return $json;
- }
- public function insertOrder($order_list)
- {
- if(!(count($order_list) > 0)){
- return false;
- }
- $queue = [];
- $shopList = new ShopList();
- $fengsuSku = new FengsuSku();
- $productConfig = new ProductConfig();
- $shopDelivery = new ShopDelivery();
- $customerSpec = new CustomerSpec();
- foreach($order_list as $item) {
- dump($item['shopId'], '店铺id');
- $status = FengsuService::getAdditionalPrice( $shopList, $fengsuSku, $productConfig, $shopDelivery, $customerSpec, $item);
- $queue[] = [
- 'shop_id' => $item['shopId'],
- 'trade_from' => $item['tradeFrom'],
- 'province' => $item['receiverProvince'],
- 'city' => $item['receiverCity'],
- 'company_name' => $item['tradeOrderPrintVos'][0]['companyName'],
- 'waybill_no' => $item['waybillNo'],
- 'consign_time' => $item['consignTime'],
- 'goods_id' => $item['tradeOrderPrintVos'][0]['goodsId'],
- 'sku_id' => $item['tradeOrderPrintVos'][0]['skuId'],
- 'num' => $item['tradeOrderPrintVos'][0]['total'],
- 'goods_title' => $item['tradeOrderPrintVos'][0]['goodsTitle'],
- 'weigh' => $item['tradeOrderPrintVos'][0]['weight'],
- 'price' => bcdiv((string)$item['payment'], '100', 2),
- 'status' => $status,
- ];
- }
- // 保存到数据库
- (new FengsuShip())->saveAll($queue);
- // 更新最后执行时间
- CrontabLog::create(['type_id' => 2,'last_time' => date('Y-m-d H:i:s')]);
- }
- }
- //风速接口返回格式
- // {
- // "shopId": "DY117939700",
- // "sysNum": "3908161982177974",
- // "groupId": "g3908162034664709",
- // "tradeFrom": "dy",
- // "tid": "6948414820472788426",
- // "fromAccountId": 0,
- // "createTime": "2025-11-26 21:27:53",
- // "payTime": "2025-11-26 21:27:55",
- // "inserTime": "2025-11-27 15:11:27",
- // "inventoryPrintTime": null,
- // "consignTime": "2025-11-27 15:11:27",
- // "refunding": 0,
- // "buyerId": "1@#MhctHqbGY6MptrPvaPcNSU6JEPT1RwM+zhPxvrsCvBSVf2u9/qsla+xb9Fu81aUBMmCH",
- // "buyerNick": null,
- // "buyerMessage": "",
- // "sellerFlag": 0,
- // "localFlag": 0,
- // "sellerMemo": null,
- // "localMemo": null,
- // "offlineMemo": null,
- // "offlineFlag": null,
- // "receiverProvince": "黑龙江省",
- // "receiverCity": "哈尔滨市",
- // "receiverDistrict": "依兰县",
- // "receiverTown": "依兰镇",
- // "desensitizationName": "昕*",
- // "desensitizationPhone": null,
- // "desensitizationAddress": "*******",
- // "desensitizationMobile": "1**********",
- // "modifyAddr": 0,
- // "invoiceType": null,
- // "invoiceTitle": null,
- // "invoiceTaxId": null,
- // "promiseShipTime": "2025-12-01 21:27:56",
- // "tradeStatus": "WAIT_CONFIRM",
- // "payment": 9440,
- // "receiptAmount": 9440,
- // "postFee": 0,
- // "splitType": 1,
- // "packageNum": 1,
- // "dpAccountId": 100673,
- // "bizDpAccountId": 100673,
- // "uid": "117939700",
- // "bizShopId": "DY117939700",
- // "companyName": "中通快递",
- // "waybillNo": null,
- // "companyId": 3,
- // "templateId": 145375,
- // "printSize": 1,
- // "mergeHash": "6BC35CF08C74762098670BB71B38F77C387FB374",
- // "mergeHash2": "AC9CEFB7FD89A32A1AA235A9E09BD69FE838D08D",
- // "mergeable": 0,
- // "handDeliverFlag": 0,
- // "tradeAttr": "{\"promise_type\":1,\"recommend_logistics_list\":\"[]\"}",
- // "localAttr": null,
- // "senderAddressEntity": null,
- // "outChannel": null,
- // "tradeFlag": null,
- // "link": "",
- // "roleFlg": true,
- // "shopFlg": true,
- // "saleFlg": true,
- // "picUrlFlag": true,
- // "preSale": 1,
- // "preSaleTime": null,
- // "splitFailReason": null,
- // "businessTag": 0,
- // "locked": 0,
- // "tradeOrderPrintVos": [
- // {
- // "distTime": null,
- // "orderStatus": "WAIT_CONFIRM",
- // "goodsTitle": "田与薯云南圆圆果·榴莲蜜薯软糯蜜甜新鲜高原黄心番薯地瓜粗粮",
- // "goodsId": "3665081518029678296",
- // "skuProp": "{\"65\":\"小糖豆(50g-150g)\",\"66\":\"5斤(精品装(带箱5斤))\",\"67\":\"5天内发货\"}",
- // "companyName": "中通快递",
- // "waybillNo": "76767227765924",
- // "outerId": null,
- // "refundStatus": null,
- // "picUrl": "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/jpeg_m_e379a8d857f16246745a757892497184_sx_320989_www1668-1668",
- // "total": 1,
- // "price": 3980,
- // "payment": 3780,
- // "receiptAmount": null,
- // "orderType": 0,
- // "consignTime": "2025-11-27 15:11:27",
- // "signTime": null,
- // "weight": 0,
- // "goodShortName": null,
- // "skuShortName": null,
- // "oid": "6948414820472788426",
- // "packageNum": 1,
- // "splitType": 1,
- // "companyId": 3,
- // "templateId": 145375,
- // "outerSkuId": "LFT-LLSPK-4.5-SC-CX",
- // "skuId": "3617103894193922",
- // "printSize": 1,
- // "printTime": "2025-11-27 15:11:22",
- // "roleType": 1,
- // "roleName": "田与薯官方旗舰店",
- // "lastFactoryId": 100673,
- // "inventoryPrintSize": 0,
- // "inventoryPrintTime": null,
- // "platCode": "ZJ",
- // "purchaseAttr": null,
- // "shelfPosition": "",
- // "pushTime": null,
- // "orderAttr": "{\"author_name\":\"田与薯官方旗舰店\",\"order_goods_type\":0,\"order_biz\":2,\"pre_sale_label\":\"全款预售\",\"compensate_for_rotten_platform_guarantee\":\"坏了包退官方保障\",\"quick_refund_label\":\"极速退\",\"unsupport_7days_refund\":\"不支持7天\",\"c_biz_self_sell\":\"小店自卖\",\"compass_source_not_ad_mark\":\"非广告\",\"compass_source_content_type_live\":\"直播\",\"afterSaleType\":\"refund\",\"source_platform\":\"\",\"period_purchase_info\":{},\"pack_id\":\"147242304405974025\"}",
- // "freeze": 0,
- // "freezeReason": null,
- // "auditStatus": 2,
- // "payStatus": null,
- // "settleStatus": null,
- // "settleRefundStatus": null,
- // "settleAmount": null,
- // "templateType": "1",
- // "productSkuName": null,
- // "productSkuCode": null
- // }
- // ],
- // "tradePrintList": null,
- // "platCode": "ZJ",
- // "purchaseId": null,
- // "purchaseStatus": null,
- // "supplierName": null,
- // "supplierId": null,
- // "purchaseName": null,
- // "offerId": null,
- // "specId": null,
- // "tradeClassify": "NORMAL",
- // "payType": "NORMAL",
- // "expressType": "NORMAL",
- // "msgTradeAttr": null,
- // "logisticsNames": null,
- // "logisticsTag": 0,
- // "tradeSource": null,
- // "printBatch": null,
- // "printBatchSn": 0,
- // "assignDeliveryId": null,
- // "factoryId": 100673,
- // "prepareShipGroupId": null,
- // "prepareShipDeliverStatus": null,
- // "prepareShipErrorMsg": null,
- // "prepareShipStatus": 0,
- // "prepareShipCreateTime": null,
- // "prepareShipUpdateTime": null,
- // "waybillEntities": [
- // {
- // "id": 7671095,
- // "dpAccountId": 100673,
- // "relationId": 3909499998804122,
- // "deliveryId": 3,
- // "waybillNo": "76767227765924",
- // "createdTime": "2025-11-27 15:11:27",
- // "recycleFlag": 0
- // }
- // ],
- // "relationId": 3909499998804122,
- // "optType": 0,
- // "obsStatus": 0,
- // "obsTime": null,
- // "obsReason": null,
- // "printFailReason": null
- // },
|