| 21 | use Tymon\JWTAuth\Facades\JWTAuth; |
| 22 | use App\Http\Services\Net\Curl; |
| 23 | class IndexController extends BaseController |
| 24 | { |
| 25 | |
| 26 | /** |
| 27 | * 订阅记录增加 |
| 28 | */ |
| 29 | function addSubscribe(Request $request) |
| 30 | { |
| 31 | $userId = $request->user_id; |
| 32 | $templateId = $request->post('template_id', ''); |
| 33 | if (!($userId && $templateId)) { |
| 34 | return $this->fail('缺少参数'); |
| 35 | } |
| 36 | |
| 37 | $subscribe = new Subscribe(); |
| 38 | $subscribe->template_id = $templateId; |
| 39 | $subscribe->user_id = $userId; |
| 40 | $subscribe->is_send = 2; |
| 41 | $res = $subscribe->save(); |
| 42 | if (!$res) { |
| 43 | return $this->fail('添加记录失败'); |
| 44 | } |
| 45 | |
| 46 | $user = User::where('id', $userId)->first(); |
| 47 | $user->subscribe_num = $user->subscribe_num + 1; |
| 48 | $res = $user->save(); |
| 49 | if (!$res) { |
| 50 | return $this->fail(); |
| 51 | } |
| 52 | return $this->success([],'提醒成功,明天继续哦'); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * 增加领红包记录 |
| 57 | */ |
| 58 | function addCouponLog(Request $request) |
| 59 | { |
| 60 | $userId = $request->user_id; |
| 61 | $projectId = $request->post('project_id', ''); |
| 62 | if (!($userId && $projectId)) { |
| 63 | return $this->fail('缺少参数'); |
| 64 | } |
| 65 | $couponLog = new GetCouponLog(); |
| 66 | $couponLog->project_id = $projectId; |
| 67 | $couponLog->user_id = $userId; |
| 68 | $res = $couponLog->save(); |
| 69 | if (!$res) { |
| 70 | return $this->fail('保存失败'); |
| 71 | } |
| 72 | $user = User::where('id', $userId)->first(); |
| 73 | $user->get_coupon_num = $user->get_coupon_num + 1; |
| 74 | if($user->save()) { |
| 75 | return $this->success(); |
| 76 | } |
| 77 | return $this->fail(); |
| 78 | } |
| 79 | } |
nothing calls this directly
no outgoing calls
no test coverage detected