Merge branch 'main' of https://gitea.lihaink.cn/mkm/multi-store
This commit is contained in:
commit
e8a515eef1
@ -62,7 +62,7 @@ class StoreBranchProductController extends BaseAdminController
|
|||||||
return $this->fail(StoreProductLogic::getError());
|
return $this->fail(StoreProductLogic::getError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->success('编辑成功', [], 1, 1);
|
return $this->success('操作成功,等待门店确认', [], 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['store_id', 'admin_id', 'operating_id', 'status'],
|
'=' => ['store_id', 'admin_id', 'staff_id', 'status'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class SystemStoreStorageLists extends BaseAdminDataLists implements ListsSearchI
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return SystemStoreStorage::where($this->searchWhere)
|
return SystemStoreStorage::where($this->searchWhere)
|
||||||
->field(['id', 'store_id', 'admin_id', 'operating_id', 'product_id', 'nums', 'status'])
|
->field(['id', 'store_id', 'admin_id', 'staff_id', 'product_id', 'nums', 'status'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
|
@ -10,6 +10,8 @@ use app\common\model\store_branch_product_attr_value\StoreBranchProductAttrValue
|
|||||||
use app\common\model\store_category\StoreCategory;
|
use app\common\model\store_category\StoreCategory;
|
||||||
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
||||||
use app\common\model\system_store\SystemStore;
|
use app\common\model\system_store\SystemStore;
|
||||||
|
use app\common\model\system_store_storage\SystemStoreStorage;
|
||||||
|
use app\Request;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
use Webman\RedisQueue\Redis;
|
use Webman\RedisQueue\Redis;
|
||||||
|
|
||||||
@ -264,7 +266,13 @@ class StoreProductLogic extends BaseLogic
|
|||||||
public static function stock($data){
|
public static function stock($data){
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
StoreBranchProduct::where(['id' => $data['id']])->inc('stock',$data['stock'])->update();
|
$find=StoreBranchProduct::where(['id' => $data['id']])->find();
|
||||||
|
SystemStoreStorage::create([
|
||||||
|
'product_id' => $find['product_id'],
|
||||||
|
'store_id' => $find['store_id'],
|
||||||
|
'nums' => $data['stock'],
|
||||||
|
'admin_id' => Request()->adminId,
|
||||||
|
]);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -31,7 +31,7 @@ class SystemStoreStorageLogic extends BaseLogic
|
|||||||
SystemStoreStorage::create([
|
SystemStoreStorage::create([
|
||||||
'store_id' => $params['store_id'],
|
'store_id' => $params['store_id'],
|
||||||
'admin_id' => $params['admin_id'],
|
'admin_id' => $params['admin_id'],
|
||||||
'operating_id' => $params['operating_id'],
|
'staff_id' => $params['staff_id'],
|
||||||
'product_id' => $params['product_id'],
|
'product_id' => $params['product_id'],
|
||||||
'nums' => $params['nums'],
|
'nums' => $params['nums'],
|
||||||
'status' => $params['status']
|
'status' => $params['status']
|
||||||
@ -61,7 +61,7 @@ class SystemStoreStorageLogic extends BaseLogic
|
|||||||
SystemStoreStorage::where('id', $params['id'])->update([
|
SystemStoreStorage::where('id', $params['id'])->update([
|
||||||
'store_id' => $params['store_id'],
|
'store_id' => $params['store_id'],
|
||||||
'admin_id' => $params['admin_id'],
|
'admin_id' => $params['admin_id'],
|
||||||
'operating_id' => $params['operating_id'],
|
'staff_id' => $params['staff_id'],
|
||||||
'product_id' => $params['product_id'],
|
'product_id' => $params['product_id'],
|
||||||
'nums' => $params['nums'],
|
'nums' => $params['nums'],
|
||||||
'status' => $params['status']
|
'status' => $params['status']
|
||||||
|
@ -9,7 +9,6 @@ use app\api\validate\OrderValidate;
|
|||||||
use app\common\enum\PayEnum;
|
use app\common\enum\PayEnum;
|
||||||
use app\common\logic\PaymentLogic;
|
use app\common\logic\PaymentLogic;
|
||||||
use app\common\logic\PayNotifyLogic;
|
use app\common\logic\PayNotifyLogic;
|
||||||
use app\common\model\retail\Cashierclass;
|
|
||||||
use app\common\model\store_order\StoreOrder;
|
use app\common\model\store_order\StoreOrder;
|
||||||
use app\common\model\system_store\SystemStoreStaff;
|
use app\common\model\system_store\SystemStoreStaff;
|
||||||
use app\common\model\user\UserAddress;
|
use app\common\model\user\UserAddress;
|
||||||
@ -475,6 +474,20 @@ class OrderController extends BaseApiController
|
|||||||
$res = StoreOrder::where($where)->whereDay('create_time', $date)->count();
|
$res = StoreOrder::where($where)->whereDay('create_time', $date)->count();
|
||||||
return $this->success('ok', ['order_count' => $res]);
|
return $this->success('ok', ['order_count' => $res]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//订单退款申请
|
||||||
|
public function apply_refund()
|
||||||
|
{
|
||||||
|
$params = (new OrderValidate())->post()->goCheck('add');
|
||||||
|
$uid = $this->userId;
|
||||||
|
// OrderLogic::dealRefund($uid,$params);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,12 +44,14 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
{
|
{
|
||||||
$userId=$this->request->userId;
|
$userId=$this->request->userId;
|
||||||
if(!$userId) return [];
|
if(!$userId) return [];
|
||||||
return StoreOrder::with(['store'])->where($this->searchWhere)->where('uid',$userId)
|
return StoreOrder::with(['store'])->where($this->searchWhere)->where('uid',$userId)
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
->each(function($item){
|
->each(function($item){
|
||||||
$item['goods_list']=StoreOrderCartInfo::where('oid',$item['id'])->with('goodsName')->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time')->limit(3)->select();
|
$item['goods_list']=StoreOrderCartInfo::where('oid',$item['id'])->with(['goodsName'=> function ($query) {
|
||||||
|
$query->withTrashed();
|
||||||
|
}])->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time')->limit(3)->select();
|
||||||
$item['goods_count']=count(explode(',',$item['cart_id']));
|
$item['goods_count']=count(explode(',',$item['cart_id']));
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
namespace app\queue\redis;
|
namespace app\queue\redis;
|
||||||
|
|
||||||
use app\admin\logic\store_product\StoreProductLogic;
|
use app\admin\logic\store_product\StoreProductLogic;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\system_store_storage\SystemStoreStorage;
|
||||||
use Webman\RedisQueue\Consumer;
|
use Webman\RedisQueue\Consumer;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
|
|
||||||
@ -22,8 +24,19 @@ class CopyProductSend implements Consumer
|
|||||||
{
|
{
|
||||||
$store_arr=$data['store_arr'];
|
$store_arr=$data['store_arr'];
|
||||||
$stock=$data['stock']??0;
|
$stock=$data['stock']??0;
|
||||||
|
$admin_id=$data['admin_id']??0;
|
||||||
foreach ($store_arr as $key => $id) {
|
foreach ($store_arr as $key => $id) {
|
||||||
StoreProductLogic::copy($data['product_id'],$id,$stock);
|
StoreProductLogic::copy($data['product_id'],$id,0);
|
||||||
|
if($stock>0){
|
||||||
|
$stocks=StoreProduct::where('id',$data['product_id'])->value('stock');
|
||||||
|
if($stocks>=$stock){
|
||||||
|
SystemStoreStorage::create(['product_id'=>$data['product_id'],'store_id'=>$id,'nums'=>$stock,'admin_id'=>$admin_id]);//设置库存
|
||||||
|
StoreProduct::where('id',$data['product_id'])->dec('stock',$stock)->update();//减少库存
|
||||||
|
}else{
|
||||||
|
SystemStoreStorage::create(['product_id'=>$data['product_id'],'store_id'=>$id,'nums'=>$stock,'admin_id'=>$admin_id,'status'=>-1,'mark'=>'库存不足']);//设置库存
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function onConsumeFailure(\Throwable $e, $package)
|
public function onConsumeFailure(\Throwable $e, $package)
|
||||||
|
34
app/queue/redis/StoreStorageSend.php
Normal file
34
app/queue/redis/StoreStorageSend.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\queue\redis;
|
||||||
|
|
||||||
|
use app\admin\logic\store_product\StoreProductLogic;
|
||||||
|
use Webman\RedisQueue\Consumer;
|
||||||
|
use support\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 门店库存记录商品
|
||||||
|
*/
|
||||||
|
class StoreStorageSend implements Consumer
|
||||||
|
{
|
||||||
|
// 要消费的队列名
|
||||||
|
public $queue = 'store_storage';
|
||||||
|
|
||||||
|
// 连接名,对应 plugin/webman/redis-queue/redis.php 里的连接`
|
||||||
|
public $connection = 'default';
|
||||||
|
|
||||||
|
// 消费
|
||||||
|
public function consume($data)
|
||||||
|
{
|
||||||
|
// $product_id=$data['product_id'];
|
||||||
|
// $store_id=$data['store_id'];
|
||||||
|
// $store_id=$data['store_id'];
|
||||||
|
// StoreBranchProduct::w
|
||||||
|
}
|
||||||
|
public function onConsumeFailure(\Throwable $e, $package)
|
||||||
|
{
|
||||||
|
$package['max_attempts']=0;
|
||||||
|
Log::error('复制商品失败product_id:'.$package['data']['product_id']);
|
||||||
|
return $package;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user