| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace ghs\controllers;
- use bizGhs\clear\classes\ClearClass;
- use bizHd\purchase\classes\PurchaseClearClass;
- use common\components\dict;
- use common\components\util;
- use Yii;
- class PurchaseClearController extends BaseController
- {
- //供货商向基地供货商结账生成订单 ssh 20220523
- public function actionCreateOrder()
- {
- $post = Yii::$app->request->post();
- $current = time();
- $list = ClearClass::getAllByCondition([
- 'clearStyle' => dict::getDict('clearStyle', 'gys2KmGys'),
- 'shopId' => $this->shopId,
- 'status' => PurchaseClearClass::STATUS_AWAIT_PAY
- ], null, '*', null, true);
- if (!empty($list)) {
- foreach ($list as $item) {
- $deadline = $item->deadline;
- $deadTime = strtotime($deadline);
- if ($current > $deadTime) {
- $item->status = PurchaseClearClass::STATUS_EXPIRE;
- $item->save();
- } else {
- util::fail('还有待付款的结账单');
- }
- }
- }
- $post['sjId'] = $this->sjId;
- $post['shopId'] = $this->shopId;
- $post['clearStyle'] = dict::getDict('clearStyle', 'gys2KmGys');
- $post['customShopAdminId'] = $this->shopAdminId;
- $post['customShopId'] = $this->shopId ?? 0;
- $shopAdmin = $this->shopAdmin;
- $shopAdminName = $shopAdmin['name'] ?? '';
- $post['customShopAdminName'] = $shopAdminName;
- $connection = Yii::$app->db;
- $transaction = $connection->beginTransaction();
- try {
- $respond = ClearClass::addOrder($post);
- $transaction->commit();
- util::success($respond);
- } catch (\Exception $e) {
- $transaction->rollBack();
- Yii::info("下单失败原因:" . $e->getMessage());
- util::fail('下单失败');
- }
- }
- }
|