WechatPlanRecord.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class WechatPlanRecord extends Model
  5. {
  6. // 自动写入时间戳字段
  7. protected $autoWriteTimestamp = 'int';
  8. // 定义时间戳字段名
  9. protected $createTime = 'createtime';
  10. protected $updateTime = 'updatetime';
  11. public function getIsOpenList()
  12. {
  13. return ['0' => __('Is_open 0'), '1' => __('Is_open 1')];
  14. }
  15. public static function getNewCode()
  16. {
  17. do {
  18. list($msec, $sec) = explode(' ', microtime());
  19. $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
  20. $orderId = 'qy' . $msectime . mt_rand(10000, 99999);
  21. } while (self::where(['contract_code' => $orderId])->find());
  22. return $orderId;
  23. }
  24. public static function plan_lst($where)
  25. {
  26. $model = new self;
  27. $xwhere = null;
  28. $order = "id desc";
  29. if (isset($where['uid']) && $where['uid'] > 0) $xwhere['uid'] = $where['uid'];
  30. if (isset($where['cid']) && $where['cid'] > 0) $xwhere['cid'] = $where['cid'];
  31. $data = $model->where($xwhere)->where('is_signing',0)->order($order)->field('id')->select();
  32. $plan=new WechatPlan();
  33. $data2=$plan->where('id','in',$data)->select();
  34. // $count = $plan->where('id','in',$data)->count();
  35. return $data2;
  36. }
  37. public static function record_lst($where)
  38. {
  39. $model = new self;
  40. $xwhere = null;
  41. $order = "id desc";
  42. if (isset($where['uid']) && $where['uid'] > 0) $xwhere['uid'] = $where['uid'];
  43. if (isset($where['cid']) && $where['cid'] > 0) $xwhere['cid'] = $where['cid'];
  44. if (isset($where['category_id']) && $where['category_id'] > 0) $xwhere['category_id'] = $where['category_id'];
  45. $data = $model->where($xwhere)->where('is_signing',0)->order($order)->select();
  46. $count = $model->where($xwhere)->count();
  47. return compact('count', 'data');
  48. }
  49. }