初始化代码
This commit is contained in:
128
app/farm/model/BreedOrderGoods.php
Normal file
128
app/farm/model/BreedOrderGoods.php
Normal file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
namespace app\farm\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class BreedOrderGoods extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_breed_order_goods';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:06
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function dataList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('status desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-03-19 16:08
|
||||
* @功能说明:开启默认
|
||||
*/
|
||||
public function updateOne($id){
|
||||
|
||||
$user_id = $this->where(['id'=>$id])->value('user_id');
|
||||
|
||||
$res = $this->where(['user_id'=>$user_id])->where('id','<>',$id)->update(['status'=>0]);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-12-29 17:19
|
||||
* @功能说明:
|
||||
*/
|
||||
public function orderAdd($goods,$order_id){
|
||||
|
||||
foreach ($goods as $v){
|
||||
|
||||
$insert = [
|
||||
|
||||
'uniacid' => $v['uniacid'],
|
||||
|
||||
'order_id' => $order_id,
|
||||
|
||||
'goods_id' => $v['goods_id'],
|
||||
|
||||
'goods_name' => $v['title'],
|
||||
|
||||
'goods_cover' => $v['cover'],
|
||||
|
||||
'goods_num' => $v['goods_num'],
|
||||
|
||||
'true_num' => $v['goods_num'],
|
||||
|
||||
'goods_price' => $v['price'],
|
||||
|
||||
];
|
||||
|
||||
$res = $this->dataAdd($insert);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user