WechatPlanRecord.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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('plan_id')->select();
  32. // var_dump($data);
  33. // $plan=new WechatPlan();
  34. // $data2=$plan->where('plan_id','in',['188873'])->select();
  35. // var_dump($data2);die();
  36. //// $count = $plan->where('id','in',$data)->count();
  37. // return $data2;
  38. // }
  39. public static function record_lst($where)
  40. {
  41. $model = new self;
  42. $xwhere = null;
  43. $order = "id desc";
  44. if (isset($where['uid']) && $where['uid'] > 0) $xwhere['uid'] = $where['uid'];
  45. if (isset($where['cid']) && $where['cid'] > 0) $xwhere['cid'] = $where['cid'];
  46. $data = $model->where($xwhere)->where('is_signing',0)->order($order)->select();
  47. $count = $model->where($xwhere)->count();
  48. return compact('count', 'data');
  49. }
  50. public static function record_info($where)
  51. {
  52. $model = new self;
  53. $xwhere = null;
  54. $order = "id desc";
  55. if (isset($where['id']) && $where['id'] > 0) $xwhere['id'] = $where['id'];
  56. if (isset($where['cid']) && $where['cid'] > 0) $xwhere['cid'] = $where['cid'];
  57. if (isset($where['uid']) && $where['uid'] > 0) $xwhere['uid'] = $where['uid'];
  58. // if (isset($where['category_id']) && $where['category_id'] > 0) $xwhere['category_id'] = $where['category_id'];
  59. $data = $model->where($xwhere)->where('is_signing',0)->order($order)->find();
  60. $count = $model->where($xwhere)->count();
  61. $laveMonth = new LaveMonth();
  62. $list = $laveMonth->where('user_id', $data['uid'])->where('cid',$data['cid'])->where('order_name', $data['order_name'])->select();
  63. return compact('count', 'data','list');
  64. }
  65. }