Merge branch 'main' of https://gitea.lihaink.cn/mkm/multi-store
# Conflicts: # app/admin/controller/LocalController.php
This commit is contained in:
commit
746f0970da
@ -91,11 +91,4 @@ class ActivityZoneController extends BaseAdminController
|
|||||||
return $this->data($result);
|
return $this->data($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function export()
|
|
||||||
{
|
|
||||||
$params = $this->request->get();
|
|
||||||
$file_path = ActivityZoneLogic::export($params);
|
|
||||||
return $this->success('导出成功', ['url' => $file_path]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
98
app/admin/controller/ActivityZoneFormController.php
Normal file
98
app/admin/controller/ActivityZoneFormController.php
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
use app\admin\lists\ActivityZoneFormLists;
|
||||||
|
use app\admin\logic\ActivityZoneFormLogic;
|
||||||
|
use app\admin\validate\ActivityZoneFormValidate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityZoneFormController控制器
|
||||||
|
* Class ActivityZoneFormController
|
||||||
|
* @package app\admin\controller
|
||||||
|
*/
|
||||||
|
class ActivityZoneFormController extends BaseAdminController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取列表
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function lists()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new ActivityZoneFormLists());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function add()
|
||||||
|
{
|
||||||
|
$params = (new ActivityZoneFormValidate())->post()->goCheck('add');
|
||||||
|
$result = ActivityZoneFormLogic::add($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('添加成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(ActivityZoneFormLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function edit()
|
||||||
|
{
|
||||||
|
$params = (new ActivityZoneFormValidate())->post()->goCheck('edit');
|
||||||
|
$result = ActivityZoneFormLogic::edit($params);
|
||||||
|
if (true === $result) {
|
||||||
|
return $this->success('编辑成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
return $this->fail(ActivityZoneFormLogic::getError());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function delete()
|
||||||
|
{
|
||||||
|
$params = (new ActivityZoneFormValidate())->post()->goCheck('delete');
|
||||||
|
ActivityZoneFormLogic::delete($params);
|
||||||
|
return $this->success('删除成功', [], 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取详情
|
||||||
|
* @return \think\response\Json
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function detail()
|
||||||
|
{
|
||||||
|
$params = (new ActivityZoneFormValidate())->goCheck('detail');
|
||||||
|
$result = ActivityZoneFormLogic::detail($params);
|
||||||
|
return $this->data($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function export()
|
||||||
|
{
|
||||||
|
$params = $this->request->get();
|
||||||
|
$file_path = ActivityZoneFormLogic::export($params);
|
||||||
|
return $this->success('导出成功', ['url' => $file_path]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace app\admin\controller;
|
namespace app\admin\controller;
|
||||||
|
|
||||||
|
use app\api\logic\DemoLogic;
|
||||||
use app\common\service\pay\PayService;
|
use app\common\service\pay\PayService;
|
||||||
|
|
||||||
class IndexController extends BaseAdminController
|
class IndexController extends BaseAdminController
|
||||||
@ -24,4 +25,9 @@ class IndexController extends BaseAdminController
|
|||||||
return $this->fail($e->extra['message']);
|
return $this->fail($e->extra['message']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public function demo2()
|
||||||
|
{
|
||||||
|
$res=DemoLogic::test();
|
||||||
|
return $this->success('成功');
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,13 +4,161 @@ namespace app\admin\controller;
|
|||||||
|
|
||||||
use app\common\model\store_category\StoreCategory;
|
use app\common\model\store_category\StoreCategory;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\store_product_group_price\StoreProductGroupPrice;
|
||||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
use support\Redis;
|
use support\Redis;
|
||||||
|
|
||||||
class LocalController extends BaseAdminController
|
class LocalController extends BaseAdminController
|
||||||
{
|
{
|
||||||
|
|
||||||
public $notNeedLogin = ['index'];
|
public $notNeedLogin = ['setPrice'];
|
||||||
|
|
||||||
|
public function setPrice()
|
||||||
|
{
|
||||||
|
$file = $this->request->file('file');
|
||||||
|
$reader = IOFactory::createReader('Xlsx');
|
||||||
|
$spreadsheet = $reader->load($file->getRealPath());
|
||||||
|
$data = $spreadsheet->getActiveSheet()->toArray();
|
||||||
|
$insert = [];
|
||||||
|
$update = [];
|
||||||
|
$productIds = [];
|
||||||
|
foreach ($data as $k => $row) {
|
||||||
|
if ($k < 2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (empty($row[0])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$productId = intval($row[0]);
|
||||||
|
if (empty($productId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$productIds[] = $productId;
|
||||||
|
}
|
||||||
|
$products = StoreProduct::whereIn('id', $productIds)->field('id,store_name,purchase')->select()->toArray();
|
||||||
|
$products = reset_index($products, 'id');
|
||||||
|
foreach ($data as $k => $row) {
|
||||||
|
if ($k < 2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (empty($row[0])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$productId = intval($row[0]);
|
||||||
|
if (empty($productId)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$product = $products[$productId] ?? [];
|
||||||
|
if (empty($product)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$groupIds = [
|
||||||
|
5 => 23,
|
||||||
|
7 => 24,
|
||||||
|
9 => 25,
|
||||||
|
11 => 26,
|
||||||
|
13 => 27,
|
||||||
|
15 => 28,
|
||||||
|
17 => 29,
|
||||||
|
19 => 30,
|
||||||
|
21 => 31,
|
||||||
|
23 => 32,
|
||||||
|
25 => 33,
|
||||||
|
27 => 34,
|
||||||
|
29 => 35,
|
||||||
|
31 => 36,
|
||||||
|
33 => 37,
|
||||||
|
35 => 1,
|
||||||
|
37 => 18,
|
||||||
|
39 => 22,
|
||||||
|
];
|
||||||
|
for ($i = 5; $i < 35; $i = $i + 2) {
|
||||||
|
$rate = intval(rtrim($row[$i] ?? 0, '%'));
|
||||||
|
if (empty($rate)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$price = $row[$i + 1] ?? 0;
|
||||||
|
if (empty($price)) {
|
||||||
|
$price = $product['purchase'] * (1 + $rate / 100);
|
||||||
|
}
|
||||||
|
$item = [
|
||||||
|
'product_id' => $productId,
|
||||||
|
'group_id' => $groupIds[$i],
|
||||||
|
'price_type' => 3,
|
||||||
|
'base_rate' => 100 + $rate,
|
||||||
|
'price' => $price
|
||||||
|
];
|
||||||
|
$insert[] = $item;
|
||||||
|
}
|
||||||
|
$productGroupPrices = StoreProductGroupPrice::where('product_id', $productId)->whereIn('group_id', [1, 18, 22])->select()->toArray();
|
||||||
|
$groupIds = array_flip($groupIds);
|
||||||
|
foreach ($productGroupPrices as $productGroupPrice) {
|
||||||
|
$cellId = $groupIds[$productGroupPrice['group_id']] ?? 0;
|
||||||
|
$rate = intval(rtrim($row[$cellId] ?? 0, '%'));
|
||||||
|
if (empty($rate)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$price = $row[$cellId + 1] ?? 0;
|
||||||
|
if (empty($price)) {
|
||||||
|
$price = $product['purchase'] * (1 + $rate / 100);
|
||||||
|
}
|
||||||
|
if ($price != $productGroupPrice['price']) {
|
||||||
|
$update[] = [
|
||||||
|
'id' => $productGroupPrice['id'],
|
||||||
|
'base_rate' => $rate,
|
||||||
|
'price' => $price,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count($insert) > 0) {
|
||||||
|
StoreProductGroupPrice::insertAll($insert);
|
||||||
|
}
|
||||||
|
if (count($update) > 0) {
|
||||||
|
(new StoreProductGroupPrice())->saveAll($update);
|
||||||
|
}
|
||||||
|
return $this->success('插入成功:' . count($insert) . '条,更新成功:' . count($update) . '条');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fixCategory()
|
||||||
|
{
|
||||||
|
$topCate = StoreCategory::where('pid', 0)->field('id,name,pid')->order('name')->select()->toArray();
|
||||||
|
$topCate = reset_index($topCate, 'name');
|
||||||
|
$sql = [];
|
||||||
|
$time = time();
|
||||||
|
foreach ($topCate as $item) {
|
||||||
|
if (isset($topCate[$item['name'] . '类'])) {
|
||||||
|
$target = $topCate[$item['name'] . '类'];
|
||||||
|
$sql[] = "##原分类id:{$item['id']},原分类名:{$item['name']},目标分类id:{$target['id']},目标分类名:{$target['name']}";
|
||||||
|
$sql[] = "update la_store_product set top_cate_id={$target['id']} where top_cate_id={$item['id']};";
|
||||||
|
$sql[] = "update la_store_product set two_cate_id={$target['id']} where two_cate_id={$item['id']};";
|
||||||
|
$sql[] = "update la_store_category set delete_time=$time where id={$item['id']};";
|
||||||
|
}
|
||||||
|
$secondCate = StoreCategory::where('pid', $item['id'])->field('id,name,pid')->order('name')->select()->toArray();
|
||||||
|
$secondCate = reset_index($secondCate, 'name');
|
||||||
|
foreach ($secondCate as $item2) {
|
||||||
|
if (isset($secondCate[$item2['name'] . '类'])) {
|
||||||
|
$target = $secondCate[$item2['name'] . '类'];
|
||||||
|
$sql[] = "##原分类id:{$item2['id']},原分类名:{$item2['name']},目标分类id:{$target['id']},目标分类名:{$target['name']}";
|
||||||
|
$sql[] = "update la_store_product set two_cate_id={$target['id']} where two_cate_id={$item2['id']};";
|
||||||
|
$sql[] = "update la_store_product set cate_id={$target['id']} where cate_id={$item2['id']};";
|
||||||
|
$sql[] = "update la_store_category set delete_time=$time where id={$item2['id']};";
|
||||||
|
}
|
||||||
|
$thirdCate = StoreCategory::where('pid', $item2['id'])->field('id,name,pid')->order('name')->select()->toArray();
|
||||||
|
$thirdCate = reset_index($thirdCate, 'name');
|
||||||
|
foreach ($thirdCate as $item3) {
|
||||||
|
if (isset($thirdCate[$item3['name'] . '类'])) {
|
||||||
|
$target = $thirdCate[$item3['name'] . '类'];
|
||||||
|
$sql[] = "##原分类id:{$item3['id']},原分类名:{$item3['name']},目标分类id:{$target['id']},目标分类名:{$target['name']}";
|
||||||
|
$sql[] = "update la_store_product set cate_id={$target['id']} where cate_id={$item3['id']};";
|
||||||
|
$sql[] = "update la_store_category set delete_time=$time where id={$item3['id']};";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_put_contents(public_path() . '/update.sql', implode(PHP_EOL, $sql));
|
||||||
|
return $this->success('数据已更新完成', $sql);
|
||||||
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
@ -19,11 +167,10 @@ class LocalController extends BaseAdminController
|
|||||||
$spreadsheet = $reader->load($file->getRealPath());
|
$spreadsheet = $reader->load($file->getRealPath());
|
||||||
$data = $spreadsheet->getActiveSheet()->toArray();
|
$data = $spreadsheet->getActiveSheet()->toArray();
|
||||||
$updateCount = 0;
|
$updateCount = 0;
|
||||||
$finishCount = Redis::get('finishCount');
|
$finishCount = Redis::get('updateFinishCount');
|
||||||
$finishCount = empty($finishCount) ? 0 : $finishCount;
|
$finishCount = empty($finishCount) ? 0 : $finishCount;
|
||||||
if ($finishCount >= count($data)) {
|
if ($finishCount >= count($data)) {
|
||||||
echo '数据已更新完成';
|
return $this->success('数据已更新完成');
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
$max = $finishCount + 100;
|
$max = $finishCount + 100;
|
||||||
foreach ($data as $k => $row) {
|
foreach ($data as $k => $row) {
|
||||||
@ -42,15 +189,15 @@ class LocalController extends BaseAdminController
|
|||||||
$updateCount++;
|
$updateCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Redis::set('finishCount', 100 + $finishCount);
|
Redis::set('updateFinishCount', 100 + $finishCount);
|
||||||
echo '更新成功:' . $updateCount . '条';
|
return $this->success('更新成功:' . $updateCount . '条');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateProduct($product, $row)
|
public function updateProduct($product, $row)
|
||||||
{
|
{
|
||||||
$topCateName = rtrim($row[1], '类');
|
$topCateName = $row[1];
|
||||||
$secondCateName = rtrim($row[2], '类');
|
$secondCateName = $row[2];
|
||||||
$cateName = rtrim($row[3], '类');
|
$cateName = $row[3];
|
||||||
$topCate = StoreCategory::where('name', $topCateName)->value('id');
|
$topCate = StoreCategory::where('name', $topCateName)->value('id');
|
||||||
$updateData = [];
|
$updateData = [];
|
||||||
if (!empty($topCate) && $topCate != $product['top_cate_id']) {
|
if (!empty($topCate) && $topCate != $product['top_cate_id']) {
|
||||||
|
@ -85,11 +85,6 @@ class BeforehandOrderCartInfoController extends BaseAdminController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$find->source_order_info = array_values($json);
|
$find->source_order_info = array_values($json);
|
||||||
$productPrice = StoreProduct::where('id',$res['product_id'])->value('price');
|
|
||||||
$procurementOrder = BeforehandOrder::where('id', $find['order_id'])->find();
|
|
||||||
$procurementOrder->total_price = bcsub($procurementOrder->total_price, bcmul($productPrice, $res['cart_num'], 2), 2);
|
|
||||||
$procurementOrder->pay_price = $procurementOrder->total_price;
|
|
||||||
$procurementOrder->save();
|
|
||||||
}
|
}
|
||||||
if ($find->need_num <= 0) {
|
if ($find->need_num <= 0) {
|
||||||
$find->delete_time = time();
|
$find->delete_time = time();
|
||||||
|
87
app/admin/lists/ActivityZoneFormLists.php
Normal file
87
app/admin/lists/ActivityZoneFormLists.php
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\lists;
|
||||||
|
|
||||||
|
use app\common\lists\ListsSearchInterface;
|
||||||
|
use app\common\model\ActivityZoneForm;
|
||||||
|
use app\common\model\store_category\StoreCategory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityZoneFormLists列表
|
||||||
|
* Class ActivityZoneFormLists
|
||||||
|
* @package app\admin\lists
|
||||||
|
*/
|
||||||
|
class ActivityZoneFormLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 设置搜索条件
|
||||||
|
* @return \string[][]
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function setSearch(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'=' => ['type'],
|
||||||
|
'%like%' => ['title'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取列表
|
||||||
|
* @return array
|
||||||
|
* @throws \think\db\exception\DataNotFoundException
|
||||||
|
* @throws \think\db\exception\DbException
|
||||||
|
* @throws \think\db\exception\ModelNotFoundException
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function lists(): array
|
||||||
|
{
|
||||||
|
$query = ActivityZoneForm::where($this->searchWhere);
|
||||||
|
$cateIds = [];
|
||||||
|
$list = $query
|
||||||
|
->field(['id', 'type', 'cate_ids', 'title', 'remark'])
|
||||||
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
|
->order(['id' => 'desc'])
|
||||||
|
->select()
|
||||||
|
->each(function ($item) use (&$cateIds) {
|
||||||
|
$item['cate_ids'] = explode(',', $item['cate_ids']);
|
||||||
|
foreach ($item['cate_ids'] as $cateId) {
|
||||||
|
if (!empty($cateId) && !in_array($cateId, $cateIds)) {
|
||||||
|
$cateIds[] = $cateId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
$cateList = StoreCategory::where('id', 'in', $cateIds)->field('id,name')->select()->toArray();
|
||||||
|
$cateList = reset_index($cateList, 'id');
|
||||||
|
foreach ($list as &$item) {
|
||||||
|
$item['cate_names'] = [];
|
||||||
|
foreach ($item['cate_ids'] as $cateId) {
|
||||||
|
if (isset($cateList[$cateId])) {
|
||||||
|
$item['cate_names'][] = $cateList[$cateId]['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$item['cate_names'] = implode(',', $item['cate_names']);
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取数量
|
||||||
|
* @return int
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
$query = ActivityZoneForm::where($this->searchWhere);
|
||||||
|
return $query->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -28,7 +28,7 @@ class ActivityZoneLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['type'],
|
'=' => ['form_id'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,12 +45,12 @@ class ActivityZoneLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$query = ActivityZone::where($this->searchWhere);
|
$query = ActivityZone::where($this->searchWhere);
|
||||||
if (!empty($this->params['keyword'])) {
|
if (!empty($this->params['store_name'])) {
|
||||||
$productIds = StoreProduct::where('store_name', 'like', "%{$this->params['keyword']}%")->column('id');
|
$productIds = StoreProduct::where('store_name', 'like', "%{$this->params['store_name']}%")->column('id');
|
||||||
$query->whereIn('product_id', $productIds);
|
$query->whereIn('product_id', $productIds);
|
||||||
}
|
}
|
||||||
$list = $query->with('product')
|
$list = $query->with('product')
|
||||||
->field(['id', 'type', 'product_id'])
|
->field(['id', 'form_id', 'product_id'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()
|
->select()
|
||||||
@ -74,8 +74,8 @@ class ActivityZoneLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
public function count(): int
|
public function count(): int
|
||||||
{
|
{
|
||||||
$query = ActivityZone::where($this->searchWhere);
|
$query = ActivityZone::where($this->searchWhere);
|
||||||
if (!empty($this->params['keyword'])) {
|
if (!empty($this->params['store_name'])) {
|
||||||
$productIds = StoreProduct::where('store_name', 'like', "%{$this->params['keyword']}%")->column('id');
|
$productIds = StoreProduct::where('store_name', 'like', "%{$this->params['store_name']}%")->column('id');
|
||||||
$query->whereIn('product_id', $productIds);
|
$query->whereIn('product_id', $productIds);
|
||||||
}
|
}
|
||||||
return $query->count();
|
return $query->count();
|
||||||
|
@ -112,6 +112,8 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
|
|||||||
$item->order_type_name = '往期补单';
|
$item->order_type_name = '往期补单';
|
||||||
} elseif ($item->order_type == 7) {
|
} elseif ($item->order_type == 7) {
|
||||||
$item->order_type_name = '采购订单';
|
$item->order_type_name = '采购订单';
|
||||||
|
} elseif ($item->order_type == 8) {
|
||||||
|
$item->order_type_name = '其他订单';
|
||||||
}
|
}
|
||||||
$item->msg = '';
|
$item->msg = '';
|
||||||
$count1 = PurchaseProductOffer::where('order_id', $item->id)->where('buyer_confirm', 0)->count('id');
|
$count1 = PurchaseProductOffer::where('order_id', $item->id)->where('buyer_confirm', 0)->count('id');
|
||||||
|
@ -71,8 +71,13 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc
|
|||||||
->select()->each(function($item) use($job_ids){
|
->select()->each(function($item) use($job_ids){
|
||||||
$item->order_sn=BeforehandOrder::where('id',$item['order_id'])->value('order_id');
|
$item->order_sn=BeforehandOrder::where('id',$item['order_id'])->value('order_id');
|
||||||
$find=StoreProduct::where('id',$item->product_id)->withTrashed()->find();
|
$find=StoreProduct::where('id',$item->product_id)->withTrashed()->find();
|
||||||
|
$item->store_info = empty($item['store_info']) ? ($find['store_info'] ?? '') : $item['store_info'];
|
||||||
|
$item->after_sales = empty($item['after_sales']) ? ($find['after_sales'] ?? '') : $item['after_sales'];
|
||||||
|
$item->marques = empty($item['marques']) ? ($find['marques'] ?? '') : $item['marques'];
|
||||||
|
$item->package = empty($item['package']) ? ($find['package'] ?? '') : $item['package'];
|
||||||
|
$item->expiration_date = $item->expiration_date ? date('Y-m-d', $item->expiration_date) : '';
|
||||||
|
$item->manufacture = $item->manufacture ? date('Y-m-d', $item->manufacture) : '';
|
||||||
$item->store_name=$find->store_name;
|
$item->store_name=$find->store_name;
|
||||||
$item->store_info=$find->store_info;
|
|
||||||
$item->image=$find->image;
|
$item->image=$find->image;
|
||||||
$item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name');
|
$item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name');
|
||||||
$item->cate_name=StoreCategory::where('id',$find->cate_id)->value('name');
|
$item->cate_name=StoreCategory::where('id',$find->cate_id)->value('name');
|
||||||
|
@ -45,8 +45,6 @@ class StoreCategoryLists extends BaseAdminDataLists implements ListsSearchInterf
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
$userGroups = UserShip::field('id,title')->select()->toArray();
|
$userGroups = UserShip::field('id,title')->select()->toArray();
|
||||||
$userGroups[] = ['id' => 100001, 'title' => '供货价'];
|
|
||||||
$userGroups[] = ['id' => 100002, 'title' => '零售价'];
|
|
||||||
return StoreCategory::where($this->searchWhere)
|
return StoreCategory::where($this->searchWhere)
|
||||||
->field(['id', 'pid', 'name', 'data', 'pic', 'sort', 'price_rate'])
|
->field(['id', 'pid', 'name', 'data', 'pic', 'sort', 'price_rate'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
@ -56,13 +54,21 @@ class StoreCategoryLists extends BaseAdminDataLists implements ListsSearchInterf
|
|||||||
$item['price_rate'] = $userGroups;
|
$item['price_rate'] = $userGroups;
|
||||||
} else {
|
} else {
|
||||||
$priceRate = reset_index($item['price_rate'], 'id');
|
$priceRate = reset_index($item['price_rate'], 'id');
|
||||||
|
unset($priceRate[100003], $priceRate[100004]);
|
||||||
|
$temp = [];
|
||||||
foreach ($userGroups as $userGroup) {
|
foreach ($userGroups as $userGroup) {
|
||||||
if (!isset($priceRate[$userGroup['id']])) {
|
if ($userGroup['id'] == 21 && !empty($priceRate[100001]) && empty($userGroup['rate'])) {
|
||||||
$userGroup['rate'] = 0;
|
$userGroup['rate'] = $priceRate[100001]['rate'];
|
||||||
$priceRate[] = $userGroup;
|
unset($priceRate[100001]);
|
||||||
|
} elseif ($userGroup['id'] == 22 && !empty($priceRate[100002]) && empty($userGroup['rate'])) {
|
||||||
|
$userGroup['rate'] = $priceRate[100002]['rate'];
|
||||||
|
unset($priceRate[100002]);
|
||||||
|
} else {
|
||||||
|
$userGroup['rate'] = $priceRate[$userGroup['id']]['rate'] ?? 0;
|
||||||
}
|
}
|
||||||
|
$temp[] = $userGroup;
|
||||||
}
|
}
|
||||||
$item['price_rate'] = array_values($priceRate);
|
$item['price_rate'] = $temp;
|
||||||
}
|
}
|
||||||
$item['is_children'] = StoreCategory::where('pid', $item->id)->count(); // 判断是否有子分类
|
$item['is_children'] = StoreCategory::where('pid', $item->id)->count(); // 判断是否有子分类
|
||||||
return $item->toArray();
|
return $item->toArray();
|
||||||
|
@ -81,8 +81,8 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
|||||||
$query->where('is_show', 1);
|
$query->where('is_show', 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($this->params['activity_zone_type'])) {
|
if (!empty($this->params['activity_zone_form_id'])) {
|
||||||
$exceptIds = ActivityZone::where('type', $this->params['activity_zone_type'])->column('product_id');
|
$exceptIds = ActivityZone::where('form_id', $this->params['activity_zone_form_id'])->column('product_id');
|
||||||
$query->where('is_show', 1)->where('product_type', '<>', 5)->whereNotIn('id', $exceptIds);
|
$query->where('is_show', 1)->where('product_type', '<>', 5)->whereNotIn('id', $exceptIds);
|
||||||
}
|
}
|
||||||
$list = $query->limit($this->limitOffset, $this->limitLength)
|
$list = $query->limit($this->limitOffset, $this->limitLength)
|
||||||
|
@ -48,15 +48,18 @@ class StoreProductPriceLists extends BaseAdminDataLists implements ListsSearchIn
|
|||||||
$this->searchWhere[]=['product_id','in',$store_id];
|
$this->searchWhere[]=['product_id','in',$store_id];
|
||||||
}
|
}
|
||||||
return StoreProductPrice::where($this->searchWhere)
|
return StoreProductPrice::where($this->searchWhere)
|
||||||
->field(['id','bhoid','offer_id', 'product_id', 'purchase_price', 'purchase_lv', 'purchase', 'cost_lv', 'cost', 'price_lv', 'price', 'price_config', 'status'])
|
->field(['id','bhoid','offer_id', 'product_id', 'purchase_price', 'purchase_lv', 'purchase', 'cost_lv', 'cost', 'price_lv', 'price', 'price_config', 'status','create_time','mark'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function($item){
|
->select()->each(function($item){
|
||||||
$find = StoreProduct::with('unitName')->where('id', $item['product_id'])->field('image,store_name,store_info,unit')->withTrashed()->find();
|
$find = StoreProduct::with('unitName')->where('id', $item['product_id'])->field('image,purchase,cost,price,store_name,store_info,unit')->withTrashed()->find();
|
||||||
$item['unit_name']=$find['unitName']['name'] ?? '';
|
$item['unit_name']=$find['unitName']['name'] ?? '';
|
||||||
$item['store_name']=$find['store_name'];
|
$item['store_name']=$find['store_name'];
|
||||||
$item['store_info']=$find['store_info'];
|
$item['store_info']=$find['store_info'];
|
||||||
$item['image']=$find['image'];
|
$item['image']=$find['image'];
|
||||||
|
$item['current_purchase']=$find['purchase'];
|
||||||
|
$item['current_cost']=$find['cost'];
|
||||||
|
$item['current_price']=$find['price'];
|
||||||
$item['status_name']=$item['status']==0?"未设置":"已设置";
|
$item['status_name']=$item['status']==0?"未设置":"已设置";
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
|
@ -45,7 +45,7 @@ class SupplierLists extends BaseAdminDataLists implements ListsSearchInterface
|
|||||||
{
|
{
|
||||||
return Supplier::where($this->searchWhere)
|
return Supplier::where($this->searchWhere)
|
||||||
->field(['id', 'category_id', 'mer_name', 'phone', 'settle_cycle', 'address', 'mark'])
|
->field(['id', 'category_id', 'mer_name', 'phone', 'settle_cycle', 'address', 'mark'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, 100)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
$item->total_completed_amount=WarehouseProduct::where('supplier_id',$item['id'])->where('financial_pm',1)->where('is_pay',1)->sum('total_price');
|
$item->total_completed_amount=WarehouseProduct::where('supplier_id',$item['id'])->where('financial_pm',1)->where('is_pay',1)->sum('total_price');
|
||||||
|
148
app/admin/logic/ActivityZoneFormLogic.php
Normal file
148
app/admin/logic/ActivityZoneFormLogic.php
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\logic;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\ActivityZone;
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\ActivityZoneForm;
|
||||||
|
use app\common\model\store_category\StoreCategory;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
|
use app\common\service\xlsx\ActivityZoneService;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityZone逻辑
|
||||||
|
* Class ActivityZoneLogic
|
||||||
|
* @package app\admin\logic
|
||||||
|
*/
|
||||||
|
class ActivityZoneFormLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加
|
||||||
|
* @param array $params
|
||||||
|
* @return bool
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public static function add(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$secondCateIds = [];
|
||||||
|
$thirdCateIds = [];
|
||||||
|
foreach ($params['cate_ids'] as $item) {
|
||||||
|
if (count($item) == 3) {
|
||||||
|
$thirdCateIds[] = $item[2];
|
||||||
|
} else {
|
||||||
|
$secondCateIds[] = $item[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$cateIds = array_merge($secondCateIds, $thirdCateIds);
|
||||||
|
$params['cate_ids'] = !empty($cateIds) ? implode(',', $cateIds) : '';
|
||||||
|
$activityZoneForm = new ActivityZoneForm();
|
||||||
|
$activityZoneForm->save($params);
|
||||||
|
$products = StoreProduct::field('id,two_cate_id,cate_id')->where('two_cate_id', 'in', $cateIds)->whereOr('cate_id', 'in', $cateIds)->select()->toArray();
|
||||||
|
$productInfo = [];
|
||||||
|
$time = time();
|
||||||
|
foreach ($products as $product) {
|
||||||
|
$productInfo[] = [
|
||||||
|
'product_id' => $product['id'],
|
||||||
|
'form_id' => $activityZoneForm->id,
|
||||||
|
'create_time' => $time,
|
||||||
|
'update_time' => $time,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
if (!empty($productInfo)) {
|
||||||
|
ActivityZone::insertAll($productInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
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/20 10:52
|
||||||
|
*/
|
||||||
|
public static function edit(array $params): bool
|
||||||
|
{
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
ActivityZoneForm::where('id', $params['id'])->update([
|
||||||
|
'type' => $params['type'],
|
||||||
|
'product_id' => $params['product_id'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
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/20 10:52
|
||||||
|
*/
|
||||||
|
public static function delete(array $params): bool
|
||||||
|
{
|
||||||
|
return ActivityZoneForm::destroy($params['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 获取详情
|
||||||
|
* @param $params
|
||||||
|
* @return array
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public static function detail($params): array
|
||||||
|
{
|
||||||
|
return ActivityZoneForm::findOrEmpty($params['id'])->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function export($params)
|
||||||
|
{
|
||||||
|
$service = new ActivityZoneService();
|
||||||
|
$activityZoneForm = ActivityZoneForm::findOrEmpty($params['id'])->toArray();
|
||||||
|
$productIds = ActivityZone::where('form_id', $params['id'])->column('product_id');
|
||||||
|
$products = StoreProduct::field('id,unit,store_name,two_cate_id')->whereIn('id', $productIds)->order('two_cate_id asc,cate_id asc')->select()->toArray();
|
||||||
|
$unitIds = array_unique(array_column($products, 'unit'));
|
||||||
|
$cateIds = array_unique(array_column($products, 'two_cate_id'));
|
||||||
|
$unit = StoreProductUnit::whereIn('id', $unitIds)->field('id,name')->withTrashed()->select()->toArray();
|
||||||
|
$categories = StoreCategory::whereIn('id', $cateIds)->field('id,name')->withTrashed()->select()->toArray();
|
||||||
|
$unit = reset_index($unit, 'id');
|
||||||
|
$categories = reset_index($categories, 'id');
|
||||||
|
$data = [];
|
||||||
|
foreach ($products as $item) {
|
||||||
|
$currentCate = $categories[$item['two_cate_id']]['name'] ?? '';
|
||||||
|
if (!empty($currentCate)) {
|
||||||
|
$item['unit_name'] = $unit[$item['unit']]['name'] ?? '';
|
||||||
|
unset($item['unit'], $item['two_cate_id']);
|
||||||
|
$data[$currentCate][] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $service->export($data, $activityZoneForm['title'], $activityZoneForm['remark']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -5,8 +5,7 @@ namespace app\admin\logic;
|
|||||||
|
|
||||||
use app\common\model\ActivityZone;
|
use app\common\model\ActivityZone;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
use app\common\model\store_product_unit\StoreProductUnit;
|
use app\common\model\ActivityZoneForm;
|
||||||
use app\common\service\xlsx\ActivityZoneService;
|
|
||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ class ActivityZoneLogic extends BaseLogic
|
|||||||
$time = time();
|
$time = time();
|
||||||
foreach ($params['product_ids'] as $product_id) {
|
foreach ($params['product_ids'] as $product_id) {
|
||||||
$insert[] = [
|
$insert[] = [
|
||||||
'type' => $params['type'],
|
'form_id' => $params['form_id'],
|
||||||
'product_id' => $product_id,
|
'product_id' => $product_id,
|
||||||
'create_time' => $time,
|
'create_time' => $time,
|
||||||
'update_time' => $time,
|
'update_time' => $time,
|
||||||
@ -64,7 +63,7 @@ class ActivityZoneLogic extends BaseLogic
|
|||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
ActivityZone::where('id', $params['id'])->update([
|
ActivityZone::where('id', $params['id'])->update([
|
||||||
'type' => $params['type'],
|
'form_id' => $params['form_id'],
|
||||||
'product_id' => $params['product_id'],
|
'product_id' => $params['product_id'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -102,25 +101,40 @@ class ActivityZoneLogic extends BaseLogic
|
|||||||
return ActivityZone::findOrEmpty($params['id'])->toArray();
|
return ActivityZone::findOrEmpty($params['id'])->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function export($params)
|
public function addProduct($product)
|
||||||
{
|
{
|
||||||
$service = new ActivityZoneService();
|
$activityFormId1 = ActivityZoneForm::whereRaw('FIND_IN_SET(:cate_id,cate_ids)', ['cate_id' => $product['two_cate_id']])->column('id');
|
||||||
$products = ActivityZone::with('product')->field('id,product_id,type')->where('type', $params['type'])->select()->toArray();
|
$activityFormId2 = ActivityZoneForm::whereRaw('FIND_IN_SET(:cate_id,cate_ids)', ['cate_id' => $product['cate_id']])->column('id');
|
||||||
$unitIds = array_unique(array_column($products, 'unit'));
|
$activityFormIds = array_unique(array_merge($activityFormId1, $activityFormId2));
|
||||||
$unit = StoreProductUnit::whereIn('id', $unitIds)->field('id,name')->withTrashed()->select()->toArray();
|
foreach ($activityFormIds as $activityFormId) {
|
||||||
$unit = reset_index($unit, 'id');
|
$activityZone = new ActivityZone();
|
||||||
foreach ($products as &$item) {
|
$activityZone->form_id = $activityFormId;
|
||||||
$item['unit_name'] = $unit[$item['unit']]['name'] ?? '';
|
$activityZone->product_id = $product['id'];
|
||||||
unset($item['unit'], $item['product_id']);
|
$activityZone->save();
|
||||||
}
|
}
|
||||||
$data = ConfigLogic::getDictByType('activity_zone');
|
}
|
||||||
foreach ($data['activity_zone'] as $value) {
|
|
||||||
if ($value['value'] == $params['type']) {
|
public function updateProduct($productId, $product)
|
||||||
$typeName = $value['remark'];
|
{
|
||||||
break;
|
$product['id'] = $productId;
|
||||||
|
$formIds = ActivityZone::where('product_id', $productId)->column('form_id');
|
||||||
|
if (empty($formIds)) {
|
||||||
|
$this->addProduct($product);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$forms = ActivityZoneForm::whereIn('id', $formIds)->select()->toArray();
|
||||||
|
foreach ($forms as $form) {
|
||||||
|
$cateIds = explode(',', $form['cate_ids']);
|
||||||
|
if (!in_array($product['two_cate_id'], $cateIds) && !in_array($product['cate_id'], $cateIds)) {
|
||||||
|
ActivityZone::where('product_id', $productId)->where('form_id', $form['id'])->update(['delete_time' => time()]);
|
||||||
}
|
}
|
||||||
|
$this->addProduct($product);
|
||||||
}
|
}
|
||||||
return $service->export($products, $typeName ?? '', $params['remark']);
|
}
|
||||||
|
|
||||||
|
public function deleteProduct($productId)
|
||||||
|
{
|
||||||
|
ActivityZone::where('product_id', $productId)->update(['delete_time' => time()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -235,6 +235,8 @@ class BeforehandOrderCartInfoLogic extends BaseLogic
|
|||||||
$data['purchase'] = $v['price'];
|
$data['purchase'] = $v['price'];
|
||||||
$data['total_price'] = $v['total_price'];
|
$data['total_price'] = $v['total_price'];
|
||||||
$data['financial_pm'] = 1;
|
$data['financial_pm'] = 1;
|
||||||
|
$data['manufacture'] = $v['manufacture'] > 0 ? date('Y-m-d H:i:s', $v['manufacture']) : '';
|
||||||
|
$data['expiration_date'] = $v['expiration_date'] > 0 ? date('Y-m-d H:i:s', $v['expiration_date']) : '';
|
||||||
$product_arr=[];
|
$product_arr=[];
|
||||||
if($v['package']!=''){
|
if($v['package']!=''){
|
||||||
$product_arr['package']=$v['package'];
|
$product_arr['package']=$v['package'];
|
||||||
|
@ -41,7 +41,11 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$procurementOrder = BeforehandOrder::where('order_type', 7)->where('buyer_id', $params['buyer_id'])->where('is_buying', 0)->where('create_time', '>=', strtotime('-3 days'))->find();
|
$procurementOrder = BeforehandOrder::where('order_type', 7)
|
||||||
|
->where('buyer_id', $params['buyer_id'])
|
||||||
|
->where('is_buying', 0)
|
||||||
|
->where('create_time', '>=', strtotime('today'))
|
||||||
|
->find();
|
||||||
if (empty($procurementOrder)) {
|
if (empty($procurementOrder)) {
|
||||||
$procurementOrder = new BeforehandOrder();
|
$procurementOrder = new BeforehandOrder();
|
||||||
$procurementOrder->order_id = getNewOrderId('CG');
|
$procurementOrder->order_id = getNewOrderId('CG');
|
||||||
@ -58,9 +62,6 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
$find=StoreProduct::where('id',$params['product_id'])->find();
|
$find=StoreProduct::where('id',$params['product_id'])->find();
|
||||||
$purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find();
|
$purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find();
|
||||||
$procurementOrder->total_price = bcadd($procurementOrder->total_price, bcmul($find['price'], $params['need_num'], 2), 2);
|
|
||||||
$procurementOrder->pay_price = $procurementOrder->total_price;
|
|
||||||
$procurementOrder->save();
|
|
||||||
if ($purchaseProductOffer) {
|
if ($purchaseProductOffer) {
|
||||||
$purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num'];
|
$purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num'];
|
||||||
if (!empty($purchaseProductOffer['source_order_info'])) {
|
if (!empty($purchaseProductOffer['source_order_info'])) {
|
||||||
@ -155,6 +156,8 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function setProcureInfo(array $params): bool
|
public static function setProcureInfo(array $params): bool
|
||||||
{
|
{
|
||||||
|
$params['manufacture'] = !empty($params['manufacture']) ? strtotime($params['manufacture']) : '';
|
||||||
|
$params['expiration_date'] = !empty($params['expiration_date']) ? strtotime($params['expiration_date']) : '';
|
||||||
$offer = PurchaseProductOffer::where(['id' => $params['id']])->find();
|
$offer = PurchaseProductOffer::where(['id' => $params['id']])->find();
|
||||||
// $uid=Admin::where('id',$params['admin_id'])->value('uid');
|
// $uid=Admin::where('id',$params['admin_id'])->value('uid');
|
||||||
// if($params['admin_id']!=1){
|
// if($params['admin_id']!=1){
|
||||||
@ -176,10 +179,16 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
'store_info' => $params['store_info'],
|
'store_info' => $params['store_info'],
|
||||||
'marques' => $params['marques'],
|
'marques' => $params['marques'],
|
||||||
'after_sales' => $params['after_sales'],
|
'after_sales' => $params['after_sales'],
|
||||||
|
'manufacture' => $params['manufacture'],
|
||||||
|
'expiration_date' => $params['expiration_date'],
|
||||||
]);
|
]);
|
||||||
// $find = StoreProductPrice::where(['offer_id' => $params['id']])->find();
|
// $find = StoreProductPrice::where(['offer_id' => $params['id']])->find();
|
||||||
$product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id')->find();
|
$product = StoreProduct::where('id', $offer['product_id'])->withTrashed()->field('id,store_name,top_cate_id,two_cate_id,cate_id')->find();
|
||||||
$unit_name=StoreProductUnit::where('id', $offer['unit'])->value('name');
|
$unit_name=StoreProductUnit::where('id', $offer['unit'])->value('name');
|
||||||
|
$order = BeforehandOrder::where('id', $params['bhoid'])->find();
|
||||||
|
$order->pay_price = PurchaseProductOffer::where('order_id', $order['id'])->sum('total_price');
|
||||||
|
$order->total_price = $order->pay_price;
|
||||||
|
$order->save();
|
||||||
self::setProductGroupPrice($params, $product);
|
self::setProductGroupPrice($params, $product);
|
||||||
// $data = [];
|
// $data = [];
|
||||||
// $dict_data = DictData::where('type_value', 'price_lv_' . $product['top_cate_id'])->field('name,value')->select();
|
// $dict_data = DictData::where('type_value', 'price_lv_' . $product['top_cate_id'])->field('name,value')->select();
|
||||||
@ -225,6 +234,7 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
return true;
|
return true;
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
|
d($e);
|
||||||
throw new BusinessException($e->getMessage());
|
throw new BusinessException($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -354,22 +364,36 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
'update_time' => time(),
|
'update_time' => time(),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
];
|
];
|
||||||
$productCatePriceRate = StoreCategory::where('id', $product['top_cate_id'])->value('price_rate');
|
$productCatePriceRate = self::getProductCatePriceRate($product);
|
||||||
if (!empty($productCatePriceRate)) {
|
if (!empty($productCatePriceRate)) {
|
||||||
$storeProductGroupPrice = StoreProductGroupPrice::where('product_id', $product['id'])->select()->toArray();
|
$storeProductGroupPrice = StoreProductGroupPrice::where('product_id', $product['id'])->select()->toArray();
|
||||||
$storeProductGroupPrice = reset_index($storeProductGroupPrice, 'group_id');
|
$storeProductGroupPrice = reset_index($storeProductGroupPrice, 'group_id');
|
||||||
|
$purchase=0;
|
||||||
foreach ($productCatePriceRate as $k => $v) {
|
foreach ($productCatePriceRate as $k => $v) {
|
||||||
if ($v['id'] == 4) {
|
if ($v['id'] == 100001 || $v['id'] == 21) {
|
||||||
$data['cost_lv'] = bcdiv($v['rate'], 100, 2);
|
//供货
|
||||||
$data['cost'] = bcmul($params['purchase'], bcadd($data['cost_lv'], 1, 2), 2);
|
|
||||||
continue;
|
|
||||||
} elseif ($v['id'] == 100001) {
|
|
||||||
$data['purchase_lv'] = bcdiv($v['rate'], 100, 2);
|
$data['purchase_lv'] = bcdiv($v['rate'], 100, 2);
|
||||||
$data['purchase'] = bcmul($params['purchase'], bcadd($data['purchase_lv'], 1, 2), 2);
|
$data['purchase'] = bcmul($params['purchase'], bcadd($data['purchase_lv'], 1, 2), 2);
|
||||||
|
$purchase=$data['purchase'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($storeProductGroupPrice)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach ($productCatePriceRate as $k => $v) {
|
||||||
|
if (empty($v['rate'])) {
|
||||||
continue;
|
continue;
|
||||||
} elseif ($v['id'] == 100002) {
|
}
|
||||||
|
if ($v['id'] == 4 &&$purchase>0) {
|
||||||
|
//商户
|
||||||
|
$data['cost_lv'] = bcdiv($v['rate'], 100, 2);
|
||||||
|
$data['cost'] = bcmul($purchase, bcadd($data['cost_lv'], 1, 2), 2);
|
||||||
|
continue;
|
||||||
|
}elseif (($v['id'] == 100002 || $v['id'] == 22) &&$purchase>0) {
|
||||||
|
//零售
|
||||||
$data['price_lv'] = bcdiv($v['rate'], 100, 2);
|
$data['price_lv'] = bcdiv($v['rate'], 100, 2);
|
||||||
$data['price'] = bcmul($params['purchase'], bcadd($data['price_lv'], 1, 2), 1);
|
$data['price'] = bcmul($purchase, bcadd($data['price_lv'], 1, 2), 1);
|
||||||
if ($product['two_cate_id'] == 15268) {
|
if ($product['two_cate_id'] == 15268) {
|
||||||
$lastNum = substr($data['price'], -1);
|
$lastNum = substr($data['price'], -1);
|
||||||
if ($lastNum <= 2) {
|
if ($lastNum <= 2) {
|
||||||
@ -382,21 +406,23 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$baseRate = 100 + $v['rate'];
|
$baseRate = ($v['id'] == 100001 || $v['id'] == 21) ? 100 : 100 + $v['rate'];
|
||||||
$item = [
|
if($purchase>0){
|
||||||
'product_id' => $product['id'],
|
$item = [
|
||||||
'group_id' => $v['id'],
|
'product_id' => $product['id'],
|
||||||
'group_name' => $v['title'],
|
'group_id' => $v['id'],
|
||||||
'price' => bcmul($params['purchase'], $baseRate / 100, 2),
|
'group_name' => $v['title'],
|
||||||
'price_type' => 3,
|
'price' => bcmul($purchase, $baseRate / 100, 2),
|
||||||
'base_rate' => $baseRate,
|
'price_type' => 3,
|
||||||
];
|
'base_rate' => $baseRate,
|
||||||
if (isset($storeProductGroupPrice[$v['id']])) {
|
];
|
||||||
$item['base_rate'] = $storeProductGroupPrice[$v['id']]['base_rate'];
|
if (isset($storeProductGroupPrice[$v['id']])) {
|
||||||
$item['price'] = bcmul($params['purchase'], $item['base_rate'] / 100, 2);
|
$item['base_rate'] = $storeProductGroupPrice[$v['id']]['base_rate'];
|
||||||
$item['id'] = $storeProductGroupPrice[$v['id']]['id'];
|
$item['price'] = bcmul($purchase, $item['base_rate'] / 100, 2);
|
||||||
|
$item['id'] = $storeProductGroupPrice[$v['id']]['id'];
|
||||||
|
}
|
||||||
|
$priceConfig[] = $item;
|
||||||
}
|
}
|
||||||
$priceConfig[] = $item;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$data['price_config'] = $priceConfig;
|
$data['price_config'] = $priceConfig;
|
||||||
@ -407,4 +433,34 @@ class PurchaseProductOfferLogic extends BaseLogic
|
|||||||
StoreProductPrice::create($data);
|
StoreProductPrice::create($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getProductCatePriceRate($product)
|
||||||
|
{
|
||||||
|
$productCatePriceRate = StoreCategory::where('id', $product['cate_id'])->value('price_rate');
|
||||||
|
if (!empty($productCatePriceRate) && self::hasPurchase($productCatePriceRate)) {
|
||||||
|
return $productCatePriceRate;
|
||||||
|
}
|
||||||
|
$productCatePriceRate = StoreCategory::where('id', $product['two_cate_id'])->value('price_rate');
|
||||||
|
if (!empty($productCatePriceRate) && self::hasPurchase($productCatePriceRate)) {
|
||||||
|
return $productCatePriceRate;
|
||||||
|
}
|
||||||
|
$productCatePriceRate = StoreCategory::where('id', $product['top_cate_id'])->value('price_rate');
|
||||||
|
if (!empty($productCatePriceRate) && self::hasPurchase($productCatePriceRate)) {
|
||||||
|
return $productCatePriceRate;
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function hasPurchase(array $productCatePriceRate): bool
|
||||||
|
{
|
||||||
|
$res = true;
|
||||||
|
foreach ($productCatePriceRate as $item) {
|
||||||
|
if ($item['id'] == 21 && empty($item['rate'])) {
|
||||||
|
$res = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,17 @@ class StoreCategoryLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
|
$priceRate = [];
|
||||||
|
foreach ($params['price_rate'] as $v) {
|
||||||
|
$priceRate[$v['id']] = $v;
|
||||||
|
}
|
||||||
StoreCategory::create([
|
StoreCategory::create([
|
||||||
'pid' => $params['pid'],
|
'pid' => $params['pid'],
|
||||||
'name' => $params['name'],
|
'name' => $params['name'],
|
||||||
'data' => $params['data'],
|
'data' => $params['data'],
|
||||||
'pic' => $params['pic'],
|
'pic' => $params['pic'],
|
||||||
'sort' => $params['sort']
|
'sort' => $params['sort'],
|
||||||
|
'price_rate' => array_values($priceRate)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
@ -57,13 +62,17 @@ class StoreCategoryLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
|
$priceRate = [];
|
||||||
|
foreach ($params['price_rate'] as $v) {
|
||||||
|
$priceRate[$v['id']] = $v;
|
||||||
|
}
|
||||||
StoreCategory::where('id', $params['id'])->update([
|
StoreCategory::where('id', $params['id'])->update([
|
||||||
'pid' => $params['pid'],
|
'pid' => $params['pid'],
|
||||||
'name' => $params['name'],
|
'name' => $params['name'],
|
||||||
'data' => $params['data'],
|
'data' => $params['data'],
|
||||||
'pic' => $params['pic'],
|
'pic' => $params['pic'],
|
||||||
'sort' => $params['sort'],
|
'sort' => $params['sort'],
|
||||||
'price_rate' => $params['price_rate']
|
'price_rate' => array_values($priceRate)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Db::commit();
|
Db::commit();
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace app\admin\logic\store_product;
|
namespace app\admin\logic\store_product;
|
||||||
|
|
||||||
|
use app\admin\logic\ActivityZoneLogic;
|
||||||
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
@ -73,6 +74,7 @@ class StoreProductLogic extends BaseLogic
|
|||||||
'store_batch' => $params['store_batch'] ?? 1,
|
'store_batch' => $params['store_batch'] ?? 1,
|
||||||
'product_type' => $params['product_type'] ?? 0,
|
'product_type' => $params['product_type'] ?? 0,
|
||||||
'is_show' => $params['is_show'] ?? 0,
|
'is_show' => $params['is_show'] ?? 0,
|
||||||
|
'made_place' => $params['made_place'] ?? '',
|
||||||
];
|
];
|
||||||
$rose = 0;
|
$rose = 0;
|
||||||
//零售-供货
|
//零售-供货
|
||||||
@ -84,6 +86,8 @@ class StoreProductLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
$data['rose']=$rose;
|
$data['rose']=$rose;
|
||||||
$res = StoreProduct::create($data);
|
$res = StoreProduct::create($data);
|
||||||
|
// 添加商品到活动专区
|
||||||
|
(new ActivityZoneLogic())->addProduct($res);
|
||||||
StoreProductAttrValue::create([
|
StoreProductAttrValue::create([
|
||||||
"bar_code" => $params["bar_code"] ?? '',
|
"bar_code" => $params["bar_code"] ?? '',
|
||||||
"image" => $params["image"] ?? '',
|
"image" => $params["image"] ?? '',
|
||||||
@ -222,6 +226,7 @@ class StoreProductLogic extends BaseLogic
|
|||||||
'manufacturer_information' => $params['manufacturer_information'] ?? '',
|
'manufacturer_information' => $params['manufacturer_information'] ?? '',
|
||||||
'swap' => $params['swap'] ?? 0,
|
'swap' => $params['swap'] ?? 0,
|
||||||
'is_show' => $params['is_show'] ?? 0,
|
'is_show' => $params['is_show'] ?? 0,
|
||||||
|
'made_place' => $params['made_place'] ?? '',
|
||||||
];
|
];
|
||||||
$rose = 0;
|
$rose = 0;
|
||||||
//零售-供货
|
//零售-供货
|
||||||
@ -233,6 +238,8 @@ class StoreProductLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
$data['rose']=$rose;
|
$data['rose']=$rose;
|
||||||
StoreProduct::update($data, ['id' => $params['id']]);
|
StoreProduct::update($data, ['id' => $params['id']]);
|
||||||
|
// 修改活动专区商品
|
||||||
|
(new ActivityZoneLogic())->updateProduct($params['id'], $data);
|
||||||
|
|
||||||
// $dealCate = self::dealChangeCate($params['cate_id']);
|
// $dealCate = self::dealChangeCate($params['cate_id']);
|
||||||
//修改
|
//修改
|
||||||
@ -248,7 +255,6 @@ class StoreProductLogic extends BaseLogic
|
|||||||
'cate_id' => $params['cate_id'],
|
'cate_id' => $params['cate_id'],
|
||||||
'top_cate_id' => $top_cate_id,
|
'top_cate_id' => $top_cate_id,
|
||||||
'two_cate_id' => $two_cate_id,
|
'two_cate_id' => $two_cate_id,
|
||||||
'cate_id' => $params['cate_id'],
|
|
||||||
'bar_code' => $params['bar_code'],
|
'bar_code' => $params['bar_code'],
|
||||||
'purchase' => $params['purchase'],
|
'purchase' => $params['purchase'],
|
||||||
'rose' => $rose,
|
'rose' => $rose,
|
||||||
@ -277,6 +283,8 @@ class StoreProductLogic extends BaseLogic
|
|||||||
public static function delete(array $params): bool
|
public static function delete(array $params): bool
|
||||||
{
|
{
|
||||||
$res = StoreProduct::destroy($params['id']);
|
$res = StoreProduct::destroy($params['id']);
|
||||||
|
// 删除活动专区商品
|
||||||
|
(new ActivityZoneLogic())->deleteProduct($params['id']);
|
||||||
StoreBranchProduct::where('product_id', $params['id'])->update(['delete_time' => time()]);
|
StoreBranchProduct::where('product_id', $params['id'])->update(['delete_time' => time()]);
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
@ -105,9 +105,7 @@ class StoreProductGroupPriceLogic extends BaseLogic
|
|||||||
{
|
{
|
||||||
$arr=StoreProductGroupPrice::where('product_id',$params['product_id'])->select()->toArray();
|
$arr=StoreProductGroupPrice::where('product_id',$params['product_id'])->select()->toArray();
|
||||||
$purchase=StoreProduct::where('id',$params['product_id'])->value('purchase');
|
$purchase=StoreProduct::where('id',$params['product_id'])->value('purchase');
|
||||||
$arr_two=UserShip::where('id','>',4)->select()->toArray();
|
$arr_two=UserShip::where('id','>',0)->select()->toArray();
|
||||||
$arr_two[] = ['id' => 100001, 'title' => '供货价'];
|
|
||||||
$arr_two[] = ['id' => 100002, 'title' => '零售价'];
|
|
||||||
foreach ($arr_two as $k=>$v){
|
foreach ($arr_two as $k=>$v){
|
||||||
$arr_two[$k]['purchase']=$purchase;
|
$arr_two[$k]['purchase']=$purchase;
|
||||||
$arr_two[$k]['product_id']=$params['product_id'];
|
$arr_two[$k]['product_id']=$params['product_id'];
|
||||||
|
@ -125,7 +125,7 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
if ($params['order_type'] != 6) {
|
if ($params['order_type'] != 6) {
|
||||||
$storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find();
|
$storege = WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id', $params['product_id'])->find();
|
||||||
if ($storege) {
|
if ($storege) {
|
||||||
if($params['order_type']!=7){
|
if(in_array($params['order_type'],[1,4])){
|
||||||
SystemStoreStorage::create([
|
SystemStoreStorage::create([
|
||||||
'store_id' => $params['store_id'],
|
'store_id' => $params['store_id'],
|
||||||
'admin_id' => $params['admin_id'],
|
'admin_id' => $params['admin_id'],
|
||||||
@ -193,7 +193,6 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public static function edit(array $params)
|
public static function edit(array $params)
|
||||||
{
|
{
|
||||||
|
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
$before_nums = 0;
|
$before_nums = 0;
|
||||||
@ -221,24 +220,24 @@ class WarehouseProductLogic extends BaseLogic
|
|||||||
$before_nums = $warehouseProductStorege['nums'];
|
$before_nums = $warehouseProductStorege['nums'];
|
||||||
$after_nums = bcsub($warehouseProductStorege['nums'], $params['nums'], 2);
|
$after_nums = bcsub($warehouseProductStorege['nums'], $params['nums'], 2);
|
||||||
}
|
}
|
||||||
|
$datas = [
|
||||||
|
'nums' => $params['nums'],
|
||||||
|
'before_nums' => $before_nums,
|
||||||
|
'after_nums' => $after_nums,
|
||||||
|
'total_price' => $params['total_price'],
|
||||||
|
];
|
||||||
if($find['financial_pm']==1){
|
if($find['financial_pm']==1){
|
||||||
$datas=[
|
$datas['supplier_id'] = $params['supplier_id'];
|
||||||
'nums' => $params['nums'],
|
$datas['pay_type'] = $params['pay_type'];
|
||||||
'supplier_id' => $params['supplier_id'],
|
$datas['purchase'] = $params['purchase'];
|
||||||
'pay_type' => $params['pay_type'],
|
|
||||||
'purchase' => $params['purchase'],
|
|
||||||
'before_nums' => $before_nums,
|
|
||||||
'after_nums' => $after_nums,
|
|
||||||
'total_price' => $params['total_price'],
|
|
||||||
];
|
|
||||||
}else{
|
}else{
|
||||||
$datas=[
|
$datas['price'] = $params['price'];
|
||||||
'nums' => $params['nums'],
|
}
|
||||||
'price' => $params['price'],
|
if (isset($params['manufacture']) && $params['manufacture'] != '') {
|
||||||
'before_nums' => $before_nums,
|
$datas['manufacture'] = strtotime($params['manufacture']);
|
||||||
'after_nums' => $after_nums,
|
}
|
||||||
'total_price' => $params['total_price'],
|
if (isset($params['expiration_date']) && $params['expiration_date'] != '') {
|
||||||
];
|
$datas['expiration_date'] = strtotime($params['expiration_date']);
|
||||||
}
|
}
|
||||||
WarehouseProduct::where('id', $params['id'])->update($datas);
|
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();
|
$finds = WarehouseProduct::where('oid', $params['oid'])->field('sum(nums) as nums,sum(total_price) as total_price')->find();
|
||||||
|
89
app/admin/validate/ActivityZoneFormValidate.php
Normal file
89
app/admin/validate/ActivityZoneFormValidate.php
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\validate;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityZone验证器
|
||||||
|
* Class ActivityZoneValidate
|
||||||
|
* @package app\admin\validate
|
||||||
|
*/
|
||||||
|
class ActivityZoneFormValidate extends BaseValidate
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置校验规则
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $rule = [
|
||||||
|
'id' => 'require',
|
||||||
|
'type' => 'require',
|
||||||
|
'title' => 'require',
|
||||||
|
'cate_ids' => 'require',
|
||||||
|
'remark' => 'string',
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数描述
|
||||||
|
* @var string[]
|
||||||
|
*/
|
||||||
|
protected $field = [
|
||||||
|
'id' => 'id',
|
||||||
|
'type' => '类型',
|
||||||
|
'product_ids' => '商品',
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 添加场景
|
||||||
|
* @return ActivityZoneValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function sceneAdd()
|
||||||
|
{
|
||||||
|
return $this->only(['type', 'title', 'cate_ids']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 编辑场景
|
||||||
|
* @return ActivityZoneValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function sceneEdit()
|
||||||
|
{
|
||||||
|
return $this->only(['id', 'type', 'title', 'cate_ids']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 删除场景
|
||||||
|
* @return ActivityZoneValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function sceneDelete()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 详情场景
|
||||||
|
* @return ActivityZoneValidate
|
||||||
|
* @author admin
|
||||||
|
* @date 2024/12/20 10:52
|
||||||
|
*/
|
||||||
|
public function sceneDetail()
|
||||||
|
{
|
||||||
|
return $this->only(['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,15 +14,14 @@ use app\common\validate\BaseValidate;
|
|||||||
class ActivityZoneValidate extends BaseValidate
|
class ActivityZoneValidate extends BaseValidate
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置校验规则
|
* 设置校验规则
|
||||||
* @var string[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'id' => 'require',
|
'id' => 'require',
|
||||||
'type' => 'require',
|
'form_id' => 'require',
|
||||||
'product_ids' => 'require',
|
'product_ids' => 'require',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -32,9 +31,8 @@ class ActivityZoneValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
protected $field = [
|
protected $field = [
|
||||||
'id' => 'id',
|
'id' => 'id',
|
||||||
'type' => '类型',
|
'form_id' => '表单',
|
||||||
'product_ids' => '商品',
|
'product_ids' => '商品',
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +44,7 @@ class ActivityZoneValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneAdd()
|
public function sceneAdd()
|
||||||
{
|
{
|
||||||
return $this->only(['type','product_ids']);
|
return $this->only(['form_id', 'product_ids']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -58,7 +56,7 @@ class ActivityZoneValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneEdit()
|
public function sceneEdit()
|
||||||
{
|
{
|
||||||
return $this->only(['id','type','product_ids']);
|
return $this->only(['id', 'form_id', 'product_ids']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
namespace app\api\controller\purchase_product_offer;
|
namespace app\api\controller\purchase_product_offer;
|
||||||
|
|
||||||
|
|
||||||
|
use app\admin\lists\supplier\SupplierLists;
|
||||||
|
use app\admin\logic\purchase_product_offer\PurchaseProductOfferLogic;
|
||||||
use app\api\lists\purchase_product_offer\PurchaseProductOfferLists;
|
use app\api\lists\purchase_product_offer\PurchaseProductOfferLists;
|
||||||
use app\api\controller\BaseApiController;
|
use app\api\controller\BaseApiController;
|
||||||
use app\common\model\dict\DictData;
|
use app\common\model\dict\DictData;
|
||||||
@ -34,21 +36,14 @@ class PurchaseProductOfferController extends BaseApiController
|
|||||||
* 提交采购信息
|
* 提交采购信息
|
||||||
*/
|
*/
|
||||||
public function offer_update(){
|
public function offer_update(){
|
||||||
$params=$this->request->post();
|
|
||||||
$data=[
|
$params = $this->request->post();
|
||||||
'buyer_nums'=>$params['nums'],
|
if($params['supplier_id']=='' ||$params['supplier_id']<=0){
|
||||||
'price'=>$params['price'],
|
return $this->fail('请选择供应商');
|
||||||
'outbound_price'=>$params['outbound_price'],
|
|
||||||
'total_price'=>$params['total_price'],
|
|
||||||
'buyer_confirm'=>1,
|
|
||||||
'pay_type'=>$params['pay_type']??0,
|
|
||||||
];
|
|
||||||
$res=PurchaseProductOffer::where('id',$params['id'])->where('buyer_id',$this->userId)->update($data);
|
|
||||||
if($res){
|
|
||||||
return $this->success('提交成功');
|
|
||||||
}else{
|
|
||||||
return $this->fail('提交失败');
|
|
||||||
}
|
}
|
||||||
|
$params['admin_id']=0;
|
||||||
|
PurchaseProductOfferLogic::setProcureInfo($params);
|
||||||
|
return $this->success('设置成功', [], 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,4 +59,9 @@ class PurchaseProductOfferController extends BaseApiController
|
|||||||
return $this->success('ok',$data);
|
return $this->success('ok',$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supplier()
|
||||||
|
{
|
||||||
|
return $this->dataLists(new SupplierLists());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ use app\common\model\store_product\StoreProduct;
|
|||||||
use app\common\model\store_product_unit\StoreProductUnit;
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
use app\api\lists\BaseApiDataLists;
|
use app\api\lists\BaseApiDataLists;
|
||||||
use app\common\model\store_category\StoreCategory;
|
use app\common\model\store_category\StoreCategory;
|
||||||
|
use app\common\model\supplier\Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购供应链商品列表
|
* 采购供应链商品列表
|
||||||
@ -49,17 +50,20 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
|
|||||||
}else{
|
}else{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return PurchaseProductOffer::where($this->searchWhere)
|
$cateIds = [];
|
||||||
->field(['id', 'order_id', 'product_id', 'price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm','need_num', 'buyer_id', 'status', 'mark','update_time'])
|
$list = PurchaseProductOffer::where($this->searchWhere)
|
||||||
|
->with('product')
|
||||||
|
->field(['id', 'order_id', 'product_id', 'price', 'total_price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm','need_num', 'buyer_id', 'status', 'mark','update_time', 'supplier_id', 'package', 'store_info', 'marques', 'after_sales', 'pay_type'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['product_id'=>'desc','id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function($item){
|
->select()->each(function($item) use(&$cateIds, &$supplierIds, &$unitIds) {
|
||||||
$find=StoreProduct::where('id',$item->product_id)->find();
|
$item->store_info = empty($item['store_info']) ? ($item['product']['store_info'] ?? '') : $item['store_info'];
|
||||||
$item->store_name=$find->store_name;
|
$item->after_sales = empty($item['after_sales']) ? ($item['product']['after_sales'] ?? '') : $item['after_sales'];
|
||||||
$item->image=$find->image;
|
$item->marques = empty($item['marques']) ? ($item['product']['marques'] ?? '') : $item['marques'];
|
||||||
$item->store_info=$find->store_info;
|
$item->package = empty($item['package']) ? ($item['product']['package'] ?? '') : $item['package'];
|
||||||
$item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name');
|
$item->store_name=$item->product->store_name ?? '';
|
||||||
$item->category_name=StoreCategory::where('id',$find->top_cate_id)->value('name');
|
$item->image=$item->product->image ?? '';
|
||||||
|
$cateIds[] = $item->product->top_cate_id ?? 0;
|
||||||
if($item->is_buyer==1){
|
if($item->is_buyer==1){
|
||||||
$item->is_buyer_name='需要采购';
|
$item->is_buyer_name='需要采购';
|
||||||
}elseif($item->is_buyer==-1){
|
}elseif($item->is_buyer==-1){
|
||||||
@ -73,9 +77,20 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
|
|||||||
$item->buyer_confirm_name='采购完成';
|
$item->buyer_confirm_name='采购完成';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
|
$suppliers = Supplier::field('id,mer_name')->whereIn('id', array_unique(array_column($list,'supplier_id')))->select()->toArray();
|
||||||
|
$suppliers = reset_index($suppliers, 'id');
|
||||||
|
$units = StoreProductUnit::field('id,name')->whereIn('id', array_unique(array_column($list,'unit')))->select()->toArray();
|
||||||
|
$units = reset_index($units, 'id');
|
||||||
|
$categories = StoreCategory::field('id,name')->whereIn('id', array_unique($cateIds))->select()->toArray();
|
||||||
|
$categories = reset_index($categories, 'id');
|
||||||
|
foreach ($list as &$item) {
|
||||||
|
$item['supplier_name'] = $suppliers[$item['supplier_id']]['mer_name'] ?? '';
|
||||||
|
$item['unit_name'] = $units[$item['unit']]['name'] ?? '';
|
||||||
|
$item['category_name'] = !empty($item['product']['top_cate_id']) && !empty($categories[$item['product']['top_cate_id']]) ? $categories[$item['product']['top_cate_id']]['name'] : '';
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,7 +13,10 @@ class DemoLogic extends BaseLogic
|
|||||||
$arr = Db::name('ceshi_two')->select();
|
$arr = Db::name('ceshi_two')->select();
|
||||||
foreach ($arr as $k => $v) {
|
foreach ($arr as $k => $v) {
|
||||||
//门店供货、商户、零售
|
//门店供货、商户、零售
|
||||||
StoreProduct::where('id', $v['product_id'])->update(['purchase' => $v['price'], 'cost' => bcadd($v['price1'], 0, 2), 'vip_price' => bcadd($v['price1'], 0, 2), 'price' => bcadd($v['price6'], 0, 2)]);
|
$res=StoreProduct::where('id', $v['product_id'])->update(['purchase' => $v['price'], 'cost' => bcadd($v['price1'], 0, 2), 'vip_price' => bcadd($v['price1'], 0, 2), 'price' => bcadd($v['price6'], 0, 2)]);
|
||||||
|
if($res){
|
||||||
|
Db::name('ceshi_two')->where('product_id', $v['product_id'])->update(['status' => 1]);
|
||||||
|
}
|
||||||
//种养殖
|
//种养殖
|
||||||
$find = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 5)->find();
|
$find = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 5)->find();
|
||||||
if ($find) {
|
if ($find) {
|
||||||
@ -21,13 +24,20 @@ class DemoLogic extends BaseLogic
|
|||||||
} else {
|
} else {
|
||||||
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 5, 'price' => bcadd($v['price8'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv8'], 100), 100, 2)]);
|
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 5, 'price' => bcadd($v['price8'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv8'], 100), 100, 2)]);
|
||||||
}
|
}
|
||||||
//酒店
|
//食堂
|
||||||
$find2 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->find();
|
$find2 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->find();
|
||||||
if ($find2) {
|
if ($find2) {
|
||||||
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->update(['price' => bcadd($v['price3'], 0, 2)]);
|
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 7)->update(['price' => bcadd($v['price3'], 0, 2)]);
|
||||||
} else {
|
} else {
|
||||||
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 7, 'price' => bcadd($v['price3'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv3'], 100), 100, 2)]);
|
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 7, 'price' => bcadd($v['price3'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv3'], 100), 100, 2)]);
|
||||||
}
|
}
|
||||||
|
//酒店
|
||||||
|
$find2 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 6)->find();
|
||||||
|
if ($find2) {
|
||||||
|
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 6)->update(['price' => bcadd($v['price3'], 0, 2)]);
|
||||||
|
} else {
|
||||||
|
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 6, 'price' => bcadd($v['price3'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv3'], 100), 100, 2)]);
|
||||||
|
}
|
||||||
//一条龙
|
//一条龙
|
||||||
$find3 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 18)->find();
|
$find3 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 18)->find();
|
||||||
if ($find3) {
|
if ($find3) {
|
||||||
@ -50,7 +60,6 @@ class DemoLogic extends BaseLogic
|
|||||||
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 19, 'price' => bcadd($v['price2'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv2'], 100), 100, 2)]);
|
Db::name('store_product_group_price')->insert(['product_id' => $v['product_id'], 'group_id' => 19, 'price' => bcadd($v['price2'], 0, 2), 'price_type' => 3, 'base_rate' => bcadd(bcmul($v['lv2'], 100), 100, 2)]);
|
||||||
}
|
}
|
||||||
//食堂会员
|
//食堂会员
|
||||||
|
|
||||||
$find4 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->find();
|
$find4 = Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->find();
|
||||||
if ($find4) {
|
if ($find4) {
|
||||||
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->update(['price' => bcadd($v['price4'], 0, 2)]);
|
Db::name('store_product_group_price')->where('product_id', $v['product_id'])->where('group_id', 20)->update(['price' => bcadd($v['price4'], 0, 2)]);
|
||||||
|
@ -11,6 +11,7 @@ use app\common\enum\user\UserShipEnum;
|
|||||||
use app\common\enum\YesNoEnum;
|
use app\common\enum\YesNoEnum;
|
||||||
use app\common\logic\user_product_storage\UserProductStorageLogic;
|
use app\common\logic\user_product_storage\UserProductStorageLogic;
|
||||||
use app\common\model\Config;
|
use app\common\model\Config;
|
||||||
|
use app\common\model\dict\DictData;
|
||||||
use app\common\model\dict\DictType;
|
use app\common\model\dict\DictType;
|
||||||
use app\common\model\finance\CapitalFlow;
|
use app\common\model\finance\CapitalFlow;
|
||||||
use app\common\model\finance\PayNotifyLog;
|
use app\common\model\finance\PayNotifyLog;
|
||||||
@ -32,6 +33,7 @@ use app\common\model\user_sign\UserSign;
|
|||||||
use app\common\model\vip_flow\VipFlow;
|
use app\common\model\vip_flow\VipFlow;
|
||||||
use app\common\service\Curl;
|
use app\common\service\Curl;
|
||||||
use app\common\service\PushService;
|
use app\common\service\PushService;
|
||||||
|
use app\common\service\xpyun\XpsdkPrintApi;
|
||||||
use support\exception\BusinessException;
|
use support\exception\BusinessException;
|
||||||
use support\Log;
|
use support\Log;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
@ -52,8 +54,9 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
self::$action($orderSn, $extra, $type);
|
self::$action($orderSn, $extra, $type);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
} catch (\Exception $e) {
|
} catch (\Throwable $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
|
d($e);
|
||||||
Log::error('支付回调处理失败' . $e->getMessage() . ',lien:' . $e->getLine() . ',file:' . $e->getFile());
|
Log::error('支付回调处理失败' . $e->getMessage() . ',lien:' . $e->getLine() . ',file:' . $e->getFile());
|
||||||
throw new BusinessException($e->getMessage());
|
throw new BusinessException($e->getMessage());
|
||||||
}
|
}
|
||||||
@ -647,6 +650,9 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
if ($order['uid'] != 1) {
|
if ($order['uid'] != 1) {
|
||||||
Redis::send('order_wetcha_push_send', ['order' => $order]);
|
Redis::send('order_wetcha_push_send', ['order' => $order]);
|
||||||
}
|
}
|
||||||
|
if($order['store_id']==21){
|
||||||
|
Redis::send('order_xprinter_push_send', ['order' => $order]);
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Log::error('订单推送失败:' . $e->getMessage());
|
Log::error('订单推送失败:' . $e->getMessage());
|
||||||
// 异常处理代码,例如记录日志或发送通知等。
|
// 异常处理代码,例如记录日志或发送通知等。
|
||||||
|
19
app/common/model/ActivityZoneForm.php
Normal file
19
app/common/model/ActivityZoneForm.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model;
|
||||||
|
|
||||||
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ActivityZoneForm模型
|
||||||
|
* Class ActivityZoneForm
|
||||||
|
* @package app\common\model
|
||||||
|
*/
|
||||||
|
class ActivityZoneForm extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
use SoftDelete;
|
||||||
|
protected $name = 'activity_zone_form';
|
||||||
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ namespace app\common\model\purchase_product_offer;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
@ -21,4 +22,9 @@ class PurchaseProductOffer extends BaseModel
|
|||||||
protected $json = ['source_order_info'];
|
protected $json = ['source_order_info'];
|
||||||
protected $jsonAssoc = true;
|
protected $jsonAssoc = true;
|
||||||
|
|
||||||
|
public function product()
|
||||||
|
{
|
||||||
|
return $this->hasOne(StoreProduct::class, 'id', 'product_id')->field('id,store_name,top_cate_id,image,store_info,package,marques,after_sales');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
|||||||
|
|
||||||
class ActivityZoneService
|
class ActivityZoneService
|
||||||
{
|
{
|
||||||
public function export($data, $typeName, $remark)
|
public function export($data, $title, $remark)
|
||||||
{
|
{
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
$sheet = $spreadsheet->getActiveSheet();
|
$sheet = $spreadsheet->getActiveSheet();
|
||||||
@ -26,7 +26,7 @@ class ActivityZoneService
|
|||||||
$sheet->mergeCells('A5:F5');
|
$sheet->mergeCells('A5:F5');
|
||||||
$sheet->mergeCells('B6:C6');
|
$sheet->mergeCells('B6:C6');
|
||||||
|
|
||||||
$sheet->setCellValue('A1', "供 投 里 海 农 特 产 品 下 单 清 单({$typeName})");
|
$sheet->setCellValue('A1', $title);
|
||||||
$sheet->setCellValue('A2', '姓名:');
|
$sheet->setCellValue('A2', '姓名:');
|
||||||
$sheet->setCellValue('C2', '电话:');
|
$sheet->setCellValue('C2', '电话:');
|
||||||
$sheet->setCellValue('E2', '会员角色:');
|
$sheet->setCellValue('E2', '会员角色:');
|
||||||
@ -65,23 +65,30 @@ class ActivityZoneService
|
|||||||
// 应用默认样式到A2:F5
|
// 应用默认样式到A2:F5
|
||||||
$sheet->getStyle('A2:F5')->applyFromArray($leftStyle);
|
$sheet->getStyle('A2:F5')->applyFromArray($leftStyle);
|
||||||
|
|
||||||
foreach ($data as $k => $v) {
|
$column = 7;
|
||||||
$column = $k + 7;
|
foreach ($data as $k => $item) {
|
||||||
$sheet->mergeCells("B{$column}:C{$column}");
|
$sheet->mergeCells("A{$column}:F{$column}");
|
||||||
$sheet->setCellValue('A' . ($k + 7), $v['id']);
|
$sheet->setCellValue('A' . $column, $k);
|
||||||
$sheet->setCellValue("B{$column}", $v['store_name']);
|
$sheet->getStyle('A' . $column)->applyFromArray([
|
||||||
$sheet->setCellValue("D{$column}", $v['unit_name']);
|
'font' => [
|
||||||
|
'bold' => true,
|
||||||
|
'size' => 16,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
$column++;
|
||||||
|
foreach ($item as $value) {
|
||||||
|
$sheet->mergeCells("B{$column}:C{$column}");
|
||||||
|
$sheet->setCellValue('A' . $column, $value['id']);
|
||||||
|
$sheet->setCellValue("B{$column}", $value['store_name']);
|
||||||
|
$sheet->setCellValue("D{$column}", $value['unit_name']);
|
||||||
|
$column++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$count = count($data);
|
$sheet->mergeCells('A' . $column . ':F' . $column);
|
||||||
$sheet->mergeCells('A' . ($count + 7) . ':F' . ($count + 7));
|
$sheet->setCellValue('A' . $column, "备注:{$remark}");
|
||||||
$sheet->setCellValue('A' . ($count + 7), "专区类型:{$typeName}");
|
$sheet->getRowDimension($column)->setRowHeight(50);
|
||||||
$sheet->mergeCells('A' . ($count + 8) . ':F' . ($count + 8));
|
$sheet->getStyle('A' . $column)->getAlignment()->setWrapText(true);
|
||||||
$sheet->setCellValue('A' . ($count + 8), "");
|
$sheet->getStyle('A' . $column. ':' . 'F' . $column)->applyFromArray($leftStyle);
|
||||||
$sheet->mergeCells('A' . ($count + 9) . ':F' . ($count + 9));
|
|
||||||
$sheet->setCellValue('A' . ($count + 9), "备注:{$remark}");
|
|
||||||
$sheet->getRowDimension($count + 9)->setRowHeight(50);
|
|
||||||
$sheet->getStyle('A' . ($count + 9))->getAlignment()->setWrapText(true);
|
|
||||||
$sheet->getStyle('A' . ($count + 7). ':' . 'F' . ($count + 9))->applyFromArray($leftStyle);
|
|
||||||
|
|
||||||
// 设置单元格的样式
|
// 设置单元格的样式
|
||||||
$styleArray = [
|
$styleArray = [
|
||||||
@ -100,10 +107,10 @@ class ActivityZoneService
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$sheet->getStyle('A1:F' . ($count + 9))->applyFromArray($styleArray);
|
$sheet->getStyle('A1:F' . $column)->applyFromArray($styleArray);
|
||||||
|
|
||||||
$writer = new Xlsx($spreadsheet);
|
$writer = new Xlsx($spreadsheet);
|
||||||
$url = '/export/' . date('Y-m') . "/供投里海农特产品下单清单({$typeName})" . date('YmdHi') . '.xlsx';
|
$url = '/export/' . date('Y-m') . $title . date('YmdHi') . '.xlsx';
|
||||||
$file_path = public_path() . $url;
|
$file_path = public_path() . $url;
|
||||||
if (!is_dir(dirname($file_path))) {
|
if (!is_dir(dirname($file_path))) {
|
||||||
mkdir(dirname($file_path), 0777, true);
|
mkdir(dirname($file_path), 0777, true);
|
||||||
|
@ -25,44 +25,49 @@ class XpsdkPrintApi
|
|||||||
* 注意:对齐标签L C R CB 请勿嵌套使用,嵌套使用内层标签有效,外层失效;
|
* 注意:对齐标签L C R CB 请勿嵌套使用,嵌套使用内层标签有效,外层失效;
|
||||||
* 同一行请勿使用多个对齐标签,否则只有最后一个对齐标签有效
|
* 同一行请勿使用多个对齐标签,否则只有最后一个对齐标签有效
|
||||||
*/
|
*/
|
||||||
public function printFontAlign($sn)
|
public function printFontAlign($sn,$order)
|
||||||
{
|
{
|
||||||
|
$system_store=$order['system_store'];
|
||||||
|
$system_phone=$order['system_phone'];
|
||||||
|
$verify_code=$order['verify_code'];
|
||||||
|
$order_id=$order['order_id'];
|
||||||
|
$create_time=$order['create_time'];
|
||||||
|
$pay_price=$order['pay_price'];
|
||||||
|
$total_price=$order['total_price'];
|
||||||
|
$deduction_price=$order['deduction_price'];
|
||||||
|
$pay_type_name=$order['pay_type_name'];
|
||||||
|
|
||||||
$printContent = <<<EOF
|
$printContent = <<<EOF
|
||||||
不加标签:默认字体大小<BR>
|
<C><BOLD><B>{$system_store}</B></BOLD><BR></C>
|
||||||
<BR>
|
<L><N>==============================
|
||||||
L标签:<L>左对齐<BR></L>
|
<L><N>核销码:<BOLD>{$verify_code}</BOLD>
|
||||||
<BR>
|
<L><N>单号:{$order_id}
|
||||||
R标签:<R>右对齐<BR></R>
|
<L><N>下单时间:{$create_time}
|
||||||
<BR>
|
<L><N>==============================
|
||||||
C标签:<C>居中对齐<BR></C>
|
<L>单价 数量 小计
|
||||||
<BR>
|
<L>
|
||||||
N标签:<N>字体正常大小<BR></N>
|
|
||||||
<BR>
|
|
||||||
HB标签:<HB>字体变高一倍<BR></HB>
|
|
||||||
<BR>
|
|
||||||
WB标签:<WB>字体变宽一倍<BR></WB>
|
|
||||||
<BR>
|
|
||||||
B标签:<B>字体放大一倍<BR></B>
|
|
||||||
<BR>
|
|
||||||
HB2标签:<HB2>字体变高二倍<BR></HB2>
|
|
||||||
<BR>
|
|
||||||
WB2标签:<WB2>字体变宽二倍<BR></WB2>
|
|
||||||
<BR>
|
|
||||||
B2标签:<B2>字体放大二倍<BR></B2>
|
|
||||||
<BR>
|
|
||||||
BOLD标签:<BOLD>字体加粗<BR></BOLD>
|
|
||||||
EOF;
|
EOF;
|
||||||
|
// 使用 for 循环生成商品列表
|
||||||
|
foreach ($order['product_arr'] as $k=>$v) {
|
||||||
|
$printContent .= <<<EOF
|
||||||
|
<L>{$v['name']}
|
||||||
|
<L>{$v['price']} *{$v['quantity']} {$v['subtotal']}
|
||||||
|
EOF;
|
||||||
|
}
|
||||||
|
|
||||||
$printContent = $printContent . '<BR>';
|
// 继续生成剩余的 printContent
|
||||||
// 嵌套使用对齐和字体
|
$printContent .= <<<EOF
|
||||||
$printContent = $printContent . '<C>嵌套使用:<BOLD>居中加粗</BOLD><BR></C>';
|
<L>
|
||||||
|
<L><N>==============================
|
||||||
// 打印条形码和二维码
|
<N>合计:{$total_price}元
|
||||||
$printContent = $printContent . '<BR>';
|
<L><N>优惠:{$deduction_price}元
|
||||||
$printContent = $printContent . '<C><BARCODE>9884822189</BARCODE></C>';
|
<L><N>实付款:{$pay_price}元
|
||||||
$printContent = $printContent . '<C><QR>https://www.xpyun.net</QR></C>';
|
<L><N>支付方式:{$pay_type_name}
|
||||||
|
<L><N>店铺电话:{$system_phone}
|
||||||
|
<L><N>==============================
|
||||||
|
|
||||||
|
<C><BOLD>欢迎下次光临!</BOLD><BR></C>
|
||||||
|
EOF;
|
||||||
$request = new PrintRequest();
|
$request = new PrintRequest();
|
||||||
$request->generateSign();
|
$request->generateSign();
|
||||||
|
|
||||||
@ -81,7 +86,7 @@ EOF;
|
|||||||
//打印模式:
|
//打印模式:
|
||||||
//值为 0 或不指定则会检查打印机是否在线,如果不在线 则不生成打印订单,直接返回设备不在线状态码;如果在线则生成打印订单,并返回打印订单号。
|
//值为 0 或不指定则会检查打印机是否在线,如果不在线 则不生成打印订单,直接返回设备不在线状态码;如果在线则生成打印订单,并返回打印订单号。
|
||||||
//值为 1不检查打印机是否在线,直接生成打印订单,并返回打印订单号。如果打印机不在线,订单将缓存在打印队列中,打印机正常在线时会自动打印。
|
//值为 1不检查打印机是否在线,直接生成打印订单,并返回打印订单号。如果打印机不在线,订单将缓存在打印队列中,打印机正常在线时会自动打印。
|
||||||
$request->mode = 1;
|
$request->mode = 0;
|
||||||
|
|
||||||
$result = $this->service->xpYunPrint($request);
|
$result = $this->service->xpYunPrint($request);
|
||||||
return $result->content;
|
return $result->content;
|
||||||
|
78
app/queue/redis/OrderXprinterPushSend.php
Normal file
78
app/queue/redis/OrderXprinterPushSend.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\queue\redis;
|
||||||
|
|
||||||
|
use app\common\enum\PayEnum;
|
||||||
|
use app\common\model\dict\DictData;
|
||||||
|
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||||
|
use app\common\model\store_product\StoreProduct;
|
||||||
|
use app\common\model\system_store\SystemStore;
|
||||||
|
use app\common\service\xpyun\XpsdkPrintApi;
|
||||||
|
use Webman\RedisQueue\Consumer;
|
||||||
|
use support\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 芯华云订单推送队列消费
|
||||||
|
*/
|
||||||
|
class OrderXprinterPushSend implements Consumer
|
||||||
|
{
|
||||||
|
// 要消费的队列名
|
||||||
|
public $queue = 'order_xprinter_push_send';
|
||||||
|
|
||||||
|
// 连接名,对应 plugin/webman/redis-queue/redis.php 里的连接`
|
||||||
|
public $connection = 'default';
|
||||||
|
|
||||||
|
// 消费
|
||||||
|
public function consume($data)
|
||||||
|
{
|
||||||
|
|
||||||
|
$order = $data['order'];
|
||||||
|
$total_price = $order['total_price'];
|
||||||
|
$pay_price = $order['pay_price'];
|
||||||
|
$store_id = $order['store_id'];
|
||||||
|
$deduction_price = $order['deduction_price'];
|
||||||
|
$pay_time = date('Y-m-d H:i:s', $order['pay_time']);
|
||||||
|
$pay_type = PayEnum::getPaySceneDesc($order['pay_type']);
|
||||||
|
$SystemStore = SystemStore::where('id', $order['store_id'])->find();
|
||||||
|
$cart_info = StoreOrderCartInfo::where('oid', $order['id'])->select()->each(function ($item) {
|
||||||
|
$find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find();
|
||||||
|
$item['store_name'] = $find['store_name'];
|
||||||
|
return $item;
|
||||||
|
});
|
||||||
|
|
||||||
|
$product_arr = [];
|
||||||
|
foreach ($cart_info as $k => $v) {
|
||||||
|
$product_arr[] = [
|
||||||
|
'name' => $v['store_name'],
|
||||||
|
'price' => $v['price'] . '元',
|
||||||
|
'quantity' => $v['cart_num'],
|
||||||
|
'subtotal' => $v['total_price'] . '元'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$api = new XpsdkPrintApi();
|
||||||
|
$order = [
|
||||||
|
'system_store' => $SystemStore['name'] ?? '',
|
||||||
|
'system_phone' => $SystemStore['phone'] ?? '',
|
||||||
|
'verify_code' => $order['verify_code'],
|
||||||
|
'order_id' => $order['order_id'],
|
||||||
|
'create_time' => $pay_time,
|
||||||
|
'pay_price' => $pay_price,
|
||||||
|
'total_price' => $total_price,
|
||||||
|
'deduction_price' => $deduction_price,
|
||||||
|
'pay_type_name' => $pay_type,
|
||||||
|
'product_arr' => $product_arr
|
||||||
|
];
|
||||||
|
$value=DictData::where('name','xprinter_'.$store_id)->value('value');
|
||||||
|
if($value){
|
||||||
|
$res = ($api->printFontAlign($value, $order));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 消费失败时
|
||||||
|
public function onConsumeFailure(\Throwable $exception, $package)
|
||||||
|
{
|
||||||
|
$package['max_attempts'] = 0;
|
||||||
|
Log::error('推送订单失败', ['order_id' => $package['data'], 'error' => $package['error']]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user