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.
197 lines
5.2 KiB
197 lines
5.2 KiB
<?php
|
|
|
|
namespace app\admin\controller\qingdong\product;
|
|
|
|
use addons\qingdong\model\Delivery;
|
|
use addons\qingdong\model\DeliveryProduct;
|
|
use addons\qingdong\model\Goods;
|
|
use addons\qingdong\model\InstockProduct;
|
|
use addons\qingdong\model\Order;
|
|
use addons\qingdong\model\ProductPart;
|
|
use addons\qingdong\model\Producttype;
|
|
use addons\qingdong\model\ProductWarehouse;
|
|
use addons\qingdong\model\Staff;
|
|
use app\admin\controller\qingdong\Base;
|
|
use app\admin\model\AuthGroup;
|
|
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
|
use PhpOffice\PhpSpreadsheet\Reader\Csv;
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xls;
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
|
|
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
|
use think\Db;
|
|
use think\Exception;
|
|
/**
|
|
* 产品列表
|
|
* 操作文档:https://doc.fastadmin.net/qingdong
|
|
* 软件介绍:https://www.fastadmin.net/store/qingdong.html
|
|
* 售后微信:qingdong_crm
|
|
*/
|
|
|
|
class Member extends Base
|
|
{
|
|
protected $relationSearch = true;
|
|
protected $searchFields = 'id,name';
|
|
/**
|
|
* @var \addons\qingdong\model\Product
|
|
*/
|
|
protected $model = null;
|
|
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->model = new \addons\qingdong\model\MemberProduct();
|
|
}
|
|
|
|
|
|
/**
|
|
* 产品列表
|
|
*/
|
|
public function index()
|
|
{
|
|
//设置过滤方法
|
|
$this->request->filter(['strip_tags', 'trim']);
|
|
|
|
//获取所有权限
|
|
$list2 = Db::name('auth_group')->where('status','=','normal')->select();
|
|
$roles = array_column($list2,'name','id');
|
|
//获取当前用户所在企业的权限组
|
|
$company = Db::name('company')->where("id",CID)->find();
|
|
$group_id = $company['group_id'];
|
|
|
|
if ($this->request->isAjax()) {
|
|
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams(null,null,0);
|
|
|
|
$sort="group_level";
|
|
$order="asc";
|
|
|
|
//负责人为空
|
|
$list = $this->model->where($where)->order($sort, $order)->paginate($limit);
|
|
$row=$list->items();
|
|
$group_level = 0;
|
|
foreach ($row as $k => $v) {
|
|
if($v['group_id'] == $group_id){
|
|
$group_level = $v['group_level'];
|
|
break;
|
|
}
|
|
|
|
$row[$k] = $v;
|
|
}
|
|
|
|
|
|
foreach ($row as $k => $v) {
|
|
$v['group_name'] = $roles[$v['group_id']]??'';
|
|
|
|
$v['buy'] = 0;
|
|
$v['buy_name'] = '可升级';
|
|
if($group_level>$v['group_level']){
|
|
$v['buy'] = 1;
|
|
$v['buy_name'] = '无需升级';
|
|
}else if($v['group_id'] == $group_id){
|
|
$v['buy'] = 1;
|
|
$v['buy_name'] = '已拥有';
|
|
}
|
|
|
|
$row[$k] = $v;
|
|
}
|
|
$result = array("total" => $list->total(), "rows" => $list->items());
|
|
|
|
return json($result);
|
|
}
|
|
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* 产品详情
|
|
*/
|
|
public function detail($ids = null)
|
|
{
|
|
$row = $this->model->get($ids);
|
|
$this->assign('row', $row);
|
|
$this->assign('ids', $ids);
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取产品分类
|
|
*/
|
|
public function get_group(){
|
|
|
|
$countrys = AuthGroup::where('status','=','normal')->field('id,name')->order('id desc')->select();
|
|
return json(['list' => $countrys, 'total' => count($countrys)]);
|
|
}
|
|
|
|
|
|
/**
|
|
* 下单
|
|
*/
|
|
public function buy($ids = null)
|
|
{
|
|
$row = $this->model->get($ids);
|
|
$orderModel = new Order();
|
|
$data = [
|
|
'type' => 0,
|
|
'order_no' => date('YmdHis')+rand(1000,9999),
|
|
'user_id' => $this->_staff?$this->_staff->id:'0',
|
|
'price' => $row['price'],
|
|
'title' => $row['name'],
|
|
'org_id' => $row['id'],
|
|
'order_source' => 5,
|
|
'order_status' => 0,
|
|
'pay_status' => 0,
|
|
'pay_way' => 1,
|
|
'num' => 1,
|
|
'order_amount' =>$row['price'],
|
|
'total_amount' =>$row['price'],
|
|
'discount_amount' =>0,
|
|
'status' =>0,
|
|
'cid' => CID
|
|
];
|
|
$orderModel->save($data);
|
|
|
|
$this->assign('row', $row);
|
|
$this->assign('data', $data);
|
|
$this->assign('ids', $ids);
|
|
//下单
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
/**
|
|
* 支付
|
|
*/
|
|
public function pay($ids = null)
|
|
{
|
|
$row = $this->model->get($ids);
|
|
$this->assign('row', $row);
|
|
$this->assign('ids', $ids);
|
|
//下单
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function get_order_status($orders = null)
|
|
{
|
|
$orderModel = new Order();
|
|
$order = $orderModel->where("order_no","=",$orders)->find();
|
|
if(!$order){
|
|
$result = ['code' => 1,'msg'=>'参数错误','status'=>500];
|
|
return json($result);
|
|
}
|
|
|
|
if($order['pay_status'] == 1){
|
|
$result = ['code' => 1,'msg'=>'支付成功','status'=>100];
|
|
return json($result);
|
|
}else{
|
|
$result = ['code' => 1,'msg'=>'等待支付','status'=>200];
|
|
return json($result);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|