|
|
@@ -4,6 +4,7 @@ namespace ghs\controllers;
|
|
|
|
|
|
use bizGhs\book\classes\BookItemClass;
|
|
|
use bizGhs\book\classes\BookItemCustomClass;
|
|
|
+use bizGhs\order\classes\OrderClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
@@ -11,18 +12,41 @@ use Yii;
|
|
|
class BookItemCustomController extends BaseController
|
|
|
{
|
|
|
|
|
|
+ //获取对象资源 ssh 20240829
|
|
|
+ public function actionGetInfo()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $orderId = $get['orderId'] ?? 0;
|
|
|
+ $productId = $get['productId'] ?? 0;
|
|
|
+ $shop = $this->shop;
|
|
|
+ $order = OrderClass::getById($orderId, true);
|
|
|
+ if (empty($order)) {
|
|
|
+ util::fail('没有找到订单');
|
|
|
+ }
|
|
|
+ $bookSn = $shop->bookSn ?? 0;
|
|
|
+ if (empty($bookSn)) {
|
|
|
+ util::fail('当前不是在预订活动中');
|
|
|
+ }
|
|
|
+ $customId = $order->customId ?? 0;
|
|
|
+ $res = BookItemCustomClass::getByCondition(['bookSn' => $bookSn, 'customId' => $customId, 'itemId' => $productId], true);
|
|
|
+ if (empty($res)) {
|
|
|
+ util::fail('数据有问题');
|
|
|
+ }
|
|
|
+ util::success(['res' => $res]);
|
|
|
+ }
|
|
|
+
|
|
|
//下架 ssh 20240721
|
|
|
public function actionGoOff()
|
|
|
{
|
|
|
$staff = $this->shopAdmin;
|
|
|
- if(isset($staff->identity) && $staff->identity == 2){
|
|
|
+ if (isset($staff->identity) && $staff->identity == 2) {
|
|
|
util::fail('不能操作');
|
|
|
}
|
|
|
|
|
|
$get = Yii::$app->request->get();
|
|
|
$id = $get['id'] ?? 0;
|
|
|
$num = $get['num'] ?? 0;
|
|
|
- if(empty($num)){
|
|
|
+ if (empty($num)) {
|
|
|
util::fail('请填写下架数量');
|
|
|
}
|
|
|
$shop = $this->shop;
|
|
|
@@ -82,7 +106,7 @@ class BookItemCustomController extends BaseController
|
|
|
public function actionGoOn()
|
|
|
{
|
|
|
$staff = $this->shopAdmin;
|
|
|
- if(isset($staff->identity) && $staff->identity == 2){
|
|
|
+ if (isset($staff->identity) && $staff->identity == 2) {
|
|
|
util::fail('不能操作');
|
|
|
}
|
|
|
|
|
|
@@ -110,10 +134,10 @@ class BookItemCustomController extends BaseController
|
|
|
public function actionBatchGoOn()
|
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
|
- $ids = $post['ids']??'';
|
|
|
+ $ids = $post['ids'] ?? '';
|
|
|
|
|
|
$staff = $this->shopAdmin;
|
|
|
- if(isset($staff->identity) && $staff->identity == 2){
|
|
|
+ if (isset($staff->identity) && $staff->identity == 2) {
|
|
|
util::fail('不能操作');
|
|
|
}
|
|
|
|
|
|
@@ -123,11 +147,11 @@ class BookItemCustomController extends BaseController
|
|
|
util::fail('预订没有开启');
|
|
|
}
|
|
|
|
|
|
- if(empty($ids)){
|
|
|
+ if (empty($ids)) {
|
|
|
util::fail('请选择要上齐的项');
|
|
|
}
|
|
|
- $arr = json_decode($ids,true);
|
|
|
- if(empty($arr)){
|
|
|
+ $arr = json_decode($ids, true);
|
|
|
+ if (empty($arr)) {
|
|
|
util::fail('请选择项');
|
|
|
}
|
|
|
|
|
|
@@ -139,13 +163,13 @@ class BookItemCustomController extends BaseController
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
- foreach($arr as $id){
|
|
|
+ foreach ($arr as $id) {
|
|
|
$num = 0;
|
|
|
$book = BookItemCustomClass::getById($id, true);
|
|
|
if (empty($book)) {
|
|
|
util::fail('有选择项没有找到');
|
|
|
}
|
|
|
- if($book->bookSn != $bookSn){
|
|
|
+ if ($book->bookSn != $bookSn) {
|
|
|
util::fail('有选择的项不是当前预订活动');
|
|
|
}
|
|
|
BookItemCustomClass::goOn($book, $shop, $params, $num);
|