You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
1.8 KiB

7 years ago
  1. <?php
  2. namespace App\Http\Model;
  3. use App\Common\ReturnData;
  4. class Payment extends BaseModel
  5. {
  6. //用户优惠券
  7. protected $table = 'payment';
  8. public $timestamps = false;
  9. /**
  10. * 不能被批量赋值的属性
  11. *
  12. * @var array
  13. */
  14. protected $guarded = array();
  15. const STATUS = 1; // 可用支付方式
  16. //获取列表
  17. public static function getList(array $param)
  18. {
  19. extract($param); //参数:limit,offset
  20. $model = new Payment;
  21. if(isset($status) && $status!=-1){$where['status'] = $status;} //-1表示获取所有
  22. if(isset($where)){$model = $model->where($where);}
  23. $res['count'] = $model->count();
  24. $res['list'] = array();
  25. if($res['count']>0)
  26. {
  27. $res['list'] = $model->orderBy('listorder','desc')->get();
  28. }
  29. return $res;
  30. }
  31. public static function getOne($where)
  32. {
  33. return self::where($where)->first();
  34. }
  35. public static function add(array $data)
  36. {
  37. if(self::where(array('pay_code'=>$data['pay_code']))->first()){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'支付方式已存在');}
  38. if ($id = self::insertGetId($data))
  39. {
  40. return ReturnData::create(ReturnData::SUCCESS,$id);
  41. }
  42. return ReturnData::create(ReturnData::SYSTEM_FAIL);
  43. }
  44. public static function modify($where, array $data)
  45. {
  46. if (self::where($where)->update($data))
  47. {
  48. return true;
  49. }
  50. return false;
  51. }
  52. //删除一条记录
  53. public static function remove($id)
  54. {
  55. if (!self::whereIn('id', explode(',', $id))->delete())
  56. {
  57. return false;
  58. }
  59. return true;
  60. }
  61. }