From b62fa2ab5ed7eccaf5cbb439fa035c44bb49f1ba Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Tue, 8 Dec 2020 21:25:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hyhproject/common/model/Settlements.php | 36 +++++++++++-------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/hyhproject/common/model/Settlements.php b/hyhproject/common/model/Settlements.php index c7e9cc3..5afd4fd 100755 --- a/hyhproject/common/model/Settlements.php +++ b/hyhproject/common/model/Settlements.php @@ -18,13 +18,10 @@ class Settlements extends Base //获取优惠款 价格*优惠率 $m = Model('common/Table'); $m->setTable('order_goods'); - $orderGoodsList = $m->getList(['orderId'=>$orderId],'goodsPrice,goodsNum,freight,discountRate'); - $discountMoney = 0;//优惠款 - foreach ($orderGoodsList as &$v) { - //$discountMoney += ($v['goodsPrice']*$v['goodsNum'] + $v['freight']) * ($v['discountRate']*0.01);//优惠款 - $discountMoney += ($v['goodsPrice']*$v['goodsNum']) * ($v['discountRate']*0.01);//优惠款 - } - $discountMoney = round($discountMoney,5); + $discountMoney = Db::table("__ORDERS__ o")->join("__ORDER_GOODS__ g", "g.orderId=o.orderId", 'inner') + ->where(['o.orderId'=>$orderId])->sum('g.goodsPrice*g.goodsNum*g.discountRate*0.01'); + $discountMoney = round($discountMoney, 5); + $calBaseNum = $discountMoney; //加入快代付值 Model('SysSummary')->addToPayFast($orderId,$discountMoney,'订单【'.($order['orderNo']?:'--').'】优惠款加入'); //获取产品额 @@ -47,15 +44,15 @@ class Settlements extends Base // $buyerPreProductNum += round($order->productTaxFee * (dataConf('buyerPreProductInTaxFeeScale')*0.01),2);//4 // $buyerPreProductNum += round($order->couponsHandlingFee * (dataConf('buyerPreProductInProductHandlingFeeScale')*0.01),2);//5 // $buyerPreProductNum += round($order->couponsTaxFee * (dataConf('buyerPreProductInProductTaxFeeScale')*0.01),2);//6 + if(3 == $order->goodsType){ + // helpSaleCouponsCalBase == 基数 + $buyerPreProductNum *= (float)dataConf('helpSaleCouponsCalBase')/100; + $buyerPreCoupousNum *= (float)dataConf('helpSaleCouponsCalBase')/100; + } $buyerPreCoupousNum = $buyerPreCoupousNum > $buyerMaxCouponsNum ? $buyerMaxCouponsNum : $buyerPreCoupousNum; $buyerPreProductNum = $buyerPreProductNum > $totalMoney ? $totalMoney : $buyerPreProductNum; if($buyerPreProductNum > 0 || $buyerPreCoupousNum > 0){ - if(3 == $order->goodsType){ - // helpSaleCouponsCalBase == 基数 - Model('common/UserVouchers')->insertVouchersNotice($order->userId,$orderId,$buyerPreProductNum*((float)dataConf('helpSaleCouponsCalBase')/100),$buyerPreCoupousNum*((float)dataConf('helpSaleCouponsCalBase')/100),'订单【'.$order->orderNo.'】购户购物所得'); - }else{ - Model('common/UserVouchers')->insertVouchersNotice($order->userId,$orderId,$buyerPreProductNum,$buyerPreCoupousNum,'订单【'.$order->orderNo.'】购户购物所得'); - } + Model('common/UserVouchers')->insertVouchersNotice($order->userId,$orderId,$buyerPreProductNum,$buyerPreCoupousNum,'订单【'.$order->orderNo.'】购户购物所得'); } } @@ -67,8 +64,6 @@ class Settlements extends Base // $discountMoney-$order->productNum-$order->couponsNum-$order->wangNum-$order->moneyNum $sellerPreProductNum = round($discountMoney * (dataConf('sellerPreProductInProductScale')*0.01),5);//1 $sellerPreCoupousNum = round($discountMoney * (dataConf('sellerPreCoupousInSaleScale')*0.01),5);//2 - $calBaseNum = Db::table("__ORDERS__ o")->join("__ORDER_GOODS__ g", "g.orderId=o.orderId", 'inner') - ->where(['o.orderId'=>$orderId])->sum('g.goodsPrice*g.goodsNum*g.discountRate*0.01'); if($sellerPreProductNum >= 0.01 || $sellerPreCoupousNum>=0.01){ if(3 != $order->goodsType){ // step 3 平台送商户:10000×0.4=4000“预获产品券” @@ -87,10 +82,6 @@ class Settlements extends Base } // step 4 平台送商户的推荐人:当消费超过限制值时10000×0.4×0.5×0.5=1000“预获产品券”。 // 当消费低于限制值时10000×0.4×0.5×0.2=400“预获产品券”。 - // 推荐人的推荐所得是指:推荐人推荐的购户购物后的推荐所得,和推荐人推荐的商户售物后的推荐所得 - // 购户均衡获得预获产品券是推荐人的推荐所得的? % - // balanceTjrGet - $toCalBaseNum *= ((float)dataConf('balanceTjrGet')/100); $uUserId = UserTrees::getUpperId($shops["userId"]); if($uUserId == null || $uUserId == 0){$uUserId = 1;} $data = Db::query('SELECT sum(`goodsMoney`) as `total` FROM `hyh_orders` WHERE DATE_FORMAT(`createTime`,"%Y%m%d")=DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day),"%Y%m%d") and `userId`="'.$uUserId.'"'); @@ -99,14 +90,13 @@ class Settlements extends Base Model('common/UserVouchers')->insertVouchersNotice($uUserId, $orderId,$toCalBaseNum*((float)dataConf("refPreProductNoInSaleScale")/100), 0,'订单【'.$order['orderNo'].'】推荐商户所得',1); }else{ - Model('common/UserVouchers')->insertVouchersNotice($uUserId, $orderId,$toCalBaseNum*((float)dataConf('helpSaleCouponsCalBase')/100)*((float)dataConf("refPreProductYesInSaleScale")/100), + Model('common/UserVouchers')->insertVouchersNotice($uUserId, $orderId,$toCalBaseNum*((float)dataConf("refPreProductYesInSaleScale")/100), 0,'订单【'.$order['orderNo'].'】推荐商户所得',1); } // step 6 平台送自己的推荐人:当消费超过限制值时10000×0.4×0.5×0.5=1000“预获产品券”; // 当消费低于限制值时10000×0.4×0.5×0.2=400“预获产品券”。 // 推荐人的推荐所得是指:推荐人推荐的购户购物后的推荐所得,和推荐人推荐的商户售物后的推荐所得 // 购户均衡获得预获产品券是推荐人的推荐所得的? % - // 前面均衡了,不要再均衡啊 $uUserId = UserTrees::getUpperId($order['userId']); if($uUserId == null || $uUserId == 0){$uUserId = 1;} $data = Db::query('SELECT sum(`goodsMoney`) as `total` FROM `hyh_orders` WHERE DATE_FORMAT(`createTime`,"%Y%m%d")=DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 day),"%Y%m%d") and `userId`="'.$uUserId.'"'); @@ -121,6 +111,10 @@ class Settlements extends Base // step 7 平台送自己的被推荐人:10000×0.4×0.5×0.5÷5=200“预获产品券”。 $childes = DB::table("hyh_user_trees")->where(["pid"=>$order['userId']])->field("uid")->select(); foreach ($childes as $child){ + // 推荐人的推荐所得是指:推荐人推荐的购户购物后的推荐所得,和推荐人推荐的商户售物后的推荐所得 + // 购户均衡获得预获产品券是推荐人的推荐所得的? % + // balanceTjrGet + $toCalBaseNum *= ((float)dataConf('balanceTjrGet')/100); Model('common/UserVouchers')->insertVouchersNotice($child['uid'], $orderId, $toCalBaseNum*((float)dataConf("helpSaleChildrenGet")/100)/sizeof($childes), 0, '订单【'.$order['orderNo'].'】被购户推荐所得',1);