feat: 更新了商品调拨、门店提现、仓库产品等功能的代码,优化了库存查询逻辑,并改进了用户提现记录的展示。
This commit is contained in:
parent
e87d906917
commit
948b3e5794
@ -0,0 +1,101 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\purchase_product_offer;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\controller\BaseAdminController;
|
||||||
|
use app\admin\lists\purchase_product_offer\PurchaseProductOfferLists;
|
||||||
|
use app\admin\logic\purchase_product_offer\PurchaseProductOfferLogic;
|
||||||
|
use app\admin\validate\purchase_product_offer\PurchaseProductOfferValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购供应链商品控制器
|
||||||
|
* Class PurchaseProductOfferController
|
||||||
|
* @package app\admin\controller\purchase_product_offer
|
||||||
|
*/
|
||||||
|
class PurchaseProductOfferController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购供应链商品列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new PurchaseProductOfferLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加采购供应链商品
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$params = (new PurchaseProductOfferValidate())->post()->goCheck('add');
|
||||||
|
$result = PurchaseProductOfferLogic::add($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('添加成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(PurchaseProductOfferLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑采购供应链商品
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = $this->request->post();
|
||||||
|
switch ($params['type']) {
|
||||||
|
case 'buyer':
|
||||||
|
PurchaseProductOfferLogic::buyer($params);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $this->fail('参数错误');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (PurchaseProductOfferLogic::hasError()) {
|
||||||
|
return $this->fail(PurchaseProductOfferLogic::getError());
|
||||||
|
}
|
||||||
|
return $this->success('设置成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除采购供应链商品
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new PurchaseProductOfferValidate())->post()->goCheck('delete');
|
||||||
|
PurchaseProductOfferLogic::delete($params);
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购供应链商品详情
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$params = (new PurchaseProductOfferValidate())->goCheck('detail');
|
||||||
|
$result = PurchaseProductOfferLogic::detail($params);
|
||||||
|
return $this->data($result);
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,8 @@ use app\admin\lists\BaseAdminDataLists;
|
|||||||
use app\common\model\inventory_transfer\InventoryTransfer;
|
use app\common\model\inventory_transfer\InventoryTransfer;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\system_store\SystemStore;
|
||||||
|
use app\common\model\warehouse\Warehouse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品调拨列表
|
* 商品调拨列表
|
||||||
@ -68,10 +70,22 @@ class InventoryTransferLists extends BaseAdminDataLists implements ListsSearchIn
|
|||||||
}
|
}
|
||||||
|
|
||||||
return InventoryTransfer::where($this->searchWhere)
|
return InventoryTransfer::where($this->searchWhere)
|
||||||
->field(['id', 'product_id', 'nums', 'before_nums', 'after_nums', 'type', 'one_id', 'two_id', 'create_time'])
|
->field(['id', 'product_id', 'nums', 'one_before_nums', 'one_after_nums','two_before_nums','two_after_nums', 'type', 'one_id', 'two_id', 'create_time'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()->each(function($item){
|
||||||
|
$item->store_name= StoreProduct::where('id',$item->product_id)->value('store_name');
|
||||||
|
if($item->type==1){
|
||||||
|
$item->type_name='商户';
|
||||||
|
$item->one_name=SystemStore::where('id',$item->one_id)->value('name');
|
||||||
|
$item->two_name=SystemStore::where('id',$item->two_id)->value('name');
|
||||||
|
}else{
|
||||||
|
$item->type_name='仓库';
|
||||||
|
$item->one_name=Warehouse::where('id',$item->one_id)->value('name');
|
||||||
|
$item->two_name=Warehouse::where('id',$item->two_id)->value('name');
|
||||||
|
}
|
||||||
|
$item->store_name= StoreProduct::where('id',$item->product_id)->value('store_name');
|
||||||
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\lists\purchase_product_offer;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\delivery_service\DeliveryService;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购供应链商品列表
|
||||||
|
* Class PurchaseProductOfferLists
|
||||||
|
* @package app\admin\listspurchase_product_offer
|
||||||
|
*/
|
||||||
|
class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['supplier_id', 'order_id', 'product_id', 'price', 'nums', 'unit', 'is_buyer', 'buyer_confirm', 'is_storage', 'is_stream', 'need_num', 'notes', 'buyer_id', 'status', 'stream_admin_id', 'stream_time', 'storage_admin_id'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购供应链商品列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return PurchaseProductOffer::where($this->searchWhere)
|
||||||
|
->field(['id', 'supplier_id', 'order_id', 'product_id', 'price', 'nums', 'unit', 'is_buyer', 'buyer_confirm', 'is_storage', 'is_stream', 'need_num', 'notes', 'buyer_id', 'status', 'stream_admin_id', 'stream_time', 'storage_admin_id'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()->each(function($item){
|
||||||
|
$find=StoreProduct::where('id',$item->product_id)->find();
|
||||||
|
$item->store_name=$find->store_name;
|
||||||
|
$item->image=$find->image;
|
||||||
|
$item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name');
|
||||||
|
if($item->is_buyer==1){
|
||||||
|
$item->is_buyer_name='需要采购';
|
||||||
|
}elseif($item->is_buyer==-1){
|
||||||
|
$item->is_buyer_name='无须采购';
|
||||||
|
}
|
||||||
|
if($item->buyer_id>0){
|
||||||
|
$item->buyer_name=DeliveryService::where('id',$item->buyer_id)->value('nickname');
|
||||||
|
if($item->buyer_confirm==0){
|
||||||
|
$item->buyer_confirm_name='采购中';
|
||||||
|
}else{
|
||||||
|
$item->buyer_confirm_name='采购完成';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购供应链商品数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return PurchaseProductOffer::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -6,7 +6,9 @@ namespace app\admin\lists\store_extract;
|
|||||||
use app\admin\lists\BaseAdminDataLists;
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
use app\common\model\store_extract\StoreExtract;
|
use app\common\model\store_extract\StoreExtract;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\system_store\SystemStore;
|
||||||
|
use app\common\model\user\User;
|
||||||
|
use app\common\model\user_ship\UserShip;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 门店提现列表
|
* 门店提现列表
|
||||||
@ -43,10 +45,23 @@ class StoreExtractLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return StoreExtract::where($this->searchWhere)
|
return StoreExtract::where($this->searchWhere)
|
||||||
->field(['id', 'store_id', 'extract_type', 'extract_price', 'mark', 'status', 'pay_status', 'admin_id', 'create_time'])
|
->field(['id', 'store_id','uid','extract_type', 'extract_price', 'mark', 'status', 'pay_status', 'admin_id', 'create_time'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()->each(function($item){
|
||||||
|
if($item->store_id>0){
|
||||||
|
$item->nickname=SystemStore::where('id',$item->store_id)->value('name');
|
||||||
|
}elseif($item->uid>0){
|
||||||
|
$find=User::where('id',$item->uid)->find();
|
||||||
|
if($find['real_name']!=''){
|
||||||
|
$name=$find['real_name'];
|
||||||
|
}else{
|
||||||
|
$name=$find['mobile'];
|
||||||
|
}
|
||||||
|
$user_ship=UserShip::where('id',$find['user_ship'])->value('title');
|
||||||
|
$item->nickname=$name.'('.$user_ship.')';
|
||||||
|
}
|
||||||
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['warehouse_id', 'financial_pm', 'store_id'],
|
'=' => ['warehouse_id', 'financial_pm', 'store_id'],
|
||||||
|
'between_time' => 'create_time'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,10 +33,10 @@ class InventoryTransferLogic extends BaseLogic
|
|||||||
$two_before_nums = 0;
|
$two_before_nums = 0;
|
||||||
$two_after_nums = 0;
|
$two_after_nums = 0;
|
||||||
if ($params['type'] == 1) {
|
if ($params['type'] == 1) {
|
||||||
$stock = StoreBranchProduct::where('product_id', $params['one_id'])->value('stock');
|
$stock = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->value('stock');
|
||||||
$stock_two = StoreBranchProduct::where('product_id', $params['two_id'])->value('stock');
|
$stock_two = StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->value('stock');
|
||||||
if ($stock < $params['nums']) {
|
if ($stock < $params['nums']) {
|
||||||
self::setError('调拨数量不能大于当前库存');
|
self::setError('调拨数量不能大于当前门店库存');
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$one_before_nums = $stock;
|
$one_before_nums = $stock;
|
||||||
@ -49,7 +49,7 @@ class InventoryTransferLogic extends BaseLogic
|
|||||||
$stock = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->value('nums');
|
$stock = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->value('nums');
|
||||||
$stock_two = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->value('nums');
|
$stock_two = WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->value('nums');
|
||||||
if ($stock < $params['nums']) {
|
if ($stock < $params['nums']) {
|
||||||
self::setError('调拨数量不能大于当前库存');
|
self::setError('调拨数量不能大于当前仓库库存');
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$one_before_nums = $stock;
|
$one_before_nums = $stock;
|
||||||
@ -72,7 +72,13 @@ class InventoryTransferLogic extends BaseLogic
|
|||||||
'one_id' => $params['one_id'],
|
'one_id' => $params['one_id'],
|
||||||
'two_id' => $params['two_id']
|
'two_id' => $params['two_id']
|
||||||
]);
|
]);
|
||||||
|
if ($params['type'] == 1) {
|
||||||
|
StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['one_id'])->dec('stock', $params['nums'])->update();
|
||||||
|
StoreBranchProduct::where('product_id', $params['product_id'])->where('store_id', $params['two_id'])->inc('stock', $params['nums'])->update();
|
||||||
|
} elseif ($params['type'] == 2) {
|
||||||
|
WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['one_id'])->dec('nums', $params['nums'])->update();
|
||||||
|
WarehouseProductStorege::where('product_id', $params['product_id'])->where('warehouse_id', $params['two_id'])->inc('nums', $params['nums'])->update();
|
||||||
|
}
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
@ -0,0 +1,134 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\logic\purchase_product_offer;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购供应链商品逻辑
|
||||||
|
* Class PurchaseProductOfferLogic
|
||||||
|
* @package app\admin\logic\purchase_product_offer
|
||||||
|
*/
|
||||||
|
class PurchaseProductOfferLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加采购供应链商品
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
PurchaseProductOffer::create([
|
||||||
|
'supplier_id' => $params['supplier_id'],
|
||||||
|
'order_id' => $params['order_id'],
|
||||||
|
'product_id' => $params['product_id'],
|
||||||
|
'price' => $params['price'],
|
||||||
|
'nums' => $params['nums'],
|
||||||
|
'unit' => $params['unit'],
|
||||||
|
'is_buyer' => $params['is_buyer'],
|
||||||
|
'buyer_confirm' => $params['buyer_confirm'],
|
||||||
|
'is_storage' => $params['is_storage'],
|
||||||
|
'is_stream' => $params['is_stream'],
|
||||||
|
'need_num' => $params['need_num'],
|
||||||
|
'notes' => $params['notes'],
|
||||||
|
'buyer_id' => $params['buyer_id'],
|
||||||
|
'status' => $params['status'],
|
||||||
|
'stream_admin_id' => $params['stream_admin_id'],
|
||||||
|
'stream_time' => $params['stream_time'],
|
||||||
|
'storage_admin_id' => $params['storage_admin_id']
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑采购供应链商品
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
PurchaseProductOffer::where('id', $params['id'])->update([
|
||||||
|
'supplier_id' => $params['supplier_id'],
|
||||||
|
'order_id' => $params['order_id'],
|
||||||
|
'product_id' => $params['product_id'],
|
||||||
|
'price' => $params['price'],
|
||||||
|
'nums' => $params['nums'],
|
||||||
|
'unit' => $params['unit'],
|
||||||
|
'is_buyer' => $params['is_buyer'],
|
||||||
|
'buyer_confirm' => $params['buyer_confirm'],
|
||||||
|
'is_storage' => $params['is_storage'],
|
||||||
|
'is_stream' => $params['is_stream'],
|
||||||
|
'need_num' => $params['need_num'],
|
||||||
|
'notes' => $params['notes'],
|
||||||
|
'buyer_id' => $params['buyer_id'],
|
||||||
|
'status' => $params['status'],
|
||||||
|
'stream_admin_id' => $params['stream_admin_id'],
|
||||||
|
'stream_time' => $params['stream_time'],
|
||||||
|
'storage_admin_id' => $params['storage_admin_id']
|
||||||
|
]);
|
||||||
|
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否需采购
|
||||||
|
*/
|
||||||
|
public static function buyer($params)
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$data=[
|
||||||
|
'is_buyer' => $params['is_buyer'],
|
||||||
|
];
|
||||||
|
if($params['is_buyer']==1){
|
||||||
|
$data['buyer_id']=$params['buyer_id'];
|
||||||
|
}
|
||||||
|
PurchaseProductOffer::where('id', $params['id'])->update($data);
|
||||||
|
Db::commit();
|
||||||
|
return true;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
self::setError($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @notes 删除采购供应链商品
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
return PurchaseProductOffer::destroy($params['id']);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\validate\purchase_product_offer;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购供应链商品验证器
|
||||||
|
* Class PurchaseProductOfferValidate
|
||||||
|
* @package app\admin\validate\purchase_product_offer
|
||||||
|
*/
|
||||||
|
class PurchaseProductOfferValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'id' => 'require',
|
||||||
|
'supplier_id' => 'require',
|
||||||
|
'product_id' => 'require',
|
||||||
|
'price' => 'require',
|
||||||
|
'nums' => 'require',
|
||||||
|
'is_buyer' => 'require',
|
||||||
|
'need_num' => 'require',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
'id' => 'id',
|
||||||
|
'supplier_id' => '供应商',
|
||||||
|
'product_id' => '商品',
|
||||||
|
'price' => '报价',
|
||||||
|
'nums' => '数量',
|
||||||
|
'is_buyer' => '-1-不采购 0-待处理 1-采购',
|
||||||
|
'need_num' => '需求数量',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return PurchaseProductOfferValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->only(['supplier_id','product_id','price','nums','is_buyer','need_num']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return PurchaseProductOfferValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
return $this->only(['id','supplier_id','product_id','price','nums','is_buyer','need_num']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return PurchaseProductOfferValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return PurchaseProductOfferValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\controller\purchase_product_offer;
|
||||||
|
|
||||||
|
|
||||||
|
use app\api\lists\purchase_product_offer\PurchaseProductOfferLists;
|
||||||
|
use app\api\controller\BaseApiController;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购供应链商品控制器
|
||||||
|
* Class PurchaseProductOfferController
|
||||||
|
* @package app\api\controller\purchase_product_offer
|
||||||
|
*/
|
||||||
|
class PurchaseProductOfferController extends BaseApiController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购供应链商品列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new PurchaseProductOfferLists());
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ use app\api\logic\user\UserLogic;
|
|||||||
use app\api\service\UserTokenService;
|
use app\api\service\UserTokenService;
|
||||||
use app\api\validate\UserValidate;
|
use app\api\validate\UserValidate;
|
||||||
use app\common\enum\PayEnum;
|
use app\common\enum\PayEnum;
|
||||||
|
use app\common\logic\CapitalFlowLogic;
|
||||||
use app\common\logic\PaymentLogic;
|
use app\common\logic\PaymentLogic;
|
||||||
use app\common\model\store_extract\StoreExtract;
|
use app\common\model\store_extract\StoreExtract;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
@ -317,11 +318,15 @@ class UserController extends BaseApiController
|
|||||||
$data['balance'] = bcsub($find['now_money'], $money, 2);
|
$data['balance'] = bcsub($find['now_money'], $money, 2);
|
||||||
$data['before_balance'] = $find['now_money'];
|
$data['before_balance'] = $find['now_money'];
|
||||||
$data['extract_type'] = 'wx';
|
$data['extract_type'] = 'wx';
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
$res = StoreExtract::create($data);
|
$res = StoreExtract::create($data);
|
||||||
if ($res) {
|
$capitalFlowDao = new CapitalFlowLogic($find);
|
||||||
|
$capitalFlowDao->userExpense('user_withdrawal', 'withdrawal', $res['id'], $money);
|
||||||
User::where('id', $this->userId)->dec('now_money', $money)->update();
|
User::where('id', $this->userId)->dec('now_money', $money)->update();
|
||||||
return $this->success('申请成功,等待审核');
|
return $this->success('申请成功,等待审核');
|
||||||
} else {
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
return $this->success('申请失败');
|
return $this->success('申请失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -343,7 +348,6 @@ class UserController extends BaseApiController
|
|||||||
}
|
}
|
||||||
$item->title = '申请提现' . $item->price . '元';
|
$item->title = '申请提现' . $item->price . '元';
|
||||||
$item->pay_status_name = $item->status == 1 ? '已打款' : '未打款';
|
$item->pay_status_name = $item->status == 1 ? '已打款' : '未打款';
|
||||||
|
|
||||||
})->toArray();
|
})->toArray();
|
||||||
return $this->data($list);
|
return $this->data($list);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\api\lists\purchase_product_offer;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\purchase_product_offer\PurchaseProductOffer;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\delivery_service\DeliveryService;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
|
use app\api\lists\BaseApiDataLists;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购供应链商品列表
|
||||||
|
* Class PurchaseProductOfferLists
|
||||||
|
* @package app\admin\listspurchase_product_offer
|
||||||
|
*/
|
||||||
|
class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['supplier_id', 'order_id', 'product_id', 'price', 'nums', 'unit', 'is_buyer', 'buyer_confirm', 'is_storage', 'is_stream', 'need_num', 'notes', 'buyer_id', 'status', 'stream_admin_id', 'stream_time', 'storage_admin_id'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购供应链商品列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return PurchaseProductOffer::where($this->searchWhere)
|
||||||
|
->field(['id', 'supplier_id', 'order_id', 'product_id', 'price', 'nums', 'unit', 'is_buyer', 'buyer_confirm', 'is_storage', 'is_stream', 'need_num', 'notes', 'buyer_id', 'status', 'stream_admin_id', 'stream_time', 'storage_admin_id'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()->each(function($item){
|
||||||
|
$find=StoreProduct::where('id',$item->product_id)->find();
|
||||||
|
$item->store_name=$find->store_name;
|
||||||
|
$item->image=$find->image;
|
||||||
|
$item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name');
|
||||||
|
if($item->is_buyer==1){
|
||||||
|
$item->is_buyer_name='需要采购';
|
||||||
|
}elseif($item->is_buyer==-1){
|
||||||
|
$item->is_buyer_name='无须采购';
|
||||||
|
}
|
||||||
|
if($item->buyer_id>0){
|
||||||
|
$item->buyer_name=DeliveryService::where('id',$item->buyer_id)->value('nickname');
|
||||||
|
if($item->buyer_confirm==0){
|
||||||
|
$item->buyer_confirm_name='采购中';
|
||||||
|
}else{
|
||||||
|
$item->buyer_confirm_name='采购完成';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购供应链商品数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/08/14 15:06
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return PurchaseProductOffer::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -177,6 +177,8 @@ class CapitalFlowLogic extends BaseLogic
|
|||||||
return "系统减少余额{$amount}元";
|
return "系统减少余额{$amount}元";
|
||||||
case 'user_balance_recharge_refund':
|
case 'user_balance_recharge_refund':
|
||||||
return "用户减少{$amount}元";
|
return "用户减少{$amount}元";
|
||||||
|
case 'user_withdrawal':
|
||||||
|
return "用户提现{$amount}元";
|
||||||
default:
|
default:
|
||||||
return "订单支付{$amount}元";
|
return "订单支付{$amount}元";
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\purchase_product_offer;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购供应链商品模型
|
||||||
|
* Class PurchaseProductOffer
|
||||||
|
* @package app\common\model\purchase_product_offer
|
||||||
|
*/
|
||||||
|
class PurchaseProductOffer extends BaseModel
|
||||||
|
{
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'purchase_product_offer';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user