CustomController.php 2.6 KB

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