Sunny.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\common\model\CouponPlanModel;
  4. use app\common\model\MachineListModel;
  5. use app\common\model\MachineModel;
  6. use app\common\model\UserModel;
  7. use app\Request;
  8. use think\console\command\optimize\Schema;
  9. use think\facade\Db;
  10. use function mysql_xdevapi\expression;
  11. class Sunny
  12. {
  13. public function sunnytest(Request $request){
  14. // return 'aa';
  15. //
  16. // return sr_getcurtime('1658268001');
  17. //
  18. // return sr_getcurtime(time(), 'Y-m-d').' 10:30:00';
  19. // $get_time = strtotime('2022-07-20 10:30:00');
  20. // $model = new CouponPlanModel();
  21. //
  22. //
  23. // Db::startTrans();
  24. // try {
  25. //
  26. // $uids = [7605659,7605660];
  27. // foreach ($uids as $key=>$val){
  28. // for ($i = 0;$i<5;$i ++){
  29. // $model->addPlan($val, 1000, 228, true, 0, $get_time);
  30. // }
  31. // }
  32. //
  33. // Db::commit();
  34. // }catch (\Exception $e){
  35. // Db::rollback();
  36. // return $e->getMessage();
  37. // }
  38. // return 'success';
  39. $m_user = new UserModel();
  40. Db::startTrans();
  41. try {
  42. $list = Db::name('shop_order')->where('user_id', 'in', '7605659,7605660')->where('status', 0)->select()->toArray();
  43. // return $list;
  44. $express = Db::name('express')->select()->toArray();
  45. // return $express[14]['code'];
  46. // return $express;
  47. foreach ($list as $key=>$val){
  48. $num = rand(1, 19);
  49. $code_len = rand(14, 19);
  50. $day = sr_getcurtime(strtotime($val['created_time']), 'Y-m-d');
  51. $other_ship = Db::name('shop_order')->whereDay('created_time', $day)->where('status', 2)->where('ship_code', $express[$num]['code'])->find();
  52. if (!$other_ship){
  53. $num = rand(1, 19);
  54. $other_ship = Db::name('shop_order')->whereDay('created_time', $day)->where('status', 2)->where('ship_code', $express[$num]['code'])->find();
  55. }
  56. if (!$other_ship){
  57. $num = rand(1, 19);
  58. $other_ship = Db::name('shop_order')->whereDay('created_time', $day)->where('status', 2)->where('ship_code', $express[$num]['code'])->find();
  59. }
  60. if (!$other_ship){
  61. $num = rand(1, 19);
  62. $other_ship = Db::name('shop_order')->whereDay('created_time', $day)->where('status', 2)->where('ship_code', $express[$num]['code'])->find();
  63. }
  64. // return $other_ship;
  65. Db::name('shop_order')->where('order_id', $val['order_id'])->save([
  66. 'pay_type'=>6,
  67. 'status'=>2,
  68. 'ship_code'=>$express[$num]['code'],
  69. 'ship_name'=>$express[$num]['name'],
  70. 'ship_number'=>$other_ship['ship_number']
  71. ]);
  72. $user = $m_user->where('id', $val['user_id'])->find();
  73. // if ($user['pid'] > 0){
  74. // if (Db::name('user')->where('id', $user['pid'])->where('is_auth', 1)->find()){
  75. // edit_user_score(15, $user['pid'], number_format($val['payment']/100, 4, '.', ''));
  76. // }
  77. //
  78. // }
  79. // 送积分
  80. edit_user_score(5, $val['user_id'], $val['rebate_score']);
  81. edit_user_redscore(1, $val['user_id'], $val['rebate_lock_score']);
  82. // if ($val['user_id'] == 7605660){
  83. // Db::name('shop_order_shipping')->where('order_id', $val['order_id'])->save([
  84. // 'sp_name'=>'张老师',
  85. // 'sp_mobile'=>'15683445552',
  86. // 'sp_province'=>'重庆',
  87. // 'sp_city'=>'九龙坡',
  88. // 'sp_county'=>'重庆',
  89. // 'sp_remark'=>'春风与湖',
  90. // 'sp_mergename'=>'重庆市九龙坡区春风与湖'
  91. // ]);
  92. // }
  93. // if ($val['user_id'] == 7605659){
  94. // Db::name('shop_order_shipping')->where('order_id', $val['order_id'])->save([
  95. // 'sp_name'=>'何正乐',
  96. // 'sp_mobile'=>'13276527172',
  97. // 'sp_province'=>'江苏',
  98. // 'sp_city'=>'扬州',
  99. // 'sp_county'=>'邗江区',
  100. // 'sp_remark'=>'文昌西路246-3号',
  101. // 'sp_mergename'=>'江苏扬州市邗江区文昌西路246-3号'
  102. // ]);
  103. //
  104. // }
  105. }
  106. Db::commit();
  107. }catch (\Exception $e){
  108. Db::rollback();
  109. return $e->getMessage();
  110. }
  111. return 'success';
  112. // return Db::name('shop_order')->where('status', 3)->whereDay('created_time', '2022-05-07')->sum('payment');
  113. // return Db::name('shop_order')->where('user_id', 7605659)->sum('payment');
  114. Db::startTrans();
  115. try {
  116. // 18215521103,15181873593,13527570720
  117. // 7605658,7605659,7605660
  118. // uid 7605658 13527570720 任务包id
  119. // uid 7605659 15181873593 任务包id
  120. // uid 7605660 18215521103 任务包id
  121. // 给用户添加一个新手矿机
  122. // $this->getmachine([ 7605658, 7605659, 7605660]);
  123. // 获取卷轴任务包
  124. // $this->getxz([ 7605658, 7605659, 7605660]);
  125. // 赠送积分跟红包
  126. $this->getScore([7605660,7605659]);
  127. Db::commit();
  128. }catch (\Exception $e){
  129. Db::rollback();
  130. return $e->getMessage();
  131. }
  132. return 'success';
  133. }
  134. function getScore($uids){
  135. $m_user = new UserModel();
  136. foreach ($uids as $k1=>$v1){
  137. $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();
  138. foreach ($list as $key=>$val){
  139. $user = $m_user->where('id', $val['user_id'])->find();
  140. // if ($user['pid'] > 0){
  141. // if (Db::name('user')->where('id', $user['pid'])->where('is_auth', 1)->find()){
  142. // edit_user_score(15, $user['pid'], number_format($val['payment']/100, 4, '.', ''));
  143. // }
  144. //
  145. // }
  146. // 送积分
  147. edit_user_score(5, $val['user_id'], $val['rebate_score']);
  148. edit_user_redscore(1, $val['user_id'], $val['rebate_lock_score']);
  149. }
  150. }
  151. }
  152. function getxz($uids){
  153. foreach ($uids as $k1=>$v1){
  154. $list = Db::name('machine_list')->where('uid', $v1)->where('state', 1)->select()->toArray();
  155. $model = new MachineModel();
  156. foreach ($list as $key=>$val){
  157. $model->getMachineAward($val['uid'], $val['id'], 'android');
  158. }
  159. }
  160. }
  161. function getmachine($uids){
  162. foreach ($uids as $key=>$val){
  163. // 给用户添加一个新手矿机
  164. // $uid = 7603922;
  165. // 新手矿机
  166. $info = MachineModel::where('mlevel', 999)->find();
  167. $m_machinelist = new MachineListModel();
  168. $time = time();
  169. $m_machinelist->insert([
  170. 'mid'=>$info['id'],
  171. 'create_time'=>sr_getcurtime($time),
  172. 'expire_time'=> sr_getcurtime(strtotime("+ ".$info['valid_day']." days")),
  173. 'back_count'=>$info['cycle'],
  174. 'once_back'=>number_format($info['total_number']/$info['cycle'], '4', '.', ''),
  175. 'over_count'=>$info['cycle'],
  176. 'get_type'=>2,
  177. 'uid'=>$val
  178. ]);
  179. edit_user_active(2, $val, $info['add_active']);
  180. }
  181. }
  182. }