Commit fa50faa6 authored by pengfei's avatar pengfei

update 团长分销-增加奖励脚本请求idgen服务异常报警

parent 1a1f019a
......@@ -59,7 +59,16 @@ class ColonelorderController extends Job
$this->getInviteOrderData($userIds, $colonelPayInfoData); // 完成目标单数
$this->getInviteNewUserData($userIds, $colonelPayInfoData); // 邀请新用户奖励
}
if (!empty($colonelPayInfoData)) {
try {
$this->loggerInfo('colonelPayInfoCount=' . count($colonelPayInfoData));
$colonelPayInfoData = $this->getFormatPayInfoData($colonelPayInfoData);
$this->handleSavePayInfo($colonelPayInfoData);
$this->loggerInfo('success');
} catch (Exception $e) {
$this->loggerError('error=' . $e->getMessage());
}
}
}
$this->loggerInfo('end');
}
......@@ -67,28 +76,26 @@ class ColonelorderController extends Job
/**
* Notes: 保存奖励信息
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:34 下
* Date: 2021/9/7 10:40 上
* @param $colonelPayInfoData
* @return bool
* @throws Exception
*/
private function handleSavePayInfo($colonelPayInfoData)
{
$this->loggerInfo('colonelPayInfoCount=' . count($colonelPayInfoData));
if (!empty($colonelPayInfoData)) {
$data = $this->getFormatPayInfoData($colonelPayInfoData);
try {
ColonelDistributorPayInfo::beginTransaction();
if (!$this->addColonelDistributorPayInfo($data)) {
throw new Exception(sprintf("写入错误参数 %s", json_encode($data)));
if (!$this->addColonelDistributorPayInfo($colonelPayInfoData)) {
throw new Exception(sprintf("写入错误参数 %s", json_encode($colonelPayInfoData)));
}
if (!ColonelDistributorPayInfo::commit()) {
throw new Exception(sprintf("事务提交失败 %s", json_encode($data)));
throw new Exception(sprintf("事务提交失败 %s", json_encode($colonelPayInfoData)));
}
$this->loggerInfo('success');
} catch (Exception $e) {
ColonelDistributorPayInfo::rollback();
$this->loggerError('error=' . $e->getMessage());
}
throw new Exception($e->getMessage());
}
return true;
}
/**
......@@ -211,21 +218,26 @@ class ColonelorderController extends Job
/**
* Notes: 获取pay_info数据
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:07 下
* Date: 2021/9/7 10:34 上
* @param $data
* @return array
* @throws Exception
*/
private function getFormatPayInfoData($data): array
{
$count = count($data);
$res = Idgen::get(appConfig('idgen.partner'), appConfig('idgen.key'), [], [
$httpParams = [
[
'type' => 'goods',
'number' => 00,
'count' => $count
]
]);
];
$res = Idgen::get(appConfig('idgen.partner'), appConfig('idgen.key'), [], $httpParams);
$ids = $res['id_datetime']['goods'] ?? [];
if ($count > count($ids)) {
throw new Exception('请求idgen服务失败,request:' . json_encode($httpParams) . ';response:' . json_encode($res));
}
foreach ($data as $key => $item) {
$data[$key]['pay_info_trade_id'] = $ids[$key];
}
......
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