初始版本

This commit is contained in:
贾祥聪
2025-08-19 14:16:51 +08:00
commit f937a1f9b9
4373 changed files with 359728 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\adminapi\logic\finance;
use app\common\enum\accountLog\CoachAccountLogEnum;
use app\common\enum\accountLog\ShopAccountLogEnum;
use app\common\enum\OrderEnum;
use app\common\enum\OrderRefundEnum;
use app\common\enum\PayEnum;
use app\common\logic\BaseLogic;
use app\common\model\accountLog\CoachAccountLog;
use app\common\model\accountLog\ShopAccountLog;
use app\common\model\coach\Coach;
use app\common\model\order\Order;
use app\common\model\order\OrderRefund;
use app\common\model\RechargeOrder;
use app\common\model\settle\Settle;
use app\common\model\shop\Shop;
use app\common\model\user\User;
class CenterLogic extends BaseLogic
{
/**
* @notes 财务中心
* @return array
* @author ljj
* @date 2022/9/9 6:28 下午
*/
public function center()
{
$managementForms = [
//累计营业额
'total_amount' => Order::where(['pay_status'=>PayEnum::ISPAID])->sum('total_order_amount'),
//累计成交订单
'total_order' => Order::where(['pay_status'=>PayEnum::ISPAID])->count(),
//已退款金额
'total_refund_amount' => OrderRefund::where(['refund_status'=>OrderRefundEnum::STATUS_SUCCESS])->sum('refund_amount'),
//退款失败金额
'fail_refund_amount' => OrderRefund::where(['refund_status'=>OrderRefundEnum::STATUS_FAIL])->sum('refund_amount'),
];
$userRecharge = [
'total_user_recharge_money' => RechargeOrder::where(['pay_status'=>PayEnum::ISPAID])->sum('order_amount'),
'total_user_money' => User::sum('user_money'),
];
$coachInfo = [
'total_coach_commission' => Settle::sum('total_coach_commission'),
'total_withdraw_commission' => CoachAccountLog::where(['change_type'=>CoachAccountLogEnum::WITHDRAW_DEC_MONEY])->sum('change_amount'),
'total_may_withdraw_commission' => Coach::sum('money'),
'total_wait_settle_commission' => Order::where(['order_status'=>OrderEnum::ORDER_STATUS_SERVER_FINISH])->sum('total_order_amount'),
];
$coachIds = Coach::where('shop_id','>',0)->field('id')->select()->toArray();
$coachIds = array_column($coachIds,'id');
$shopInfo = [
'total_shop_commission' => Settle::sum('total_shop_commission'),
'total_withdraw_commission' => ShopAccountLog::where(['change_type'=>ShopAccountLogEnum::WITHDRAW_DEC_MONEY])->sum('change_amount'),
'total_may_withdraw_commission' => Shop::sum('money'),
'total_wait_settle_commission' => Order::where(['coach_id'=>$coachIds,'order_status'=>OrderEnum::ORDER_STATUS_SERVER_FINISH])->sum('total_order_amount'),
];
$depositInfo = [
'total_coach_deposit' => Coach::sum('deposit'),
'total_shop_deposit' => Shop::sum('deposit'),
];
return [
'management_forms' => $managementForms,
'user_recharge' => $userRecharge,
'coach_info' => $coachInfo,
'shop_info' => $shopInfo,
'deposit_info' => $depositInfo,
];
}
}

View File

