Commit fa50faa6 authored by pengfei's avatar pengfei

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

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