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

Reviewed-on: https://gitea.lihaink.cn/mkm/multi-store/pulls/506
This commit is contained in:
mkm 2025-02-08 09:44:56 +08:00
commit 0a3e465b9d
13 changed files with 185 additions and 99 deletions

View File

@ -3,6 +3,7 @@
namespace app\admin\controller\accounts_receivable;
use app\admin\controller\BaseAdminController;
use app\admin\lists\AccountsReceivableInfoLists;
use app\admin\lists\AccountsReceivableLists;
use app\admin\logic\AccountsReceivableLogic;
use app\admin\validate\app_update\AppUpdateValidate;
@ -21,10 +22,10 @@ class AccountsReceivableController extends BaseAdminController
public function edit()
{
$params = (new AppUpdateValidate())->post()->goCheck('edit');
$params = $this->request->post();
$result = AccountsReceivableLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(AccountsReceivableLogic::getError());
}
@ -43,4 +44,9 @@ class AccountsReceivableController extends BaseAdminController
return $this->data($result);
}
public function record()
{
return $this->dataLists(new AccountsReceivableInfoLists());
}
}

View File

@ -354,4 +354,12 @@ class BeforehandOrderController extends BaseAdminController
return $this->success('复制成功');
}
public function transfer()
{
$params = $this->request->post();
$params['admin_id'] = $this->adminId;
BeforehandOrderLogic::transfer($params);
return $this->success('操作成功');
}
}

View File

@ -7,7 +7,7 @@ use app\admin\controller\BaseAdminController;
use app\admin\lists\warehouse_product_storege\WarehouseProductStoregeLists;
use app\admin\logic\warehouse_product_storege\WarehouseProductStoregeLogic;
use app\admin\validate\warehouse_product_storege\WarehouseProductStoregeValidate;
use app\common\model\warehouse_product_storege\WarehouseProductStorege;
/**
* 仓库商品存储控制器
@ -88,6 +88,15 @@ class WarehouseProductStoregeController extends BaseAdminController
// $result = WarehouseProductStoregeLogic::detail($params);
// return $this->data($result);
// }
/**
* @notes 修改商品状态
* @return \think\response\Json
* @date 2024/05/31 10:53
*/
public function verify(){
$params=$this->request->post();
WarehouseProductStorege::where('id',$params['id'])->update(['is_verify'=>$params['is_verify']]);
return $this->success('操作成功',[],1,1);
}
}

View File

