Commit 44296154 by 朱继来

设置样片过期接口

parent f0275b78
......@@ -5,12 +5,15 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\UserMainModel;
use App\Model\UserInfoModel;
use App\Model\UserCompanyModel;
use App\Model\OrderModel;
use App\Model\OrderPriceModel;
use App\Model\OrderInvoiceModel;
use App\Model\OrderActionLogModel;
use App\Model\PayLogModel;
use App\Model\UserSampleApplyModel;
use App\Model\UserSampleInviteModel;
use DB;
use Excel;
use Log;
......@@ -318,4 +321,28 @@ class SpecialController extends Controller
return '调整成功';
}
// 自营样片设置过期,剩余领取机会归零,不在领取表的用户默认1次领取机会
public function setSampleExpire()
{
$UserInfoModel = new UserInfoModel;
$UserSampleApplyModel = new UserSampleApplyModel;
$UserSampleInviteModel = new UserSampleInviteModel;
$res = $UserSampleApplyModel->where('is_expire', 1)->update(['is_expire' => -1]);
dump($res);
$res = $UserSampleInviteModel->where('is_expire', 1)->update(['is_expire' => -1]);
dump($res);
$user_ids = $UserSampleApplyModel->where('is_expire', -1)->groupBy('user_id')->lists('user_id')->toArray();
if ($user_ids) {
$res = $UserInfoModel->whereIn('user_id', $user_ids)->update(['apply_count' => 0]);
dump($res);
$res = $UserInfoModel->whereNotIn('user_id', $user_ids)->where('apply_count', '>', 1)->update(['apply_count' => 1]);
dump($res);
}
}
}
\ No newline at end of file
......@@ -42,10 +42,10 @@ Route::group(['middleware' => 'web'], function () {
Route::get('/change/{id}', 'OrderController@changeOrder');
Route::match(['get', 'post'], '/sendSales/{id?}', 'OrderController@sendSales');
Route::post('/ajaxdeletegoods', 'OrderController@ajaxdeletegoods');
Route::post('/ajaxSaveChange', 'OrderController@ajaxSaveChange');
Route::post('/ajaxApplyManagerAudit', 'OrderController@ajaxApplyManagerAudit');
Route::post('/ajaxAuditPass', 'OrderController@ajaxAuditPass');
Route::post('/ajaxReAudit', 'OrderController@ajaxReAudit');
Route::post('/ajaxSaveChange', 'OrderController@ajaxSaveChange');
Route::post('/ajaxApplyManagerAudit', 'OrderController@ajaxApplyManagerAudit');
Route::post('/ajaxAuditPass', 'OrderController@ajaxAuditPass');
Route::post('/ajaxReAudit', 'OrderController@ajaxReAudit');
Route::get('/check/{id}', 'OrderController@check');
Route::match(['get', 'post'], '/applyAdjust/{id}', 'OrderController@applyAdjust');
Route::match(['get', 'post'], '/send/{id}', 'OrderController@send');
......@@ -159,14 +159,15 @@ Route::group(['middleware' => 'api'], function () {
Route::get ('/api/check/sendsms', 'OrderController@checkOrderSendSms');
Route::get ('/api/check/cancelorder', 'OrderController@checkOrderCancel');
Route::get ('/api/check/histroyorder', 'OrderController@checkHistroyOrder');
Route::get('/act/useramount', 'CronController@userAmount'); // 活动统计用户实付金额
Route::get('/act/clear', 'CronController@clearData'); // 清除活动统计用户表和缓存
Route::get('/act/sendactmsg', 'CronController@sendActMsg'); // 推送活动短信
Route::get ('/api/check/changeprice', 'SpecialController@changeOrderPrice');
Route::get ('/api/check/exportdimission', 'SpecialController@exportDimission');
Route::match (['get', 'post'], '/api/check/importdimission', 'SpecialController@importDimission');
Route::get('/act/useramount', 'CronController@userAmount'); // 活动统计用户实付金额
Route::get('/act/clear', 'CronController@clearData'); // 清除活动统计用户表和缓存
Route::get ('/handle/paylog', 'SpecialController@handlePayLog'); // 处理支付记录
Route::get('/act/sendactmsg', 'CronController@sendActMsg'); // 推送活动短信
Route::get ('/handle/paytype', 'SpecialController@changeOrderPayType'); // 自营更改预付款支付方式
Route::get ('/handle/sample', 'SpecialController@setSampleExpire'); // 设置自营样片过期
Route::post('/hprose/service', function (Request $request) {
$server = new \App\Services\ExportService();
......
......@@ -13,6 +13,7 @@ class UserSampleApplyModel extends Model
protected $primaryKey = 'apply_id';
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = null;
/** * @param \DateTime|int $value * @return false|int * @author dividez */
public function fromDateTime($value)
......@@ -99,8 +100,8 @@ class UserSampleApplyModel extends Model
$v['work_function'] = $UserInfoModel->getWorkFunction($v['user_id']);
$v['invite_count'] = $UserSampleInviteModel->getUserInviteCount($v['user_id']);
$v['apply_num_total'] = $this->getSampleApplySum($v['user_id']); // 获取指定用户申请的样片总数
// $v['quota_total'] = $this->getSampleApplySum($v['user_id'], 'quota'); // 获取指定用户申请的样片总
$v['quota_total'] = $this->getUsedCount($v['user_id']); // 获取指定用户申请的样片消耗总人数
$v['quota_total'] = $this->getSampleApplySum($v['user_id'], 'quota'); // 获取指定用户申请的样片消耗总人
// $v['quota_total'] = $this->getUsedCount($v['user_id']); //
$v['apply_count'] = $UserInfoModel->getUserApplyCount($v['user_id']);
}
......@@ -113,20 +114,9 @@ class UserSampleApplyModel extends Model
return $this->from('lie_user_sample_apply as s')
->join('lie_order as o', 's.order_id', '=', 'o.order_id')
->where('s.user_id', '=', $user_id)
->where('s.is_expire', '=', 1)
->where('o.status', '<>', '-1')
->sum('apply_num');
// return $this->where('user_id', $user_id)->sum($field);
}
// 获取指定用户申请的样片消耗总人数
public function getUsedCount($user_id)
{
return $this->from('lie_user_sample_apply as s')
->join('lie_order as o', 's.order_id', '=', 'o.order_id')
->where('s.user_id', '=', $user_id)
->where('o.status', '<>', '-1')
->sum('quota');
->sum($field);
}
// 获取领取记录
......@@ -160,7 +150,7 @@ class UserSampleApplyModel extends Model
$order = $OrderModel->where('order_id', $v['order_id'])->select('status')->first();
if (!$order) continue;
$v['order_status'] = Config('params.order_status')[$order->status];
}
......
......@@ -13,6 +13,7 @@ class UserSampleInviteModel extends Model
protected $primaryKey = 'invite_id';
public $timestamps = true;
const CREATED_AT = 'create_time';
const UPDATED_AT = null;
/** * @param \DateTime|int $value * @return false|int * @author dividez */
public function fromDateTime($value)
......@@ -41,7 +42,7 @@ class UserSampleInviteModel extends Model
// 获取指定用户邀约人数
public function getUserInviteCount($user_id)
{
return $this->where('user_id', $user_id)->count();
return $this->where('user_id', $user_id)->where('is_expire', 1)->count();
}
// 获取用户邀约列表
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment