|
|
@@ -23,33 +23,41 @@ class PurchaseController extends Controller
|
|
|
$date = date("Y-m-d H:i:s");
|
|
|
$query->where(['status' => PurchaseClass::STATUS_UN_PAY])->andWhere(['<=', 'deadline', $date]);
|
|
|
$query->orderBy('deadline ASC');
|
|
|
- $connection = Yii::$app->db;//事务处理
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
|
|
|
- Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'hd');
|
|
|
+ Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'hd');
|
|
|
+
|
|
|
+ $arr = [];
|
|
|
+ foreach ($query->batch() as $purchases) {
|
|
|
+
|
|
|
+ foreach ($purchases as $purchase) {
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
|
|
|
- try {
|
|
|
- $arr = [];
|
|
|
- foreach ($query->batch() as $purchases) {
|
|
|
- foreach ($purchases as $purchase) {
|
|
|
$id = $purchase['id'] ?? 0;
|
|
|
$current = PurchaseClass::getById($id, true);
|
|
|
PurchaseService::expire($current);
|
|
|
- $log = "过期的采购单:{$id} json:" . json_encode($purchase);
|
|
|
- $arr[] = $log;
|
|
|
+ $transaction->commit();
|
|
|
+
|
|
|
+ noticeUtil::push("采购单过期库存回滚 orderSn:{$current->orderSn}", '15280215347');
|
|
|
+
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $msg = $e->getMessage();
|
|
|
+ noticeUtil::push("采购单过期处理,报错:{$msg}", '15280215347');
|
|
|
}
|
|
|
+
|
|
|
+ $log = "过期的采购单:{$id} json:" . json_encode($purchase);
|
|
|
+ $arr[] = $log;
|
|
|
}
|
|
|
- $transaction->commit();
|
|
|
- if (!empty($arr)) {
|
|
|
- foreach ($arr as $item) {
|
|
|
- Yii::info($item);
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($arr)) {
|
|
|
+ foreach ($arr as $item) {
|
|
|
+ Yii::info($item);
|
|
|
}
|
|
|
- } catch (Exception $e) {
|
|
|
- $transaction->rollBack();
|
|
|
- $msg = $e->getMessage();
|
|
|
- noticeUtil::push("采购订单过期变更报错:{$msg}", '15280215347');
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|