Commit 3342603a by lizhilin

更新

parent eb09e88e
......@@ -30,6 +30,7 @@ public function handle(array $input)
$order = OrderInfo::find($this->payload['id']);
$order->order_status = 2; //待领取状态
$order->verification_code = $code;
$order->verifi_code_at = date("Y-m-d H:i:s");
$order->save();
return $this->response()->success('确认成功')->refresh();
}
......
......@@ -44,14 +44,20 @@ public function add(Request $request)
$ogObj->is_comment = 1;
$ogObj->save();
}
DB::commit();
//2分钟执行订单分佣
$count = OrderGoods::where('order_id', $oid)->where('is_comment', 0)->count();
Log::add('订单商品评论' . $og_id, ['num' => $count]);
if ($count == 0) {
Log::add('调用分佣', $orderObj->toArray());
$this->dispatch(new AutoCompleteOrder($orderObj, 10));
if ($useObj->spuid || $useObj->merchant_id) {
$orderObj->is_commission = 1;
$orderObj->order_status = 4;
$orderObj->save();
}
// Log::add('调用分佣', $orderObj->toArray());
// $this->dispatch(new AutoCompleteOrder($orderObj, 10));
}
DB::commit();
return $this->JsonResponse('');
} catch (\Exception $exception) {
Log::add('添加评论失败', $exception->getMessage());
......
......@@ -72,7 +72,12 @@ public function add(Request $request)
if ($balance < $money) {
return $this->JsonResponse('', '余额不足', 500);
}
$exist = Income::where(['user_type' => $type, 'um_id' => $um_id])
->orderBy('id', 'DESC')
->first();
if ($exist) {
return $this->JsonResponse('', '提现审核中!', 500);
}
DB::beginTransaction();
try {
$comObj = new Income();
......
......@@ -3,6 +3,8 @@
namespace App\Http\Controllers\Api;
use App\Command\Log;
use App\Models\OrderInfo as OrderInfoModel;
use App\Models\OrderDivideRecord;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
......@@ -22,4 +24,60 @@ public function update(Request $request)
return $this->JsonResponse('');
}
//定时任务--待领取状态下七天未领取,自动到待评价状态
public function autoChangeReceiveStatus()
{
$chunkSize = 50; // 每次处理的订单数量
$orders = OrderInfoModel::where(["order_status" => 2])->whereNull('verification_at')->whereNotNull('verifi_code_at')->orderBy('id')->take($chunkSize);
while ($orders->count() > 0) {
$orders->chunk($chunkSize, function ($batch) {
foreach ($batch as $order) {
$nowtime = time();
if ($order->verifi_code_at) {
$wait_time = strtotime($order->verifi_code_at);
$diff_time = $nowtime - $wait_time;
$d = $diff_time / 86400;
if ($d >= 7) {
$order->order_status = 3;
$order->save();
}
}
}
});
// 移动游标到下一批
$orders->skip($chunkSize);
$orders = $orders->getQuery();
sleep(2);
}
return '--ok--';
}
//定时任务--订单分佣
public function autoOrderCommission()
{
$chunkSize = 50; // 每次处理的订单数量
$orders = OrderInfoModel::where(["order_status" => 4, 'is_commission' => 1])->orderBy('id')->take($chunkSize);
while ($orders->count() > 0) {
$orders->chunk($chunkSize, function ($batch) {
foreach ($batch as $order) {
//佣金分配
$res = OrderDivideRecord::divide($order->id);
if ($res) {
$order->is_commission = 2;
$order->save();
}
}
});
// 移动游标到下一批
$orders->skip($chunkSize);
$orders = $orders->getQuery();
sleep(3);
}
return '--ok--';
}
}
......@@ -369,14 +369,19 @@ public function share(Request $request)
if (!$spObj) {
return $this->JsonResponse('', '参数错误', 201);
}
//分享人注册时间
$sp_time = strtotime($spObj->created_at);
$userObj = $request->user();
$user_id = $userObj->id;
$spuid = $userObj->spuid; //是否已有推荐人
if (!$spuid && $user_id != $shuid) {
$userObj->spuid = $shuid; //直推
$userObj->second_spuid = $spObj->spuid; //间推
$userObj->save();
$user_time = strtotime($userObj->created_at);
if ($user_time > $sp_time) {
$user_id = $userObj->id;
$spuid = $userObj->spuid; //是否已有推荐人
if (!$spuid && $user_id != $shuid) {
$userObj->spuid = $shuid; //直推
$userObj->second_spuid = $spObj->spuid; //间推
$userObj->save();
}
}
return $this->JsonResponse('');
}
......
......@@ -69,6 +69,7 @@ public static function divide($order_id)
self::addRecord($item->id, $order_id, $goods_amount, $divide_price, $merchant_commission, $merchant_id, $user_id, 3);
}
}
return true;
}
public static function addRecord($og_id, $order_id, $goods_amount, $divide_price, $commission, $um_id, $user_id, $sh_type)
......
......@@ -74,6 +74,10 @@
Route::get('send/config/update', 'SystemController@update');
Route::get('auto-to-commentstatus', 'SystemController@autoChangeReceiveStatus'); //定时任务--待领取状态下七天未领取,自动到待评价状态
Route::get('auto-order-commission', 'SystemController@autoOrderCommission'); //定时完成--订单完成后分佣
Route::middleware('auth:sanctum')->group(function () {
Route::get('user-info', 'UserController@info'); //获取小程序端用户资料
......
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 to comment