123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace app\models\user;
- use think\Model;
- class UserPartake extends Model
- {
- protected $name = 'user_partake';
- protected $autoWriteTimestamp = true;
- /**
- * 参与累计金额
- * @param $order
- * @return void
- */
- public static function cumulative()
- {
- $user = User::select();
- foreach ($user as $item){
- $partake = UserPartake::where('uid', $item['uid'])->where('status', 0)->find();
- if ($partake){
- $out = Out::where('id', $partake['out_id'])->find();
- if ($item['pay_price'] >= $out['number']){
- User::where('uid', $item['uid'])->dec('pay_price', $out['number'])->update();
- User::where('uid', $item['uid'])->inc('use_price', $out['number'])->update();
- $partake['status'] = 1;
- $partake['money'] = $out['number'];
- $partake->save();
- }
- }
- }
- }
- }
|