CustomController.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\sj\classes\MerchantClass;
  4. use bizHd\saas\classes\ApplyClass;
  5. use bizHd\saas\services\ApplyService;
  6. use bizGhs\custom\classes\CustomClass;
  7. use bizGhs\custom\services\CustomService;
  8. use common\components\stringUtil;
  9. use common\components\util;
  10. use Yii;
  11. class CustomController extends BaseController
  12. {
  13. //客户列表 shish 2021.7.8
  14. public function actionList()
  15. {
  16. $get = Yii::$app->request->get();
  17. $type = isset($get['type']) ? $get['type'] : 0;
  18. $name = isset($get['name']) ? $get['name'] : '';
  19. $where = ['sjId' => $this->sjId];
  20. switch ($type) {
  21. case 1:
  22. //已开店
  23. $where['isOpen'] = 1;
  24. break;
  25. default:
  26. }
  27. if (!empty($name)) {
  28. if (stringUtil::isMobile($name)) {
  29. $where['mobile'] = $name;
  30. } else {
  31. $where['shopName'] = ['like', $name];
  32. }
  33. }
  34. $list = CustomService::getCustomList($where);
  35. util::success($list);
  36. }
  37. //客户详情 shish 2021.1.8
  38. public function actionDetail()
  39. {
  40. $get = Yii::$app->request->get();
  41. $customId = $get['id'] ?? 0;
  42. $info = CustomService::getCustomInfo($customId);
  43. CustomClass::valid($info, $this->sjId);
  44. $info['sn'] = 1254358;
  45. util::success($info);
  46. }
  47. //允许月结开关 shish 2021.1.8
  48. public function actionDebt()
  49. {
  50. $get = Yii::$app->request->get();
  51. $debt = isset($get['debt']) ? $get['debt'] : 0;
  52. $customId = isset($get['customId']) ? $get['customId'] : 0;
  53. $custom = CustomClass::getById($customId);
  54. CustomClass::valid($custom, $this->sjId);
  55. CustomClass::debt($custom, $debt);
  56. util::complete();
  57. }
  58. //添加新客户 shish 2021.1.8
  59. public function actionAdd()
  60. {
  61. $post = Yii::$app->request->post();
  62. $post['style'] = MerchantClass::STYLE_RETAIL;
  63. $post['from'] = ApplyClass::FROM_GHS;
  64. $post['introSjId'] = $this->sjId;
  65. $post['introStyle'] = MerchantClass::STYLE_SUPPLIER;
  66. $post['certType'] = ApplyClass::CERT_TYPE_MOBILE;
  67. $mobile = $post['mobile'] ?? '';
  68. $confirmMobile = $post['confirmMobile'];
  69. if (stringUtil::isMobile($mobile) == false) {
  70. util::fail(' 请填写正确的手机号');
  71. }
  72. if ($mobile != $confirmMobile) {
  73. util::fail('二次号码填写不一致');
  74. }
  75. ApplyService::replaceApply($post);
  76. util::complete('添加成功,等待审核');
  77. }
  78. //欠款客户 shish 2021.2.4
  79. public function actionDebtList()
  80. {
  81. $get = Yii::$app->request->get();
  82. $where = ['sjId' => $this->sjId, 'isDebt' => 1];
  83. if (isset($get['name']) && !empty($get['name'])) {
  84. $where['name'] = ['like', $get['name']];
  85. }
  86. $list = CustomService::getDebtList($where);
  87. util::success($list);
  88. }
  89. }