更新
This commit is contained in:
parent
ec7bd4f197
commit
f02ffce416
29
app/admin/controller/financial/FinancialRecordController.php
Normal file
29
app/admin/controller/financial/FinancialRecordController.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\financial;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\financial\FinancialRecordLists;
|
||||
|
||||
|
||||
/**
|
||||
* 订单流水控制器
|
||||
* Class FinancialRecordController
|
||||
* @package app\admin\controller\supplier
|
||||
*/
|
||||
class FinancialRecordController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 获取订单流水列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new FinancialRecordLists());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\supplier;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\supplier\SupplierBindGoodsLists;
|
||||
use app\admin\logic\supplier\SupplierBindGoodsLogic;
|
||||
use app\admin\validate\supplier\SupplierBindGoodsValidate;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 供应商商品绑定控制器
|
||||
* Class SupplierBindGoodsController
|
||||
* @package app\admin\controller\supplier
|
||||
*/
|
||||
class SupplierBindGoodsController extends BaseAdminController
|
||||
{
|
||||
/**
|
||||
* @notes 获取供应商商品绑定列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new SupplierBindGoodsLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加供应商商品绑定
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = SupplierBindGoodsLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupplierBindGoodsLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑供应商商品绑定
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new SupplierBindGoodsValidate())->post()->goCheck('edit');
|
||||
$result = SupplierBindGoodsLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(SupplierBindGoodsLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除供应商商品绑定
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new SupplierBindGoodsValidate())->post()->goCheck('delete');
|
||||
SupplierBindGoodsLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取供应商商品绑定详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new SupplierBindGoodsValidate())->goCheck('detail');
|
||||
$result = SupplierBindGoodsLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
}
|
65
app/admin/lists/financial/FinancialRecordLists.php
Normal file
65
app/admin/lists/financial/FinancialRecordLists.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\financial;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\financial\FinancialRecord;
|
||||
use app\common\model\merchant\Merchant;
|
||||
use app\common\model\user\User;
|
||||
|
||||
/**
|
||||
* 订单流水列表
|
||||
* Class SupplierBindGoodsLists
|
||||
* @package app\admin\listssupplier
|
||||
*/
|
||||
class FinancialRecordLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取流水列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return FinancialRecord::where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($item){
|
||||
$item['user_nickname']=User::where('id',$item['user_id'])->value('nickname');
|
||||
$item['financial_pm']=$item['financial_pm']==0?"支出":"获得";
|
||||
if($item['type']=='商户'){
|
||||
$item['mer_name']=Merchant::where('mer_id',$item['mer_id'])->value('mer_name');
|
||||
}
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取流水数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return FinancialRecord::where($this->searchWhere)->count();
|
||||
}
|
||||
}
|
74
app/admin/lists/supplier/SupplierBindGoodsLists.php
Normal file
74
app/admin/lists/supplier/SupplierBindGoodsLists.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\supplier;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\supplier\SupplierBindGoods;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\Goodsclass;
|
||||
|
||||
/**
|
||||
* 供应商商品绑定列表
|
||||
* Class SupplierBindGoodsLists
|
||||
* @package app\admin\listssupplier
|
||||
*/
|
||||
class SupplierBindGoodsLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['supplier_id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取供应商商品绑定列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return SupplierBindGoods::where($this->searchWhere)->withoutField(['update_time','delete_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($item){
|
||||
$goods=Goods::where('id',$item['goods_id'])->field('name,class,spec,imgs')->find();
|
||||
if($goods){
|
||||
$item['class_name']=Goodsclass::where('id',$goods['class'])->value('name');
|
||||
$item['goods_name']=$goods['name'];
|
||||
$item['imgs']=$goods['imgs'];
|
||||
$item['spec']=$goods['spec'];
|
||||
}
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取供应商商品绑定数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return SupplierBindGoods::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -12,6 +12,7 @@ use app\common\model\opurchase\Opurchaseinfo;
|
||||
use app\common\model\order\Cart;
|
||||
use app\common\model\retail\Cashierclass;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\model\supplier\SupplierBindGoods;
|
||||
use support\Log;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -195,38 +196,30 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
public static function createSupplierGoods($goods)
|
||||
{
|
||||
try {
|
||||
$sys_labels = Goods::where('id', $goods['goods'])->value('sys_labels');
|
||||
$supplier_arr = [];
|
||||
$goods_offer = [];
|
||||
|
||||
if ($sys_labels) {
|
||||
$sys_labels_arr = explode(',', $sys_labels);
|
||||
foreach ($sys_labels_arr as $k => $v) {
|
||||
if ($v > 0) {
|
||||
$supplier = Supplier::whereLike('sys_labels', "%," . $v . ",%")->field('id,mer_name')->select();
|
||||
foreach ($supplier as $key => $value) {
|
||||
$supplier_arr[] = $value;
|
||||
}
|
||||
$supplier_arr=SupplierBindGoods::where('goods_id')->column('supplier_id');
|
||||
if($supplier_arr){
|
||||
$supplier_arr=array_unique($supplier_arr);
|
||||
foreach ($supplier_arr as $k => $v) {
|
||||
$goods_offer[] = [
|
||||
'supplier_id' => $v['id'],
|
||||
'goods_id' => $goods['goods'],
|
||||
'order_id' => $goods['pid'],
|
||||
'price' => 0,
|
||||
'need_num' => $goods['nums'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
}
|
||||
if (count($goods_offer) >= 1) {
|
||||
$res = OpurchaseGoodsOffer::insertAll($goods_offer);
|
||||
if ($res) {
|
||||
Opurchaseinfo::where('id',$goods['id'])->update(['is_push'=>1]);
|
||||
return $goods_offer;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
}
|
||||
foreach ($supplier_arr as $k => $v) {
|
||||
$goods_offer[] = [
|
||||
'supplier_id' => $v['id'],
|
||||
'goods_id' => $goods['goods'],
|
||||
'order_id' => $goods['pid'],
|
||||
'price' => 0,
|
||||
'need_num' => $goods['nums'],
|
||||
'create_time'=>time()
|
||||
];
|
||||
}
|
||||
if (count($goods_offer) >= 1) {
|
||||
$res = OpurchaseGoodsOffer::insertAll($goods_offer);
|
||||
if ($res) {
|
||||
Opurchaseinfo::where('id',$goods['id'])->update(['is_push'=>1]);
|
||||
return $goods_offer;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
Log::error('添加采购订单报价失败:' . $e->getMessage());
|
||||
|
105
app/admin/logic/supplier/SupplierBindGoodsLogic.php
Normal file
105
app/admin/logic/supplier/SupplierBindGoodsLogic.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic\supplier;
|
||||
|
||||
use app\common\model\supplier\SupplierBindGoods;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
|
||||
/**
|
||||
* 供应商商品绑定逻辑
|
||||
* Class SupplierBindGoodsLogic
|
||||
* @package app\admin\logic\supplier
|
||||
*/
|
||||
class SupplierBindGoodsLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加供应商商品绑定
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$list=[];
|
||||
foreach($params['data'] as $item){
|
||||
$list[]=[
|
||||
'supplier_id'=>$item['supplier_id'],
|
||||
'goods_id'=>$item['goods_id'],
|
||||
'goods_name'=>$item['goods_name'],
|
||||
'goods_price'=>$item['price'],
|
||||
];
|
||||
}
|
||||
(new SupplierBindGoods())->saveAll($list);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑供应商管理
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
SupplierBindGoods::where('id', $params['id'])->update([
|
||||
'goods_id'=>$params['goods_id'],
|
||||
'supplier_id'=>$params['supplier_id'],
|
||||
'price'=>$params['price'],
|
||||
'goods_name'=>$params['goods_name'],
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除供应商管理
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return SupplierBindGoods::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取供应商管理详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = SupplierBindGoods::findOrEmpty($params['id']);
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
85
app/admin/validate/supplier/SupplierBindGoodsValidate.php
Normal file
85
app/admin/validate/supplier/SupplierBindGoodsValidate.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\supplier;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 供应商管理验证器
|
||||
* Class SupplierValidate
|
||||
* @package app\admin\validate\supplier
|
||||
*/
|
||||
class SupplierBindGoodsValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'goods_id' => 'require',
|
||||
'supplier_id' => 'require',
|
||||
'goods_name' => 'require',
|
||||
'price' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'goods_id' => '商品id',
|
||||
'supplier_id' => '供应链id',
|
||||
'goods_name' => '商品名称',
|
||||
'price' => '价格',
|
||||
];
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return SupplierValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['goods_id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return SupplierValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return SupplierValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return SupplierValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 14:33
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ class OrderEnum
|
||||
* @MERCHANT_ORDER_PAY 商户订单支付
|
||||
* @PLATFORM_ORDER_OBTAINS 平台订单获得
|
||||
* @SUPPLIER_ORDER_OBTAINS 供应链订单获得
|
||||
* @MERCHANT_ORDER_PAY 平台订单支付
|
||||
* @PLATFORM_ORDER_PAY 平台订单支付
|
||||
*/
|
||||
const USER_ORDER_PAY = 1;
|
||||
const MERCHANT_ORDER_OBTAINS = 2;
|
||||
@ -45,7 +45,30 @@ class OrderEnum
|
||||
const PLATFORM =2;
|
||||
const SUPPLIER =3;
|
||||
|
||||
/**
|
||||
* @notes 获取支付类型
|
||||
* @param bool $value
|
||||
* @return string|string[]
|
||||
* @author 段誉
|
||||
* @date 2023/2/23 15:36
|
||||
*/
|
||||
public static function getFinancialType($value = true)
|
||||
{
|
||||
$data = [
|
||||
self::USER_ORDER_PAY=>'用户订单支付',
|
||||
self::MERCHANT_ORDER_PAY=>'商户订单支付',
|
||||
self::PLATFORM_ORDER_PAY=>'平台订单支付',
|
||||
self::MERCHANT_ORDER_OBTAINS=>'商户订单提现',
|
||||
self::ORDER_HANDLING_FEES=>'订单手续费',
|
||||
self::PLATFORM_ORDER_OBTAINS=>'平台订单获得',
|
||||
self::SUPPLIER_ORDER_OBTAINS=>'供应商订单获得',
|
||||
|
||||
];
|
||||
if ($value === true) {
|
||||
return $data;
|
||||
}
|
||||
return $data[$value] ?? '';
|
||||
}
|
||||
|
||||
|
||||
}
|
40
app/common/model/financial/FinancialRecord.php
Normal file
40
app/common/model/financial/FinancialRecord.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\financial;
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 采购订单模型
|
||||
* Class FinancialRecord
|
||||
* @package app\common\model\FinancialRecord
|
||||
*/
|
||||
class FinancialRecord extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'financial_record';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
/**
|
||||
* @notes 获取类型
|
||||
*/
|
||||
public function getTypeAttr($value){
|
||||
$type=[
|
||||
'0'=>'用户',
|
||||
'1'=>'商户',
|
||||
'2'=>'平台',
|
||||
'3'=>'供应链',
|
||||
];
|
||||
return $type[$value]??'无属性';
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取流水类型
|
||||
*/
|
||||
public function getFinancialTypeAttr($value){
|
||||
return OrderEnum::getFinancialType($value)??'无属性';
|
||||
}
|
||||
}
|
22
app/common/model/supplier/SupplierBindGoods.php
Normal file
22
app/common/model/supplier/SupplierBindGoods.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\supplier;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\user\UserAuth;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 供应商商品绑定模型
|
||||
* Class Supplier
|
||||
* @package app\common\model\supplier
|
||||
*/
|
||||
class SupplierBindGoods extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'supplier_bind_goods';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user