| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace app\common\model;
- class OrderProductModel extends BaseModel
- {
- protected $table = 'erp_order_product';
- protected function genSchema(array $schema)
- {
- // TODO: Implement genSchema() method.
- }
- /**
- * @param $o_id
- * @return OrderProductModel[]|array|\think\Collection
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function findByOrderId($o_id) {
- return $this->where('is_delete', 0)
- ->where('order_id',$o_id)
- ->select();
- }
- /**
- * @param $c_id
- * @param int $is_upload_numerology
- * @param int $is_upload
- * @return int
- * @throws \think\db\exception\DbException
- */
- public function countByCustomerId($c_id, $is_upload_numerology = 1, $is_upload = null) {
- $where = [
- ['is_delete', '=', 0],
- ['customer_id', '=', $c_id],
- ['is_upload_numerology', '=', $is_upload_numerology]
- ];
- if ($is_upload) {
- array_push($where,['is_upload', '=', $is_upload]);
- }
- return $this->where($where)
- ->count();
- }
- public function countByAdviser($adviser_1_id,$start_time = null, $end_time = null) {
- $where = [
- ['is_delete', '=', 0],
- ['adviser_1_id', '=', $adviser_1_id],
- ];
- if($start_time) array_push($where, ['create_time', '>=', $start_time]);
- if($end_time) array_push($where, ['create_time', '<=', $end_time]);
- return [
- $this->where($where)->sum('real_price'),
- $this->where(array_merge($where,[
- ['is_upload_numerology', '=', 1],
- ['is_upload', '=', 1]
- ]))->count(),
- $this->where([
- ['is_delete', '=', 0],
- ['adviser_1_id', '=', $adviser_1_id],
- ['is_upload_numerology', '=', 1],
- ])->count(),
- $this->where([
- ['is_delete', '=', 0],
- ['adviser_1_id', '=', $adviser_1_id],
- ['is_serve', '=', 0],
- ])->sum('real_price'),
- $this->where([
- ['is_delete', '=', 0],
- ['adviser_1_id', '=', $adviser_1_id],
- ['teacher_id', '>', 0],
- ])->sum('real_price'),
- $this->where([
- ['is_delete', '=', 0],
- ['adviser_1_id', '=', $adviser_1_id],
- ['is_serve', '=', 1],
- ])->sum('real_price'),
- ];
- }
- public function groupByAdviser($adviser_1_id, $start_time = null, $end_time = null) {
- return $this->where([
- ['is_delete', '=', 0],
- ['adviser_1_id', '=', $adviser_1_id],
- ])->sum('real_price');
- }
- }
|