zxhxx 3 lat temu
rodzic
commit
5f6c5e78a1

+ 3 - 0
app/admin/controller/user/User.php

@@ -332,6 +332,7 @@ class User extends AuthController
         $f[] = Form::input('card_id', '身份证号', $user->getData('card_id'));
         $f[] = Form::textarea('mark', '用户备注', $user->getData('mark'));
         $f[] = Form::radio('is_promoter', '推广员', $user->getData('is_promoter'))->options([['value' => 1, 'label' => '开启'], ['value' => 0, 'label' => '关闭']]);
+        $f[] = Form::radio('is_sys', '是否平台用户', $user->getData('is_sys'))->options([['value' => 1, 'label' => '开启'], ['value' => 0, 'label' => '关闭']]);
         $f[] = Form::radio('status', '状态', $user->getData('status'))->options([['value' => 1, 'label' => '开启'], ['value' => 0, 'label' => '锁定']]);
         $form = Form::make_post_form('添加用户通知', $f, Url::buildUrl('update', array('uid' => $uid)), 5);
         $this->assign(compact('form'));
@@ -352,6 +353,7 @@ class User extends AuthController
             ['integration_status', 0],
             ['integration', 0],
             ['status', 0],
+            ['is_sys',0],
         ]);
         if (!$uid) return $this->failed('数据不存在');
         $user = UserModel::get($uid);
@@ -413,6 +415,7 @@ class User extends AuthController
         $edit['birthday'] = strtotime($data['birthday']);
         $edit['mark'] = $data['mark'];
         $edit['is_promoter'] = $data['is_promoter'];
+        $edit['is_sys'] = $data['is_sys'];
         if ($edit) $res3 = UserModel::edit($edit, $uid);
         else $res3 = true;
         if ($res1 && $res2 && $res3) $res = true;

+ 95 - 14
app/api/controller/activity/WholeController.php

@@ -76,7 +76,7 @@ class WholeController
             ['limit', 0],
         ], $request, true);
         if (!$time) return app('json')->fail('参数错误');
