commit
2a287fb738
@ -96,6 +96,12 @@ class PurchaseProductOfferController extends BaseAdminController
|
||||
PurchaseProductOfferLogic::setStoreroomInfo($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
public function setStoreroomInfoTwo()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
PurchaseProductOfferLogic::setStoreroomInfoTwo($params);
|
||||
return $this->success('设置成功', [], 1, 1);
|
||||
}
|
||||
/**
|
||||
* @notes 删除采购商品
|
||||
* @return \think\response\Json
|
||||
|
@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\store_product_group_price;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\store_product_group_price\StoreProductGroupPriceLists;
|
||||
use app\admin\logic\store_product_group_price\StoreProductGroupPriceLogic;
|
||||
use app\admin\validate\store_product_group_price\StoreProductGroupPriceValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 分组报价控制器
|
||||
* Class StoreProductGroupPriceController
|
||||
* @package app\admin\controller\store_product_group_price
|
||||
*/
|
||||
class StoreProductGroupPriceController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取分组报价列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new StoreProductGroupPriceLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加分组报价
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new StoreProductGroupPriceValidate())->post()->goCheck('add');
|
||||
$result = StoreProductGroupPriceLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(StoreProductGroupPriceLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑分组报价
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = StoreProductGroupPriceLogic::edit($params);
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除分组报价
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new StoreProductGroupPriceValidate())->post()->goCheck('delete');
|
||||
StoreProductGroupPriceLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取分组报价详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = StoreProductGroupPriceLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\store_product_group_price;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\store_product_group_price\StoreProductGroupPrice;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\user_ship\UserShip;
|
||||
|
||||
/**
|
||||
* 分组报价列表
|
||||
* Class StoreProductGroupPriceLists
|
||||
* @package app\admin\listsstore_product_group_price
|
||||
*/
|
||||
class StoreProductGroupPriceLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['product_id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取分组报价列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreProduct::where($this->searchWhere)->limit($this->limitOffset, $this->limitLength)
|
||||
->field('id,store_name,purchase,cost,vip_price,price,unit')
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$item['lists'] =StoreProductGroupPrice::where('product_id',$item['id'])->field('id,group_id,price')
|
||||
->select()->each(function ($item_two){
|
||||
$item_two['group_name']=UserShip::where('id',$item_two['group_id'])->value('title');
|
||||
});
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取分组报价数量
|
||||
* @return int
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return StoreProduct::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -58,6 +58,11 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
if ($order_type == 4) {
|
||||
throw new BusinessException('不能添加线上订单,线上订单只能转换');
|
||||
}
|
||||
if($order_type==7 ||$order_type==5){
|
||||
$is_buyer=1;
|
||||
}else{
|
||||
$is_buyer=-1;
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$datas = [];
|
||||
@ -83,6 +88,7 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
$datas[$k]['net_weight'] = $v['net_weight'] ?? '';
|
||||
$datas[$k]['cart_num'] = $v['nums'];
|
||||
$datas[$k]['accept_num'] = $v['nums'];
|
||||
$datas[$k]['is_buyer'] = $is_buyer;
|
||||
$datas[$k]['price'] = $v['price'];
|
||||
$datas[$k]['package'] = $v['package'] ?? '';
|
||||
$datas[$k]['total_price'] = $total_prices;
|
||||
|
@ -255,6 +255,18 @@ class PurchaseProductOfferLogic extends BaseLogic
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
public static function setStoreroomInfoTwo(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
PurchaseProductOffer::where('id', $params['id'])->update(['buyer_nums' => $params['buyer_nums']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 是否需采购
|
||||
*/
|
||||
|
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\logic\store_product_group_price;
|
||||
|
||||
|
||||
use app\common\model\store_product_group_price\StoreProductGroupPrice;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\user_ship\UserShip;
|
||||
use support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 分组报价逻辑
|
||||
* Class StoreProductGroupPriceLogic
|
||||
* @package app\admin\logic\store_product_group_price
|
||||
*/
|
||||
class StoreProductGroupPriceLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加分组报价
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
StoreProductGroupPrice::create([
|
||||
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑分组报价
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
foreach($params as $k=>$v){
|
||||
if($v['group_price_id']==0 && !empty($v['price'])){
|
||||
StoreProductGroupPrice::create([
|
||||
'product_id'=>$v['product_id'],
|
||||
'group_id'=>$v['id'],
|
||||
'price_type'=>$v['price_type'],
|
||||
'base_rate'=>$v['base_rate'],
|
||||
'price'=>$v['price'],
|
||||
]);
|
||||
}elseif($v['group_price_id']>0 && !empty($v['price'])){
|
||||
StoreProductGroupPrice::where('id', $v['group_price_id'])->update([
|
||||
'price_type'=>$v['price_type'],
|
||||
'base_rate'=>$v['base_rate'],
|
||||
'price'=>$v['price'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
Db::rollback();
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除分组报价
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return StoreProductGroupPrice::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取分组报价详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$arr=StoreProductGroupPrice::where('product_id',$params['product_id'])->select()->toArray();
|
||||
$purchase=StoreProduct::where('id',$params['product_id'])->value('purchase');
|
||||
$arr_two=UserShip::where('id','>',4)->select()->toArray();
|
||||
foreach ($arr_two as $k=>$v){
|
||||
$arr_two[$k]['purchase']=$purchase;
|
||||
$arr_two[$k]['product_id']=$params['product_id'];
|
||||
$arr_two[$k]['group_price_id']=0;
|
||||
foreach ($arr as $k_two=>$v_two){
|
||||
if($v['id']==$v_two['group_id']){
|
||||
$arr_two[$k]['price_type']=$v_two['price_type'];
|
||||
$arr_two[$k]['base_rate']=$v_two['base_rate'];
|
||||
$arr_two[$k]['price']=$v_two['price'];
|
||||
$arr_two[$k]['group_price_id']=$v_two['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $arr_two;
|
||||
}
|
||||
}
|
@ -218,16 +218,26 @@ class WarehouseProductLogic extends BaseLogic
|
||||
$before_nums = $warehouseProductStorege['nums'];
|
||||
$after_nums = bcsub($warehouseProductStorege['nums'], $params['nums'], 2);
|
||||
}
|
||||
WarehouseProduct::where('id', $params['id'])->update([
|
||||
'nums' => $params['nums'],
|
||||
'supplier_id' => $params['supplier_id'],
|
||||
'pay_type' => $params['pay_type'],
|
||||
'nums' => $params['nums'],
|
||||
'purchase' => $params['purchase'],
|
||||
'before_nums' => $before_nums,
|
||||
'after_nums' => $after_nums,
|
||||
'total_price' => $params['nums'] * $params['purchase'],
|
||||
]);
|
||||
if($find['financial_pm']==1){
|
||||
$datas=[
|
||||
'nums' => $params['nums'],
|
||||
'supplier_id' => $params['supplier_id'],
|
||||
'pay_type' => $params['pay_type'],
|
||||
'purchase' => $params['purchase'],
|
||||
'before_nums' => $before_nums,
|
||||
'after_nums' => $after_nums,
|
||||
'total_price' => $params['total_price'],
|
||||
];
|
||||
}else{
|
||||
$datas=[
|
||||
'nums' => $params['nums'],
|
||||
'price' => $params['price'],
|
||||
'before_nums' => $before_nums,
|
||||
'after_nums' => $after_nums,
|
||||
'total_price' => $params['total_price'],
|
||||
];
|
||||
}
|
||||
WarehouseProduct::where('id', $params['id'])->update($datas);
|
||||
$finds = WarehouseProduct::where('oid', $params['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
|
||||
if ($finds) {
|
||||
WarehouseOrder::where('id', $params['oid'])->update([
|
||||
|
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\store_product_group_price;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 分组报价验证器
|
||||
* Class StoreProductGroupPriceValidate
|
||||
* @package app\admin\validate\store_product_group_price
|
||||
*/
|
||||
class StoreProductGroupPriceValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return StoreProductGroupPriceValidate
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return StoreProductGroupPriceValidate
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return StoreProductGroupPriceValidate
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return StoreProductGroupPriceValidate
|
||||
* @author admin
|
||||
* @date 2024/12/02 15:42
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\store_product_group_price;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 分组报价模型
|
||||
* Class StoreProductGroupPrice
|
||||
* @package app\common\model\store_product_group_price
|
||||
*/
|
||||
class StoreProductGroupPrice extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'store_product_group_price';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user