|
|
@@ -9,7 +9,7 @@ use app\common\model\ProductOrder;
|
|
|
use think\Db;
|
|
|
use Exception;
|
|
|
use app\api\logic\WelfareLoginc;
|
|
|
-use app\common\model\UserModel;
|
|
|
+use app\common\model\UserSynthesis;
|
|
|
use app\common\model\Synthesis as SynthesisModel;
|
|
|
|
|
|
|
|
|
@@ -67,7 +67,7 @@ class Synthesis extends Api
|
|
|
/*
|
|
|
* 合成
|
|
|
*/
|
|
|
- public function create(ProductOrder $productOrder, UserModel $userModel)
|
|
|
+ public function create(ProductOrder $productOrder, UserSynthesis $userSynthesis)
|
|
|
{
|
|
|
$id = $this->request->post('id', 0, 'intval');
|
|
|
$num = $this->request->post('num', 0, 'intval');
|
|
|
@@ -76,7 +76,6 @@ class Synthesis extends Api
|
|
|
//合成详情
|
|
|
$synthesis = SynthesisModel::get($id);
|
|
|
if (empty($synthesis)) $this->error(__("合成活动不存在"));
|
|
|
-
|
|
|
$time = time();
|
|
|
if ($synthesis->start_time > $time || $synthesis->end_time < $time)$this->error(__("合成活动已结束"));
|
|
|
if ($synthesis->num + $num > $synthesis->stock)$this->error(__("库存不足"));
|
|
|
@@ -89,6 +88,9 @@ class Synthesis extends Api
|
|
|
|
|
|
// 添加新订单
|
|
|
WelfareLoginc::setUserProductOrder($num, 0, $synthesis->id, 0, $synthesis->product_id, $this->auth->id, $productOrder::Synthesi);
|
|
|
+
|
|
|
+ //合成记录
|
|
|
+ $userSynthesis::setUserSynthesisLog($this->auth->id, $id, $num, $productList);
|
|
|
|
|
|
$synthesis->num += $num;
|
|
|
$synthesis->save();
|