WechatPlanRecord.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. $model = $model->where('is_signing','<>',2);
  47. $data = $model->where($xwhere)->order($order)->select();
  48. $wechatPlan = new WechatPlan();
  49. foreach ($data as $k => $v){
  50. $data[$k]['image'] = $wechatPlan->where('plan_id', $v['plan_id'])->value('image');
  51. }
  52. $count = $model->where($xwhere)->count();
  53. return compact('count', 'data');
  54. }
  55. public static function record_info($where)
  56. {
  57. $model = new self;
  58. $xwhere = null;
  59. $order = "id desc";
  60. if (isset($where['id']) && $where['id'] > 0) $xwhere['id'] = $where['id'];
  61. if (isset($where['cid']) && $where['cid'] > 0) $xwhere['cid'] = $where['cid'];
  62. if (isset($where['uid']) && $where['uid'] > 0) $xwhere['uid'] = $where['uid'];
  63. // if (isset($where['category_id']) && $where['category_id'] > 0) $xwhere['category_id'] = $where['category_id'];
  64. $model = $model->where('is_signing','<>',2);
  65. $data = $model->where($xwhere)->order($order)->find();
  66. $count = $model->where($xwhere)->count();
  67. $laveMonth = new LaveMonth();
  68. $list = $laveMonth->where('user_id', $data['uid'])->where('cid',$data['cid'])->where('record_id',$data['id'])->select();
  69. return compact('count', 'data','list');
  70. }
  71. }