初始版本
This commit is contained in:
80
server/app/shopapi/logic/DepositLogic.php
Executable file
80
server/app/shopapi/logic/DepositLogic.php
Executable file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
namespace app\shopapi\logic;
|
||||
use app\common\enum\shop\ShopEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\deposit\DepositOrder;
|
||||
use app\common\model\deposit\DepositPackage;
|
||||
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($shopUserId)
|
||||
{
|
||||
$deposit = Shop::where(['shop_user_id'=>$shopUserId,'audit_status'=>ShopEnum::AUDIT_STATUS_PASS])->value('deposit');
|
||||
$packageLists = DepositPackage::where(['type'=>2])
|
||||
->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 $shopId
|
||||
* @return array|bool
|
||||
* @author cjhao
|
||||
* @date 2024/8/27 18:52
|
||||
*/
|
||||
public function sumbitOrder(array $params,int $shopId)
|
||||
{
|
||||
try {
|
||||
$money = $params['money'] ?? 0;
|
||||
$payWay = $params['pay_way'] ?? 0;
|
||||
|
||||
if($money < 0){
|
||||
throw new Exception('充值金额不能小于零');
|
||||
}
|
||||
if(empty($payWay)){
|
||||
throw new Exception('请选择支付方式');
|
||||
}
|
||||
$depositOrder = DepositOrder::create([
|
||||
'sn' => generate_sn((new DepositOrder()), 'sn'),
|
||||
'type' => 2,
|
||||
'order_amount' => $money,
|
||||
'relation_id' => $shopId,
|
||||
'pay_way' => $payWay,
|
||||
]);
|
||||
return [
|
||||
'id' => $depositOrder->id,
|
||||
'sn' => $depositOrder->sn,
|
||||
'type' => 'deposit'
|
||||
];
|
||||
|
||||
}catch (Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user