PurchaseClearController.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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,77951])) {
  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. //淘花里小榄店 thl_xl_clear
  52. if (in_array($this->shopId, [72366])) {
  53. if (!in_array($this->adminId, [69792,55445,55707,69792])) {
  54. util::fail('你不能销单那。。。');
  55. }
  56. }
  57. //淘花里珠海店
  58. if (in_array($this->shopId, [78556])) {
  59. if (!in_array($this->adminId, [69132, 75771, 43732, 55734, 47775, 55711, 40678, 75798])) {
  60. util::fail('你不能销单,编号6553');
  61. }
  62. }
  63. //小齐鲜花总店和出车,多处请搜索关键词 xq_clear_control
  64. if (in_array($this->shopId, [41467, 42946])) {
  65. if (!in_array($this->adminId, [40144,42912,42023])) {
  66. util::fail('不能操作哈。。');
  67. }
  68. }
  69. //恋善好多花控制销账权限
  70. if (in_array($this->shopId, [55238,56609,56611])) {
  71. if (!in_array($this->adminId, [43856, 54620])) {
  72. util::fail('暂无权限,请联系老板或财务');
  73. }
  74. }
  75. } else {
  76. if (in_array($this->shopId, [36523])) {
  77. // if (!in_array($this->adminId, [919])) {
  78. // util::fail('不能操作...');
  79. // }
  80. }
  81. }
  82. $post['sjId'] = $this->sjId;
  83. $post['shopId'] = $this->shopId;
  84. $post['clearStyle'] = dict::getDict('clearStyle', 'gys2KmGys');
  85. $post['customShopAdminId'] = $this->shopAdminId;
  86. $post['customShopId'] = $this->shopId ?? 0;
  87. $shopAdmin = $this->shopAdmin;
  88. $shopAdminName = $shopAdmin['name'] ?? '';
  89. $post['customShopAdminName'] = $shopAdminName;
  90. $connection = Yii::$app->db;
  91. $transaction = $connection->beginTransaction();
  92. try {
  93. $respond = ClearClass::addOrder($post);
  94. $transaction->commit();
  95. util::success($respond);
  96. } catch (\Exception $e) {
  97. $transaction->rollBack();
  98. Yii::info("下单失败原因:" . $e->getMessage());
  99. util::fail('下单失败');
  100. }
  101. }
  102. }