|
|
@@ -949,7 +949,15 @@ class ProductRepository extends BaseRepository
|
|
949
|
949
|
|
|
950
|
950
|
$res['attr'] = $this->detailAttr($res['attr']);
|
|
951
|
951
|
|
|
952
|
|
- $res['yanglao'] = $this->yanglaojin($res['product_id']);
|
|
|
952
|
+ $k=$this->pvParm($res['product_id']);
|
|
|
953
|
+
|
|
|
954
|
+// $res['yanglao'] = $this->pvParm($res['product_id']);
|
|
|
955
|
+ $res['yanglao']=($k['yanglao']);
|
|
|
956
|
+ $res['pv']=($k['pv']);
|
|
|
957
|
+ $res['jifen']=($k['jifen']);
|
|
|
958
|
+ $res['gongxian']=($k['gongxian']);
|
|
|
959
|
+ $res['jfduihuan']=($k['jfduihuan']);
|
|
|
960
|
+ $res['jdduihuan']=($k['jdduihuan']);
|
|
953
|
961
|
|
|
954
|
962
|
foreach ($res['merchant']['recommend'] as $k => $v) {
|
|
955
|
963
|
// $is_seckill=Db::name('store_product')->where('product_id',$v['product_id'])->value('seckill');
|
|
|
@@ -1231,11 +1239,22 @@ class ProductRepository extends BaseRepository
|
|
1231
|
1239
|
// var_dump($where);
|
|
1232
|
1240
|
// echo Db::getlastsql();die;
|
|
1233
|
1241
|
$list = $query->page($page, $limit)->setOption('field', [])->with(['issetCoupon'])->field('volunteer,product_id,cate_id,mer_id,image,store_name,sort,sales,price,create_time,keyword')->select();
|
|
1234
|
|
- foreach ($list as &$v) {
|
|
1235
|
|
- $yanglao = $this->yanglaojin($v['product_id']);
|
|
1236
|
|
- $v['yanglao'] = $yanglao;
|
|
|
1242
|
+ $arr=[];
|
|
|
1243
|
+ foreach ($list["list"] as $v) {
|
|
|
1244
|
+ $k = $this->pvParm($v['product_id']);
|
|
|
1245
|
+// $v['yanglao'] = $yanglao;
|
|
1237
|
1246
|
// $v["yanglao"]
|
|
|
1247
|
+ $v['yanglao']=($k['yanglao']);
|
|
|
1248
|
+ $v['pv']=($k['pv']);
|
|
|
1249
|
+ $v['jifen']=($k['jifen']);
|
|
|
1250
|
+ $v['gongxian']=($k['gongxian']);
|
|
|
1251
|
+ $v['jfduihuan']=($k['jfduihuan']);
|
|
|
1252
|
+ $v['jdduihuan']=($k['jdduihuan']);
|
|
|
1253
|
+// $v=($v,$k);
|
|
|
1254
|
+// array_push($v,$k);
|
|
|
1255
|
+ $arr[]=$v;
|
|
1238
|
1256
|
}
|
|
|
1257
|
+ $list["list"]=$arr;
|
|
1239
|
1258
|
return compact('count', 'list');
|
|
1240
|
1259
|
}
|
|
1241
|
1260
|
|
|
|
@@ -1530,6 +1549,77 @@ class ProductRepository extends BaseRepository
|
|
1530
|
1549
|
}
|
|
1531
|
1550
|
|
|
1532
|
1551
|
|
|
|
1552
|
+ /**
|
|
|
1553
|
+ * 通过产品id,价格,商户id,获取pv,贡献值,积分,养老金等
|
|
|
1554
|
+ * @param int $good_id
|
|
|
1555
|
+ * @param int $price
|
|
|
1556
|
+ * @param int $dc
|
|
|
1557
|
+ * @param null $product_attr_unique
|
|
|
1558
|
+ * @return string
|
|
|
1559
|
+ */
|
|
|
1560
|
+ public function pvParm($good_id = 0, $price = 0,$mer_id=0, $dc = 0, $product_attr_unique = null)
|
|
|
1561
|
+ {
|
|
|
1562
|
+
|
|
|
1563
|
+ $yanglao = 0;//养老金
|
|
|
1564
|
+ $pv = 0;//pv值
|
|
|
1565
|
+ $gongxian = 0;//贡献值
|
|
|
1566
|
+ $jifen = 0;//积分
|
|
|
1567
|
+ $jfduihuan = "";//积分+现金兑换
|
|
|
1568
|
+ $jdduihuan = "";//京豆+现金兑换
|
|
|
1569
|
+ $total_price = 0;//产品价格
|
|
|
1570
|
+ $srtArry[]="";//返回的数组
|
|
|
1571
|
+
|
|
|
1572
|
+// $extension_bili = 0;
|
|
|
1573
|
+ //线上商品
|
|
|
1574
|
+ if ($good_id > 0) {
|
|
|
1575
|
+ if ($good_id == 15323) {
|
|
|
1576
|
+ //19800商品固定200养老金
|
|
|
1577
|
+ return 200;
|
|
|
1578
|
+ }
|
|
|
1579
|
+ $product = Db::name('store_product')->where('product_id', $good_id)->find();
|
|
|
1580
|
+ if ($price) {
|
|
|
1581
|
+ $total_price = $price;
|
|
|
1582
|
+ } else {
|
|
|
1583
|
+ $total_price = $product['price'];
|
|
|
1584
|
+ }
|
|
|
1585
|
+
|
|
|
1586
|
+ //plate_mer_profit 产品获得的佣金 数据库添加商品已经算好的佣金
|
|
|
1587
|
+ $pv=decimal2($product['plate_mer_profit']*0.5);//pv=佣金的50%
|
|
|
1588
|
+ $dui_jifen=decimal2($product['plate_mer_profit']*0.4);
|
|
|
1589
|
+ $dui_jingdou=decimal2($product['plate_mer_profit']*0.5);
|
|
|
1590
|
+ $dui_price=$total_price-$dui_jifen;//用积分兑换,所需要的现金 佣金的*40%
|
|
|
1591
|
+ $jidou__price=$total_price-$dui_jingdou;//用京豆兑换,所需要的现金 佣金的*50%
|
|
|
1592
|
+
|
|
|
1593
|
+ $jfduihuan="{$dui_price} + {$dui_jifen}";
|
|
|
1594
|
+ $jdduihuan="{$jidou__price} + {$dui_jingdou}";
|
|
|
1595
|
+ $srtArry['jfduihuan']=$jfduihuan;
|
|
|
1596
|
+ $srtArry['jdduihuan']=$jdduihuan;
|
|
|
1597
|
+
|
|
|
1598
|
+ }else{//线下商品
|
|
|
1599
|
+
|
|
|
1600
|
+ if ($mer_id>0){
|
|
|
1601
|
+ $base_commission= merchantConfig($mer_id, 'base_commission') ?: [
|
|
|
1602
|
+ 'base_commission' => 5
|
|
|
1603
|
+ ];// 如果没有查到商户的设置,系统默认最小5%让利
|
|
|
1604
|
+ $rangli=$total_price*($base_commission/100);//商户让利的金额
|
|
|
1605
|
+ $pv=$rangli;//线下的pv等与让利100%
|
|
|
1606
|
+ }
|
|
|
1607
|
+
|
|
|
1608
|
+ }
|
|
|
1609
|
+ $jifen=$pv;
|
|
|
1610
|
+ $gongxian=$pv;
|
|
|
1611
|
+ $yanglao=decimal2($pv*0.05);//养老金=pv的5%
|
|
|
1612
|
+ $srtArry['pv']=$pv;
|
|
|
1613
|
+ $srtArry['jifen']=$jifen;
|
|
|
1614
|
+ $srtArry['gongxian']=$gongxian;
|
|
|
1615
|
+ $srtArry['yanglao']=$yanglao;
|
|
|
1616
|
+
|
|
|
1617
|
+ return $srtArry;
|
|
|
1618
|
+
|
|
|
1619
|
+
|
|
|
1620
|
+ }
|
|
|
1621
|
+
|
|
|
1622
|
+
|
|
1533
|
1623
|
/*
|
|
1534
|
1624
|
*
|
|
1535
|
1625
|
@good_id 商品id
|
|
|
@@ -1540,7 +1630,7 @@ class ProductRepository extends BaseRepository
|
|
1540
|
1630
|
* 计算商品的养老金
|
|
1541
|
1631
|
* @param int $good_id
|
|
1542
|
1632
|
* @param int $price
|
|
1543
|
|
- * @param int $dc
|
|
|
1633
|
+ * @param int $dc
|
|
1544
|
1634
|
* @param null $product_attr_unique
|
|
1545
|
1635
|
* @return string
|
|
1546
|
1636
|
*/
|