123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- namespace App\Modules\Ali\Models;
- use DB;
- use Illuminate\Database\Eloquent\Model;
- class AliSendOrder extends Model
- {
- protected $table = 'ali_send_orders';
- protected $fillable = [
- 'name',
- 'promotion_type',
- 'distribution_channel_id',
- 'fan_num',
- 'cost',
- 'is_enable',
- 'pre_send_date',
- 'star_num',
- 'remark',
- 'send_time'
- ];
-
- /**
- * 创建推广派单
- */
- static function createOrder($data)
- {
- return self::firstOrCreate($data);
- }
- /**
- * 删除派单
- * @param $id 派单id
- * @param $distribution_channel_id 渠道id
- * @return
- */
- static function removeSendOrder($id, $distribution_channel_id)
- {
- return self::where('id', $id)->where('distribution_channel_id', $distribution_channel_id)->update(['is_enable' => 0]);
- }
-
- /**
- * 获取派单信息
- */
- static function search($params, $isAll = false)
- {
- $search_object = self::where('is_enable', 1)->orderBy('id', 'desc');
-
- if (isset($params['distribution_channel_id']) && $params['distribution_channel_id']) {
- $search_object->where('ali_send_orders.distribution_channel_id', $params['distribution_channel_id']);
- }
-
- if (isset($params['name']) && $params['name']) {
- $search_object->where('ali_send_orders.name', 'like', '%' . $params['name'] . '%');
- }
-
- if (isset($params['start_time']) && $params['start_time']) {
- $search_object->where('ali_send_orders.created_at', '>=', $params['start_time']);
- }
-
- if (isset($params['end_time']) && $params['end_time']) {
- $search_object->where('ali_send_orders.created_at', '<=', $params['end_time']);
- }
-
- if (isset($params['send_time_start_time']) && $params['send_time_start_time']) {
- $search_object->where('ali_send_orders.send_time', '>=', $params['send_time_start_time']);
- }
-
- if (isset($params['send_time_end_time']) && $params['send_time_end_time']) {
- $search_object->where('ali_send_orders.send_time', '<=', $params['send_time_end_time']);
- }
-
- if (isset($params['pre_send_date_end']) && $params['pre_send_date_end']) {
- $search_object->where('ali_send_orders.pre_send_date', '<=', $params['pre_send_date_end']);
- }
-
- if (isset($params['pre_send_date_start']) && $params['pre_send_date_start']) {
- $search_object->where('ali_send_orders.pre_send_date', '>=', $params['pre_send_date_start']);
- }
-
- if (isset($params['start_send_time']) && $params['start_send_time']) {
- $search_object->where('ali_send_orders.send_time', '>=', $params['start_send_time']);
- }
-
- if (isset($params['end_send_time']) && $params['end_send_time']) {
- $search_object->where('ali_send_orders.send_time', '<=', $params['end_send_time']);
- }
-
- if (isset($params['promotion_type']) && $params['promotion_type']) {
- $search_object->where('ali_send_orders.promotion_type', $params['promotion_type']);
- }
-
- if (isset($params['id']) && $params['id']) {
- $search_object->where('ali_send_orders.id', $params['id']);
- }
- if ($isAll) {
- return $search_object->get();
- } else {
- return $search_object->paginate();
- }
- }
-
-
- }
|