@ -0,0 +1,68 @@
<?php
namespace app\admin\lists;
use app\common\lists\ListsSearchInterface;
use app\common\model\beforehand_order\BeforehandOrder;
use app\common\model\finance\AccountsReceivable;
use app\common\model\finance\AccountsReceivableInfo;
use app\common\model\system_store\SystemStore;
/**
* AccountsReceivableInfoLists
* Class AccountsReceivableInfoLists
* @package app\admin\lists
*/
class AccountsReceivableInfoLists extends BaseAdminDataLists implements ListsSearchInterface
{
public function setSearch(): array
{
return [
'=' => ['accounts_receivable_id'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function lists(): array
{
$query = AccountsReceivableInfo::where($this->searchWhere);
$list = $query
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
$accountReceivable = AccountsReceivable::field('id,store_id,nickname')->where('id', $this->params['accounts_receivable_id'])->findOrEmpty()->toArray();
$store = SystemStore::where('id', $accountReceivable['store_id'])->value('name');
$payTypeMap = [
1 => '现金',
2 => '微信支付',
3 => '支付宝支付',
4 => '对公账号',
5 => '其他'
];
foreach ($list as &$item) {
$item['store_name'] = $store;
$item['pay_type_name'] = $payTypeMap[$item['pay_type']];
$item['nickname'] = $accountReceivable['nickname'];
}
return $list;
}
/**
* @notes 获取数量
* @return int
*/
public function count(): int
{
$query = AccountsReceivableInfo::where($this->searchWhere);
return $query->count();
}
}

View File

@ -6,8 +6,6 @@ use app\common\lists\ListsSearchInterface;
use app\common\model\beforehand_order\BeforehandOrder;
use app\common\model\finance\AccountsReceivable;
use app\common\model\system_store\SystemStore;
use app\common\model\user\User;
use Illuminate\Contracts\Cache\Store;
/**
* AccountsReceivableLists
@ -51,6 +49,8 @@ class AccountsReceivableLists extends BaseAdminDataLists implements ListsSearchI
foreach ($list as &$item) {
$item['store_name'] = $stores[$item['store_id']]['name'];
$item['order_sn'] = $orderInfo[$item['order_id']]['order_id'];
$item['debt_day'] = intval((time() - strtotime($item['create_time'])) / 86400);
$item['deadline'] = date('Y-m-d H:i:s', $item['deadline']);
}
return $list;
}

View File

@ -88,7 +88,7 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
$oid=WarehouseOrder::where('financial_pm',0)->where('code','like','%'.$order_ck)->column('id');
$this->searchWhere[] = ['outbound_id','in',$oid];
}
$file=['id','uid', 'order_id', 'order_sn','store_id', 'order_type', 'total_num', 'total_price', 'outbound_id', 'admin_id', 'create_time', 'status', 'mark', 'warehousing_id', 'file','other_data', 'audit_status', 'store_staff_id'];
$file=['id','uid', 'order_id', 'order_sn','store_id', 'order_type', 'total_num', 'total_price', 'outbound_id', 'admin_id', 'create_time', 'status', 'mark', 'warehousing_id', 'file','other_data', 'audit_status', 'store_staff_id', 'is_arrears'];
$query = BeforehandOrder::where($this->searchWhere);
return $query
->field($file)

View File

@ -34,7 +34,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
public function setSearch(): array
{
return [
'=' => ['oid','product_id','is_pay'],
'=' => ['oid','product_id','is_pay','store_id'],
];
}
@ -53,6 +53,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
return StoreOrderCartInfo::where($this->searchWhere)
->field('id,oid,uid,product_id,store_id,cart_num,price,total_price,create_time,refund_num,refund_amount')->limit($this->limitOffset, $this->limitLength)
->select()->each(function ($item) {
$item['order_id']=StoreOrder::where('id',$item['oid'])->value('order_id')??"";//订单号
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->withTrashed()->find();
$item['nickname']='无';
$item['mobile']='';

View File

@ -54,7 +54,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
{
if ($this->request->get('product_id')) {
$product_id = $this->request->get('product_id');
$ids = StoreProduct::where('store_name', 'like', '%' . $product_id . '%')->column('id');
$ids = StoreProduct::where('store_name', 'like', '%' . $product_id . '%')->withTrashed()->column('id');
if ($ids) {
$this->searchWhere[] = ['product_id', 'in', $ids];
$this->ids = $ids;
@ -64,7 +64,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
}
if ($this->request->get('bar_code')) {
$bar_code = $this->request->get('bar_code');
$ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->column('id');
$ids = StoreProduct::where('bar_code', 'like', '%' . $bar_code . '%')->withTrashed()->column('id');
if ($ids) {
$this->searchWhere[] = ['product_id', 'in', $ids];
$this->ids = $ids;
@ -134,6 +134,27 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt
}
$item->expiration_date = $item->expiration_date ? date('Y-m-d', $item->expiration_date) : '';
$item->manufacture = $item->manufacture ? date('Y-m-d', $item->manufacture) : '';
if ($item->order_type == 1) {
$item->order_type_name = '铺货订单';
} elseif ($item->order_type == 2) {
$item->order_type_name = '商贩订单';
} elseif ($item->order_type == 3) {
$item->order_type_name = '一条龙订单';
} elseif ($item->order_type == 4) {
$item->order_type_name = '线上订单';
} elseif ($item->order_type == 5) {
$item->order_type_name = '仓库补货';
$item->outbound = '无须出库';
} elseif ($item->order_type == 6) {
$item->order_type_name = '往期补单-出库';
} elseif ($item->order_type == 7) {
$item->order_type_name = '采购订单';
} elseif ($item->order_type == 8) {
$item->order_type_name = '其他订单';
}elseif ($item->order_type == 9) {
$item->order_type_name = '往期补单-入库';
}
})
->toArray();
}

View File

@ -85,7 +85,7 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe
}
}
return WarehouseProductStorege::where($this->searchWhere)
->field(['id', 'warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status'])
->field(['id','is_verify','warehouse_id', 'product_id', 'nums', 'price', 'total_price', 'status'])
->limit($this->limitOffset, $this->limitLength)
->order($this->sortOrder)
->select()->each(function ($item) {
@ -96,6 +96,7 @@ class WarehouseProductStoregeLists extends BaseAdminDataLists implements ListsSe
$item->image = $find->image;
$item->bar_code = $find->bar_code;
$item->price = $find->price;
$item->vip_price = $find->vip_price;
$item->cost = $find->cost;
$item->purchase = $find->purchase;
$item->store_info = $find->store_info;

View File

@ -2,10 +2,9 @@
namespace app\admin\logic;
use app\common\model\ActivityZone;
use app\common\logic\BaseLogic;
use app\common\model\ActivityZoneForm;
use app\common\model\finance\AccountsReceivable;
use app\common\model\finance\AccountsReceivableInfo;
use support\exception\BusinessException;
use think\facade\Db;
@ -26,97 +25,51 @@ class AccountsReceivableLogic extends BaseLogic
$model->order_id = $order['id'];
$model->store_id = $order['store_id'];
$model->user_id = $order['uid'];
$model->nickname = $order['other_data']->nickname;
$model->phone = $order['other_data']->phone;
$model->deadline = time() + 86400 * 15;
$model->total_debt = $order['total_price'];
$model->surplus_debt = $order['total_price'];
$model->save();
}
/**
* @notes 编辑
* @param array $params
* @return bool
* @author admin
* @date 2024/12/20 10:52
*/
public static function edit(array $params): bool
public static function edit($params)
{
Db::startTrans();
try {
ActivityZone::where('id', $params['id'])->update([
'form_id' => $params['form_id'],
'product_id' => $params['product_id'],
]);
$accountsReceivable = AccountsReceivable::where(['id' => $params['accounts_receivable_id']])->find();
if ($accountsReceivable->surplus_debt <= 0) {
throw new BusinessException('该账单已支付');
}
$surplusDebt = bcsub($accountsReceivable->surplus_debt, $params['pay_debt'], 2);
$model = new AccountsReceivableInfo();
$model->accounts_receivable_id = $params['accounts_receivable_id'];
$model->pay_type = $params['pay_type'];
$model->total_debt = $params['surplus_debt'];
$model->pay_debt = $params['pay_debt'];
$model->recipient = $params['recipient'];
$model->surplus_debt = $surplusDebt;
$model->file = $params['file'];
$model->mark = $params['mark'];
if (!$model->save()) {
throw new BusinessException('添加失败');
}
$accountsReceivable->pay_debt = bcadd($accountsReceivable->pay_debt, $params['pay_debt'], 2);
$accountsReceivable->surplus_debt = $surplusDebt;
if (!$accountsReceivable->save()) {
throw new BusinessException('更新账单出错');
}
Db::commit();
return true;
} catch (\Throwable $e) {
} catch (\Exception $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
public static function record($params)
{
return ActivityZone::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author admin
* @date 2024/12/20 10:52
*/
public static function detail($params): array
{
return ActivityZone::findOrEmpty($params['id'])->toArray();
}
public function addProduct($product)
{
$activityFormId1 = ActivityZoneForm::whereRaw('FIND_IN_SET(:cate_id,cate_ids)', ['cate_id' => $product['two_cate_id']])->column('id');
$activityFormId2 = ActivityZoneForm::whereRaw('FIND_IN_SET(:cate_id,cate_ids)', ['cate_id' => $product['cate_id']])->column('id');
$activityFormIds = array_unique(array_merge($activityFormId1, $activityFormId2));
foreach ($activityFormIds as $activityFormId) {
$activityZone = new ActivityZone();
$activityZone->form_id = $activityFormId;
$activityZone->product_id = $product['id'];
$activityZone->save();
}
}
public function updateProduct($productId, $product)
{
$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);
}
}
public function deleteProduct($productId)
{
ActivityZone::where('product_id', $productId)->update(['delete_time' => time()]);
}
}

View File

@ -377,19 +377,20 @@ class BeforehandOrderLogic extends BaseLogic
throw new BusinessException('该订单已创建出库单');
}
$info = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->select()->toArray();
// $product_column = array_column($info, 'product_id');
// $storege_arr=WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id','in',$product_column)->select();
$product_column = array_column($info, 'product_id');
$storege_arr=WarehouseProductStorege::where('warehouse_id', $params['warehouse_id'])->where('product_id','in',$product_column)->select();
foreach ($info as $k => $v) {
if ($v['pay_price'] <= 0) {
throw new BusinessException('商品价格为空 不能生成出库订单,对应id:' . $v['id']);
}
// foreach ($storege_arr as $key => $value) {
// if ($value['is_verify']==1 && $v['product_id'] == $value['product_id']) {
// if ($v['cart_num'] > $value['nums']) {
// throw new BusinessException('仓库库存不足 不能生成出库订单,对应id:' . $v['id']);
// }
// }
// }
foreach ($storege_arr as $key => $value) {
if ($value['is_verify']==1 && $v['product_id'] == $value['product_id']) {
if (($v['cart_num'] < $value['nums'])==false) {
$store_name=StoreProduct::where('id', $v['product_id'])->withTrashed()->value('store_name');
throw new BusinessException('商品:'.$store_name.'已开启强制库存校验,库存不足,库存数量' . $value['nums'].',需求数量:' . $v['cart_num']);
}
}
}
}
$count = BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->where('cart_num', 0)->count('id');
if ($count > 0) {
@ -455,7 +456,7 @@ class BeforehandOrderLogic extends BaseLogic
}
BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->update(['is_buyer' => -1]);
if ($order['is_arrears'] == 2) {
AccountsReceivableLogic::add($order);
AccountsReceivableLogic::add($order->toArray());
}
self::confirm(['id' => $params['bhoid']]);
Db::commit();
@ -1132,4 +1133,21 @@ class BeforehandOrderLogic extends BaseLogic
}
}
public static function transfer($params)
{
Db::startTrans();
try {
$order = BeforehandOrder::where('id', $params['id'])->findOrEmpty()->toArray();
if ($order['is_arrears'] != 1) {
throw new BusinessException('该订单已转欠款');
}
AccountsReceivableLogic::add($order);
BeforehandOrder::where('id', $params['id'])->update(['is_arrears' => 2]);
Db::commit();
} catch (\Exception $e) {
Db::rollback();
throw new BusinessException($e->getMessage());
}
}
}

