commit
a93547de10
@ -52,12 +52,13 @@ class StoreOrderController extends BaseAdminController
|
|||||||
*/
|
*/
|
||||||
public function add()
|
public function add()
|
||||||
{
|
{
|
||||||
$params = (new StoreOrderValidate())->post()->goCheck('add');
|
$params = $this->request->post();
|
||||||
$result = StoreOrderLogic::add($params);
|
$result = StoreOrderLogic::add($params);
|
||||||
if (true === $result) {
|
if (StoreOrderLogic::hasError()) {
|
||||||
return $this->success('添加成功', [], 1, 1);
|
|
||||||
}
|
|
||||||
return $this->fail(StoreOrderLogic::getError());
|
return $this->fail(StoreOrderLogic::getError());
|
||||||
|
}else{
|
||||||
|
return $this->success('添加成功,请在30分钟内支付', [], 1, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ use app\admin\controller\BaseAdminController;
|
|||||||
use app\admin\lists\store_product\StoreProductLists;
|
use app\admin\lists\store_product\StoreProductLists;
|
||||||
use app\admin\logic\store_product\StoreProductLogic;
|
use app\admin\logic\store_product\StoreProductLogic;
|
||||||
use app\admin\validate\store_product\StoreProductValidate;
|
use app\admin\validate\store_product\StoreProductValidate;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
|
||||||
use Webman\RedisQueue\Redis;
|
use Webman\RedisQueue\Redis;
|
||||||
|
|
||||||
@ -112,12 +113,17 @@ class StoreProductController extends BaseAdminController
|
|||||||
if ($count == 1) {
|
if ($count == 1) {
|
||||||
$store_id = $store_arr[0];
|
$store_id = $store_arr[0];
|
||||||
foreach ($product_arr as $key => $arr) {
|
foreach ($product_arr as $key => $arr) {
|
||||||
Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]);
|
$find = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
|
||||||
|
StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
|
||||||
|
|
||||||
|
// Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($product_arr as $key => $arr) {
|
foreach ($product_arr as $key => $arr) {
|
||||||
foreach ($store_arr as $k => $store_id) {
|
foreach ($store_arr as $k => $store_id) {
|
||||||
Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]);
|
$find = StoreProduct::where('id', $arr['id'])->findOrEmpty()->toArray();
|
||||||
|
StoreProductLogic::ordinary($arr, $store_id, $this->adminId, $find, $warehouse_id);
|
||||||
|
// Redis::send('store-storage', ['product_arr' => $arr, 'store_id' => $store_id, 'stock_type' => $stock_type, 'admin_id' => $this->adminId, 'warehouse_id' => $warehouse_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
namespace app\admin\logic\store_order;
|
namespace app\admin\logic\store_order;
|
||||||
|
|
||||||
|
use app\api\logic\order\CartLogic;
|
||||||
|
use app\api\logic\order\OrderLogic;
|
||||||
use app\common\enum\PayEnum;
|
use app\common\enum\PayEnum;
|
||||||
use app\common\model\store_order\StoreOrder;
|
use app\common\model\store_order\StoreOrder;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use app\common\logic\PayNotifyLogic;
|
use app\common\logic\PayNotifyLogic;
|
||||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||||
|
use app\common\model\user\User;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
@ -28,15 +31,23 @@ class StoreOrderLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function add(array $params): bool
|
public static function add(array $params): bool
|
||||||
{
|
{
|
||||||
Db::startTrans();
|
$cartId = [];
|
||||||
try {
|
foreach ($params['product_arr'] as $k => $v) {
|
||||||
StoreOrder::create([]);
|
$v['uid'] = $params['user_id'];
|
||||||
|
$v['store_id'] = $params['store_id'];
|
||||||
Db::commit();
|
$v['product_id'] = $v['id'];
|
||||||
|
$v['cart_num'] = $v['stock'];
|
||||||
|
$res = CartLogic::add($v);
|
||||||
|
$cartId[] = $res['id'];
|
||||||
|
}
|
||||||
|
$user = User::where('id', $params['user_id'])->find();
|
||||||
|
$params['shipping_type'] = 2;
|
||||||
|
$params['pay_type'] = 7;
|
||||||
|
$order = OrderLogic::createOrder($cartId, null, $user, $params);
|
||||||
|
if ($order != false) {
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} else {
|
||||||
Db::rollback();
|
OrderLogic::getError();
|
||||||
self::setError($e->getMessage());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -547,8 +547,8 @@ class StoreProductLogic extends BaseLogic
|
|||||||
if($warehouse['nums']< $product_arr['stock']){
|
if($warehouse['nums']< $product_arr['stock']){
|
||||||
$storage['status'] = -1;
|
$storage['status'] = -1;
|
||||||
$data['status'] = -1;
|
$data['status'] = -1;
|
||||||
$storage['mark'] = '库存不足,分库存为:' .$warehouse['nums'];
|
$storage['mark'] = '库存【'.$warehouse_id.'】不足,分库存为:' .$warehouse['nums'];
|
||||||
$data['mark'] = '库存不足,分库存为:' .$warehouse['nums'].' 总仓库存为:'.$find['stock'];
|
$data['mark'] = '库存【'.$warehouse_id.'】不足,分库存为:' .$warehouse['nums'].' 总仓库存为:'.$find['stock'];
|
||||||
}
|
}
|
||||||
$res=WarehouseProductLogic::add($data);
|
$res=WarehouseProductLogic::add($data);
|
||||||
$storage['outbound_id']=$res['id']??0;
|
$storage['outbound_id']=$res['id']??0;
|
||||||
|
@ -25,7 +25,7 @@ class CartLogic extends BaseLogic
|
|||||||
* @author likeadmin
|
* @author likeadmin
|
||||||
* @date 2024/04/24 10:37
|
* @date 2024/04/24 10:37
|
||||||
*/
|
*/
|
||||||
public static function add(array $params): bool
|
public static function add(array $params)
|
||||||
{
|
{
|
||||||
if ($params['store_id'] <= 0) {
|
if ($params['store_id'] <= 0) {
|
||||||
self::setError('门店ID不能为空');
|
self::setError('门店ID不能为空');
|
||||||
@ -66,7 +66,7 @@ class CartLogic extends BaseLogic
|
|||||||
'cart_num' => $params['cart_num'],
|
'cart_num' => $params['cart_num'],
|
||||||
]);
|
]);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return $cart;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
@ -86,9 +86,11 @@ class CartLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
Cart::where(['uid'=>$params['uid'],
|
Cart::where([
|
||||||
|
'uid' => $params['uid'],
|
||||||
'store_id' => $params['store_id'],
|
'store_id' => $params['store_id'],
|
||||||
'product_id'=>$params['product_id']])
|
'product_id' => $params['product_id']
|
||||||
|
])
|
||||||
->update(['cart_num' => $params['cart_num']]);
|
->update(['cart_num' => $params['cart_num']]);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user