|
|
@@ -9,6 +9,7 @@ use app\api\services\ThirdPayServices;
|
|
|
use app\api\services\UserAuthServices;
|
|
|
use app\api\services\UserServices;
|
|
|
use app\common\model\BoxMidHandleModel;
|
|
|
+use app\common\model\BoxHandleModel;
|
|
|
use app\common\model\CouponAreaModel;
|
|
|
use app\common\model\CouponPlanLogModel;
|
|
|
use app\common\model\CouponPlanModel;
|
|
|
@@ -40,67 +41,261 @@ use think\Request;
|
|
|
use utils\Queue;
|
|
|
|
|
|
use jianyan\excel\Excel;
|
|
|
-use utils\WBAes;
|
|
|
-use utils\ZLAes;
|
|
|
|
|
|
class Test
|
|
|
{
|
|
|
-
|
|
|
- public function test3()
|
|
|
+ public function test5(Request $request)
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
+ $user_info = $request->user_info;
|
|
|
+ $userId = isset($user_info['id'])? $user_info['id'] : 0;
|
|
|
+ $cacheKey = "caches:box:rebuy:u_{$userId}";
|
|
|
+ $redis = new Redis();
|
|
|
+ if($redis->get($cacheKey)){
|
|
|
+ return api_succ_return('请不要频繁提交');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $redis->set($cacheKey,['uid'=> $request->uid, 'data'=> $request->post()], rand(2,3));
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+ if(rand(100,1000) > 500){
|
|
|
+ sr_throw('参数或状态错误');
|
|
|
+ }
|
|
|
+ $res = '';
|
|
|
+ //$res = $model->boxGoodsReBuy($request->uid, $request->post(), $request->user_info);
|
|
|
+ Db::commit();
|
|
|
+ }catch (\Exception $e){
|
|
|
+ Db::rollback();
|
|
|
+ $redis->del($cacheKey);
|
|
|
+ return api_error_return($e->getMessage());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ $redis->del($cacheKey);
|
|
|
+ $data = $redis->get($cacheKey);
|
|
|
+ var_dump($data);
|
|
|
+ if ($res){
|
|
|
+ return api_succ_return(['msg'=>'成功', 'data'=>$res]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return api_succ_return('成功');
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return 'success';
|
|
|
+
|
|
|
+ $users = Db::name('user')->where('score_account_id','<=',0)->field('id,mobile,money,score,remark')->select();
|
|
|
+
|
|
|
+ $count = 0;
|
|
|
+ $ids = [];
|
|
|
+ $ids1 = [];
|
|
|
+ if($users){
|
|
|
+
|
|
|
+ foreach ($users as $item){
|
|
|
+ /*
|
|
|
+ $moneyCount = Db::name('money_log')->where(['uid'=> $item['id']])
|
|
|
+ ->where('create_at','<=','2023-02-19 19:30:00')
|
|
|
+ ->count('id');
|
|
|
+
|
|
|
+ if($moneyCount<=0){
|
|
|
+ Db::name('user')->where(['id'=> $item['id']])->update(['remark'=>$item['remark'].'|更新余额:'.$item['money'].'++0','money'=> 0]);
|
|
|
+ echo '用户'.$item['id'].'处理成功<br>';
|
|
|
+ $ids[] = $item['id'];
|
|
|
+ $count++;
|
|
|
+ }else{
|
|
|
+ $ids1[] = $item['id'];
|
|
|
+ }
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ /*
|
|
|
+
|
|
|
+ $lastMoneyLog = Db::name('money_log')->where(['uid'=> $item['id']])
|
|
|
+ ->where('create_at','<=','2023-02-19 19:30:00')
|
|
|
+ ->order('create_at','desc')
|
|
|
+ ->order('id','desc')
|
|
|
+ ->find();
|
|
|
+
|
|
|
+ $lastMoneyId = isset($lastMoneyLog['id'])? $lastMoneyLog['id']:0;
|
|
|
+ $lastMoney = isset($lastMoneyLog['after_money'])? $lastMoneyLog['after_money']:0;
|
|
|
+
|
|
|
+ echo '处理用户:'.$item['id'].'++'.$item['money'].'++'.$lastMoneyId.'++'.$lastMoney."<br>";
|
|
|
+ if($lastMoneyLog && $lastMoneyId){
|
|
|
+ Db::name('user')->where(['id'=> $item['id']])->update(['remark'=>$item['remark'].'|更新余额:'.$item['money'].'++'.$lastMoney,'account_id'=> $lastMoneyId,'money'=> $lastMoney]);
|
|
|
+ echo '处理成功<br>';
|
|
|
+ $count++;
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $lastScoreLog = Db::name('score_log')
|
|
|
+ ->where(['uid'=> $item['id']])
|
|
|
+ ->where('create_at','<=','2023-02-19 19:30:00')
|
|
|
+ ->order('create_at','desc')
|
|
|
+ ->order('id','desc')
|
|
|
+ ->find();
|
|
|
+
|
|
|
+ $lastScoreId = isset($lastScoreLog['id'])? $lastScoreLog['id']:0;
|
|
|
+ $lastScore = isset($lastScoreLog['after_score'])? $lastScoreLog['after_score']:0;
|
|
|
+ echo '处理用户:'.$item['id'].'++'.$item['score'].'++'.$lastScoreId.'++'.$lastScore."<br>";
|
|
|
+ if($lastScoreLog && $lastScoreId){
|
|
|
+ Db::name('user')->where(['id'=> $item['id']])->update(['remark'=>$item['remark'].'|更新积分:'.$item['score'].'++'.$lastScore,'score_account_id'=> $lastScoreId,'score'=> $lastScore]);
|
|
|
+ echo '处理成功<br>';
|
|
|
+ $count++;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ echo "累计处理:".$count."<br>";
|
|
|
+ echo "累计ID:".implode(',', $ids)."<br>";
|
|
|
+ echo "累计ID1:".implode(',', $ids1)."<br>";
|
|
|
+ return 'success';
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function test4()
|
|
|
+ {
|
|
|
+
|
|
|
+ return false;
|
|
|
+ $count = 0;
|
|
|
+ $list = Db::name('money_log')->where(['type'=> 3])
|
|
|
+ ->where('from_id','>', 0)
|
|
|
+ ->where('create_at','>','2023-02-19 21:00:00')
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ foreach($list as $v){
|
|
|
+ echo "空盒退换余额记录:".$v['uid'].'+m+'.$v['money'].'+t+'.$v['type'].'++'.$v['state'].'++'.$v['from_id'].'<br>';
|
|
|
+
|
|
|
+ if($v['uid']){
|
|
|
+ $totalNum = Db::name('box_record')
|
|
|
+ ->where(['uid'=> $v['uid'],'pay_type'=>2])
|
|
|
+ ->where('create_time','>','2023-02-19 19:30:00')
|
|
|
+ ->sum('num');
|
|
|
+
|
|
|
+ $boxNum = Db::name('box_record')
|
|
|
+ ->where(['uid'=> $v['uid'],'pay_type'=>2])
|
|
|
+ ->where('create_time','>','2023-02-19 19:30:00')
|
|
|
+ ->sum(Db::raw('box10+box20+box30+box40'));
|
|
|
+
|
|
|
+ $emptyNum = $totalNum - $boxNum;
|
|
|
+
|
|
|
+ $backNum = Db::name('money_log')
|
|
|
+ ->where(['type'=> 3,'uid'=> $v['uid']])
|
|
|
+ ->where('from_id','>', 0)
|
|
|
+ ->where('create_at','>','2023-02-19 21:00:00')
|
|
|
+ ->count('id');
|
|
|
+
|
|
|
+ echo "用户空盒统计:".$v['uid'].'++'.$totalNum.'++'.$boxNum.'++应退'.$emptyNum.'++退了'.$backNum."个<br>";
|
|
|
+
|
|
|
+ $getNum = max(0, $backNum - $emptyNum);
|
|
|
+
|
|
|
+ /**
|
|
|
+ if($getNum>0){
|
|
|
+ $info = Db::name('user')->where(['id'=> $v['uid']])->field('id,money,score,profit_money')->find();
|
|
|
+ $money = $getNum * 288;
|
|
|
+
|
|
|
+ if(!Db::name('user')->where('id',$v['uid'])->dec('money', $money)->update()){
|
|
|
+ Db::rollback();
|
|
|
+ return '运行账户错误:'.$v['uid'].'++'.$money.'<br>';
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'uid'=>$v['uid'],
|
|
|
+ 'type'=> 98,
|
|
|
+ 'money'=> $money,
|
|
|
+ 'create_at'=> sr_getcurtime(time()),
|
|
|
+ 'state'=> 0,
|
|
|
+ 'before_money'=> $info['money'],
|
|
|
+ 'after_money'=> max(0, $info['money'] - $money),
|
|
|
+ 'from_id'=> 0,
|
|
|
+ 'uid2'=> 0,
|
|
|
+ 'free_type'=> 0
|
|
|
+ ];
|
|
|
+
|
|
|
+ if(!Db::name('money_log')->insertGetId($data)){
|
|
|
+ Db::rollback();
|
|
|
+ return '运行流水错误:'.$v['uid'].'+'.$money."<br>";
|
|
|
+ }
|
|
|
+
|
|
|
+ $count++;
|
|
|
+ }
|
|
|
+ **/
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ echo '合计处理:'.$count."个";
|
|
|
+ return 'success';
|
|
|
+ }
|
|
|
+
|
|
|
+ public function test3()
|
|
|
+ {
|
|
|
+ return false;
|
|
|
$temps = [];
|
|
|
$temps1 = [];
|
|
|
$userIds = [];
|
|
|
$lists = Db::name('user_unmoney')->where(['status'=>1])
|
|
|
- ->where('create_time','>','2023-02-19 21:00:00')
|
|
|
- ->select();
|
|
|
+ ->where('create_time','>','2023-02-19 21:00:00')
|
|
|
+ ->select();
|
|
|
foreach ($lists as $v){
|
|
|
$ids = isset($v['ids'])? $v['ids'] : '';
|
|
|
$ids = $ids? explode(',', $ids): [];
|
|
|
- $uid = isset($v['uid'])? $v['uid'] : 0;
|
|
|
- $mid = isset($v['id'])? $v['id'] : 0;
|
|
|
- $tempIds = [];
|
|
|
-
|
|
|
- Db::startTrans();
|
|
|
- echo 'IDS:'.$v['ids']."<br>";
|
|
|
- $profitTotal = $profitTotal1= $v['money'];
|
|
|
- foreach ($ids as $id){
|
|
|
- $info = Db::name('box_handle')->where('id','=', $id)->find();
|
|
|
- //var_dump($info);
|
|
|
- $rid = isset($info['rid'])? $info['rid'] : 0;
|
|
|
-
|
|
|
- if($rid && !isset($temps[$rid])){
|
|
|
- //Db::name('box_handle')->where('create_time','>','2023-02-19 19:30:00')->where(['id'=> $id])->update(['is_delete'=>1]);
|
|
|
+ $uid = isset($v['uid'])? $v['uid'] : 0;
|
|
|
+ $mid = isset($v['id'])? $v['id'] : 0;
|
|
|
+ $tempIds = [];
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ echo 'IDS:'.$v['ids']."<br>";
|
|
|
+ $profitTotal = $profitTotal1= $v['money'];
|
|
|
+ /**
|
|
|
+ foreach ($ids as $id){
|
|
|
+ $boxInfo = Db::name('box_handle')->where('id','=', $id)->find();
|
|
|
+ //var_dump($info);
|
|
|
+ $rid = isset($boxInfo['rid'])? $boxInfo['rid'] : 0;
|
|
|
+
|
|
|
+ if($rid && !isset($temps[$rid])){
|
|
|
+ //Db::name('box_handle')->where('create_time','>','2023-02-19 19:30:00')->where(['id'=> $id])->update(['is_delete'=>1]);
|
|
|
echo "保留:".$mid.'++'.$uid.'++'.$rid.'-'.$id."<br>";
|
|
|
-
|
|
|
+
|
|
|
$temps[$rid] = $rid;
|
|
|
$userIds[] = $uid;
|
|
|
$tempIds[] = $id;
|
|
|
}else{
|
|
|
- $goodsPrice = isset($info['goods_price'])? $info['goods_price'] : 0;
|
|
|
+ $goodsPrice = isset($boxInfo['goods_price'])? $boxInfo['goods_price'] : 0;
|
|
|
$sourcePrice = 288;
|
|
|
$fee = 10;
|
|
|
$backProfit = max(0, $goodsPrice - $fee - $sourcePrice);
|
|
|
$profitTotal = max(0, $profitTotal - $backProfit);
|
|
|
-
|
|
|
+
|
|
|
echo "清除:".$mid.'++'.$uid.'++'.$backProfit.'++'.$goodsPrice.'++'.$rid.'-'.$id."<br>";
|
|
|
$info = Db::name('user')->where(['id'=> $uid])->field('id,money,score,profit_money')->find();
|
|
|
-
|
|
|
-
|
|
|
- if(!Db::name('user')->where('id',$uid)->dec('money', $sourcePrice)){
|
|
|
+
|
|
|
+
|
|
|
+ if(!Db::name('user')->where('id',$uid)->dec('money', $sourcePrice)->update()){
|
|
|
Db::rollback();
|
|
|
- return $uid.'++'.$rid.'++'.$id;
|
|
|
+ return $uid.'+1+'.$rid.'++'.$id.'++'.$sourcePrice;
|
|
|
}
|
|
|
-
|
|
|
- if($backProfit>0 && !Db::name('user')->where(['id'=> $uid])->dec('profit_money', $backProfit)){
|
|
|
+
|
|
|
+ // return false;
|
|
|
+ if($backProfit>0 && !Db::name('user')->where(['id'=> $uid])->dec('profit_money', $backProfit)->update()){
|
|
|
Db::rollback();
|
|
|
- return $uid.'++'.$rid.'++'.$id;
|
|
|
+ return $uid.'+2+'.$rid.'++'.$id;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
$data = [
|
|
|
'uid'=>$uid,
|
|
|
- 'type'=> 99,
|
|
|
+ 'type'=> 98,
|
|
|
'money'=> $sourcePrice,
|
|
|
'create_at'=> sr_getcurtime(time()),
|
|
|
'state'=> 0,
|
|
|
@@ -110,40 +305,67 @@ class Test
|
|
|
'uid2'=> 0,
|
|
|
'free_type'=> 0
|
|
|
];
|
|
|
-
|
|
|
+
|
|
|
if(!Db::name('money_log')->insertGetId($data)){
|
|
|
Db::rollback();
|
|
|
- return $uid.'++'.$rid.'++'.$id;
|
|
|
+ return $uid.'+3+'.$rid.'++'.$id;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if(!Db::name('box_handle')->where('create_time','>','2023-02-19 19:30:00')->where(['id'=> $id])->update(['is_delete'=>1])){
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if($boxInfo['is_delete'] != 1 && !Db::name('box_handle')->where('create_time','>','2023-02-19 19:30:00')->where(['id'=> $id])->update(['is_delete'=>1,'update_time'=> date('Y-m-d H:i:s')])){
|
|
|
Db::rollback();
|
|
|
- return $uid.'++'.$rid.'++'.$id;
|
|
|
+ return $uid.'+4+'.$rid.'++'.$id;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
$temps1[] = $id;
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ //var_dump($tempIds);
|
|
|
+
|
|
|
+ if($profitTotal>0 && $profitTotal != $profitTotal1 && $mid && $tempIds && $temps1 && !Db::name('user_unmoney')->where(['status'=>1,'id'=> $mid])->update(['money'=> $profitTotal,'ids'=> implode(',', $tempIds)])){
|
|
|
+ Db::rollback();
|
|
|
+ return $uid.'+5+'.$mid;
|
|
|
+ }
|
|
|
+
|
|
|
+ **/
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+ echo "处理:".$mid."++".$uid.'++'.$profitTotal.'++'.$profitTotal1.'++'.($tempIds?implode(',', $tempIds):'')."<br>";
|
|
|
+ }
|
|
|
+
|
|
|
+ echo count($temps).'<br>';
|
|
|
+ echo count($temps1);
|
|
|
+ return 'success';
|
|
|
+ }
|
|
|
+
|
|
|
+ public function test2()
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ $temps = [];
|
|
|
+ $temps1 = [];
|
|
|
+ $userIds = [];
|
|
|
+ $lists = Db::name('box_handle')->where(['status'=>2,'handle_type'=>2])->where('create_time','>','2023-02-19 19:30:00')->select();
|
|
|
+ foreach ($lists as $v){
|
|
|
+ $rid = isset($v['rid'])? $v['rid'] : 0;
|
|
|
+ $id = isset($v['id'])? $v['id'] : 0;
|
|
|
+ $uid = isset($v['uid'])? $v['uid'] : 0;
|
|
|
+ if($rid && !isset($temps[$rid])){
|
|
|
+ //Db::name('box_handle')->where('create_time','>','2023-02-19 19:30:00')->where(['id'=> $id])->update(['is_delete'=>1]);
|
|
|
+
|
|
|
+
|
|
|
+ $temps[$rid] = $rid;
|
|
|
+ $userIds[] = $uid;
|
|
|
+ }else{
|
|
|
+ $price = $v['goods_price'];
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- if($profitTotal>0 && $mid && $tempIds && ! Db::name('user_unmoney')->where(['status'=>1,'id'=> $mid])->update(['money'=> $profitTotal,'ids'=> implode(',', $tempIds)])){
|
|
|
- Db::rollback();
|
|
|
- return $uid.'++'.$mid;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- Db::commit();
|
|
|
- echo "处理:".$mid."++".$uid.'++'.$profitTotal.'++'.$profitTotal1.'++'.implode(',', $tempIds)."<br>";
|
|
|
}
|
|
|
-
|
|
|
- echo count($temps).'<br>';
|
|
|
- echo count($temps1);
|
|
|
+
|
|
|
+ echo count($temps);
|
|
|
return 'success';
|
|
|
}
|
|
|
|
|
|
@@ -165,6 +387,7 @@ class Test
|
|
|
|
|
|
return date($format, $time);
|
|
|
}
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
@@ -184,7 +407,6 @@ class Test
|
|
|
}
|
|
|
|
|
|
public function test1(Request $request){
|
|
|
-
|
|
|
die();
|
|
|
$test_info = Db::name('test')->where('id', '=', 1)->lock(true)->find();//加锁查询
|
|
|
$test_info = Db::name('test')->where('id', '=', 1)->update(['msg'=>intval($test_info['msg'])+1]);
|
|
|
@@ -197,82 +419,8 @@ class Test
|
|
|
|
|
|
|
|
|
public function test(Request $request){
|
|
|
- edit_user_money(13, 5345140, 62.5);
|
|
|
-
|
|
|
- return 33;
|
|
|
- edit_user_recyclecard(4, 5347487,100);
|
|
|
- edit_user_recyclecard(4, 5347497,100);
|
|
|
- return 33;
|
|
|
-
|
|
|
- edit_user_money(12, 5344956, 60);
|
|
|
- edit_user_money(12, 5344956, 120);
|
|
|
-
|
|
|
- return 33;
|
|
|
-
|
|
|
- $md5Key = "&2QD=JFkOR9";
|
|
|
- $aesKey = "MsNWingUE5SwSoIgEfpltOaZ";
|
|
|
-// $timestamps = time();
|
|
|
- $timestamps = 1676617810;
|
|
|
-
|
|
|
- $plainText = md5($md5Key. ":" .$timestamps);
|
|
|
- $iv = substr($aesKey,0,16);
|
|
|
- $aesTool = new ZLAes($aesKey, 'AES-192-CBC', $iv);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-// echo "<hr />";
|
|
|
- $cipherText = $aesTool->encrypt($plainText);
|
|
|
-// echo '加密后的密文:'.$cipherText."<br />";
|
|
|
- $outPlainText = $aesTool->decrypt($cipherText);
|
|
|
-
|
|
|
- return $cipherText;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $md5Key = "&2QD=JFkOR9";
|
|
|
- $aesKey = "MsNWingUE5SwSoIgEfpltOaZ";
|
|
|
- $timestamps = time();
|
|
|
- $plainText = md5($md5Key. ":" .$timestamps);
|
|
|
- $iv = substr($aesKey,0,16);
|
|
|
-
|
|
|
-// 返回的iv的值
|
|
|
- // MsNWingUE5SwSoIg
|
|
|
- return $iv;
|
|
|
-
|
|
|
- return 33;
|
|
|
-
|
|
|
- // TDFyZ3n/5GksjKtjhj2G1w==
|
|
|
- return AESjiami('abcd123456');
|
|
|
- return 33;
|
|
|
-
|
|
|
-
|
|
|
-// edit_user_money(6, 5344920, 96);
|
|
|
-// edit_user_money(2, 5346907, 328);
|
|
|
- return 33;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-die();
|
|
|
-
|
|
|
- return 33;
|
|
|
-
|
|
|
-
|
|
|
- edit_user_money(15, 5344735, 350);
|
|
|
- edit_user_money(12, 5346184, 91);
|
|
|
- edit_user_money(12, 5346085, 83.5);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- $money = Db::name('money_log')->where('type', 1)->whereDay('create_at', 'today')->sum('money');
|
|
|
- $score = Db::name('score_log')->where('type', 1)->whereDay('create_at', 'today')->sum('score');
|
|
|
-
|
|
|
-return $money + $score;
|
|
|
-
|
|
|
- return Db::name('box_record')->where('box_id', 23426)->sum('num');
|
|
|
-// echo "<hr />";
|
|
|
-// return '解密后明文:'.$outPlainText."<br />";
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
// 13=>'提现失败退回
|
|
|
// edit_user_money(13, 5346035, 1518);
|