
- 添加AfterSales类处理售后服务相关接口 - 新增ContentTemplate控制器和模型用于内容模板管理 - 添加diandian渠道服务类 - 更新Feedov控制器和添加FeedovHfAuto命令类 - 新增autoCard视图用于自动发卡设置
120 lines
3.3 KiB
PHP
120 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace app\queue\command\feedov;
|
|
|
|
|
|
use app\channel\service\ChannelService;
|
|
use app\gateway\service\RedisService;
|
|
use app\merchant\service\MerchantService;
|
|
|
|
use app\openapi\controller\Feedov;
|
|
use think\admin\Command;
|
|
use think\console\Input;
|
|
use think\console\Output;
|
|
use think\Collection;
|
|
|
|
/**
|
|
* 飞之度
|
|
* Class FeedovDyAuto
|
|
* @package app\data\command
|
|
*/
|
|
class FeedovDyAuto extends Command
|
|
{
|
|
protected $redis = false;
|
|
|
|
protected function configure()
|
|
{
|
|
|
|
$this->setName('xQueue:FeedovDyAuto')->setDescription('[ 飞之度 ] 抖币自动报价处理');
|
|
}
|
|
|
|
/**
|
|
* @param Input $input
|
|
* @param Output $output
|
|
* @throws \think\admin\Exception
|
|
*/
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
ini_set('memory_limit', '1024M');
|
|
|
|
$channelService = ChannelService::instance();
|
|
|
|
$merchantService = MerchantService::instance();
|
|
$merchantList = $merchantService->db()->where(['merchant_type'=>7,'status'=>1])->select()->toArray();
|
|
if(!$merchantList) $this->setQueueSuccess("未找到支持的蜜蜂商家");
|
|
$merchantList_num = count($merchantList);
|
|
$count_sum = 0;
|
|
$total_sum=0;
|
|
|
|
$this->redis = RedisService::getInstance();
|
|
|
|
$account_data = $channelService->call('account', 13, '');
|
|
$balance = $account_data['account'];
|
|
$redis_balance = $this->redis->get('channel_account-13');
|
|
if(!$this->redis->get('channel_account-13')){
|
|
$this->redis->set('channel_account-13',$balance,24*60*60);
|
|
$stock = intval(bcdiv($balance, '1.002', 3)); // 第三个参数是保留的小数位数,可根据需要调整
|
|
|
|
$need_update = true;
|
|
}else{
|
|
$this->redis->set('channel_account-13',$balance,24*60*60);
|
|
if($balance<=$redis_balance){
|
|
$need_update = false;
|
|
}else{
|
|
$stock = intval(bcdiv($balance, '1.002', 3)); // 第三个参数是保留的小数位数,可根据需要调整
|
|
$need_update = true;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
$class = new Feedov($this->app);
|
|
if(!$need_update){
|
|
$this->setQueueSuccess("当前账户余额为{$balance},无需更新");
|
|
return;
|
|
}
|
|
foreach ($merchantList as $merchant) {
|
|
$mid = $merchant['id'];
|
|
$request_data = [
|
|
'goods' =>[
|
|
[
|
|
'goods_id' => 10000595,
|
|
'status' => 1,
|
|
'user_quote_stock' =>$stock,
|
|
]
|
|
]
|
|
];
|
|
$request = [
|
|
'app_key'=>$merchant['agentId'],
|
|
'app_secret'=>$merchant['agentkey'],
|
|
'data'=>$request_data
|
|
];
|
|
|
|
$msg = $class->editSupplyGoodManageStock($request);
|
|
$array = json_decode($msg,true);
|
|
if(is_array($array) && isset($array['code']) && $array['code']==0){
|
|
$this->setQueueProgress($array['data']['successMsgs']['10000595'] ?? '商品更新成功');
|
|
}else{
|
|
$this->setQueueProgress($array['data']['errorMsgs']['10000595'] ?? '商品更新失败');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->setQueueSuccess("成功更新");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|