|
|
@@ -18,7 +18,29 @@ class OrderItemController extends BaseController
|
|
|
//赠送花材 ssh 20230411
|
|
|
public function actionGiveItem()
|
|
|
{
|
|
|
- util::success([], '赠送成功');
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = $get['id'] ?? 0;
|
|
|
+ $num = $get['num'] ?? 0;
|
|
|
+ if (is_numeric($num) == false || $num <= 0) {
|
|
|
+ util::fail('请填写赠送数量');
|
|
|
+ }
|
|
|
+ $orderItem = OrderItemClass::getById($id, true);
|
|
|
+ if (empty($orderItem)) {
|
|
|
+ util::fail('没有找到花材');
|
|
|
+ }
|
|
|
+ if ($orderItem->mainId != $this->mainId) {
|
|
|
+ util::fail('没有权限操作');
|
|
|
+ }
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ $transaction->commit();
|
|
|
+ util::success([], '赠送成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("赠送出错了:" . $e->getMessage());
|
|
|
+ util::fail('出错了');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//重选花材 ssh 2021.3.2
|