OrderClearController.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\order\classes\OrderClearClass;
  4. use Yii;
  5. use common\components\util;
  6. class OrderClearController extends BaseController
  7. {
  8. //收款 ssh 2021.2.4
  9. public function actionClear()
  10. {
  11. $id = Yii::$app->request->post('id');
  12. $customId = Yii::$app->request->post('customId');
  13. if (empty($id)) {
  14. util::fail('请选择交易记录');
  15. }
  16. //抹零之后的价格
  17. $modifyPrice = Yii::$app->request->post('modifyPrice', 0.00);
  18. if (is_numeric($modifyPrice) == false || $modifyPrice <= 0) {
  19. util::fail('金额填错了哦');
  20. }
  21. $connection = Yii::$app->db;
  22. $transaction = $connection->beginTransaction();
  23. $name = $this->shopAdmin['name'] ?? '';
  24. $data = [
  25. 'customId' => $customId,
  26. 'ghsShopAdminId' => $this->shopAdminId,
  27. 'ghsShopAdminName' => $name,
  28. 'modifyPrice' => $modifyPrice,
  29. ];
  30. try {
  31. OrderClearClass::clear($data, $id, $this->sjId, $this->shopId);
  32. $transaction->commit();
  33. } catch (\Exception $exception) {
  34. $transaction->rollBack();
  35. Yii::info("批量收款失败:" . $exception->getMessage());
  36. util::fail('操作失败');
  37. }
  38. util::complete();
  39. }
  40. }