初始版本

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,83 @@
<?php
namespace app\coachapi\logic;
use app\common\enum\coach\CoachEnum;
use app\common\logic\BaseLogic;
use app\common\model\coach\Coach;
use app\common\model\deposit\DepositOrder;
use app\common\model\deposit\DepositPackage;
use app\common\model\order\OrderAppend;
use app\common\model\shop\Shop;
use think\Exception;
/**
* 保证金套餐逻辑类
* Class DepositLogic
* @package app\coachapi\logic
*/
class DepositLogic extends BaseLogic
{
/**
* @notes 套餐列表
* @param $coachId
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2024/8/27 18:25
*/
public function depositPackage($coachUserId)
{
$deposit = Coach::where(['coach_user_id'=>$coachUserId,'audit_status'=>CoachEnum::AUDIT_STATUS_PASS])->order('id desc')->value('deposit');
$packageLists = DepositPackage::where(['type'=>1])
->withoutField('is_show,create_time,update_time,delete_time')
->order('id desc')
->select();
return [
'deposit' => $deposit,
'package_list' => $packageLists,
];
}
/**
* @notes 提交订单
* @param array $params
* @param int $coachId
* @return array|bool
* @author cjhao
* @date 2024/8/27 18:52
*/
public function sumbitOrder(array $params,int $coachId)
{
try {
$money = $params['money'] ?? 0;
$payWay = $params['pay_way'] ?? 0;
if(empty($coachId)){
return '请先申请成为技师';
}
if($money <= 0){
throw new Exception('充值金额不能小于零');
}
if(empty($payWay)){
throw new Exception('请选择支付方式');
}
$depositOrder = DepositOrder::create([
'sn' => generate_sn((new DepositOrder()), 'sn'),
'order_amount' => $money,
'relation_id' => $coachId,
'pay_way' => $payWay,
]);
return [
'id' => $depositOrder->id,
'sn' => $depositOrder->sn,
'type' => 'deposit'
];
}catch (Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
}