Merge pull request 'dev' (#368) from dev into main

Reviewed-on: https://gitea.lihaink.cn/mkm/multi-store/pulls/368
This commit is contained in:
mkm 2024-11-30 15:13:31 +08:00
commit 9d8cceb1e4
2 changed files with 68 additions and 23 deletions

View File

@ -145,6 +145,8 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
$address = ''; $address = '';
$arrival_time = ''; $arrival_time = '';
$pay_price = ''; $pay_price = '';
$warehousing_price='';
$outbound_price='';
if($export==2){ if($export==2){
if($item['order_sn']!=''){ if($item['order_sn']!=''){
$find=StoreOrder::where('order_id',$item['order_sn'])->field('paid,pay_type,pay_price')->find(); $find=StoreOrder::where('order_id',$item['order_sn'])->field('paid,pay_type,pay_price')->find();
@ -179,10 +181,18 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
} }
} }
if($item['warehousing_id']>0){ if($item['warehousing_id']>0){
$order_rk=WarehouseOrder::where('id',$item['warehousing_id'])->value('code'); $warehouseOrder=WarehouseOrder::where('id',$item['warehousing_id'])->field('code,total_price')->find();
if($warehouseOrder){
$order_rk=$warehouseOrder['code'];
$warehousing_price=$warehouseOrder['total_price'];
}
} }
if($item['outbound_id']>0){ if($item['outbound_id']>0){
$order_ck=WarehouseOrder::where('id',$item['outbound_id'])->value('code'); $warehouseOrder=WarehouseOrder::where('id',$item['outbound_id'])->field('code,total_price')->find();
if($warehouseOrder){
$order_ck=$warehouseOrder['code'];
$outbound_price=$warehouseOrder['total_price'];
}
} }
$nickname = $item->other_data?->nickname??''; $nickname = $item->other_data?->nickname??'';
$phone = $item->other_data?->phone??''; $phone = $item->other_data?->phone??'';
@ -193,6 +203,8 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
$item['pay_type_name'] = $pay_type_name; $item['pay_type_name'] = $pay_type_name;
$item['order_ck'] = $order_ck; $item['order_ck'] = $order_ck;
$item['order_rk'] = $order_rk; $item['order_rk'] = $order_rk;
$item['warehousing_price']=$warehousing_price;
$item['outbound_price']=$outbound_price;
$item['nickname'] = $nickname; $item['nickname'] = $nickname;
$item['phone'] = $phone; $item['phone'] = $phone;
$item['address'] = $address; $item['address'] = $address;
@ -245,7 +257,9 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
'system_store' => '门店', 'system_store' => '门店',
'admin_name' => '门店', 'admin_name' => '门店',
'warehousing' => '入库', 'warehousing' => '入库',
'warehousing_price' => '入库金额',
'outbound' => '出库', 'outbound' => '出库',
'outbound_price' => '出库金额',
'total_price' => '总价', 'total_price' => '总价',
'admin_name' => '用户', 'admin_name' => '用户',
'mark' => '备注', 'mark' => '备注',

View File

@ -58,7 +58,7 @@ class IndexController extends BaseApiController
public function index() public function index()
{ {
d(1); d(1);
$arr=Db::name('ceshi_copy')->select(); $arr = Db::name('ceshi_copy')->select();
foreach ($arr as $k => $v) { foreach ($arr as $k => $v) {
$data = [ $data = [
@ -74,9 +74,9 @@ class IndexController extends BaseApiController
if ($rose_price > 0) { if ($rose_price > 0) {
//利润除于零售 //利润除于零售
$price_div = bcdiv($rose_price, $v['price'], 2); $price_div = bcdiv($rose_price, $v['price'], 2);
$rose=bcmul($price_div, 100, 2); $rose = bcmul($price_div, 100, 2);
} }
$data['rose']=$rose; $data['rose'] = $rose;
StoreProduct::update($data, ['id' => $v['product_id']]); StoreProduct::update($data, ['id' => $v['product_id']]);
//修改 //修改
StoreBranchProduct::where('product_id', $v['product_id'])->whereNotIn('store_id', [17, 18])->update([ StoreBranchProduct::where('product_id', $v['product_id'])->whereNotIn('store_id', [17, 18])->update([
@ -89,16 +89,16 @@ class IndexController extends BaseApiController
]); ]);
} }
d(11); d(11);
$pay_price=StoreOrder::where('store_id',3)->where('id','>=',1867)->where('id','<=',4826)->where('paid',1)->sum('pay_price'); $pay_price = StoreOrder::where('store_id', 3)->where('id', '>=', 1867)->where('id', '<=', 4826)->where('paid', 1)->sum('pay_price');
$refund_price=StoreOrder::where('store_id',3)->where('id','>=',1867)->where('id','<=',4826)->where('paid',1)->sum('refund_price'); $refund_price = StoreOrder::where('store_id', 3)->where('id', '>=', 1867)->where('id', '<=', 4826)->where('paid', 1)->sum('refund_price');
d($pay_price,$refund_price); d($pay_price, $refund_price);
$arr=StoreOrder::where('store_id',3)->where('id','>',551)->where('paid',1)->field('id,pay_price,deduction_price,refund_price')->select()->toArray(); $arr = StoreOrder::where('store_id', 3)->where('id', '>', 551)->where('paid', 1)->field('id,pay_price,deduction_price,refund_price')->select()->toArray();
$data=[]; $data = [];
foreach ($arr as $k => $v) { foreach ($arr as $k => $v) {
$total_price=StoreOrderCartInfo::where('oid', $v['id'])->sum('total_price'); $total_price = StoreOrderCartInfo::where('oid', $v['id'])->sum('total_price');
if($total_price != $v['pay_price']){ if ($total_price != $v['pay_price']) {
$s=$v; $s = $v;
$s['total_price']=$total_price; $s['total_price'] = $total_price;
$data[] = $s; $data[] = $s;
} }
} }
@ -259,13 +259,13 @@ class IndexController extends BaseApiController
*/ */
public function purchase_product_offer() public function purchase_product_offer()
{ {
$date=$this->request->get('date'); $date = $this->request->get('date');
if($date){ if ($date) {
$this->request->setGet(['date'=>$date,'export'=>2]); $this->request->setGet(['date' => $date, 'export' => 2]);
$lists=new PurchaseProductOfferListsTwo(); $lists = new PurchaseProductOfferListsTwo();
$exportDownloadUrl = $lists->createExcel($lists->setExcelFields(), $lists->lists()); $exportDownloadUrl = $lists->createExcel($lists->setExcelFields(), $lists->lists());
$fileKey=explode('?file=',$exportDownloadUrl)[1]; $fileKey = explode('?file=', $exportDownloadUrl)[1];
//通过文件缓存的key获取文件储存的路径 //通过文件缓存的key获取文件储存的路径
$exportCache = new ExportCache(); $exportCache = new ExportCache();
$fileInfo = $exportCache->getFile($fileKey); $fileInfo = $exportCache->getFile($fileKey);
if (empty($fileInfo)) { if (empty($fileInfo)) {
@ -273,10 +273,41 @@ class IndexController extends BaseApiController
} }
//下载前删除缓存 //下载前删除缓存
Cache::delete($fileKey); Cache::delete($fileKey);
return response()->download($fileInfo['src'] . $fileInfo['name'],$fileInfo['name']); return response()->download($fileInfo['src'] . $fileInfo['name'], $fileInfo['name']);
}else{ } else {
return $this->fail('时间不能为空'); return $this->fail('时间不能为空');
} }
} }
/**
* @notes 采购商品下载
*/
public function wps_product()
{
$data = $this->request->post();
if ($data) {
if ($data['product_id'] > 0) {
$find = Db::name('wps_product')->where('product_id', $data['product_id'])->find();
$arr = [];
if ($data['purchase'] > 0) {
$arr['purchase'] = $data['purchase'];
}
if ($data['cost'] > 0) {
$arr['cost'] = $data['cost'];
}
if ($data['price'] > 0) {
$arr['price'] = $data['price'];
}
if ($find) {
Db::name('wps_product')->where('id', $find['id'])->update($arr);
} else {
$arr['product_id']=$data['product_id'];
$arr['name']=$data['name'];
Db::name('wps_product')->insert($arr);
}
}
} else {
return $this->fail('时间不能为空');
}
}
} }