@@ -0,0 +1,256 @@
<?php
namespace app\adminapi\logic\finance;
use app\common\enum\accountLog\CoachAccountLogEnum;
use app\common\enum\accountLog\ShopAccountLogEnum;
use app\common\logic\CoachAccountLogLogic;
use app\common\logic\ShopAccountLogLogic;
use app\common\model\coach\Coach;
use app\common\model\shop\Shop;
use app\common\model\withdraw\WithdrawApply;
use Exception;
use think\facade\Db;
class WithdrawLogic
{
/**
* @notes 详情
* @param $id
* @return WithdrawApply|array|\think\Model
* @author cjhao
* @date 2024/10/31 16:22
*/
public function detail($id)
{
$detail = WithdrawApply::where(['id'=>$id])->append(['apply_type_desc'])->findOrEmpty();
if(1 == $detail['source']){
$detail['relation_info'] = Coach::where(['id'=>$detail['relation_id']])->field('id,name,sn,work_photo as image,mobile')->findOrEmpty()->toArray();
}else {
$detail['relation_info'] = Shop::where(['id' => $detail['relation_id']])->field('id,name,sn,logo as image,mobile')->findOrEmpty()->toArray();
}
return $detail->toArray();
}
/**
* @notes 审核
* @param $params
* @return string|true
* @author cjhao
* @date 2024/10/31 17:44
*/
public function audit($params)
{
try {
Db::startTrans();
$id = $params['id'] ?? '';
$status = $params['status'] ?? '';
$remark = $params['remark'] ?? '';
if(empty($id)){
throw new Exception('请选择提现记录');
}
if('' == $status){
throw new Exception('请选择审核操作');
}
if(empty($remark) && 0 == $status){
throw new Exception('请输入备注');
}
$apply = WithdrawApply::where(['id'=>$id])->findOrEmpty();
if(1 != $apply->status){
throw new Exception('记录状态已改变');
}
$auditStatus = 2;
if(0 == $status){
$auditStatus = 3;
}
$apply->status = $auditStatus;
$apply->verify_remark = $remark;
$apply->save();
//拒绝,退回余额
if(0 == $status){
//申请类型
if(1 == $apply['apply_type']){
//类型
if( 1 == $apply['source']){
$relation = Coach::where(['id'=>$apply['relation_id']])->findOrEmpty();
//余额
$relation->money = round($relation->money+$apply['money']);
$relation->save();
CoachAccountLogLogic::add(
$relation->id,
CoachAccountLogEnum::MONEY,
CoachAccountLogEnum::WITHDRAW_INC_MONEY,
1,
$apply['money'],
$apply['sn']
);
}else{
$relation = shop::where(['id'=> $apply['relation_id']])->findOrEmpty();
//余额
$relation->money = round($relation->money+$apply['money']);
$relation->save();
ShopAccountLogLogic::add(
$relation->id,
ShopAccountLogEnum::MONEY,
ShopAccountLogEnum::WITHDRAW_INC_MONEY,
1,
$apply['money'],
$apply['sn']
);
}
}else{
if( 1 == $apply['source']){
$relation = coach::where(['id'=> $apply['relation_id']])->findOrEmpty();
//余额
$relation->deposit = round($relation->deposit+$apply['money']);
$relation->save();
CoachAccountLogLogic::add(
$relation->id,
CoachAccountLogEnum::DEPOSIT,
CoachAccountLogEnum::WITHDRAW_INC_DEPOSIT,
1,
$apply['money'],
$apply['sn']
);
}else{
$relation = shop::where(['id'=> $apply['relation_id']])->findOrEmpty();
//余额
$relation->deposit = round($relation->deposit+$apply['money']);
$relation->save();
ShopAccountLogLogic::add(
$relation->id,
ShopAccountLogEnum::DEPOSIT,
ShopAccountLogEnum::WITHDRAW_INC_DEPOSIT,
1,
$apply['money'],
$apply['sn']
);
}
}
}
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 转账
* @param $params
* @return string|true
* @author cjhao
* @date 2024/10/31 18:13
*/
public function transfer($params)
{
try {
Db::startTrans();
$id = $params['id'] ?? '';
$status = $params['status'] ?? '';
$remark = $params['remark'] ?? '';
$transferProof = $params['transfer_proof'] ?? '';
if(empty($id)){
throw new Exception('请选择提现记录');
}
if('' == $status){
throw new Exception('请选择审核操作');
}
if(empty($remark) && 0 == $status){
throw new Exception('请输入备注');
}
$auditStatus = 5;
if(1 == $status){
if(empty($transferProof)){
throw new Exception('请上传转账凭证');
}
}else{
$auditStatus = 6;
}
$apply = WithdrawApply::where(['id'=>$id])->findOrEmpty();
$apply->status = $auditStatus;
$apply->verify_remark = $remark;
$apply->transfer_proof = $transferProof;
$apply->save();
//拒绝,退回余额
if(0 == $status){
//申请类型
if(1 == $apply['apply_type']){
//类型
if( 1 == $apply['source']){
$relation = Coach::where(['id'=>$apply['relation_id']])->findOrEmpty();
//余额
$relation->money = round($relation->money+$apply['money']);
$relation->save();
CoachAccountLogLogic::add(
$relation->id,
CoachAccountLogEnum::MONEY,
CoachAccountLogEnum::WITHDRAW_INC_MONEY,
1,
$apply['money'],
);
}else{
$relation = shop::where(['id'=> $apply['relation_id']])->findOrEmpty();
//余额
$relation->money = round($relation->money+$apply['money']);
$relation->save();
ShopAccountLogLogic::add(
$relation->id,
ShopAccountLogEnum::MONEY,
ShopAccountLogEnum::WITHDRAW_INC_MONEY,
1,
$apply['money'],
);
}
}else{
if( 1 == $apply['source']){
$relation = coach::where(['id'=>$apply['relation_id']])->findOrEmpty();
//余额
$relation->deposit = round($relation->deposit+$apply['money']);
$relation->save();
CoachAccountLogLogic::add(
$relation->id,
CoachAccountLogEnum::DEPOSIT,
CoachAccountLogEnum::WITHDRAW_INC_DEPOSIT,
1,
$apply['money'],
);
}else{
$relation = shop::where(['id'=> $apply['relation_id']])->findOrEmpty();
//余额
$relation->deposit = round($relation->deposit+$apply['money']);
$relation->save();
ShopAccountLogLogic::add(
$relation->id,
ShopAccountLogEnum::DEPOSIT,
ShopAccountLogEnum::WITHDRAW_INC_DEPOSIT,
1,
$apply['money'],
);
}
}
}
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
return $e->getMessage();
}
}
}