You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.0 KiB
68 lines
2.0 KiB
<?php
|
|
|
|
namespace app\model;
|
|
|
|
use think\Model;
|
|
|
|
class ConsumptionRecords extends Model
|
|
{
|
|
/**
|
|
* 创建消费记录
|
|
* @param $user_id // 用户id
|
|
* @param $z_g_id // 专区商品id
|
|
* @param $price // 原价
|
|
* @param $actual_price // 实际支付金额
|
|
* @param $residue_amount // 剩余余额
|
|
* @param $data // 剩余余额
|
|
*/
|
|
public static function createRecords($user_id,$z_g_id,$price,$actual_price,$residue_amount,$data)
|
|
{
|
|
$records = new ConsumptionRecords();
|
|
|
|
$records->user_id = $user_id;
|
|
$records->zone_goods_id = $z_g_id;
|
|
$records->price = $price;
|
|
$records->text_data = serialize($data);
|
|
$records->actual_price = $actual_price;
|
|
$records->residue_amount = $residue_amount;
|
|
$records->create_time = date("Y-m-d H:i:s",time());
|
|
$records->save();
|
|
return $records->id;
|
|
}
|
|
|
|
/**
|
|
* 完成订单
|
|
* @param $c_r_id
|
|
* @param $awards_amount // 中奖金额
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public static function endOrder($c_r_id,$awards_amount)
|
|
{
|
|
|
|
$zoneOrder = ConsumptionRecords::find($c_r_id);
|
|
$zoneOrder->status = 1;
|
|
$zoneOrder->complete_time = date("Y-m-d H:i:s",time());
|
|
if ($awards_amount > 0) {
|
|
$zoneOrder->awards_status = 1;
|
|
}
|
|
$zoneOrder->save();
|
|
}
|
|
|
|
/**
|
|
* 保存是否中奖字段
|
|
* @param $data
|
|
* @param $id
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public static function awardsData($data,$id)
|
|
{
|
|
$ConsumptionRecords = ConsumptionRecords::find($id);
|
|
$ConsumptionRecords->text_data = serialize($data);
|
|
$ConsumptionRecords->save();
|
|
}
|
|
|
|
}
|