View File

@ -60,9 +60,8 @@ class PurchaseProductOfferLogic extends BaseLogic
if ($mark == '') {
$mark = BeforehandOrderCartInfo::where('bhoid', $params['order_id'])->where('product_id', $params['product_id'])->value('mark');
}
$find = StoreProduct::where('id', $params['product_id'])->withTrashed()->find();
$purchaseProductOffer = PurchaseProductOffer::where(['order_id' => $procurementOrder['id'], 'product_id' => $params['product_id']])->find();
if ($purchaseProductOffer) {
if (isset($params['merge_product']) && $params['merge_product'] == 1 && $purchaseProductOffer) {
$purchaseProductOffer->need_num = $purchaseProductOffer['need_num'] + $params['need_num'];
if (!empty($purchaseProductOffer['source_order_info'])) {
$sourceOrderInfo = $purchaseProductOffer['source_order_info'];

View File

@ -51,7 +51,9 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
->select()
->each(function ($item) {
$item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id'])
->field('id,product_id,cart_num,verify_code,is_writeoff,writeoff_time,cart_info,status')->select()
->field('id,product_id,cart_num,verify_code,is_writeoff,writeoff_time,cart_info,status')
->limit(3)
->select()
->each(function ($v) use ($item) {
$v['store_name'] = '';
$v['image'] = '';