|
|
@@ -3,8 +3,11 @@
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
-use app\common\library\EthSign;
|
|
|
-use app\common\library\Token;
|
|
|
+use app\common\model\ProductOrder;
|
|
|
+use think\console\Output;
|
|
|
+use think\Exception;
|
|
|
+use app\common\model\Region;
|
|
|
+use app\common\model\UserPledge;
|
|
|
use fast\Random;
|
|
|
|
|
|
/**
|
|
|
@@ -17,22 +20,43 @@ class Index extends Api
|
|
|
|
|
|
private $loaded = false;
|
|
|
private $data;
|
|
|
-
|
|
|
- public function index() {
|
|
|
- if(!$this->loaded) {
|
|
|
-
|
|
|
- $this->loadData();
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('请求成功', $this->data);
|
|
|
+
|
|
|
+ //测试脚本
|
|
|
+ public function task(UserPledge $userPledge, ProductOrder $productOrder) {
|
|
|
+
|
|
|
+ //$rows = UserPledge::where('status', '=', 1)->select();
|
|
|
+ $list = $userPledge::alias('a')
|
|
|
+ ->join('product_pledge b', 'a.pledge_id = b.id', 'left')
|
|
|
+ ->where('a.status', '=', 1)
|
|
|
+ ->field('a.*,b.day_num')
|
|
|
+ ->select();
|
|
|
+ $i = 0;
|
|
|
+ $time= time();
|
|
|
+ foreach ($list as $rows) {
|
|
|
+
|
|
|
+ $day = 86400;
|
|
|
+ $total = 0; //当前累计收益
|
|
|
+ $reta = bcdiv($rows->day_num, $day, 6); //天数
|
|
|
+ $inter = ($rows->last_time == 0) ? $time - $rows->create_time: $time - $rows->last_time; //最后收取时间
|
|
|
+ $total = bcmul($reta, $inter, 6) * $rows->num; //累计收益
|
|
|
+ $rows->total_self= bcadd($total, $rows->total_self, 6);
|
|
|
+
|
|
|
+ //修改详情订单状态
|
|
|
+ $detail = json_decode($rows['details'], true);
|
|
|
+ $productOrder::where('status', 6)->whereIn('id', array_column($detail, 'id'))->setField('status', ProductOrder::Paid);
|
|
|
+
|
|
|
+ //更新存储订单状态
|
|
|
+ $rows->last_time = $time;
|
|
|
+ $rows->status = 2;
|
|
|
+ $rows->save();
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('ok:'. $i);
|
|
|
}
|
|
|
|
|
|
|
|
|
- private function loadData(){
|
|
|
- // 耗时的数据加载操作
|
|
|
- $this->data =/* ... */
|
|
|
- $this->loaded =true;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
|