RedStorePoolModel.php 898 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\common\model;
  3. use think\Exception;
  4. use think\Model;
  5. use think\facade\Db;
  6. class RedStorePoolModel extends Model
  7. {
  8. protected $name = 'red_store_pool';
  9. public function getUserStoreRedPoolList($uid, $limit, $request, $page)
  10. {
  11. $list = self::where(['uid'=>$uid])->page($page, $request->data['limit'])->order('status asc,create_at desc')->select()->toArray();
  12. return $list;
  13. }
  14. public function getStoreRed($request){
  15. $record = self::where(['id'=>$request->data['id']])->find();
  16. if (!$record){
  17. throw new Exception('id不存在');
  18. }
  19. if ($record['status'] == 2){
  20. throw new Exception('已领取');
  21. }
  22. self::where(['id'=>$request->data['id']])->save(['status'=>2, 'get_time'=>sr_getcurtime(time())]);
  23. edit_user_money(3, $request->uid, $record['money']);
  24. }
  25. }