MarketCustom.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\api\controller\custom;
  3. use app\model\MarketCustomer;
  4. use support\Request;
  5. class MarketCustom
  6. {
  7. public function updateStatus(Request $request)
  8. {
  9. $params = $request->post();
  10. if (empty($params['mobile'])) {
  11. return json_fail('手机号不能为空');
  12. }
  13. $mobile = $params['mobile'];
  14. $where = [
  15. ['mobile', '=', $mobile],
  16. [function($query) {
  17. $query->orWhere(function ($query){
  18. $diffNums = (60 * 60 * 24 * 30);
  19. $currentTime = time();
  20. $query->whereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0)")->where('current_status', '=', 1);
  21. })->orWhereIn('current_status', [2,3,4]);
  22. }],
  23. ['check_status', '=', 2]
  24. ];
  25. $info = MarketCustomer::where($where)->first();
  26. if (empty($info)) {
  27. return json_fail('客户不存在');
  28. }
  29. $info->current_status = 3;
  30. $result = $info->save();
  31. if ($result) {
  32. return json_success('修改成功');
  33. } else {
  34. return json_fail('修改失败');
  35. }
  36. }
  37. }