-        $seckillInfo = StoreWholesale::WholeList($time, $page, $limit);
+        $seckillInfo = Package::lst(['time_id'=>$time,'page'=>$page,'limit'=>$limit]);
         if (count($seckillInfo)) {
             foreach ($seckillInfo as $key => &$item) {
 
@@ -91,15 +91,14 @@ class WholeController
      * @param $id
      * @return mixed
      */
-    public function detail(Request $request, $id, $time = 0, $status = 1)
+    public function detail(Request $request, $id, $time = 0, $status = 1,$is_news=0)
     {
-        $storeInfo = StoreWholesale::getValidProduct($id);
+        $storeInfo = StoreWholesale::getValidProduct($id,'',$is_news);
         if ($storeInfo)
             $storeInfo = $storeInfo->hidden(['cost', 'add_time', 'is_del'])->toArray();
         else
             $storeInfo = [];
         if (!$id || !$storeInfo) return app('json')->fail('商品不存在或已下架!');
-
         $siteUrl = sys_config('site_url');
         $storeInfo['image'] = set_file_url($storeInfo['image'], $siteUrl);
         $storeInfo['image_base'] = set_file_url($storeInfo['image'], $siteUrl);
@@ -117,20 +116,22 @@ class WholeController
      */
     public function reserve(Request $request)
     {
-        list($package_manager,$price,$day,$proportion,$pass) = UtilService::postMore(
+        list($whole_id,$time_id,$price,$to_uid,$first_price,$last_id) = UtilService::postMore(
             [
-                ['package_manager',0],
+                ['whole_id',0],
+                ['time_id',0],
                 ['price',0],
-                ['day',0],
-                ['proportion',0],
-                ['pass',0]
+                ['to_uid',0],
+                ['first_price',0],
+                ['last_id',0],
             ],$request,true
         );
-        if($package_manager==0) return app('json')->fail('包编号错误');
-        if($price==0) return app('json')->fail('价值不能为空');
-        if($day==0) return app('json')->fail('收益天数错误');
-        if($proportion==0) return app('json')->fail('收益比例不能为空');
-        $rs = Package::reserve($request->uid(),$package_manager,$price,$day,$proportion,$pass);
+        if($whole_id==0) return app('json')->fail('商品不能为空');
+        if($time_id==0) return app('json')->fail('时间段不能为空');
+        if($price==0) return app('json')->fail('价格不能为0');
+        if($to_uid==0) $first_price = $price;
+        if($last_id>0 && !self::be(['id'=>$last_id,'uid'=>$to_uid])) return app('json')->fail('非法数据');
+        $rs = Package::reserve($request->uid(),$whole_id,$time_id,$to_uid,$price,$first_price,$last_id);
         if($rs)
         {
             return app('json')->successful($rs);
@@ -140,7 +141,87 @@ class WholeController
             return app('json')->fail(Package::getErrorInfo());
         }
     }
+    /**
+     * 我的记录
+     * @param Request $request
+     * @return mixed
+     */
+    public function mylist(Request $request)
+    {
+        $where = UtilService::postMore(
+            [
+                ['page',1],
+                ['limit',0],
+                ['data',''],
+                ['status',-4],
+            ],$request
+        );
+        $where['uid'] = $request->uid();
+        return app('json')->successful(Package::lst($where));
+    }
+
+    /**
+     * 上传评证
+     * @param Request $request
+     */
+    public function evaluation(Request $request)
+    {
+        $where = UtilService::postMore(
+            [
+                ['pay_evaluation',''],
+            ],$request
+        );
+        if($where['pay_evaluation']=='') return app('json')->fail('上传图片评证');
+        if(!Package::be(['uid'=>$request->uid(),'id'=>input('id'),'status'=>1]))return app('json')->fail('参数错误或已上传!');
+        $where['submit_time'] = time();
+        $where['status'] = 2;
+        return app('json')->successful(Package::edit($where,input('id')));
+    }
 
+    /**
+     * 我的订单
+     * @param Request $request
+     * @return mixed
+     */
+    public function order(Request $request)
+    {
+        $where = UtilService::postMore(
+            [
+                ['page',1],
+                ['limit',0],
+                ['status',-4],
+            ],$request
+        );
+        $where['to_uid'] = $request->uid();
+        return app('json')->successful(Package::lst($where));
+    }
+
+    /**
+     * 订单审核
+     * @param Request $request
+     */
+    public function audit(Request $request)
+    {
+        $where = UtilService::postMore(
+            [
+                ['re',''],
+                ['status',3],
+            ],$request
+        );
+        $id = input('id');
+        if(!Package::be(['to_uid'=>$request->uid(),'status'=>2,'id'=>$id])) return app('json')->fail('参数有误或已审核');
+        if($where['status']==3)
+        {
+            $rs = Package::take($id);
+        }
+        else
+        {
+            $rs = Package::invalid($id,$where['re']);
+        }
+        if($rs) return app('json')->successful('审核通过');
+        else return app('json')->fail(Package::getErrorInfo());
+
+    }
     /**
      * 新人批发
      * @param Request $request

+ 3 - 2
app/api/controller/store/StoreCartController.php

@@ -34,7 +34,7 @@ class StoreCartController
      */
     public function add(Request $request)
     {
-        list($productId, $cartNum, $uniqueId, $combinationId, $secKillId, $bargainId, $new) = UtilService::postMore([
+        list($productId, $cartNum, $uniqueId, $combinationId, $secKillId, $bargainId, $new,$is_gold) = UtilService::postMore([
             ['productId',0],//普通产品编号
             ['cartNum',1], //购物车数量
             ['uniqueId',''],//属性唯一值
@@ -42,10 +42,11 @@ class StoreCartController
             ['secKillId',0],//秒杀产品编号
             ['bargainId',0],//砍价产品编号
             ['new',1], // 1 加入购物车直接购买  0 加入购物车
+            ['is_gold',0],
         ], $request, true);
         if (!$productId || !is_numeric($productId)) return app('json')->fail('参数错误');
         if ($bargainId && StoreBargainUserHelp::getSurplusPrice($bargainId, $request->uid())) return app('json')->fail('请先砍价');
-        $res = StoreCart::setCart($request->uid(), $productId, $cartNum, $uniqueId, 'product', $new, $combinationId, $secKillId, $bargainId);
+        $res = StoreCart::setCart($request->uid(), $productId, $cartNum, $uniqueId, 'product', $new, $combinationId, $secKillId, $bargainId,$is_gold);
         if (!$res) return app('json')->fail(StoreCart::getErrorInfo());
         else  return app('json')->successful('ok', ['cartId' => $res->id]);
     }

+ 1 - 1
app/api/controller/store/StoreProductController.php

@@ -43,7 +43,7 @@ class StoreProductController
             [['page', 'd'], 0],
             [['limit', 'd'], 0],
             [['type', 0], 0],
-            ['is_gold',0],
+            ['is_gold',-1],
         ], $request);
         return app('json')->successful(StoreProduct::getProductList($data, $request->uid()));
     }

+ 28 - 87
app/models/store/Package.php

@@ -26,102 +26,45 @@ class Package extends BaseModel
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public static function reserve($uid,$package_manager,$price,$day,$proportion,$pass)
+    public static function reserve($uid,$whole_id,$time_id,$to_uid,$price,$first_price,$last_id)
     {
+        $user = User::find($uid);
         $data['uid'] = $uid;
-        $data['package_manager'] = $package_manager;
-        //if(!self::is_valid()) return self::setErrorInfo('非活动时间,不能预约');
-        $start = strtotime(date("Y-m-d"));
-        if(self::where('package_manager',$package_manager)->where('uid',$uid)->where('add_time','>=',$start)->find())
+        $data['whole_id'] = $whole_id;
+        $data['time_id'] = $time_id;
+        $data['first_price'] = $first_price;
+        $data['last_id'] = $last_id;
+        $data['price'] = $price;
+        if($last_id>0 && self::where('last_id',$last_id)->where('uid',$uid)->find())
         {
             return self::setErrorInfo('你已报名,无需重复报名');
         }
+        $integral = bcmul($price,bcdiv(sys_config('reserve_integral'),100,2),2);
+        if($integral>$user['integral']) return self::setErrorInfo('金豆不足,请先买金豆专区');
+        if($last_id>0 && self::where('id',$last_id)->value('status')!=3) return self::setErrorInfo('已有用户预约,换个商品预约');
         $data['add_time'] = time();
         $data['order_id'] = self::getNewOrderId();
-        $data['proportion'] = $proportion;
-        $data['price'] = $price;
-        $data['day'] = $day;
-        $data['am'] = date("H")>12?0:1;
-        $data['pass'] = $pass;
-        return self::create($data);
-    }
-
-    /**
-     * 是否活动时间
-     */
-    public static function is_valid()
-    {
-        $am= explode("~",sys_config('start_time'));
-        $pm = explode("~",sys_config('end_time'));
-        if((date("H:i")>$am[0] && date("H:i")<$am[1]))
+        if($to_uid==0)
         {
-            return 1;
+            $to_uid = User::where('is_sys', 1)->order('sys_pay asc,uid asc')->value('uid');
         }
-        elseif((date("H:i")>$pm[0] && date("H:i")<$pm[1]))
-        {
-            return 2;
-        }
-        return 0;
-    }
+        $data['to_uid'] = $to_uid;
+        self::beginTrans();
+        try{
+            $data['use_integral'] = $integral;
+            $res = self::create($data);
+            User::where('uid',$uid)->dec('integral',$integral)->update();
+            UserBill::expend("预约扣金豆",$uid,'integral','pay_money',$integral,$res['id'],bcsub($user['integral'],$integral,2),'预约扣除'.$integral."金豆");
+            User::edit(['is_whole'=>1],$uid);
+            self::commitTrans();
+            return $res->toArray();
 
-    /**
-     * 兑换
-     * @param $uid
-     * @param $package_manager
-     * @param $price
-     * @param $day
-     * @param $proportion
-     * @param $consume_pass
-     * @param int $type
-     * @param int $am
-     */
-    public static function create_order($uid,$tu_uid=0,$id,$price)
-    {
-        $user = User::find($uid);
-        $H = date("H");
-        if ($type==1 && $H < 12 ) {
-            return self::setErrorInfo("推荐兑换只能在下午市进行");
-        }
-        if($type>0 && $consume_pass==0 || $user['now_money']<$consume_pass)
-        {
-            return self::setErrorInfo('通行证少于'.$consume_pass.",请先买通行证!");
-        }
-        if( $user['brokerage_price']<$price)
-        {
-            return self::setErrorInfo('收益少于'.$price);
-        }
-        $i = date("i");
-        if ($i < 30) {
-            $start = strtotime(date("Y-m-d H:00:00"));
-            $end = strtotime(date("Y-m-d H:29:59"));
-        } else {
-            $start = strtotime(date("Y-m-d H:30:00"));
-            $end = strtotime(date("Y-m-d H:59:59"));
-        }
-        if(self::where('package_manager',$package_manager)->where('uid',$uid)->where('add_time','>=',$start)->where('add_time','<=',$end)->find())
+        }catch (Exception $e)
         {
-            return self::setErrorInfo('你已报名,无需重复报名');
+            Log::error('预约出错:' . $e->getLine().'--'.$e->getMessage());
+            return self::setErrorInfo($e->getMessage(),true);
         }
-
-        $data['uid'] =$uid;
-        $data['package_manager'] = $package_manager;
-        $data['add_time'] = time();
-        $data['order_id'] = self::getNewOrderId();
-        $data['proportion'] = $proportion;
-        $data['price'] = $price;
-        $data['day'] = $day;
-        $data['consume_pass'] =$consume_pass;
-        $data['am'] = date("H")>12?0:1;
-        $data['pass'] = $pass;
-        $data['type'] = $type;
-        $data['status'] = 4;
-        $res = self::create($data);
-        User::where('uid',$uid)->dec('now_money',$consume_pass)->dec('brokerage_price',$price)->update();
-        UserBill::expend("兑换包扣通证",$uid,'now_money','pay_money',$consume_pass,$res['id'],bcsub($user['now_money'],$consume_pass,2),'兑换包扣除'.$consume_pass."通行证");
-        UserBill::expend("兑换包扣收益",$uid,'now_money','pay_money',$price,$res['id'],bcsub($user['brokerage_price'],$price,2),'兑换包扣除'.$price."收益");
-        return  $res;
     }
-
     /**
      * 生成订单唯一id
      * @param $uid 用户uid
@@ -161,10 +104,7 @@ class Package extends BaseModel
     public static function take($id)
     {
         $info = self::find($id);
-        $data['start_day'] = time();
-        $data['end_day'] = strtotime("+".$info['day']." days");
         $data['status'] = 3;
-        $data['sum_revenue'] = bcdiv(bcmul(bcmul($info['proportion'],$info['day'],4),$info['price'],4),100,2);
         $data['paid'] = 1;
         self::beginTrans();
         try {
@@ -466,11 +406,12 @@ class Package extends BaseModel
         if(isset($where['uid']) && $where['uid']>0) $model = $model->where('uid',$where['uid']);
         if(isset($where['to_uid']) && $where['to_uid']>0) $model = $model->where('to_uid',$where['to_uid']);
         if(isset($where['status']) && $where['status']>-4) $model = $model->where('status',$where['status']);
-        if(isset($where['type']) && $where['type']>-1) $model = $model->where('type',$where['type']);
+        if(isset($where['time_id']) && $where['time_id']>-4) $model = $model->where('time_id',$where['time_id']);
         $count = $model->value('count(id)')?:0;
         $data = $model->order('id desc')->page($where['page'],$where['limit'])->select();
         foreach ($data as &$v)
         {
+            $v['whole'] = StoreWholesale::find($v['whole_id'])->toArray();
             $v['user'] = User::where('uid',$v['uid'])->field('real_name,avatar,phone')->find()->toArray();
             if($v['to_uid']>0) {
                 $v['touser'] = User::where('uid', $v['to_uid'])->field('real_name,avatar,phone,wx_qr,wx_no,alipay_no,alipay_name,account_Bank,bank_card,bank_name,bank_branch')->find()->toArray();

+ 3 - 3
app/models/store/StoreCart.php

@@ -41,7 +41,7 @@ class StoreCart extends BaseModel
         return time();
     }
 
-    public static function setCart($uid, $product_id, $cart_num = 1, $product_attr_unique = '', $type = 'product', $is_new = 0, $combination_id = 0, $seckill_id = 0, $bargain_id = 0)
+    public static function setCart($uid, $product_id, $cart_num = 1, $product_attr_unique = '', $type = 'product', $is_new = 0, $combination_id = 0, $seckill_id = 0, $bargain_id = 0,$is_gold)
     {
         if ($cart_num < 1) $cart_num = 1;
         if (!$product_attr_unique) {
@@ -75,7 +75,7 @@ class StoreCart extends BaseModel
             return $cart;
         } else {
             $add_time = time();
-            return self::create(compact('uid', 'product_id', 'cart_num', 'product_attr_unique', 'is_new', 'type', 'combination_id', 'add_time', 'bargain_id', 'seckill_id'));
+            return self::create(compact('uid', 'product_id', 'cart_num', 'product_attr_unique', 'is_new', 'type', 'combination_id', 'add_time', 'bargain_id', 'seckill_id','is_gold'));
         }
     }
 
@@ -206,7 +206,7 @@ class StoreCart extends BaseModel
                         $invalid[] = $cart;
                     else {
                         $cart['productInfo']['attrInfo'] = $attrInfo;
-                        if ($cart['combination_id'] || $cart['seckill_id'] || $cart['bargain_id']) {
+                        if ($cart['combination_id'] || $cart['seckill_id'] || $cart['bargain_id'] || $cart['is_gold']) {
                             if ($cart['bargain_id']) {
                                 $cart['truePrice'] = $cart['productInfo']['price'];
                             } else {

+ 1 - 1
app/models/store/StoreOrder.php

@@ -1127,7 +1127,7 @@ class StoreOrder extends BaseModel
             $open && BaseModel::beginTrans();
             $integral = bcadd($userInfo['integral'], $order['gain_integral'], 2);
             $res1 = false != User::where('uid', $userInfo['uid'])->update(['integral' => $integral]);
-            $res2 = false != UserBill::income('购买商品赠送积分', $order['uid'], 'integral', 'gain', $order['gain_integral'], $order['id'], bcadd($userInfo['integral'], $order['gain_integral'], 2), '购买商品赠送' . floatval($order['gain_integral']) . '积分');
+            $res2 = false != UserBill::income('购买商品赠送金豆', $order['uid'], 'integral', 'gain', $order['gain_integral'], $order['id'], bcadd($userInfo['integral'], $order['gain_integral'], 2), '购买商品赠送' . floatval($order['gain_integral']) . '积分');
             $res = $res1 && $res2;
             $open && BaseModel::checkTrans($res);
             RoutineTemplate::sendUserIntegral($order['uid'], $order, $order['gain_integral'], $integral);

+ 1 - 1
app/models/store/StoreProduct.php

@@ -107,7 +107,7 @@ class StoreProduct extends BaseModel
         }
         if (!empty($keyword)) $model->where('keyword|store_name', 'LIKE', htmlspecialchars("%$keyword%"));
         if ($news != 0) $model->where('is_new', 1);
-        if (isset($data['is_gold']) && $data['is_gold']==1) $model->where('is_gold', 1);
+        if (isset($data['is_gold']) && $data['is_gold']>-1) $model->where('is_gold', $data['is_gold']);
         $baseOrder = '';
         if ($priceOrder) $baseOrder = $priceOrder == 'desc' ? 'price DESC' : 'price ASC';
 //        if($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'sales DESC' : 'sales ASC';//真实销量

+ 5 - 2
app/models/store/StoreWholesale.php

@@ -113,10 +113,13 @@ class StoreWholesale extends BaseModel
      * @param string $field
      * @return array|false|\PDOStatement|string|\think\Model
      */
-    public static function getValidProduct($id, $field = '*')
+    public static function getValidProduct($id, $field = '*',$is_news=0)
     {
         $time = time();
-        $info = self::alias('n')->where('n.id', $id)->where('n.is_del', 0)->where('n.status', 1)->where('n.start_time', '<', $time)->where('n.stop_time', '>', $time - 86400)->field('n.*')->find();
+       $model = self::alias('n')->where('n.id', $id)->where('n.is_del', 0)->where('n.status', 1);
+        if($is_news==0) $model = $model->where('n.start_time', '<', $time)->where('n.stop_time', '>', $time - 86400);
+        $info = $model->field('n.*')->find();
+
         if ($info['id']) {
             return $info;
         } else {

+ 6 - 6
route/api/route.php

@@ -63,14 +63,14 @@ Route::group(function () {
     //批发
     Route::get('whole/index', 'activity.WholeController/index')->name('wholeIndex');//批发产品时间区间
     Route::get('whole/list/:time', 'activity.WholeController/lst')->name('wholeList');//批发产品列表
-    Route::get('whole/detail/:id/[:time]/[:status]', 'activity.WholeController/detail')->name('wholeDetail');//批发产品详情
+    Route::get('whole/detail/:id/[:time]/[:status]/[:is_news]', 'activity.WholeController/detail')->name('wholeDetail');//批发产品详情
     Route::get('whole/news', 'activity.WholeController/news')->name('wholenews');//新人
 
-    Route::post('package/reserve', 'activity.PachageController/reserve')->name('packagereserve');//预约包
-    Route::post('package/mylist', 'activity.PachageController/mylist')->name('packagemylist');//我的包
-    Route::post('package/evaluation', 'activity.PachageController/evaluation')->name('packageevaluation');//上传评证
-    Route::post('package/order', 'activity.PachageController/order')->name('packagemylist');//我的卖出
-    Route::post('package/audit', 'activity.PachageController/audit')->name('packageaudit');//我的审核
+    Route::post('package/reserve', 'activity.WholeController/reserve')->name('packagereserve');//预约包
+    Route::post('package/mylist', 'activity.WholeController/mylist')->name('packagemylist');//我的包
+    Route::post('package/evaluation', 'activity.WholeController/evaluation')->name('packageevaluation');//上传评证
+    Route::post('package/order', 'activity.WholeController/order')->name('packagemylist');//我的卖出
+    Route::post('package/audit', 'activity.WholeController/audit')->name('packageaudit');//我的审核
 
      //公共类
     Route::post('upload/image', 'PublicController/upload_image')->name('uploadImage');//图片上传