WechatPlanRecord.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. if (isset($where['category_id']) && $where['category_id'] > 0) $xwhere['category_id'] = $where['category_id'];
  47. $data = $model->where($xwhere)->where('is_signing',0)->order($order)->select();
  48. $count = $model->where($xwhere)->count();
  49. return compact('count', 'data');
  50. }
  51. }