|
@@ -0,0 +1,96 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\api\controller\company;
|
|
|
+
|
|
|
+use app\common\controller\Apic;
|
|
|
+use think\Db;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 客户
|
|
|
+ */
|
|
|
+class Customer extends Apic
|
|
|
+{
|
|
|
+ protected $noNeedLogin = [];
|
|
|
+ protected $noNeedRight = '*';
|
|
|
+
|
|
|
+ //头部统计
|
|
|
+ public function index(){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //列表
|
|
|
+ public function lists(){
|
|
|
+ $list = Db::name('user_wallet')->alias('w')
|
|
|
+ ->field('w.*,user.nickname,user.mobile,user.avatar')
|
|
|
+ ->join('user','w.user_id = user.id','LEFT')
|
|
|
+ ->where('w.company_id',$this->auth->company_id)
|
|
|
+ ->order('id desc')->autopage()->select();
|
|
|
+ $list = list_domain_image($list,['avatar']);
|
|
|
+
|
|
|
+ if(!empty($list)){
|
|
|
+ $user_ids = array_column($list,'user_id');
|
|
|
+ $user_car = Db::name('user_car')->where('user_id','IN',$user_ids)->select();
|
|
|
+ foreach($list as $key => &$val){
|
|
|
+ $val['car_number'] = '';
|
|
|
+ $car_number = [];
|
|
|
+ foreach($user_car as $k => $v){
|
|
|
+ if($val['user_id'] == $v['user_id']){
|
|
|
+ $car_number[] = $v['car_number'];
|
|
|
+ }
|
|
|
+ $val['car_number'] = implode(',',$car_number);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增
|
|
|
+ public function add(){
|
|
|
+ $field = ['price','giftprice'];
|
|
|
+ $data = request_post_hub($field);
|
|
|
+
|
|
|
+ $data['company_id'] = $this->auth->company_id;
|
|
|
+ $data['status'] = 1;
|
|
|
+
|
|
|
+ Db::startTrans();
|
|
|
+ $config_id = Db::name('recharge_config')->insertGetId($data);
|
|
|
+ if(!$config_id){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('添加失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ //赠送卡券
|
|
|
+ $gift_data = input('gift_data','','trim');
|
|
|
+ $gift_data = json_decode(htmlspecialchars_decode($gift_data),true);
|
|
|
+
|
|
|
+ if(is_array($gift_data) && !empty($gift_data)){
|
|
|
+ $recharge_gift = [];
|
|
|
+ foreach($gift_data as $key => $val){
|
|
|
+ $recharge_gift[] = [
|
|
|
+ 'config_id' => $config_id,
|
|
|
+ 'coupon_id' => $val['coupon_id'],
|
|
|
+ 'number' => $val['number'],
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ if(!empty($recharge_gift)){
|
|
|
+ $rs_gift = Db::name('recharge_gift')->insertAll($recharge_gift);
|
|
|
+ if($rs_gift === false){
|
|
|
+ Db::rollback();
|
|
|
+ $this->error('添加失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+
|
|
|
+ $this->success('添加成功');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|