Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev
This commit is contained in:
commit
1400d2919d
@ -63,7 +63,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
}
|
}
|
||||||
|
|
||||||
return StoreBranchProduct::where($this->searchWhere)->where($where)
|
return StoreBranchProduct::where($this->searchWhere)->where($where)
|
||||||
->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status','batch','vip_price'])
|
->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status','batch','vip_price','manufacturer_information'])
|
||||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||||
$query->where('store_id', $this->adminInfo['store_id']);
|
$query->where('store_id', $this->adminInfo['store_id']);
|
||||||
})
|
})
|
||||||
|
@ -46,7 +46,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return StoreProduct::where($this->searchWhere)
|
return StoreProduct::where($this->searchWhere)
|
||||||
->field(['id', 'image', 'store_name','swap', 'cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code'])
|
->field(['id', 'image', 'store_name','swap', 'cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code','manufacturer_information'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
|
@ -49,6 +49,7 @@ class StoreProductLogic extends BaseLogic
|
|||||||
'purchase' => $params['purchase'],
|
'purchase' => $params['purchase'],
|
||||||
'rose' => $params['rose'],
|
'rose' => $params['rose'],
|
||||||
'is_return' => $params['is_return'],
|
'is_return' => $params['is_return'],
|
||||||
|
'manufacturer_information' => $params['manufacturer_information']??'',
|
||||||
'swap' => $params['swap'] ?? 0,
|
'swap' => $params['swap'] ?? 0,
|
||||||
'batch' => $params['batch'] ?? 0,
|
'batch' => $params['batch'] ?? 0,
|
||||||
];
|
];
|
||||||
@ -149,6 +150,7 @@ class StoreProductLogic extends BaseLogic
|
|||||||
'price' => $params['price'],
|
'price' => $params['price'],
|
||||||
'vip_price' => $params['vip_price'],
|
'vip_price' => $params['vip_price'],
|
||||||
'batch' => $params['batch'],
|
'batch' => $params['batch'],
|
||||||
|
'manufacturer_information' => $params['manufacturer_information']??'',
|
||||||
'swap' => $params['swap'] ?? 0,
|
'swap' => $params['swap'] ?? 0,
|
||||||
|
|
||||||
];
|
];
|
||||||
@ -177,7 +179,8 @@ class StoreProductLogic extends BaseLogic
|
|||||||
StoreBranchProduct::where('product_id', $params['id'])->update([
|
StoreBranchProduct::where('product_id', $params['id'])->update([
|
||||||
'price' => $params['price'], 'vip_price' => $params['vip_price'],
|
'price' => $params['price'], 'vip_price' => $params['vip_price'],
|
||||||
'cost' => $params['cost'],
|
'cost' => $params['cost'],
|
||||||
'batch'=>$params['batch'],'store_name'=>$params['store_name']
|
'batch'=>$params['batch'],'store_name'=>$params['store_name'],
|
||||||
|
'manufacturer_information' => $params['manufacturer_information']??'',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
@ -290,6 +293,7 @@ class StoreProductLogic extends BaseLogic
|
|||||||
'store_id' => $store_id,
|
'store_id' => $store_id,
|
||||||
'sales' => 0,
|
'sales' => 0,
|
||||||
'stock' => $stock,
|
'stock' => $stock,
|
||||||
|
'manufacturer_information' => $find['manufacturer_information']??'',
|
||||||
];
|
];
|
||||||
StoreBranchProduct::create($product);
|
StoreBranchProduct::create($product);
|
||||||
$arr = [
|
$arr = [
|
||||||
|
@ -63,7 +63,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
|||||||
*/
|
*/
|
||||||
public function setDefaultOrder(): array
|
public function setDefaultOrder(): array
|
||||||
{
|
{
|
||||||
return ['sales' => 'desc', 'price' => 'asc'];
|
return [ 'price' => 'asc','id' => 'desc'];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,10 +107,12 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
|||||||
$this->searchWhere[] = ['stock', '>', 0];
|
$this->searchWhere[] = ['stock', '>', 0];
|
||||||
return StoreBranchProduct::where($this->searchWhere)
|
return StoreBranchProduct::where($this->searchWhere)
|
||||||
->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch'])
|
->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
|
||||||
->with(['className', 'unitName'])
|
->with(['className', 'unitName'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order($this->sortOrder)
|
->order($this->sortOrder)
|
||||||
->select()?->toArray();
|
// ->page($this->limitOffset +1,$this->limitLength)
|
||||||
|
->select()->toArray();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,24 +224,17 @@ class OrderLogic extends BaseLogic
|
|||||||
try {
|
try {
|
||||||
$order = StoreOrder::create($_order);
|
$order = StoreOrder::create($_order);
|
||||||
$goods_list = $orderInfo['cart_list'];
|
$goods_list = $orderInfo['cart_list'];
|
||||||
$updateData = [];
|
|
||||||
foreach ($goods_list as $k => $v) {
|
foreach ($goods_list as $k => $v) {
|
||||||
$goods_list[$k]['oid'] = $order->id;
|
$goods_list[$k]['oid'] = $order->id;
|
||||||
$goods_list[$k]['uid'] = $user['id'];
|
$goods_list[$k]['uid'] = $user['id'];
|
||||||
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
||||||
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
|
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
|
||||||
$StoreBranchProduct = StoreBranchProduct::where('id',$v['branch_product_id'])->withTrashed()->find();
|
$StoreBranchProduct = StoreBranchProduct::where('id',$v['branch_product_id'])->withTrashed()->find();
|
||||||
$updateData[] = [
|
|
||||||
'id' => $v['branch_product_id'],
|
|
||||||
'stock' => $StoreBranchProduct['stock']-$v['cart_num'],
|
|
||||||
'sales' => ['inc', $v['cart_num']]
|
|
||||||
];
|
|
||||||
if($StoreBranchProduct['stock']-$v['cart_num']<=0){
|
if($StoreBranchProduct['stock']-$v['cart_num']<=0){
|
||||||
Db::name('store_product_cate')->where(['cate_id'=>$StoreBranchProduct['cate_id'],'store_id'=>$params['store_id']])->update(['count'=>0]);
|
Db::name('store_product_cate')->where(['cate_id'=>$StoreBranchProduct['cate_id'],'store_id'=>$params['store_id']])->update(['count'=>0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(new StoreOrderCartInfo())->saveAll($goods_list);
|
(new StoreOrderCartInfo())->saveAll($goods_list);
|
||||||
(new StoreBranchProduct())->saveAll($updateData);
|
|
||||||
$where = ['is_pay' => 0];
|
$where = ['is_pay' => 0];
|
||||||
Cart::whereIn('id', $cartId)->where($where)->update(['is_pay' => 1]);
|
Cart::whereIn('id', $cartId)->where($where)->update(['is_pay' => 1]);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
@ -447,6 +440,7 @@ class OrderLogic extends BaseLogic
|
|||||||
// }
|
// }
|
||||||
$order=StoreOrder::where('id',$data['id'])->find();
|
$order=StoreOrder::where('id',$data['id'])->find();
|
||||||
PayNotifyLogic::afterPay($order);
|
PayNotifyLogic::afterPay($order);
|
||||||
|
PayNotifyLogic::descStock($order['id']);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -9,6 +9,7 @@ use app\common\enum\user\UserShipEnum;
|
|||||||
use app\common\model\dict\DictType;
|
use app\common\model\dict\DictType;
|
||||||
use app\common\model\finance\PayNotifyLog;
|
use app\common\model\finance\PayNotifyLog;
|
||||||
use app\common\model\pay\PayNotify;
|
use app\common\model\pay\PayNotify;
|
||||||
|
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||||
use app\common\model\store_order\StoreOrder;
|
use app\common\model\store_order\StoreOrder;
|
||||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||||
@ -89,6 +90,9 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||||
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'],'',0,$order['store_id']);
|
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'],'',0,$order['store_id']);
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
|
if($order['shipping_type'] == 3){
|
||||||
|
self::descStock($order['id']);
|
||||||
|
}
|
||||||
// self::afterPay($order);
|
// self::afterPay($order);
|
||||||
// Redis::send('push-platform-print', ['id' => $order['id']], 60);
|
// Redis::send('push-platform-print', ['id' => $order['id']], 60);
|
||||||
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
||||||
@ -136,6 +140,9 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
OrderLogic::writeOff($params);
|
OrderLogic::writeOff($params);
|
||||||
}
|
}
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
|
if($order['shipping_type'] == 3){
|
||||||
|
self::descStock($order['id']);
|
||||||
|
}
|
||||||
|
|
||||||
// self::afterPay($order);
|
// self::afterPay($order);
|
||||||
// Redis::send('push-platform-print', ['id' => $order['id']], 60);
|
// Redis::send('push-platform-print', ['id' => $order['id']], 60);
|
||||||
@ -175,6 +182,9 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
|
if($order['shipping_type'] == 3){
|
||||||
|
self::descStock($order['id']);
|
||||||
|
}
|
||||||
|
|
||||||
// if ($order->pay_type == 9) {
|
// if ($order->pay_type == 9) {
|
||||||
// $extra['create_time'] = $order['create_time'];
|
// $extra['create_time'] = $order['create_time'];
|
||||||
@ -273,6 +283,9 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
$cashFlowLogic = new CashFlowLogic();
|
$cashFlowLogic = new CashFlowLogic();
|
||||||
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
|
$cashFlowLogic->insert($order['store_id'], $order['pay_price']);
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
|
if($order['shipping_type'] == 3){
|
||||||
|
self::descStock($order['id']);
|
||||||
|
}
|
||||||
// Redis::send('push-platform-print', ['id' => $order['id']]);
|
// Redis::send('push-platform-print', ['id' => $order['id']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,6 +317,9 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
self::afterPay($order);
|
self::afterPay($order);
|
||||||
}
|
}
|
||||||
self::dealProductLog($order);
|
self::dealProductLog($order);
|
||||||
|
if($order['shipping_type'] == 3){
|
||||||
|
self::descStock($order['id']);
|
||||||
|
}
|
||||||
|
|
||||||
// if ($order->pay_type == 9) {
|
// if ($order->pay_type == 9) {
|
||||||
// $extra['create_time'] = $order['create_time'];
|
// $extra['create_time'] = $order['create_time'];
|
||||||
@ -621,4 +637,38 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扣库存
|
||||||
|
* @param $oid
|
||||||
|
* @return void
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public static function descStock($oid)
|
||||||
|
{
|
||||||
|
$updateData = [];
|
||||||
|
$goods_list = StoreOrderCartInfo::where('oid',$oid)->select()->toArray();
|
||||||
|
foreach ($goods_list as $v) {
|
||||||
|
$StoreBranchProduct =StoreBranchProduct::where(
|
||||||
|
[
|
||||||
|
'store_id'=>$v['store_id'],
|
||||||
|
'product_id'=>$v['product_id'],
|
||||||
|
]
|
||||||
|
)->withTrashed()->find();
|
||||||
|
$updateData[] = [
|
||||||
|
'id' => $StoreBranchProduct['id'],
|
||||||
|
'stock' => $StoreBranchProduct['stock']-$v['cart_num'],
|
||||||
|
'sales' => ['inc', $v['cart_num']]
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
(new StoreBranchProduct())->saveAll($updateData);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ class StoreStorageSend implements Consumer
|
|||||||
'cost' => $find['cost'],
|
'cost' => $find['cost'],
|
||||||
'purchase' => $find['purchase'],
|
'purchase' => $find['purchase'],
|
||||||
'vip_price' => $find['vip_price'],
|
'vip_price' => $find['vip_price'],
|
||||||
|
'manufacturer_information' => $find['manufacturer_information']??'',
|
||||||
'unit' => $find['unit'],
|
'unit' => $find['unit'],
|
||||||
'batch' => $find['batch'],
|
'batch' => $find['batch'],
|
||||||
'store_id' => $store_id,
|
'store_id' => $store_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user