success('返回成功', $this->request->param()); } /** * 无需登录的接口 * */ public function test1() { $this->success('返回成功', ['action' => 'test1']); } /** * 需要登录的接口 * */ public function test2() { $this->success('返回成功', ['action' => 'test2']); } /** * 需要登录且需要验证有相应组的权限 * */ public function test3() { $this->success('返回成功', ['action' => 'test3']); } //订单算奖金。计划任务的逻辑 public function test4(){ $order_id = 488359520289034240; $product_list = Db::name('unishop_order_product')->where('order_id',$order_id)->select();//已支付 foreach($product_list as $key => $product){ //收益 $shouyi = bcmul($product['number'],$product['pifa_shouyi'],0); } $user_id = 1; //我的下级数量 Db::name('user')->where('intro_uid',$user_id)->count(); //我的上级id $my_intro_uid = Db::name('user')->where('id',$user_id)->value('intro_uid'); //我的上上级id $two_intro_uid =Db::name('user')->where('id',$my_intro_uid)->value('intro_uid') ?: 0; //结算订单后,用户活跃时间更新 Db::name('user_wallet')->where('user_id',$user_id)->update(['active_time'=>time()]); } //结算要按10天算 public function jiesuan_tendays_ago(){ $nowtime = time(); $today = strtotime(date('Y-m-d',$nowtime)); $toweek = date('w',$nowtime); $enum = [ 1 => 11, 2 => 12, 3 => 12, 4 => 12, // 5 => 12, // 6 => 11, // 0 => 11, // ]; $rs = $today - ($enum[$toweek] * 86400); dump(date('Y-m-d',$rs)); return $rs; } }