PurchaseClearController.php 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace ghs\controllers;
  3. use bizGhs\clear\classes\ClearClass;
  4. use bizHd\purchase\classes\PurchaseClearClass;
  5. use common\components\dict;
  6. use common\components\util;
  7. use Yii;
  8. class PurchaseClearController extends BaseController
  9. {
  10. //供货商向基地供货商结账生成订单 ssh 20220523
  11. public function actionCreateOrder()
  12. {
  13. $post = Yii::$app->request->post();
  14. $current = time();
  15. $list = ClearClass::getAllByCondition([
  16. 'clearStyle' => dict::getDict('clearStyle', 'gys2KmGys'),
  17. 'shopId' => $this->shopId,
  18. 'status' => PurchaseClearClass::STATUS_AWAIT_PAY
  19. ], null, '*', null, true);
  20. if (!empty($list)) {
  21. foreach ($list as $item) {
  22. $deadline = $item->deadline;
  23. $deadTime = strtotime($deadline);
  24. if ($current > $deadTime) {
  25. $item->status = PurchaseClearClass::STATUS_EXPIRE;
  26. $item->save();
  27. } else {
  28. util::fail('还有待付款的结账单');
  29. }
  30. }
  31. }
  32. if (getenv('YII_ENV') == 'production') {
  33. //小向花卉采购的结账确认,有多处,关键词ghs_cg_clear_confirm
  34. if (in_array($this->mainId, [23390, 24516])) {
  35. if (!in_array($this->adminId, [24655])) {
  36. util::fail('不能操作哈');
  37. }
  38. }
  39. //花大苪 洋桔梗,只有叶荷姐才能销账,多处请搜索关键词hdb_clear_control
  40. if (in_array($this->shopId, [16070])) {
  41. if (!in_array($this->adminId, [9303, 4])) {
  42. util::fail('暂无权限');
  43. }
  44. }
  45. //中山淘花里,销账权限控制,多处请搜索 thl_clear_control
  46. if (in_array($this->shopId, [17118])) {
  47. if (!in_array($this->adminId, [55494, 55445, 17908, 55459, 55707, 55709])) {
  48. util::fail('你不能销单!');
  49. }
  50. }
  51. //小齐鲜花总店和出车,多处请搜索关键词 xq_clear_control
  52. if (in_array($this->shopId, [41467, 42946])) {
  53. if (!in_array($this->adminId, [40144,42912,42023])) {
  54. util::fail('不能操作哈。。');
  55. }
  56. }
  57. //恋善好多花控制销账权限
  58. if (in_array($this->shopId, [55238,56609,56611])) {
  59. if (!in_array($this->adminId, [43856, 54620])) {
  60. util::fail('暂无权限,请联系老板或财务');
  61. }
  62. }
  63. } else {
  64. if (in_array($this->shopId, [36523])) {
  65. // if (!in_array($this->adminId, [919])) {
  66. // util::fail('不能操作...');
  67. // }
  68. }
  69. }
  70. $post['sjId'] = $this->sjId;
  71. $post['shopId'] = $this->shopId;
  72. $post['clearStyle'] = dict::getDict('clearStyle', 'gys2KmGys');
  73. $post['customShopAdminId'] = $this->shopAdminId;
  74. $post['customShopId'] = $this->shopId ?? 0;
  75. $shopAdmin = $this->shopAdmin;
  76. $shopAdminName = $shopAdmin['name'] ?? '';
  77. $post['customShopAdminName'] = $shopAdminName;
  78. $connection = Yii::$app->db;
  79. $transaction = $connection->beginTransaction();
  80. try {
  81. $respond = ClearClass::addOrder($post);
  82. $transaction->commit();
  83. util::success($respond);
  84. } catch (\Exception $e) {
  85. $transaction->rollBack();
  86. Yii::info("下单失败原因:" . $e->getMessage());
  87. util::fail('下单失败');
  88. }
  89. }
  90. }