|
@@ -36,7 +36,7 @@ class Goods extends Controller
|
|
|
$award_crystal = 0; // 已抽中的明信片
|
|
|
$crystal = 0;//明信片成本
|
|
|
$goods_arr = Db::table('store_goods')
|
|
|
- ->field('id,spec,goods_price,base_stock,stock,special_award,last_award')
|
|
|
+ ->field('id,spec,goods_price,base_stock,stock,special_award,last_award,multi_rand')
|
|
|
->order('id desc')
|
|
|
->select();
|
|
|
foreach ($goods_arr as $value){
|
|
@@ -54,6 +54,12 @@ class Goods extends Controller
|
|
|
foreach (json_decode($value['last_award'],true) as $lv ){
|
|
|
if($lv['is_over'] == 1 && $lv['crystal']>0) $award_crystal = bcadd($award_crystal,$lv['num'] * $lv['crystal'] ,2);
|
|
|
}
|
|
|
+ // sp
|
|
|
+ if($value['stock'] == 0){
|
|
|
+ $sp = json_decode($value['multi_rand']);
|
|
|
+ $sp_crystal = array_sum(array_column($sp,'multi_crystal'));
|
|
|
+ $award_crystal += $sp_crystal;
|
|
|
+ }
|
|
|
$this->total_money = bcadd(($value['base_stock']-$value['stock']) * $value['goods_price'],$this->total_money,2);
|
|
|
}
|
|
|
$this->total_cost = $award_crystal;// 成本
|
|
@@ -88,6 +94,12 @@ class Goods extends Controller
|
|
|
foreach (json_decode($value['last_award'],true) as $lv ){
|
|
|
if($lv['is_over'] == 1 && $lv['crystal']>0) $award_crystal = bcadd($award_crystal,$lv['num'] * $lv['crystal'] ,2);
|
|
|
}
|
|
|
+ if($value['stock'] == 0){
|
|
|
+ $sp = json_decode($value['multi_rand']);
|
|
|
+ $sp_crystal = array_sum(array_column($sp,'multi_crystal'));
|
|
|
+ $award_crystal += $sp_crystal;
|
|
|
+ }
|
|
|
+
|
|
|
$value['award_crystal'] = $award_crystal;
|
|
|
$value['total_money'] = ($value['base_stock']- $value['stock']) * $value['goods_price'];
|
|
|
$value['goods_profit'] = bcsub($value['total_money'],$value['award_crystal']);
|