1
This commit is contained in:
parent
66571b43a1
commit
d0842aadc5
@ -2,6 +2,7 @@
|
|||||||
namespace app\admin\controller\purchase_order;
|
namespace app\admin\controller\purchase_order;
|
||||||
use app\admin\controller\BaseAdminController;
|
use app\admin\controller\BaseAdminController;
|
||||||
use app\admin\lists\purchase_order\PurchaseOrderLists;
|
use app\admin\lists\purchase_order\PurchaseOrderLists;
|
||||||
|
use app\admin\lists\purchase_order_info\PurchaseOrderInfoLists;
|
||||||
use app\admin\logic\purchase_order\PurchaseOrderLogic;
|
use app\admin\logic\purchase_order\PurchaseOrderLogic;
|
||||||
|
|
||||||
class PurchaseOrderController extends BaseAdminController{
|
class PurchaseOrderController extends BaseAdminController{
|
||||||
@ -10,7 +11,10 @@ class PurchaseOrderController extends BaseAdminController{
|
|||||||
{
|
{
|
||||||
return $this->dataLists(new PurchaseOrderLists());
|
return $this->dataLists(new PurchaseOrderLists());
|
||||||
}
|
}
|
||||||
|
public function info_lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new PurchaseOrderInfoLists());
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 合并今日商户订单
|
* 合并今日商户订单
|
||||||
*/
|
*/
|
||||||
@ -25,4 +29,13 @@ class PurchaseOrderController extends BaseAdminController{
|
|||||||
PurchaseOrderLogic::platformTodayOrder();
|
PurchaseOrderLogic::platformTodayOrder();
|
||||||
return $this->success('合并成功');
|
return $this->success('合并成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
|
public function detail(){
|
||||||
|
$id=$this->request->get('id');
|
||||||
|
$res=PurchaseOrderLogic::detail($id);
|
||||||
|
return $this->data($res);
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ namespace app\admin\lists\purchase_order;
|
|||||||
use app\admin\lists\BaseAdminDataLists;
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\purchase_order\PurchaseOrder;
|
use app\common\model\purchase_order\PurchaseOrder;
|
||||||
|
use app\common\model\system_store\SystemStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购订单列表
|
* 采购订单列表
|
||||||
@ -25,7 +26,7 @@ class PurchaseOrderLists extends BaseAdminDataLists implements ListsSearchInterf
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['store_id', 'order_id'],
|
'=' => ['store_id', 'order_id', 'is_mer','storage'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,10 +42,45 @@ class PurchaseOrderLists extends BaseAdminDataLists implements ListsSearchInterf
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
|
if($this->request->get('o_id')){
|
||||||
|
$arr=PurchaseOrder::where('id',$this->request->get('o_id'))->value('order_arr');
|
||||||
|
if($arr){
|
||||||
|
$this->searchWhere[]=['id','in',$arr];
|
||||||
|
}
|
||||||
|
}
|
||||||
return PurchaseOrder::where($this->searchWhere)
|
return PurchaseOrder::where($this->searchWhere)
|
||||||
->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) {
|
||||||
|
$item->system_store = SystemStore::where('id',$item->store_id)->value('name');
|
||||||
|
} else {
|
||||||
|
$item->system_store = '平台';
|
||||||
|
}
|
||||||
|
if ($item->is_mer == 1) {
|
||||||
|
$item->mer_name = '商户';
|
||||||
|
} else {
|
||||||
|
$item->mer_name = '平台';
|
||||||
|
}
|
||||||
|
if ($item->is_opurchase == 1) {
|
||||||
|
$item->opurchase_name = '已采购';
|
||||||
|
} else {
|
||||||
|
$item->opurchase_name = '未采购';
|
||||||
|
}
|
||||||
|
switch ($item->storage) {
|
||||||
|
case 0:
|
||||||
|
$item->storage_name = '未入库';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
$item->storage_name = '部分入库';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$item->storage_name = '已入库';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$item->storage_name = '未入库';
|
||||||
|
}
|
||||||
|
})->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -58,5 +94,4 @@ class PurchaseOrderLists extends BaseAdminDataLists implements ListsSearchInterf
|
|||||||
{
|
{
|
||||||
return PurchaseOrder::where($this->searchWhere)->count();
|
return PurchaseOrder::where($this->searchWhere)->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\lists\purchase_order_info;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\BaseAdminDataLists;
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\purchase_order_info\PurchaseOrderInfo;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
|
use app\common\model\system_store\SystemStore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购订单详情表
|
||||||
|
* Class PurchaseOrderInfoLists
|
||||||
|
* @package app\admin\lists\purchase_order
|
||||||
|
*/
|
||||||
|
class PurchaseOrderInfoLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/05/31 17:09
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['store_id', 'oid', ],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购订单列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/05/31 17:09
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
return PurchaseOrderInfo::where($this->searchWhere)
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()->each(function ($item) {
|
||||||
|
$find=StoreProduct::where('id',$item->product_id)->field('store_info,unit,store_name,image')->find();
|
||||||
|
if($find){
|
||||||
|
$item->store_name=$find->store_name;
|
||||||
|
$item->unit_name=StoreProductUnit::where('id',$find->unit)->value('name');
|
||||||
|
$item->store_info=$find->store_info;
|
||||||
|
$item->image=$find->image;
|
||||||
|
}
|
||||||
|
switch ($item->storage) {
|
||||||
|
case 0:
|
||||||
|
$item->storage_name = '未入库';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
$item->storage_name = '部分入库';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$item->storage_name = '已入库';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$item->storage_name = '未入库';
|
||||||
|
}
|
||||||
|
})->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取采购订单数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/05/31 17:09
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return PurchaseOrderInfo::where($this->searchWhere)->count();
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ use app\common\logic\BaseLogic;
|
|||||||
use app\common\model\purchase_order_info\PurchaseOrderInfo;
|
use app\common\model\purchase_order_info\PurchaseOrderInfo;
|
||||||
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;
|
||||||
|
use app\common\model\system_store\SystemStore;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
@ -81,27 +82,26 @@ class PurchaseOrderLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function platformTodayOrder()
|
public static function platformTodayOrder()
|
||||||
{
|
{
|
||||||
// Db::startTrans();
|
Db::startTrans();
|
||||||
// try {
|
try {
|
||||||
$purchaseOrderInfo = new PurchaseOrderInfo();
|
$purchaseOrderInfo = new PurchaseOrderInfo();
|
||||||
$purchase_order_info=[];
|
$purchase_order_info=[];
|
||||||
$order_arr = PurchaseOrder::whereDay('create_time')->where('is_mer',1)->column('id');
|
$order_arr = PurchaseOrder::whereDay('create_time')->where('is_mer',1)->column('id');
|
||||||
// $price = PurchaseOrder::whereDay('create_time')->field('SUM(actual) as pay_price,SUM(total) as total_price')->find();
|
$price = PurchaseOrder::whereDay('create_time')->field('SUM(actual) as pay_price,SUM(total) as total_price')->find();
|
||||||
// $data = [
|
$data = [
|
||||||
// 'store_id' => 0,
|
'store_id' => 0,
|
||||||
// 'order_arr' => json_encode($order_arr),
|
'order_arr' => json_encode($order_arr),
|
||||||
// 'order_id' => getNewOrderId('PT'),
|
'order_id' => getNewOrderId('PT'),
|
||||||
// 'total' => $price['total_price'],
|
'total' => $price['total_price'],
|
||||||
// 'actual' => $price['pay_price'],
|
'actual' => $price['pay_price'],
|
||||||
// 'money' => $price['pay_price'],
|
'money' => $price['pay_price'],
|
||||||
// 'paid' => 1,
|
'paid' => 1,
|
||||||
// 'is_mer' => 2,
|
'is_mer' => 2,
|
||||||
// 'create_time' => time(),
|
'create_time' => time(),
|
||||||
// 'update_time' => time(),
|
'update_time' => time(),
|
||||||
// ];
|
];
|
||||||
// $res = PurchaseOrder::create($data);
|
$res = PurchaseOrder::create($data);
|
||||||
$info = StoreOrderCartInfo::where('oid', 'in', $order_arr)->field('store_id, product_id,price,SUM(total_price) as total_price, SUM(cart_num) as cart_num')->group('store_id, product_id')->select();
|
$info = PurchaseOrderInfo::where('oid', 'in', $order_arr)->field('store_id, product_id,price,SUM(total_price) as total_price, SUM(cart_num) as cart_num')->group('store_id, product_id')->select();
|
||||||
d($info);
|
|
||||||
foreach ($info as $item) {
|
foreach ($info as $item) {
|
||||||
$arr['oid'] = $res['id'];
|
$arr['oid'] = $res['id'];
|
||||||
$arr['store_id'] = $item['store_id'];
|
$arr['store_id'] = $item['store_id'];
|
||||||
@ -114,14 +114,14 @@ class PurchaseOrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
$purchaseOrderInfo->saveAll($purchase_order_info);
|
$purchaseOrderInfo->saveAll($purchase_order_info);
|
||||||
|
|
||||||
// Db::commit();
|
Db::commit();
|
||||||
// return true;
|
return true;
|
||||||
// } catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Db::rollback();
|
Db::rollback();
|
||||||
// d($e);
|
d($e);
|
||||||
// self::setError($e->getMessage());
|
self::setError($e->getMessage());
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,8 +144,29 @@ class PurchaseOrderLogic extends BaseLogic
|
|||||||
* @author admin
|
* @author admin
|
||||||
* @date 2024/08/01 16:32
|
* @date 2024/08/01 16:32
|
||||||
*/
|
*/
|
||||||
public static function detail($params): array
|
public static function detail($id): array
|
||||||
{
|
{
|
||||||
return PurchaseOrder::findOrEmpty($params['id'])->toArray();
|
$data= PurchaseOrder::findOrEmpty($id)->toArray();
|
||||||
|
if($data){
|
||||||
|
if($data['store_id']){
|
||||||
|
$data['system_store']=SystemStore::where('id',$data['store_id'])->value('name');
|
||||||
|
}else{
|
||||||
|
$data['system_store']='平台';
|
||||||
|
}
|
||||||
|
switch ($data['storage']) {
|
||||||
|
case 0:
|
||||||
|
$data['storage_name'] = '未入库';
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
$data['storage_name'] = '部分入库';
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$data['storage_name'] = '已入库';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$data['storage_name'] = '未入库';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@ class PurchaseOrder extends BaseModel
|
|||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
protected $name = 'purchase_order';
|
protected $name = 'purchase_order';
|
||||||
protected $deleteTime = 'delete_time';
|
protected $deleteTime = 'delete_time';
|
||||||
|
protected $json = ['order_arr'];
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user