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