Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev
This commit is contained in:
commit
5cbda7166e
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\accounts_receivable;
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\AccountsReceivableLists;
|
||||
use app\admin\logic\AccountsReceivableLogic;
|
||||
use app\admin\validate\app_update\AppUpdateValidate;
|
||||
|
||||
/**
|
||||
* Class AccountsReceivableController
|
||||
* @package app\admin\controller\accounts_receivable
|
||||
*/
|
||||
class AccountsReceivableController extends BaseAdminController
|
||||
{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new AccountsReceivableLists());
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$params = (new AppUpdateValidate())->post()->goCheck('edit');
|
||||
$result = AccountsReceivableLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(AccountsReceivableLogic::getError());
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$params = (new AppUpdateValidate())->post()->goCheck('delete');
|
||||
AccountsReceivableLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
public function detail()
|
||||
{
|
||||
$params = (new AppUpdateValidate())->goCheck('detail');
|
||||
$result = AccountsReceivableLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
}
|
60
app/admin/lists/AccountsReceivableLists.php
Normal file
60
app/admin/lists/AccountsReceivableLists.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists;
|
||||
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\beforehand_order\BeforehandOrder;
|
||||
use app\common\model\finance\AccountsReceivable;
|
||||
|
||||
/**
|
||||
* AccountsReceivableLists
|
||||
* Class AccountsReceivableLists
|
||||
* @package app\admin\lists
|
||||
*/
|
||||
class AccountsReceivableLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['store_id', 'user_id'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$query = AccountsReceivable::where($this->searchWhere);
|
||||
if (!empty($this->params['order_sn'])) {
|
||||
$orderIds = BeforehandOrder::where('order_id', 'like', '%' . $this->params['order_sn'] . '%')->column('id');
|
||||
$query->whereIn('order_id', $orderIds);
|
||||
}
|
||||
return $query
|
||||
->with('info')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$query = AccountsReceivable::where($this->searchWhere);
|
||||
if (!empty($this->params['order_sn'])) {
|
||||
$orderIds = BeforehandOrder::where('order_id', 'like', '%' . $this->params['order_sn'] . '%')->column('id');
|
||||
$query->whereIn('order_id', $orderIds);
|
||||
}
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
}
|
122
app/admin/logic/AccountsReceivableLogic.php
Normal file
122
app/admin/logic/AccountsReceivableLogic.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
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 support\exception\BusinessException;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* Class AccountsReceivableLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class AccountsReceivableLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $order
|
||||
*/
|
||||
public static function add(array $order)
|
||||
{
|
||||
$model = new AccountsReceivable();
|
||||
$model->order_id = $order['id'];
|
||||
$model->store_id = $order['store_id'];
|
||||
$model->user_id = $order['uid'];
|
||||
$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
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
ActivityZone::where('id', $params['id'])->update([
|
||||
'form_id' => $params['form_id'],
|
||||
'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 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()]);
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\admin\logic\beforehand_order;
|
||||
|
||||
use app\admin\logic\AccountsReceivableLogic;
|
||||
use app\admin\logic\store_branch_product\StoreBranchProductLogic;
|
||||
use app\admin\logic\store_product\StoreProductLogic;
|
||||
use app\admin\logic\warehouse_product\WarehouseProductLogic;
|
||||
@ -129,6 +130,7 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
'address' => $params['address'] ?? '',
|
||||
'mark' => $params['mark'] ?? '',
|
||||
'order_type' => $order_type,
|
||||
'is_arrears' => $params['is_arrears'] ?? 1,
|
||||
'other_data' => json_encode($params['other_data'], true)
|
||||
]);
|
||||
/** 添加审批记录 */
|
||||
@ -452,6 +454,9 @@ class BeforehandOrderLogic extends BaseLogic
|
||||
throw new BusinessException('出库失败,预订单更新出错');
|
||||
}
|
||||
BeforehandOrderCartInfo::where('bhoid', $params['bhoid'])->update(['is_buyer' => -1]);
|
||||
if ($order['is_arrears'] == 2) {
|
||||
AccountsReceivableLogic::add($order);
|
||||
}
|
||||
self::confirm(['id' => $params['bhoid']]);
|
||||
Db::commit();
|
||||
return true;
|
||||
|
@ -501,8 +501,10 @@ class PayNotifyLogic extends BaseLogic
|
||||
if ($order['other_uid'] > 0) {
|
||||
$uid = $order['other_uid'];
|
||||
}
|
||||
$cashFlowLogic = new CashFlowLogic();
|
||||
$cashFlowLogic->insert($order['store_id'], $order['price'], $orderSn);
|
||||
if ($type == 'wechat') {
|
||||
$cashFlowLogic = new CashFlowLogic();
|
||||
$cashFlowLogic->insert($order['store_id'], $order['price'], $orderSn);
|
||||
}
|
||||
|
||||
PushService::push('wechat_mmp_' . $uid, $uid, ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'INDUSTRYMEMBERS', 'msg' => '订单支付成功', 'data' => ['id' => $order['id'], 'paid' => 1]]);
|
||||
|
20
app/common/model/finance/AccountsReceivable.php
Normal file
20
app/common/model/finance/AccountsReceivable.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\finance;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
class AccountsReceivable extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $deleteTime = 'delete_time';
|
||||
// 不生成该表的日志
|
||||
public $doNotRecordLog = true;
|
||||
|
||||
public function info()
|
||||
{
|
||||
return $this->hasMany(AccountsReceivableInfo::class, 'accounts_receivable_id', 'id');
|
||||
}
|
||||
|
||||
}
|
14
app/common/model/finance/AccountsReceivableInfo.php
Normal file
14
app/common/model/finance/AccountsReceivableInfo.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\finance;
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
class AccountsReceivableInfo extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $deleteTime = 'delete_time';
|
||||
// 不生成该表的日志
|
||||
public $doNotRecordLog = true;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user