| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace addons\Store\console\controllers;
- use addons\Store\common\listeners\order\OrderPaidListener;
- use addons\Store\common\models\SettlementLog;
- use addons\Store\common\models\Store;
- use yii\console\ExitCode;
- use yii\console\Controller;
- class IndexController extends Controller
- {
- public function actionSettlementLog()
- {
- try {
- $logs = SettlementLog::find()
- ->where(['is_settlement'=>0])
- ->andWhere(['<','settlement_at',time()])
- ->all();
- if(!empty($logs)){
- foreach($logs as $log){
- $trans = \Yii::$app->db->beginTransaction();
- try{
- $log->is_settlement = 1;
- if(!$log->save()){
- throw new \Exception('门店订单结算异常,id:'.$log->id);
- }
- //结算货款
- Store::settlementStoreCommission($log['order_id'], $log['store_id'], $log['order_no']);
- $trans->commit();
- }catch(\Exception $e){
- $trans->rollBack();
- throw new \Exception($e->getMessage());
- }
- }
- }
- return ExitCode::OK;
- } catch (\Exception $e) {
- return ExitCode::UNSPECIFIED_ERROR;
- }
- }
- public function actionTest()
- {
- OrderPaidListener::async_handle(['id' => 1092]);
- }
- }
|