Commit 9353698a authored by 刘小敏's avatar 刘小敏

AI试戴接口优化

parent 89218a74
...@@ -135,6 +135,7 @@ class AiTryon extends Common ...@@ -135,6 +135,7 @@ class AiTryon extends Common
// 'goods_title' => $params['goods_title'], // 'goods_title' => $params['goods_title'],
// 'goods_subtitle' => $params['goods_subtitle'], // 'goods_subtitle' => $params['goods_subtitle'],
// 'goods_image' => $params['jewelry_image'], // 'goods_image' => $params['jewelry_image'],
// 'person_image' => $params['person_image'],
// 'ai_task_id' => '', // 'ai_task_id' => '',
// 'ai_type' => 0, // 'ai_type' => 0,
// ]; // ];
...@@ -161,6 +162,10 @@ class AiTryon extends Common ...@@ -161,6 +162,10 @@ class AiTryon extends Common
// $tryonData['ai_status'] = 1; // $tryonData['ai_status'] = 1;
// $tryonData['ai_url'] = config('shopro.api_host') . $attachment['data']; // $tryonData['ai_url'] = config('shopro.api_host') . $attachment['data'];
// $tryonModel->save($tryonData); // $tryonModel->save($tryonData);
// //试戴次数+1
// $userService = new User();
// $res = $userService->addTryTimes($user->id);
// //
// $this->success($res['msg'], config('shopro.api_host') . $attachment['data']); // $this->success($res['msg'], config('shopro.api_host') . $attachment['data']);
// } // }
...@@ -227,6 +232,7 @@ class AiTryon extends Common ...@@ -227,6 +232,7 @@ class AiTryon extends Common
// 'goods_title' => $params['goods_title'], // 'goods_title' => $params['goods_title'],
// 'goods_subtitle' => $params['goods_subtitle'], // 'goods_subtitle' => $params['goods_subtitle'],
// 'goods_image' => $params['jewelry_image'], // 'goods_image' => $params['jewelry_image'],
// 'person_image' => $params['person_image'],
// 'ai_type' => 1, // 'ai_type' => 1,
// ]; // ];
// //
...@@ -245,6 +251,10 @@ class AiTryon extends Common ...@@ -245,6 +251,10 @@ class AiTryon extends Common
// $tryonData['ai_task_id'] = isset($res['data']) ? $res['data'] : ''; // $tryonData['ai_task_id'] = isset($res['data']) ? $res['data'] : '';
// $tryonModel->save($tryonData); // $tryonModel->save($tryonData);
// $id = $tryonModel->id; // $id = $tryonModel->id;
// //试戴次数+1
// $userService = new User();
// $res = $userService->addTryTimes($user->id);
// //
// // 推送队列 // // 推送队列
// \think\Queue::push('\addons\shopro\job\AiVideoGen@save', ['taskid' => $res['data'], 'user' => $user], 'shopro-high'); // \think\Queue::push('\addons\shopro\job\AiVideoGen@save', ['taskid' => $res['data'], 'user' => $user], 'shopro-high');
......
...@@ -101,6 +101,7 @@ class Order ...@@ -101,6 +101,7 @@ class Order
if ($order->type == 'goods' && $order->deduct_score){ if ($order->type == 'goods' && $order->deduct_score){
// 这里会自动检测订单支付状态 // 这里会自动检测订单支付状态
$order = $payOper->score($order, $order->deduct_score); $order = $payOper->score($order, $order->deduct_score);
} }
// 删除购物车 // 删除购物车
......
...@@ -53,9 +53,32 @@ class User ...@@ -53,9 +53,32 @@ class User
} else { } else {
$ai_count = intval($res->ai_count)+1; $ai_count = intval($res->ai_count)+1;
} }
userModel::where('id', $user_id)->update(['ai_count' => $ai_count, 'ai_time' => time()]); // userModel::where('id', $user_id)->update(['ai_count' => $ai_count, 'ai_time' => time()]);
return 1; // 可以试戴 return 1; // 可以试戴
} }
} }
/**
* @name 试戴次数+1
* @param int|object $user 会员对象或会员ID
* @return int
*/
public function addTryTimes($user_id)
{
// 查询我的试戴列表
$res = userModel::where('id', $user_id)
->find();
if ($res->ai_count > 4 && $res->ai_time > Time::today()[0]) {
return 0; // 不可以试戴
} else {
if($res->ai_time < Time::today()[0]) {
$ai_count = 1;
} else {
$ai_count = intval($res->ai_count)+1;
}
userModel::where('id', $user_id)->update(['ai_count' => $ai_count, 'ai_time' => time()]);
return 1; // 可以试戴
}
}
} }
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