| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?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],
- ['lose_time', '<=', time()],
- ])->order('lose_time', 'Asc')->find();
- }
- }
|