Commit 49b895ce authored by luhongguang's avatar luhongguang

update:lastid调整

parent 11196bee
<?php
namespace App\Models\tmp\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
/**
* Class QyqTicketData
* 老商品数据,跑数据用
* @package App\Models\goods\mysql
*/
class QyqTicketData extends MysqlBase
{
const TABLE_NAME = 'qyq_ticketdata';
const CONFIG_INDEX = 'goods';
public static function getRecordList($where = [], $columns = [])
{
if (empty($columns)) {
$columns = '*';
}
return self::select($columns, $where);
}
}
\ No newline at end of file
<?php
use Api\PhpUtils\Http\Request;
use App\Base\Cli;
use App\Exception\custom\InterfaceException;
use \App\Models\tmp\mysql\QyqTicketData;
/**
* 导入老商品数据
* php public/cli.php GoodsToInit run
* Class GoodsToInitController
*/
class GoodsToInitController extends Cli
{
public function runAction()
{
$total = $this->getDataCount();
$pageSize = 10;
$pageTotal = floor($total/$pageSize) + 1;
for ($i = 0; $i <= $pageTotal; $i++) {
echo $i."\n";
$list = $this->getDataList($i, $pageSize);
foreach ($list as $item) {
$lifeAccountId = $item["life_account_id"];
$merchantId = $this->getMerchantId($lifeAccountId);
if (empty($merchantId)) {
echo "生活号 ".$lifeAccountId." 没有对应的 merchant_id \n";
continue;
}
}
}
}
/**
* 总数
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
private function getDataCount()
{
return QyqTicketData::count([]);
}
/**
* 每页取指定条数数据处理
* @param $page
* @param $limit
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
private function getDataList($page, $limit)
{
$from = $page * $limit;
$where["LIMIT"] = [$from, $limit];
return QyqTicketData::select("*", $where);
}
/**
* 脚本第一步,把所有的
*/
private function dealShopData()
{
}
/**
* 获取 merchant_id
* @param $lifeAccountId
* @return mixed|string
* @throws InterfaceException
*/
private function getMerchantId($lifeAccountId)
{
$url = config('interface', 'merchant.lifeaccount.get_life_account_by_id');
if (empty($url)) {
throw new InterfaceException(['cus' => 0]);
}
$lifeAccountRes = (new Request())->get($url, ["life_account_id" => $lifeAccountId]);
return empty($lifeAccountRes["response"]["result"]["merchant_id"]) ? "" : $lifeAccountRes["response"]["result"]["merchant_id"];
}
}
\ No newline at end of file
...@@ -935,7 +935,7 @@ class GoodsService ...@@ -935,7 +935,7 @@ class GoodsService
$lastId = $sku["goods_spu_id"]; $lastId = $sku["goods_spu_id"];
} }
} else { } else {
$lastId = -1; $lastId = "-1";
} }
return ["status_list" => $statusList, "goods_list" => $data, "last_id" => $lastId]; return ["status_list" => $statusList, "goods_list" => $data, "last_id" => $lastId];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment