Wayne 1 year ago
commit 512fe6e670
  1. 3
      app/api/model/Goods.php
  2. 3
      app/api/model/Order.php
  3. 3
      app/api/service/Cart.php
  4. 130
      app/api/service/Goods.php

@ -534,6 +534,7 @@ class Goods extends GoodsModel
{ {
// 判断是否登录 // 判断是否登录
if (!UserService::isLogin()) { if (!UserService::isLogin()) {
$goods['line_price_min'] = $goods['goods_price_min'];
return; return;
} }
$catService = new \app\store\model\GoodsCategoryRel(); $catService = new \app\store\model\GoodsCategoryRel();
@ -545,6 +546,7 @@ class Goods extends GoodsModel
// $price_list_dealer[] = GoodsPriceModel::getDiscountPrice($v, 2, $goods['goods_price_min']); // $price_list_dealer[] = GoodsPriceModel::getDiscountPrice($v, 2, $goods['goods_price_min']);
// } // }
$goods['line_price_min'] = $goods['goods_price_min'];//划线价格等于市场价 $goods['line_price_min'] = $goods['goods_price_min'];//划线价格等于市场价
//价格判断 //价格判断
if (UserService::isstore()) { if (UserService::isstore()) {
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); $priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
@ -561,6 +563,7 @@ class Goods extends GoodsModel
$goods['goods_price_min'] = $priceArr['distributionPrice']; $goods['goods_price_min'] = $priceArr['distributionPrice'];
//$goods['goods_price_min_dealer'] = min($price_list_dealer); //$goods['goods_price_min_dealer'] = min($price_list_dealer);
} }
// 会员折扣价: 商品sku列表 // 会员折扣价: 商品sku列表
if ($goods->getRelation('skuList')) { if ($goods->getRelation('skuList')) {
foreach ($goods['skuList'] as &$skuItem) { foreach ($goods['skuList'] as &$skuItem) {

@ -90,8 +90,9 @@ class Order extends OrderModel
$item['skuInfo'] = GoodsModel::getSkuInfo($item, $goodsSkuId, false); $item['skuInfo'] = GoodsModel::getSkuInfo($item, $goodsSkuId, false);
// 商品封面 (优先sku封面) // 商品封面 (优先sku封面)
$item['goods_image'] = $item['skuInfo']['goods_image'] ?: $item['goods_image']; $item['goods_image'] = $item['skuInfo']['goods_image'] ?: $item['goods_image'];
// 商品单价 // 商品单价
$item['goods_price'] = $item['skuInfo']['goods_price']; $item['goods_price'] = \app\api\service\Goods::getGoodsPrice($item['goods_id'], $item['skuInfo']['goods_price'], $item['skuInfo']['cost_price']);
// 商品购买数量 // 商品购买数量
$item['total_num'] = $goodsNum; $item['total_num'] = $goodsNum;
// 商品SKU索引 // 商品SKU索引

@ -80,7 +80,8 @@ class Cart extends BaseService
// 商品记录 // 商品记录
$goods = $item['goods']; $goods = $item['goods'];
// 商品单价 // 商品单价
$goods['goods_price'] = $goods['skuInfo']['goods_price']; $goods['goods_price'] = \app\api\service\Goods::getGoodsPrice($item['goods_id'], $goods['skuInfo']['goods_price'], $goods['skuInfo']['cost_price']);
//$goods['goods_price'] = $goods['skuInfo']['goods_price'];
// 商品购买数量 // 商品购买数量
$goods['total_num'] = $item['goods_num']; $goods['total_num'] = $item['goods_num'];
// 商品SKU索引 // 商品SKU索引

@ -223,6 +223,19 @@ class Goods extends GoodsService
province_id,city_id,region_id,shop_id,address,latitude,longitude,wechat_img_id,history1,history2,history3,remark,history,parking_name,parking_desc,parking_latitude,parking_longitude,shop_image_id,fuwu_hours,fuwu_num')->find()->toArray(); province_id,city_id,region_id,shop_id,address,latitude,longitude,wechat_img_id,history1,history2,history3,remark,history,parking_name,parking_desc,parking_latitude,parking_longitude,shop_image_id,fuwu_hours,fuwu_num')->find()->toArray();
//todo wmc //todo wmc
$info['remark'] = json_decode($info['remark'],true); $info['remark'] = json_decode($info['remark'],true);
$arr = explode(" ", $info['shop_hours']);
$arr = explode("-", $arr[1] ?? "");
$info['is_open'] = 0;
// if ($arr && count($arr) == 2) {
// $start = explode(":", $arr[0]);
// $end = explode(":", $arr[1]);
// $start_time = ($start[0] ?? 0)
// if ($start[0]) {
// // code...
// }
// $info['is_open'] = 0;
// }
// $info['is_open'] = $arr && $arr[]
// $info['fuwu_hours'] = 5; // $info['fuwu_hours'] = 5;
// $info['fuwu_num'] = 15; // $info['fuwu_num'] = 15;
// $info['wechat'] = 'https://www.saas.njrenzhou.com/uploads/10001/20240127/12bb1b1747e652d258443247a5c4777c.png'; // $info['wechat'] = 'https://www.saas.njrenzhou.com/uploads/10001/20240127/12bb1b1747e652d258443247a5c4777c.png';
@ -290,7 +303,19 @@ class Goods extends GoodsService
// return $list; // return $list;
// } // }
public static function getGoodsPrice($goods_id, $price, $cost_price){
$catService = new \app\store\model\GoodsCategoryRel();
$catIds = $catService->where(['goods_id' => $goods_id])->column('category_id');
if (UserService::isstore()) {
$price = $cost_price;
} elseif (UserService::isPlusMember()) {
$price = \app\common\model\PriceSet::membershipPrice($price, $cost_price, $catIds);
} elseif (UserService::isDealerMember()) {
$priceArr = \app\common\model\PriceSet::distributionPrice($price, $cost_price, $catIds);
$price = $priceArr['goods_price_min_dealer'];
}
return $price;
}
/** /**
* 格式化商品列表 * 格式化商品列表
* @param $goodsList * @param $goodsList
@ -298,56 +323,61 @@ class Goods extends GoodsService
*/ */
private function formatGoodsList($goodsList): array private function formatGoodsList($goodsList): array
{ {
$data = []; // echo "<pre>";
foreach ($goodsList as $goods) { // print_r($goodsList->toArray());
$temp = [ // exit();
'goods_id' => $goods['goods_id'], // $data = [];
'goods_name' => $goods['goods_name'], // foreach ($goodsList as $goods) {
'selling_point' => $goods['selling_point'], // $temp = [
'goods_image' => $goods['goods_image'], // 'goods_id' => $goods['goods_id'],
'goods_price_min' => $goods['goods_price_min'],//商品价格 // 'goods_name' => $goods['goods_name'],
'goods_price_max' => $goods['goods_price_max'], // 'selling_point' => $goods['selling_point'],
'line_price_min' => $goods['goods_price_min'],//划线价格等于市场价 // 'goods_image' => $goods['goods_image'],
'line_price_max' => $goods['line_price_max'], // 'goods_price_min' => $goods['goods_price_min'],//商品价格
'goods_sales' => $goods['goods_sales'], // 'goods_price_max' => $goods['goods_price_max'],
'remaizhishu' => $goods['remaizhishu'], // 'line_price_min' => $goods['goods_price_min'],//划线价格等于市场价
]; // 'line_price_max' => $goods['line_price_max'],
// 'goods_sales' => $goods['goods_sales'],
if (UserService::isLogin()) { // 'remaizhishu' => $goods['remaizhishu'],
$catService = new \app\store\model\GoodsCategoryRel(); // ];
$catIds = $catService->where(['goods_id' => $goods['goods_id']])->column('category_id'); // var_dump($goods->toArray());
// $price_list_plus = $price_list_dealer = []; // var_dump($temp);
// foreach ($catIds as $k => $v) { // exit();
// $price_list_plus[] = GoodsPriceModel::getDiscountPrice($v, 1, $goods['goods_price_min']); // if (UserService::isLogin()) {
// $price_list_dealer[] = GoodsPriceModel::getDiscountPrice($v, 2, $goods['goods_price_min']); // $catService = new \app\store\model\GoodsCategoryRel();
// } // $catIds = $catService->where(['goods_id' => $goods['goods_id']])->column('category_id');
// // $price_list_plus = $price_list_dealer = [];
//价格判断 // // foreach ($catIds as $k => $v) {
if (UserService::isstore()) { // // $price_list_plus[] = GoodsPriceModel::getDiscountPrice($v, 1, $goods['goods_price_min']);
// // $price_list_dealer[] = GoodsPriceModel::getDiscountPrice($v, 2, $goods['goods_price_min']);
// // }
// //价格判断
// if (UserService::isstore()) {
// //$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
// // $temp['goods_price_min_plus'] = $priceArr['membershipPrice'];
// // $temp['goods_price_min_dealer'] = $priceArr['distributionPrice'];
// $temp['goods_price_min'] = $goods['cost_price_min'];
// // $temp['goods_price_min_plus'] = min($price_list_plus);
// // $temp['goods_price_min_dealer'] = min($price_list_dealer);
// } elseif (UserService::isPlusMember()) {
// //$temp['goods_price_min_plus'] = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
// $temp['goods_price_min'] = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
// // $temp['goods_price_min'] = $temp['goods_price_min_plus'];
// // $temp['goods_price_max'] = $temp['goods_price_min_plus'];
// //$temp['goods_price_min_plus'] = min($price_list_plus);
// } elseif (UserService::isDealerMember()) {
// $priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); // $priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
// //$temp['goods_price_min_dealer'] = $priceArr['distributionPrice'];
// $temp['goods_price_min_plus'] = $priceArr['membershipPrice']; // $temp['goods_price_min'] = $priceArr['goods_price_min_dealer'];
// $temp['goods_price_min_dealer'] = $priceArr['distributionPrice']; // //$temp['goods_price_min_dealer'] = min($price_list_dealer);
$temp['goods_price_min'] = $goods['cost_price_min']; // }
// $temp['goods_price_min_plus'] = min($price_list_plus); // }
// $temp['goods_price_min_dealer'] = min($price_list_dealer); // $data[] = $temp;
} elseif (UserService::isPlusMember()) { // }
//$temp['goods_price_min_plus'] = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); return is_array($goodsList) ? $goodsList : $goodsList->toArray();
$temp['goods_price_min'] = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
// $temp['goods_price_min'] = $temp['goods_price_min_plus'];
// $temp['goods_price_max'] = $temp['goods_price_min_plus'];
//$temp['goods_price_min_plus'] = min($price_list_plus);
} elseif (UserService::isDealerMember()) {
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
//$temp['goods_price_min_dealer'] = $priceArr['distributionPrice'];
$temp['goods_price_min'] = $priceArr['goods_price_min_dealer'];
//$temp['goods_price_min_dealer'] = min($price_list_dealer);
}
}
$data[] = $temp;
}
return $data;
} }

Loading…
Cancel
Save