终版初始化
							parent
							
								
									872946ba8c
								
							
						
					
					
						commit
						7301ad8031
					
				| 
						 | 
					@ -8,6 +8,7 @@ use app\model\CouponBill;
 | 
				
			||||||
use app\model\CouponMain;
 | 
					use app\model\CouponMain;
 | 
				
			||||||
use app\model\Deduction;
 | 
					use app\model\Deduction;
 | 
				
			||||||
use app\model\Redpack;
 | 
					use app\model\Redpack;
 | 
				
			||||||
 | 
					use app\model\Business as BusinessModel;
 | 
				
			||||||
use app\model\Score;
 | 
					use app\model\Score;
 | 
				
			||||||
use app\model\UsingRule;
 | 
					use app\model\UsingRule;
 | 
				
			||||||
use app\repository\AccountRepository;
 | 
					use app\repository\AccountRepository;
 | 
				
			||||||
| 
						 | 
					@ -302,15 +303,15 @@ class Coupon extends Base
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //签到距离
 | 
					        //签到距离
 | 
				
			||||||
        Config::load('extra/wechat', 'wechat');
 | 
					        Config::load('extra/wechat', 'wechat');
 | 
				
			||||||
        $signDistance = config('wechat.signDistance')??0;
 | 
					        $signDistance = config('wechat.signDistance') ?? 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if($signDistance > 0 ){
 | 
					        if($signDistance > 0 ){
 | 
				
			||||||
                $Distance =   get_distance($coupon->lat,$coupon->lng,$lat,$lng);
 | 
					                $Distance =   get_distance($coupon->lat,$coupon->lng,$lat,$lng);
 | 
				
			||||||
                if($Distance > $signDistance){
 | 
					                if($Distance > $signDistance){
 | 
				
			||||||
                    return $this->json(4001, "请在规定区域内使用优惠券");
 | 
					                    return $this->json(4001, "您距离商家位置距离超过规定距离{$Distance}米");
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $business =  BusinessRepository::getInstance()->getModel()->with(["agency"])->where(["code"=>$coupon->couponMain->business_code])->lock(true)->find();
 | 
					        $business =  BusinessRepository::getInstance()->getModel()->with(["agency"])->where(["code"=>$coupon->couponMain->business_code])->lock(true)->find();
 | 
				
			||||||
        if(empty($business)){
 | 
					        if(empty($business)){
 | 
				
			||||||
            return $this->json(4001, "商家不存在");
 | 
					            return $this->json(4001, "商家不存在");
 | 
				
			||||||
| 
						 | 
					@ -335,14 +336,22 @@ class Coupon extends Base
 | 
				
			||||||
            ]);
 | 
					            ]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //可分配金额
 | 
					            //可分配金额  如果是普通商家
 | 
				
			||||||
            $deductionMoney     = $coupon->couponMain->deduction_money;
 | 
					            if($account->business["model"] == BusinessModel::model_ordinary) {
 | 
				
			||||||
            $agencyMoney        =  (($deductionMoney/100) * $coupon->couponMain->commission_agency);
 | 
					                $deductionMoney     = $coupon->couponMain->deduction_money;
 | 
				
			||||||
            $adminMoney         =  (($deductionMoney/100) * $coupon->couponMain->commission_admin);
 | 
					                $agencyMoney        =  (($deductionMoney/100) * $coupon->couponMain->commission_agency);
 | 
				
			||||||
            $consumerMoney      =  (($deductionMoney/100) * $coupon->couponMain->commission_consumer);
 | 
					                $adminMoney         =  (($deductionMoney/100) * $coupon->couponMain->commission_admin);
 | 
				
			||||||
            $agencyMoney        = round($agencyMoney,2);        //四舍五入 精确到分
 | 
					                $consumerMoney      =  (($deductionMoney/100) * $coupon->couponMain->commission_consumer);
 | 
				
			||||||
            $adminMoney         = round($adminMoney,2);         //四舍五入 精确到分
 | 
					                $agencyMoney        = round($agencyMoney,2);        //四舍五入 精确到分
 | 
				
			||||||
            $consumerMoney      = round($consumerMoney,2);      //四舍五入 精确到分
 | 
					                $adminMoney         = round($adminMoney,2);         //四舍五入 精确到分
 | 
				
			||||||
 | 
					                $consumerMoney      = round($consumerMoney,2);      //四舍五入 精确到分
 | 
				
			||||||
 | 
					            }else{
 | 
				
			||||||
 | 
					                $deductionMoney     = $coupon->couponMain->deduction_money;
 | 
				
			||||||
 | 
					                $adminMoney         =  0;
 | 
				
			||||||
 | 
					                $consumerMoney      =  round($deductionMoney,2) ;
 | 
				
			||||||
 | 
					                $agencyMoney        = 0;        //四舍五入 精确到分
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // 2. 写入优惠券流水
 | 
					            // 2. 写入优惠券流水
 | 
				
			||||||
            $couponBillData = [
 | 
					            $couponBillData = [
 | 
				
			||||||
                "coupon_main_id"            =>$coupon->couponMain->id,
 | 
					                "coupon_main_id"            =>$coupon->couponMain->id,
 | 
				
			||||||
| 
						 | 
					@ -464,7 +473,17 @@ class Coupon extends Base
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $totalC = $distributionProportion['agency'] + $distributionProportion['admin'] + $distributionProportion['consumer'];
 | 
					        $totalC = $distributionProportion['agency'] + $distributionProportion['admin'] + $distributionProportion['consumer'];
 | 
				
			||||||
        if ($totalC != 100) {
 | 
					        if ($totalC != 100) {
 | 
				
			||||||
            return $this->json(5002, "系统设置分配比例总和不等于100,不能发布");
 | 
					            return $this->json(4002, "系统设置分配比例总和不等于100,不能发布");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        //持有限量
 | 
				
			||||||
 | 
					        Config::load("extra/wechat","wechat");
 | 
				
			||||||
 | 
					        $hasCouponMax = config("wechat.hasCouponMax")??0;
 | 
				
			||||||
 | 
					        if ($hasCouponMax > 0) {
 | 
				
			||||||
 | 
					            $hasCouponCount = CouponRepository::getInstance()->getBusinessOnShelfOnCount($account->business->code);
 | 
				
			||||||
 | 
					            if ($hasCouponCount > $hasCouponMax) {
 | 
				
			||||||
 | 
					                return $this->json(4001, "商家持有商家优惠券不能超过{$hasCouponMax}");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //验证通过  不管是商家还是工作人员  都可以发布优惠券
 | 
					        //验证通过  不管是商家还是工作人员  都可以发布优惠券
 | 
				
			||||||
| 
						 | 
					@ -491,7 +510,10 @@ class Coupon extends Base
 | 
				
			||||||
        $usingRule = input("using_rule/a");
 | 
					        $usingRule = input("using_rule/a");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $validate = new CouponRelease();
 | 
					        $validate = new CouponRelease();
 | 
				
			||||||
        if (!$validate->check($couponMain)) {
 | 
					
 | 
				
			||||||
 | 
					        //普通商家要验证扣除金额
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (!$validate->scene($account->business["model"] == BusinessModel::model_ordinary ? "ordinary" : "")->check($couponMain)) {
 | 
				
			||||||
            return $this->json(4001, $validate->getError());
 | 
					            return $this->json(4001, $validate->getError());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -513,9 +535,10 @@ class Coupon extends Base
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        //未领取的优惠券
 | 
					        //未领取的优惠券
 | 
				
			||||||
        $NotClaimedMoney = CouponRepository::getInstance()->getBusinessNotClaimedCoupon($account->business["code"]);
 | 
					        $NotClaimedMoney = CouponRepository::getInstance()->getBusinessNotClaimedCoupon($account->business["code"]);
 | 
				
			||||||
 | 
					        if($account->business["model"] == BusinessModel::model_ordinary) {
 | 
				
			||||||
        if ($account->business["balance"] < ($totalMoney + $NotClaimedMoney)) {
 | 
					            if ($account->business["balance"] < ($totalMoney + $NotClaimedMoney)) {
 | 
				
			||||||
            return $this->json(4001, '商家余额不足');
 | 
					                return $this->json(4001, '商家余额不足');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Db::startTrans();
 | 
					        Db::startTrans();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,8 +44,8 @@ class User extends Base
 | 
				
			||||||
            'gender'        => $this->request->param('gender/d', 0),
 | 
					            'gender'        => $this->request->param('gender/d', 0),
 | 
				
			||||||
            'real_name'     => $this->request->param('real_name/s', '',"trim"),
 | 
					            'real_name'     => $this->request->param('real_name/s', '',"trim"),
 | 
				
			||||||
            'mobile'        => $this->request->param('mobile/s', ''),
 | 
					            'mobile'        => $this->request->param('mobile/s', ''),
 | 
				
			||||||
            'lat'        => $this->request->param('lat/f', 0),
 | 
					            'lat'           => $this->request->param('lat/f', 0),
 | 
				
			||||||
            'lng'        => $this->request->param('lng/f', 0),
 | 
					            'lng'           => $this->request->param('lng/f', 0),
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $validate = new UserValidate();
 | 
					        $validate = new UserValidate();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -241,6 +241,7 @@ class Business extends Base
 | 
				
			||||||
        $this->data["item"] = $business;
 | 
					        $this->data["item"] = $business;
 | 
				
			||||||
        $this->data["type"] = CategoryModel::getByGroup();
 | 
					        $this->data["type"] = CategoryModel::getByGroup();
 | 
				
			||||||
        $this->data["businessCircle"] = BusinessCircleModel::getList();
 | 
					        $this->data["businessCircle"] = BusinessCircleModel::getList();
 | 
				
			||||||
 | 
					        $this->data["model"] = BusinessModel::allModel();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $this->view();
 | 
					        return $this->view();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,11 +6,13 @@ use app\exception\RepositoryException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use app\model\CouponMain;
 | 
					use app\model\CouponMain;
 | 
				
			||||||
use app\model\Member;
 | 
					use app\model\Member;
 | 
				
			||||||
 | 
					use app\model\Business as BusinessModel;
 | 
				
			||||||
use app\repository\BusinessRepository;
 | 
					use app\repository\BusinessRepository;
 | 
				
			||||||
use app\repository\CouponRepository;
 | 
					use app\repository\CouponRepository;
 | 
				
			||||||
use app\validate\CouponRelease;
 | 
					use app\validate\CouponRelease;
 | 
				
			||||||
use app\validate\CouponUsingRule;
 | 
					use app\validate\CouponUsingRule;
 | 
				
			||||||
use Exception;
 | 
					use Exception;
 | 
				
			||||||
 | 
					use think\facade\Config;
 | 
				
			||||||
use think\facade\Db;
 | 
					use think\facade\Db;
 | 
				
			||||||
use think\response\Json;
 | 
					use think\response\Json;
 | 
				
			||||||
use think\response\View;
 | 
					use think\response\View;
 | 
				
			||||||
| 
						 | 
					@ -186,8 +188,16 @@ class Coupon extends Base
 | 
				
			||||||
        if ($this->request->isPost()) {
 | 
					        if ($this->request->isPost()) {
 | 
				
			||||||
            $data = input("item/a", []);
 | 
					            $data = input("item/a", []);
 | 
				
			||||||
            $usingRule = input("using_rule/a", []);
 | 
					            $usingRule = input("using_rule/a", []);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            $business = BusinessRepository::getInstance()->getBusinessAccount($data["business_code"], true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (empty($business)) {
 | 
				
			||||||
 | 
					                return $this->json(4001, '商家不存在');
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            $validate = new CouponRelease();
 | 
					            $validate = new CouponRelease();
 | 
				
			||||||
            if (!$validate->check($data)) {
 | 
					            //普通商家要验证扣除金额
 | 
				
			||||||
 | 
					            if (!$validate->scene($business["model"] ==BusinessModel::model_ordinary?"ordinary":"")->check($data)) {
 | 
				
			||||||
                return $this->json(4001, $validate->getError());
 | 
					                return $this->json(4001, $validate->getError());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -196,11 +206,18 @@ class Coupon extends Base
 | 
				
			||||||
                return $this->json(4001, $usingRuleValidate->getError());
 | 
					                return $this->json(4001, $usingRuleValidate->getError());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $business = BusinessRepository::getInstance()->getBusinessAccount($data["business_code"], true);
 | 
					            //持有限量
 | 
				
			||||||
 | 
					            Config::load("extra/wechat","wechat");
 | 
				
			||||||
            if (empty($business)) {
 | 
					            $hasCouponMax = config("wechat.hasCouponMax")??0;
 | 
				
			||||||
                return $this->json(4001, '商家不存在');
 | 
					            if ($hasCouponMax > 0) {
 | 
				
			||||||
 | 
					                $hasCouponCount = CouponRepository::getInstance()->getBusinessOnShelfOnCount($business->code);
 | 
				
			||||||
 | 
					                if ($hasCouponCount > $hasCouponMax) {
 | 
				
			||||||
 | 
					                    return $this->json(4001, "商家持有商家优惠券不能超过{$hasCouponMax}");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $data['business_type'] = $business['type'];
 | 
					            $data['business_type'] = $business['type'];
 | 
				
			||||||
            $data['business_name'] = $business['business_name'];
 | 
					            $data['business_name'] = $business['business_name'];
 | 
				
			||||||
            $data['lng'] = $business['lng'];
 | 
					            $data['lng'] = $business['lng'];
 | 
				
			||||||
| 
						 | 
					@ -227,10 +244,12 @@ class Coupon extends Base
 | 
				
			||||||
            $totalMoney = $data['money'] * $data['count'];
 | 
					            $totalMoney = $data['money'] * $data['count'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            //未领取的优惠券
 | 
					            //未领取的优惠券
 | 
				
			||||||
            $NotClaimedMoney = CouponRepository::getInstance()->getBusinessNotClaimedCoupon($account->business["code"]);
 | 
					            $NotClaimedMoney = CouponRepository::getInstance()->getBusinessNotClaimedCoupon($business["code"]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ($business["balance"] < ($totalMoney + $NotClaimedMoney)) {
 | 
					            if($business["model"] == BusinessModel::model_ordinary){
 | 
				
			||||||
                return $this->json(4001, '商家余额不足');
 | 
					                if ($business["balance"] < ($totalMoney + $NotClaimedMoney)) {
 | 
				
			||||||
 | 
					                    return $this->json(4001, '商家余额不足');
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            $data['type_name'] = $type[$data['type']]['name'];
 | 
					            $data['type_name'] = $type[$data['type']]['name'];
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,7 +12,7 @@ use app\repository\CouponRepository;
 | 
				
			||||||
class Statistical extends Base
 | 
					class Statistical extends Base
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 性别比例
 | 
					     * 签到
 | 
				
			||||||
     * */
 | 
					     * */
 | 
				
			||||||
    public function sign()
 | 
					    public function sign()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
| 
						 | 
					@ -74,5 +74,44 @@ class Statistical extends Base
 | 
				
			||||||
        return $this->view();
 | 
					        return $this->view();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 注册位置
 | 
				
			||||||
 | 
					     * */
 | 
				
			||||||
 | 
					    public function register(){
 | 
				
			||||||
 | 
					        if($this->request->isPost()){
 | 
				
			||||||
 | 
					            $page =input("page/d",1);
 | 
				
			||||||
 | 
					            $size =input("size/d",1000);
 | 
				
			||||||
 | 
					            $data = AccountRepository::getInstance()->findList([
 | 
				
			||||||
 | 
					                ["lat",">",0],
 | 
				
			||||||
 | 
					                ["lng",">",0],
 | 
				
			||||||
 | 
					            ],["lat","lng","id as value"],$page,$size,function ($q){
 | 
				
			||||||
 | 
					                return $q->withAttr("value",function ($value){
 | 
				
			||||||
 | 
					                    return 100;
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            },["id"=>"desc"]);
 | 
				
			||||||
 | 
					            return $this->json(0,"success",$data);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return $this->view();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 领取优惠券位置
 | 
				
			||||||
 | 
					     * */
 | 
				
			||||||
 | 
					    public function receive(){
 | 
				
			||||||
 | 
					        if($this->request->isPost()){
 | 
				
			||||||
 | 
					            $page =input("page/d",1);
 | 
				
			||||||
 | 
					            $size =input("size/d",1000);
 | 
				
			||||||
 | 
					            $data = CouponRepository::getInstance()->findList([
 | 
				
			||||||
 | 
					                ["lat",">",0],
 | 
				
			||||||
 | 
					                ["lng",">",0],
 | 
				
			||||||
 | 
					            ],["lat","lng","id as value"],$page,$size,function ($q){
 | 
				
			||||||
 | 
					                return $q->withAttr("value",function ($value){
 | 
				
			||||||
 | 
					                    return 100;
 | 
				
			||||||
 | 
					                });
 | 
				
			||||||
 | 
					            },["id"=>"desc"]);
 | 
				
			||||||
 | 
					            return $this->json(0,"success",$data);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return $this->view();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,14 +6,25 @@ use think\model\relation\HasOne;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Business extends Base
 | 
					class Business extends Base
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    const state_reviewing = 0;
 | 
					    const state_reviewing = 0;//待审核
 | 
				
			||||||
    const state_on        = 1;
 | 
					    const state_on        = 1;//审核通过
 | 
				
			||||||
    const state_off       = 2;
 | 
					    const state_off       = 2;//驳回
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const model_ordinary        = 0;//普通商家
 | 
				
			||||||
 | 
					    const model_annual_fee      = 1;//年费商家
 | 
				
			||||||
 | 
					    const model_zero            = 2;//0元商家
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @remarks 代理商、平台商、平台代理商、渠道商等词组均描述的是代理商,因此文案统一为【代理商】
 | 
					     * @remarks 代理商、平台商、平台代理商、渠道商等词组均描述的是代理商,因此文案统一为【代理商】
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static function allModel()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					            return [
 | 
				
			||||||
 | 
					                self::model_ordinary=>"普通商家",
 | 
				
			||||||
 | 
					                self::model_annual_fee=>"年费商家",
 | 
				
			||||||
 | 
					                self::model_zero=>"0元商家",
 | 
				
			||||||
 | 
					            ];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    public function category()
 | 
					    public function category()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return $this->hasOne(Category::class, 'id',"type");
 | 
					        return $this->hasOne(Category::class, 'id',"type");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -144,4 +144,14 @@ trait CouponMainTrait
 | 
				
			||||||
            ->toArray()
 | 
					            ->toArray()
 | 
				
			||||||
            ;
 | 
					            ;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 获取商家商家的优惠券
 | 
				
			||||||
 | 
					     * */
 | 
				
			||||||
 | 
					    public function getBusinessOnShelfOnCount($businessCode)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return CouponMain::where("business_code",$businessCode)
 | 
				
			||||||
 | 
					            ->where("on_shelf",CouponMain::on_shelf_on)
 | 
				
			||||||
 | 
					            ->count();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -16,8 +16,8 @@ class CouponRelease extends Validate
 | 
				
			||||||
        'start_time|开始时间' => 'require|date',
 | 
					        'start_time|开始时间' => 'require|date',
 | 
				
			||||||
        'end_time|结束时间' => 'require|date|checkEndTime',
 | 
					        'end_time|结束时间' => 'require|date|checkEndTime',
 | 
				
			||||||
        'name|优惠券名称' => 'require|length:3,32',
 | 
					        'name|优惠券名称' => 'require|length:3,32',
 | 
				
			||||||
        'money|金额' => 'require|>:0|<:5000',
 | 
					        'money|金额' => 'require|>:0|<=:5000',
 | 
				
			||||||
        'deduction_money|扣除金额' => 'require|checkDeductionMoney|>=:0.1|<:5000',
 | 
					        'deduction_money|扣除金额' => 'require|>=:0.1|<=:5000',
 | 
				
			||||||
        //'image_url|预览图' => '',
 | 
					        //'image_url|预览图' => '',
 | 
				
			||||||
        //'using_rule|使用规则' => '',
 | 
					        //'using_rule|使用规则' => '',
 | 
				
			||||||
        //'punishing_rule|处罚规则' => '',
 | 
					        //'punishing_rule|处罚规则' => '',
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,12 @@ class CouponRelease extends Validate
 | 
				
			||||||
        'api_edit' => ['name', 'type', 'start_time',"end_time","image_url"],
 | 
					        'api_edit' => ['name', 'type', 'start_time',"end_time","image_url"],
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // edit 验证场景定义
 | 
				
			||||||
 | 
					    public function sceneOrdinary()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return $this->append('deduction_money', 'checkDeductionMoney');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected function checkEndTime($value, $rule, $data = [])
 | 
					    protected function checkEndTime($value, $rule, $data = [])
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (strtotime($value) <= strtotime($data['start_time'])) {
 | 
					        if (strtotime($value) <= strtotime($data['start_time'])) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,10 @@ class User extends Validate
 | 
				
			||||||
        'lng|位置'          => 'require|>:0',
 | 
					        'lng|位置'          => 'require|>:0',
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					    protected $message = [
 | 
				
			||||||
 | 
					        'lat.require' => '请授权位置信息',
 | 
				
			||||||
 | 
					        'lng.require'     => '请授权位置信息',
 | 
				
			||||||
 | 
					    ];
 | 
				
			||||||
    protected $scene = [
 | 
					    protected $scene = [
 | 
				
			||||||
        // 微信小程序登录
 | 
					        // 微信小程序登录
 | 
				
			||||||
        'wx_applets' => ['code', 'nick_name', 'gender',"lat","lng"],
 | 
					        'wx_applets' => ['code', 'nick_name', 'gender',"lat","lng"],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -192,6 +192,16 @@
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            <div class="layui-form-item">
 | 
				
			||||||
 | 
					                <label class="layui-form-label required">商家模式</label>
 | 
				
			||||||
 | 
					                <div class="layui-input-block">
 | 
				
			||||||
 | 
					                    <select name="model">
 | 
				
			||||||
 | 
					                        {foreach $model as $key=> $value}
 | 
				
			||||||
 | 
					                        <option value="{$key}" {if $item['model'] == $key }  selected {/if}>{$value}</option>
 | 
				
			||||||
 | 
					                        {/foreach}
 | 
				
			||||||
 | 
					                    </select>
 | 
				
			||||||
 | 
					                </div>
 | 
				
			||||||
 | 
					            </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            <div class="layui-form-item">
 | 
					            <div class="layui-form-item">
 | 
				
			||||||
                <div class="layui-input-block">
 | 
					                <div class="layui-input-block">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -117,6 +117,15 @@
 | 
				
			||||||
                    <div class="layui-form-mid layui-word-aux">商家余额不足以支付相应数量优惠券时,进行充值提醒</div>
 | 
					                    <div class="layui-form-mid layui-word-aux">商家余额不足以支付相应数量优惠券时,进行充值提醒</div>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                <div class="layui-form-item layui-form-item-lg">
 | 
				
			||||||
 | 
					                    <label class="layui-form-label">优惠券持有限量</label>
 | 
				
			||||||
 | 
					                    <div class="layui-input-inline">
 | 
				
			||||||
 | 
					                        <input class="layui-input" type="text" name="hasCouponMax" value="{$item.hasCouponMax ?? 0}"/>
 | 
				
			||||||
 | 
					                    </div>
 | 
				
			||||||
 | 
					                    <div class="layui-form-mid layui-word-aux">(0表示不限):商家可以同时上架的优惠券数量,超过此数量时商家无法发布优惠券,并提示商家</div>
 | 
				
			||||||
 | 
					                </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <div class="layui-form-item layui-form-item-lg layui-hide">
 | 
					                <div class="layui-form-item layui-form-item-lg layui-hide">
 | 
				
			||||||
                    <label class="layui-form-label">商家发布优惠券</label>
 | 
					                    <label class="layui-form-label">商家发布优惠券</label>
 | 
				
			||||||
                    <div class="layui-input-block">
 | 
					                    <div class="layui-input-block">
 | 
				
			||||||
| 
						 | 
					@ -141,14 +150,15 @@
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <div class="layui-form-item layui-form-item-lg">
 | 
					                <div class="layui-form-item layui-form-item-lg">
 | 
				
			||||||
                    <label class="layui-form-label">签到距离(0表示不限)</label>
 | 
					                    <label class="layui-form-label">签到距离/米(0表示不限)</label>
 | 
				
			||||||
                    <div class="layui-input-inline">
 | 
					                    <div class="layui-input-inline">
 | 
				
			||||||
                        <input class="layui-input" type="text" name="signDistance" value="{$item.signDistance ?? 0}"/>
 | 
					                        <input class="layui-input" type="text" name="signDistance" value="{$item.signDistance ?? 0}"/>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
 | 
					                    <div class="layui-form-mid layui-word-aux">设置签到时用户的位置和商家的地理位置最大不能超过多少米</div>
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                <div class="layui-form-item layui-form-item-lg">
 | 
					                <div class="layui-form-item layui-form-item-lg">
 | 
				
			||||||
                    <label class="layui-form-label">优惠券最小佣金(0表示不限)</label>
 | 
					                    <label class="layui-form-label">优惠券最小佣金/元(0表示不限)</label>
 | 
				
			||||||
                    <div class="layui-input-inline">
 | 
					                    <div class="layui-input-inline">
 | 
				
			||||||
                        <input class="layui-input" type="text" name="minCouponDeductionMoney" value="{$item.minCouponDeductionMoney ?? 0}"/>
 | 
					                        <input class="layui-input" type="text" name="minCouponDeductionMoney" value="{$item.minCouponDeductionMoney ?? 0}"/>
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,12 +59,12 @@
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<!--            <div class="layui-form-item">-->
 | 
					            <div class="layui-form-item">
 | 
				
			||||||
<!--                <label class="layui-form-label required">扣除金额</label>-->
 | 
					                <label class="layui-form-label required">扣除金额</label>
 | 
				
			||||||
<!--                <div class="layui-input-block">-->
 | 
					                <div class="layui-input-block">
 | 
				
			||||||
<!--                    <input type="number" name="item[deduction_money]" lay-verify="required|number" value="" lay-reqtext="必须>=0,不能为空" placeholder="请输入" class="layui-input">-->
 | 
					                    <input type="number" name="item[deduction_money]" lay-verify="required|number" value="" lay-reqtext="必须>=0,不能为空" placeholder="请输入" class="layui-input">
 | 
				
			||||||
<!--                </div>-->
 | 
					                </div>
 | 
				
			||||||
<!--            </div>-->
 | 
					            </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -59,12 +59,12 @@
 | 
				
			||||||
                </div>
 | 
					                </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<!--            <div class="layui-form-item">-->
 | 
					            <div class="layui-form-item">
 | 
				
			||||||
<!--                <label class="layui-form-label required">扣除金额</label>-->
 | 
					                <label class="layui-form-label required">扣除金额</label>
 | 
				
			||||||
<!--                <div class="layui-input-block">-->
 | 
					                <div class="layui-input-block">
 | 
				
			||||||
<!--                    <input type="number" name="item[deduction_money]" lay-verify="required|number" value="" lay-reqtext="必须>=0,不能为空" placeholder="请输入" class="layui-input">-->
 | 
					                    <input type="number" name="item[deduction_money]" lay-verify="required|number" value="" lay-reqtext="必须>=0,不能为空" placeholder="请输入" class="layui-input">
 | 
				
			||||||
<!--                </div>-->
 | 
					                </div>
 | 
				
			||||||
<!--            </div>-->
 | 
					            </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,92 @@
 | 
				
			||||||
 | 
					{layout name="manager/layout" /}
 | 
				
			||||||
 | 
					<style type="text/css">
 | 
				
			||||||
 | 
						#container {
 | 
				
			||||||
 | 
							height: 100vh;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
 | 
					<script src="/static/js/jquery-3.3.1.js"></script>
 | 
				
			||||||
 | 
					<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&libraries=visualization&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
 | 
				
			||||||
 | 
					<script>
 | 
				
			||||||
 | 
						var page = 1;
 | 
				
			||||||
 | 
						var data = {
 | 
				
			||||||
 | 
							max: 100,
 | 
				
			||||||
 | 
							min: 0,
 | 
				
			||||||
 | 
							data: []
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						window.onload = function() {
 | 
				
			||||||
 | 
							// 创建地图
 | 
				
			||||||
 | 
							var map = new qq.maps.Map(document.getElementById("container"), {
 | 
				
			||||||
 | 
								center: new qq.maps.LatLng(30.572952, 104.066172),
 | 
				
			||||||
 | 
								zoom: 8
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							// 创建热力图对象
 | 
				
			||||||
 | 
							var heat = new qq.maps.visualization.Heat({
 | 
				
			||||||
 | 
								map: map, // 必填参数,指定显示热力图的地图对象
 | 
				
			||||||
 | 
								radius: 20, // 辐射半径,默认为20
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							function getHeatData(cnt, max, min) {
 | 
				
			||||||
 | 
								let data = [];
 | 
				
			||||||
 | 
								// let center = {
 | 
				
			||||||
 | 
								// 	lat: 30.572952,
 | 
				
			||||||
 | 
								// 	lng: 104.066172
 | 
				
			||||||
 | 
								// };
 | 
				
			||||||
 | 
								// cnt = cnt || 100;
 | 
				
			||||||
 | 
								// max = max || 100;
 | 
				
			||||||
 | 
								// min = min || 0;
 | 
				
			||||||
 | 
								// for (let index = 0; index < 100; index++) {
 | 
				
			||||||
 | 
								// 	let r = Math.random()*10;
 | 
				
			||||||
 | 
								// 	let angle = Math.random() * Math.PI * 2;
 | 
				
			||||||
 | 
								// 	// 点颜色变化
 | 
				
			||||||
 | 
								// 	let heatValue = Math.random() * (max - min) + min;
 | 
				
			||||||
 | 
								// 	// data.push({
 | 
				
			||||||
 | 
								// 	// 	lat: 30.65805,
 | 
				
			||||||
 | 
								// 	// 	lng: 104.136153,
 | 
				
			||||||
 | 
								// 	// 	value: 100
 | 
				
			||||||
 | 
								// 	// });
 | 
				
			||||||
 | 
								// 	data.push({
 | 
				
			||||||
 | 
								// 		lat: center.lat + r * Math.sin(angle),
 | 
				
			||||||
 | 
								// 		lng: center.lng + r * Math.cos(angle),
 | 
				
			||||||
 | 
								// 		value: 100
 | 
				
			||||||
 | 
								// 	});
 | 
				
			||||||
 | 
								// }
 | 
				
			||||||
 | 
								return {
 | 
				
			||||||
 | 
									max: max,
 | 
				
			||||||
 | 
									min: min,
 | 
				
			||||||
 | 
									data: data
 | 
				
			||||||
 | 
								};
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							function getRegister(){
 | 
				
			||||||
 | 
								$.ajax('/manager/statistical/receive', {
 | 
				
			||||||
 | 
									data: {
 | 
				
			||||||
 | 
										"page": page,
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									,dataType : 'json'
 | 
				
			||||||
 | 
									,type: 'POST'
 | 
				
			||||||
 | 
								}).done(function (res) {
 | 
				
			||||||
 | 
									if(res.code ==0 ){
 | 
				
			||||||
 | 
										if(res.data.list.length==0){
 | 
				
			||||||
 | 
											layer.msg("加载完毕")
 | 
				
			||||||
 | 
										}else{
 | 
				
			||||||
 | 
											page ++;
 | 
				
			||||||
 | 
											data.data = data.data.concat(res.data.list);
 | 
				
			||||||
 | 
											// console.log(res.data.list)
 | 
				
			||||||
 | 
											console.log(data)
 | 
				
			||||||
 | 
											heat.setData(data);
 | 
				
			||||||
 | 
											setTimeout(getRegister(),100)
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							getRegister();
 | 
				
			||||||
 | 
							// 获取热力数据
 | 
				
			||||||
 | 
							// var data = getHeatData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 向热力图传入数据
 | 
				
			||||||
 | 
							// heat.setData(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					<div id="container" style="position: relative; background-color: rgb(229, 227, 223); overflow: hidden; transform: translateZ(0px);"></div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,92 @@
 | 
				
			||||||
 | 
					{layout name="manager/layout" /}
 | 
				
			||||||
 | 
					<style type="text/css">
 | 
				
			||||||
 | 
						#container {
 | 
				
			||||||
 | 
							height: 100vh;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					</style>
 | 
				
			||||||
 | 
					<script src="/static/js/jquery-3.3.1.js"></script>
 | 
				
			||||||
 | 
					<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&libraries=visualization&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
 | 
				
			||||||
 | 
					<script>
 | 
				
			||||||
 | 
						var page = 1;
 | 
				
			||||||
 | 
						var data = {
 | 
				
			||||||
 | 
							max: 100,
 | 
				
			||||||
 | 
							min: 0,
 | 
				
			||||||
 | 
							data: []
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						window.onload = function() {
 | 
				
			||||||
 | 
							// 创建地图
 | 
				
			||||||
 | 
							var map = new qq.maps.Map(document.getElementById("container"), {
 | 
				
			||||||
 | 
								center: new qq.maps.LatLng(30.572952, 104.066172),
 | 
				
			||||||
 | 
								zoom: 8
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							// 创建热力图对象
 | 
				
			||||||
 | 
							var heat = new qq.maps.visualization.Heat({
 | 
				
			||||||
 | 
								map: map, // 必填参数,指定显示热力图的地图对象
 | 
				
			||||||
 | 
								radius: 20, // 辐射半径,默认为20
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							function getHeatData(cnt, max, min) {
 | 
				
			||||||
 | 
								let data = [];
 | 
				
			||||||
 | 
								// let center = {
 | 
				
			||||||
 | 
								// 	lat: 30.572952,
 | 
				
			||||||
 | 
								// 	lng: 104.066172
 | 
				
			||||||
 | 
								// };
 | 
				
			||||||
 | 
								// cnt = cnt || 100;
 | 
				
			||||||
 | 
								// max = max || 100;
 | 
				
			||||||
 | 
								// min = min || 0;
 | 
				
			||||||
 | 
								// for (let index = 0; index < 100; index++) {
 | 
				
			||||||
 | 
								// 	let r = Math.random()*10;
 | 
				
			||||||
 | 
								// 	let angle = Math.random() * Math.PI * 2;
 | 
				
			||||||
 | 
								// 	// 点颜色变化
 | 
				
			||||||
 | 
								// 	let heatValue = Math.random() * (max - min) + min;
 | 
				
			||||||
 | 
								// 	// data.push({
 | 
				
			||||||
 | 
								// 	// 	lat: 30.65805,
 | 
				
			||||||
 | 
								// 	// 	lng: 104.136153,
 | 
				
			||||||
 | 
								// 	// 	value: 100
 | 
				
			||||||
 | 
								// 	// });
 | 
				
			||||||
 | 
								// 	data.push({
 | 
				
			||||||
 | 
								// 		lat: center.lat + r * Math.sin(angle),
 | 
				
			||||||
 | 
								// 		lng: center.lng + r * Math.cos(angle),
 | 
				
			||||||
 | 
								// 		value: 100
 | 
				
			||||||
 | 
								// 	});
 | 
				
			||||||
 | 
								// }
 | 
				
			||||||
 | 
								return {
 | 
				
			||||||
 | 
									max: max,
 | 
				
			||||||
 | 
									min: min,
 | 
				
			||||||
 | 
									data: data
 | 
				
			||||||
 | 
								};
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							function getRegister(){
 | 
				
			||||||
 | 
								$.ajax('/manager/statistical/register', {
 | 
				
			||||||
 | 
									data: {
 | 
				
			||||||
 | 
										"page": page,
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									,dataType : 'json'
 | 
				
			||||||
 | 
									,type: 'POST'
 | 
				
			||||||
 | 
								}).done(function (res) {
 | 
				
			||||||
 | 
									if(res.code ==0 ){
 | 
				
			||||||
 | 
										if(res.data.list.length==0){
 | 
				
			||||||
 | 
											layer.msg("加载完毕")
 | 
				
			||||||
 | 
										}else{
 | 
				
			||||||
 | 
											page ++;
 | 
				
			||||||
 | 
											data.data = data.data.concat(res.data.list);
 | 
				
			||||||
 | 
											// console.log(res.data.list)
 | 
				
			||||||
 | 
											console.log(data)
 | 
				
			||||||
 | 
											heat.setData(data);
 | 
				
			||||||
 | 
											setTimeout(getRegister(),100)
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							getRegister();
 | 
				
			||||||
 | 
							// 获取热力数据
 | 
				
			||||||
 | 
							// var data = getHeatData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 向热力图传入数据
 | 
				
			||||||
 | 
							// heat.setData(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
							<div id="container" style="position: relative; background-color: rgb(229, 227, 223); overflow: hidden; transform: translateZ(0px);"></div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue