|
|
@@ -16,47 +16,6 @@ class OrderItemController extends BaseController
|
|
|
|
|
|
public $guestAccess = [];
|
|
|
|
|
|
- //更换花材 ssh 20240430
|
|
|
- public function actionChangeItem()
|
|
|
- {
|
|
|
- $post = Yii::$app->request->post();
|
|
|
- $delId = $post['delId'] ?? 0;
|
|
|
- $orderSn = $post['orderSn'] ?? '';
|
|
|
- $num = $post['num'] ?? 0;
|
|
|
- $price = $post['price'] ?? 0;
|
|
|
- $productId = $post['productId'] ?? 0;
|
|
|
- $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
|
|
|
- if (empty($order)) {
|
|
|
- util::fail('订单没有找到哦');
|
|
|
- }
|
|
|
- if ($order->mainId != $this->mainId) {
|
|
|
- util::fail('不是你的订单');
|
|
|
- }
|
|
|
- $delInfo = OrderItemClass::getById($delId, true);
|
|
|
- if (empty($delInfo)) {
|
|
|
- util::fail('没有找到要删除的花材');
|
|
|
- }
|
|
|
- if ($delInfo->orderSn != $orderSn) {
|
|
|
- util::fail('这个花材你不能删除');
|
|
|
- }
|
|
|
- $connection = Yii::$app->db;//事务处理
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
-
|
|
|
- OrderItemClass::bookDelItem($order, $delId);
|
|
|
-
|
|
|
- $new = [];
|
|
|
- $new[$productId] = ['num' => $num, 'productId' => $productId, 'price' => $price];
|
|
|
- OrderItemClass::bookAddItem($order, $new);
|
|
|
- $transaction->commit();
|
|
|
- util::complete('更换成功');
|
|
|
- } catch (\Exception $e) {
|
|
|
- $transaction->rollBack();
|
|
|
- Yii::info("出错了:" . $e->getMessage());
|
|
|
- util::fail('出错了');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
//过滤名称 ssh 20240429
|
|
|
public function actionFilterName()
|
|
|
{
|
|
|
@@ -131,6 +90,45 @@ class OrderItemController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //更换花材 ssh 20240430
|
|
|
+ public function actionChangeItem()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $delId = $post['delId'] ?? 0;
|
|
|
+ $orderSn = $post['orderSn'] ?? '';
|
|
|
+ $num = $post['num'] ?? 0;
|
|
|
+ $price = $post['price'] ?? 0;
|
|
|
+ $productId = $post['productId'] ?? 0;
|
|
|
+ $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
|
|
|
+ if (empty($order)) {
|
|
|
+ util::fail('订单没有找到哦');
|
|
|
+ }
|
|
|
+ if ($order->mainId != $this->mainId) {
|
|
|
+ util::fail('不是你的订单');
|
|
|
+ }
|
|
|
+ $delInfo = OrderItemClass::getById($delId, true);
|
|
|
+ if (empty($delInfo)) {
|
|
|
+ util::fail('没有找到要删除的花材');
|
|
|
+ }
|
|
|
+ if ($delInfo->orderSn != $orderSn) {
|
|
|
+ util::fail('这个花材你不能删除');
|
|
|
+ }
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ OrderItemClass::delBookItem($order, $delId);
|
|
|
+ $new = [];
|
|
|
+ $new[$productId] = ['num' => $num, 'productId' => $productId, 'price' => $price];
|
|
|
+ OrderItemClass::addBookItemFn($order, $new);
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete('更换成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("出错了:" . $e->getMessage());
|
|
|
+ util::fail('出错了');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//删除花材 ssh 20240123
|
|
|
public function actionDelItem()
|
|
|
{
|
|
|
@@ -156,7 +154,7 @@ class OrderItemController extends BaseController
|
|
|
$connection = Yii::$app->db;//事务处理
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
- OrderItemClass::bookDelItem($order, $smallId);
|
|
|
+ OrderItemClass::delBookItem($order, $smallId);
|
|
|
$transaction->commit();
|
|
|
util::complete('删除成功');
|
|
|
} catch (\Exception $e) {
|
|
|
@@ -203,7 +201,7 @@ class OrderItemController extends BaseController
|
|
|
$connection = Yii::$app->db;//事务处理
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
- OrderItemClass::bookAddItem($order, $new);
|
|
|
+ OrderItemClass::addBookItemFn($order, $new);
|
|
|
$transaction->commit();
|
|
|
util::complete('添加成功');
|
|
|
} catch (\Exception $e) {
|