CustomController.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\sj\classes\SjClass;
  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. //客户列表 ssh 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 = ['ownSjId' => $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['name'] = ['like', $name];
  32. }
  33. }
  34. $list = CustomService::getCustomList($where);
  35. util::success($list);
  36. }
  37. //客户详情 ssh 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. util::success($info);
  45. }
  46. //允许月结开关 ssh 2021.1.8
  47. public function actionDebt()
  48. {
  49. $get = Yii::$app->request->get();
  50. $debt = isset($get['debt']) ? $get['debt'] : 0;
  51. $customId = isset($get['customId']) ? $get['customId'] : 0;
  52. $custom = CustomClass::getById($customId);
  53. CustomClass::valid($custom, $this->sjId);
  54. CustomClass::debt($custom, $debt);
  55. util::complete();
  56. }
  57. //添加新客户 ssh 2021.1.8
  58. public function actionAdd()
  59. {
  60. $post = Yii::$app->request->post();
  61. $post['style'] = SjClass::STYLE_RETAIL;
  62. $post['from'] = ApplyClass::FROM_GHS;
  63. $post['introSjId'] = $this->sjId;
  64. $post['introStyle'] = SjClass::STYLE_SUPPLIER;
  65. $post['certType'] = ApplyClass::CERT_TYPE_MOBILE;
  66. $mobile = $post['mobile'] ?? '';
  67. $confirmMobile = $post['confirmMobile'];
  68. if (stringUtil::isMobile($mobile) == false) {
  69. util::fail(' 请填写正确的手机号');
  70. }
  71. if ($mobile != $confirmMobile) {
  72. util::fail('二次号码填写不一致');
  73. }
  74. ApplyService::replaceApply($post);
  75. util::complete('添加成功,等待审核');
  76. }
  77. //欠款客户 ssh 2021.2.4
  78. public function actionDebtList()
  79. {
  80. $get = Yii::$app->request->get();
  81. $where = ['ownSjId' => $this->sjId, 'isDebt' => 1];
  82. if (isset($get['name']) && !empty($get['name'])) {
  83. $where['name'] = ['like', $get['name']];
  84. }
  85. $list = CustomService::getDebtList($where);
  86. util::success($list);
  87. }
  88. }