新版数智员工
This commit is contained in:
@@ -5,12 +5,12 @@ namespace app\store\model;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 订单模型
|
||||
* 供应商订单模型
|
||||
*/
|
||||
class VendorOrderModel extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $table = 'ck_vendor_order';
|
||||
protected $name = 'vendor_order';
|
||||
|
||||
// 主键
|
||||
protected $pk = 'id';
|
||||
@@ -26,6 +26,21 @@ class VendorOrderModel extends Model
|
||||
const STATUS_COMPLETED = 2; // 已完成
|
||||
const STATUS_CANCELED = 3; // 已取消
|
||||
|
||||
// 类型转换
|
||||
protected $type = [
|
||||
'id' => 'integer',
|
||||
'userId' => 'integer',
|
||||
'companyId' => 'integer',
|
||||
'packageId' => 'integer',
|
||||
'totalAmount' => 'float',
|
||||
'payAmount' => 'float',
|
||||
'advancePayment' => 'float',
|
||||
'status' => 'integer',
|
||||
'createTime' => 'timestamp',
|
||||
'updateTime' => 'timestamp',
|
||||
'payTime' => 'timestamp',
|
||||
];
|
||||
|
||||
/**
|
||||
* 与套餐的关联
|
||||
*/
|
||||
@@ -40,6 +55,54 @@ class VendorOrderModel extends Model
|
||||
*/
|
||||
public static function generateOrderNo()
|
||||
{
|
||||
return date('YmdHis') . rand(1000, 9999);
|
||||
$prefix = 'GY';
|
||||
$date = date('YmdHis');
|
||||
$random = mt_rand(10000, 99999);
|
||||
|
||||
return $prefix . $date . $random;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建订单
|
||||
*
|
||||
* @param int $userId 用户ID
|
||||
* @param int $companyId 公司ID
|
||||
* @param int $packageId 套餐ID
|
||||
* @param string $packageName 套餐名称
|
||||
* @param float $totalAmount 订单总额
|
||||
* @param float $payAmount 支付金额
|
||||
* @param float $advancePayment 预付款
|
||||
* @param string $remark 备注
|
||||
* @return array|false
|
||||
*/
|
||||
public static function createOrder($userId, $companyId, $packageId, $packageName, $totalAmount, $payAmount, $advancePayment = 0, $remark = '')
|
||||
{
|
||||
$orderNo = self::generateOrderNo();
|
||||
|
||||
$data = [
|
||||
'userId' => intval($userId),
|
||||
'companyId' => intval($companyId),
|
||||
'packageId' => intval($packageId),
|
||||
'packageName' => $packageName,
|
||||
'orderNo' => $orderNo,
|
||||
'totalAmount' => floatval($totalAmount),
|
||||
'payAmount' => floatval($payAmount),
|
||||
'advancePayment' => floatval($advancePayment),
|
||||
'status' => self::STATUS_UNPAID,
|
||||
'remark' => $remark,
|
||||
'createTime' => time(),
|
||||
'updateTime' => time(),
|
||||
];
|
||||
|
||||
$model = new self();
|
||||
$result = $model->save($data);
|
||||
|
||||
if ($result) {
|
||||
return $model->toArray();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user