| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- <?php
- namespace app\api\controller\v1;
- use app\common\model\CouponPlanModel;
- use app\common\model\MachineListModel;
- use app\common\model\MachineModel;
- use app\common\model\UserModel;
- use app\Request;
- use think\console\command\optimize\Schema;
- use think\facade\Db;
- use function mysql_xdevapi\expression;
- class Sunny
- {
- public function sunnytest(Request $request){
- // return 'aa';
- //
- // return sr_getcurtime('1658268001');
- //
- // return sr_getcurtime(time(), 'Y-m-d').' 10:30:00';
- // $get_time = strtotime('2022-07-20 10:30:00');
- // $model = new CouponPlanModel();
- //
- //
- // Db::startTrans();
- // try {
- //
- // $uids = [7605659,7605660];
- // foreach ($uids as $key=>$val){
- // for ($i = 0;$i<5;$i ++){
- // $model->addPlan($val, 1000, 228, true, 0, $get_time);
- // }
- // }
- //
- // Db::commit();
- // }catch (\Exception $e){
- // Db::rollback();
- // return $e->getMessage();
- // }
- // return 'success';
- $m_user = new UserModel();
- Db::startTrans();
- try {
- $list = Db::name('shop_order')->where('user_id', 'in', '7605659,7605660')->where('status', 0)->select()->toArray();
- // return $list;
- $express = Db::name('express')->select()->toArray();
- // return $express[14]['code'];
- // return $express;
- foreach ($list as $key=>$val){
- $num = rand(1, 19);
- $code_len = rand(14, 19);
- $day = sr_getcurtime(strtotime($val['created_time']), 'Y-m-d');
- $other_ship = Db::name('shop_order')->whereDay('created_time', $day)->where('status', 2)->where('ship_code', $express[$num]['code'])->find();
- if (!$other_ship){
- $num = rand(1, 19);
- $other_ship = Db::name('shop_order')->whereDay('created_time', $day)->where('status', 2)->where('ship_code', $express[$num]['code'])->find();
- }
- if (!$other_ship){
- $num = rand(1, 19);
- $other_ship = Db::name('shop_order')->whereDay('created_time', $day)->where('status', 2)->where('ship_code', $express[$num]['code'])->find();
- }
- if (!$other_ship){
- $num = rand(1, 19);
- $other_ship = Db::name('shop_order')->whereDay('created_time', $day)->where('status', 2)->where('ship_code', $express[$num]['code'])->find();
- }
- // return $other_ship;
- Db::name('shop_order')->where('order_id', $val['order_id'])->save([
- 'pay_type'=>6,
- 'status'=>2,
- 'ship_code'=>$express[$num]['code'],
- 'ship_name'=>$express[$num]['name'],
- 'ship_number'=>$other_ship['ship_number']
- ]);
- $user = $m_user->where('id', $val['user_id'])->find();
- // if ($user['pid'] > 0){
- // if (Db::name('user')->where('id', $user['pid'])->where('is_auth', 1)->find()){
- // edit_user_score(15, $user['pid'], number_format($val['payment']/100, 4, '.', ''));
- // }
- //
- // }
- // 送积分
- edit_user_score(5, $val['user_id'], $val['rebate_score']);
- edit_user_redscore(1, $val['user_id'], $val['rebate_lock_score']);
- // if ($val['user_id'] == 7605660){
- // Db::name('shop_order_shipping')->where('order_id', $val['order_id'])->save([
- // 'sp_name'=>'张老师',
- // 'sp_mobile'=>'15683445552',
- // 'sp_province'=>'重庆',
- // 'sp_city'=>'九龙坡',
- // 'sp_county'=>'重庆',
- // 'sp_remark'=>'春风与湖',
- // 'sp_mergename'=>'重庆市九龙坡区春风与湖'
- // ]);
- // }
- // if ($val['user_id'] == 7605659){
- // Db::name('shop_order_shipping')->where('order_id', $val['order_id'])->save([
- // 'sp_name'=>'何正乐',
- // 'sp_mobile'=>'13276527172',
- // 'sp_province'=>'江苏',
- // 'sp_city'=>'扬州',
- // 'sp_county'=>'邗江区',
- // 'sp_remark'=>'文昌西路246-3号',
- // 'sp_mergename'=>'江苏扬州市邗江区文昌西路246-3号'
- // ]);
- //
- // }
- }
- Db::commit();
- }catch (\Exception $e){
- Db::rollback();
- return $e->getMessage();
- }
- return 'success';
- // return Db::name('shop_order')->where('status', 3)->whereDay('created_time', '2022-05-07')->sum('payment');
- // return Db::name('shop_order')->where('user_id', 7605659)->sum('payment');
- Db::startTrans();
- try {
- // 18215521103,15181873593,13527570720
- // 7605658,7605659,7605660
- // uid 7605658 13527570720 任务包id
- // uid 7605659 15181873593 任务包id
- // uid 7605660 18215521103 任务包id
- // 给用户添加一个新手矿机
- // $this->getmachine([ 7605658, 7605659, 7605660]);
- // 获取卷轴任务包
- // $this->getxz([ 7605658, 7605659, 7605660]);
- // 赠送积分跟红包
- $this->getScore([7605660,7605659]);
- Db::commit();
- }catch (\Exception $e){
- Db::rollback();
- return $e->getMessage();
- }
- return 'success';
- }
- function getScore($uids){
- $m_user = new UserModel();
- foreach ($uids as $k1=>$v1){
- $list = Db::name('shop_order')->where('user_id', $v1)->where('order_id', 'in', '410,411,486,488,554,596,642')->where('status', 2)->select()->toArray();
- foreach ($list as $key=>$val){
- $user = $m_user->where('id', $val['user_id'])->find();
- // if ($user['pid'] > 0){
- // if (Db::name('user')->where('id', $user['pid'])->where('is_auth', 1)->find()){
- // edit_user_score(15, $user['pid'], number_format($val['payment']/100, 4, '.', ''));
- // }
- //
- // }
- // 送积分
- edit_user_score(5, $val['user_id'], $val['rebate_score']);
- edit_user_redscore(1, $val['user_id'], $val['rebate_lock_score']);
- }
- }
- }
- function getxz($uids){
- foreach ($uids as $k1=>$v1){
- $list = Db::name('machine_list')->where('uid', $v1)->where('state', 1)->select()->toArray();
- $model = new MachineModel();
- foreach ($list as $key=>$val){
- $model->getMachineAward($val['uid'], $val['id'], 'android');
- }
- }
- }
- function getmachine($uids){
- foreach ($uids as $key=>$val){
- // 给用户添加一个新手矿机
- // $uid = 7603922;
- // 新手矿机
- $info = MachineModel::where('mlevel', 999)->find();
- $m_machinelist = new MachineListModel();
- $time = time();
- $m_machinelist->insert([
- 'mid'=>$info['id'],
- 'create_time'=>sr_getcurtime($time),
- 'expire_time'=> sr_getcurtime(strtotime("+ ".$info['valid_day']." days")),
- 'back_count'=>$info['cycle'],
- 'once_back'=>number_format($info['total_number']/$info['cycle'], '4', '.', ''),
- 'over_count'=>$info['cycle'],
- 'get_type'=>2,
- 'uid'=>$val
- ]);
- edit_user_active(2, $val, $info['add_active']);
- }
- }
- }
|