OrderModel.php
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
namespace api\common\model;
use EasyWeChat\Payment\Order;
use think\Model;
class OrderModel extends Model
{
protected $name = 'orders';
public function setOrder($user_id,$good_id,$num,$address_id,$remark=''){
$GoodModel= new GoodsModel();
$good=$GoodModel->where('id',$good_id)->find();
$Address=new AddressModel();
$address=$Address->where('id',$address_id)->find();
$insert['order_sn']=cmf_get_order_sn();
$insert['good_id']=$good_id;
$insert['create_time']=time();
$insert['user_id']=$user_id;
$insert['num']=$num;
$insert['is_real']=$good['real_good'];
$insert['address_info']=$address['address'];
$insert['name']=$address['name'];
$insert['mobile']=$address['tel'];
$insert['remark']=$remark;
$insert['expend']=$good['work_time']*$num;
$insert['address']=$address['province'].$address['city'].$address['district'];
$this->insert($insert);
return $insert['order_sn'];
}
/**
* @param $order_id
* @return array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function orderInfo($order_id){
$map['o.id']=$order_id;
$order_info=$this->alias('o')
->field('o.*')
->join('goods g','o.good_id=g.id')
->where($map)
->find();
$goodModel=new GoodsModel();
$order_info['remark']=cmf_replace_content_file_url(htmlspecialchars_decode($order_info['remark']));
$order_info['content_info']=cmf_replace_content_file_url(htmlspecialchars_decode($order_info['content_info']));
$order_info['reason']=cmf_replace_content_file_url(htmlspecialchars_decode($order_info['reason']));
$order_info['good']=$goodModel->getGoods($order_info['good_id']);
return $order_info;
}
}