| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace app\common\model;
- class CustomerZueCoinModel extends BaseModel
- {
- protected $table = 'erp_customer_zue_coin';
- protected function genSchema(array $schema)
- {
- // TODO: Implement genSchema() method.
- }
- /**
- * @return \think\model\relation\HasOne
- */
- public function customer()
- {
- return self::hasOne(CustomerModel::class,'id','customer_id')->where('is_delete',0);
- }
- public function record() {
- return self::hasMany(ZueCoinRecordModel::class,'zue_coin_id','id')->where('is_delete',0)->order('create_time', 'desc');
- }
- /**
- * @param array $params
- * @return \think\Paginator
- * @throws \think\db\exception\DbException
- */
- public function findByPaginate(array $params) {
- $where = [];
- if ($params['customer']) {
- $where = [['id|name_zh|name_en', 'like', '%'.$params['customer'].'%']];
- }
- return $this->where('erp_customer_zue_coin.is_delete',0)
- ->with('customer')
- ->hasWhere('customer', $where)
- ->paginate(['list_rows'=>10, "query" => $params]);
- }
- public function findById($id) {
- return $this->where([
- ['id' ,'=', $id],
- ['is_delete', '=', 0]
- ])->with(['customer', 'record'])->find();
- }
- public function findByCustomerId($c_id) {
- return $this->where([
- ['is_delete', '=', 0],
- ['customer_id', '=', $c_id],
- ['lose_time', '>=', time()],
- ])->order('lose_time', 'Asc')->find();
- }
- }
|