feat: 修改了订单相关的API逻辑,移除了不必要的经纬度参数,并优化了成本计算方式。
This commit is contained in:
parent
e2e470d092
commit
a0bc922207
@ -339,18 +339,12 @@ class OrderController extends BaseApiController
|
||||
public function detail()
|
||||
{
|
||||
$order_id = (int)$this->request->get('order_id');
|
||||
$lat = $this->request->get('lat', '');
|
||||
$lng = $this->request->get('long', '');
|
||||
$where = [
|
||||
'id' => $order_id,
|
||||
'uid' => $this->userId,
|
||||
];
|
||||
$url = 'https://' . $this->request->host(true);
|
||||
$parm = [
|
||||
'lat' => $lat,
|
||||
'long' => $lng
|
||||
];
|
||||
$order = OrderLogic::detail($where, $url, $parm);
|
||||
$order = OrderLogic::detail($where, $url);
|
||||
if ($order) {
|
||||
return $this->data($order);
|
||||
} else {
|
||||
|
@ -149,7 +149,7 @@ class OrderLogic extends BaseLogic
|
||||
|
||||
//利润
|
||||
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
||||
$cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本
|
||||
$cart_select[$k]['total_purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本
|
||||
$cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $price, 2); //订单支付金额
|
||||
$cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //商户价
|
||||
$cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2) ?? 0; //vip售价
|
||||
@ -181,13 +181,14 @@ class OrderLogic extends BaseLogic
|
||||
$cart_select[$k]['cart_info'] = json_encode($cartInfo);
|
||||
//理论上每笔都是拆分了
|
||||
$cart_select[$k]['name'] = $find['store_name'];
|
||||
$cart_select[$k]['purchase'] = $find['purchase'];
|
||||
$cart_select[$k]['imgs'] = $find['image'];
|
||||
$cart_select[$k]['store_id'] = $params['store_id'] ?? 0;
|
||||
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name');
|
||||
$cart_select[$k]['total_price'] = $cart_select[$k]['pay_price'];
|
||||
self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2);
|
||||
self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2);
|
||||
self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2);
|
||||
self::$cost = bcadd(self::$cost, $cart_select[$k]['total_purchase'], 2);
|
||||
self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //商户价
|
||||
self::$deduction_price = bcadd(self::$deduction_price, $deduction_price, 2); //抵扣金额
|
||||
// self::$frozen_money = bcadd(self::$frozen_money, $cart_select[$k]['vip_frozen_price'], 2); //返还金额
|
||||
@ -343,7 +344,6 @@ class OrderLogic extends BaseLogic
|
||||
$goods_list[$k]['oid'] = $order->id;
|
||||
$goods_list[$k]['uid'] = $uid;
|
||||
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
||||
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
|
||||
}
|
||||
(new StoreOrderCartInfo())->saveAll($goods_list);
|
||||
$where = ['is_pay' => 0];
|
||||
@ -500,13 +500,11 @@ class OrderLogic extends BaseLogic
|
||||
if ($find) {
|
||||
|
||||
$find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id'])
|
||||
->field('product_id,cart_num nums,store_id')->select()->each(function ($item) use ($find) {
|
||||
->field('product_id,cart_num nums,store_id,price')->select()->each(function ($item) {
|
||||
$find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find();
|
||||
|
||||
$item['store_name'] = $find['store_name'];
|
||||
$item['nums'] = floatval($item['nums']);
|
||||
$item['image'] = $find['image'];
|
||||
$item['price'] = $find['price'];
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? '';
|
||||
$item['msg'] = '预计48小时发货';
|
||||
return $item;
|
||||
@ -523,22 +521,6 @@ class OrderLogic extends BaseLogic
|
||||
$tmpFilename = $generator->getBarcode($find['verify_code'], $generator::TYPE_CODE_128);
|
||||
$find['verify_base64'] = 'data:image/png;base64,' . base64_encode($tmpFilename);
|
||||
}
|
||||
//处理返回最近的店铺
|
||||
if ($param['lat'] && $param['long']) {
|
||||
$storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray();
|
||||
$nearestStore = null;
|
||||
$minDistance = PHP_FLOAT_MAX;
|
||||
foreach ($storeAll as $value) {
|
||||
$value['distance'] = haversineDistance($value['latitude'], $value['longitude'], $param['lat'], $param['long']);
|
||||
if ($value['distance'] < $minDistance) {
|
||||
$minDistance = $value['distance'];
|
||||
$nearestStore = $value;
|
||||
}
|
||||
}
|
||||
if ($nearestStore) {
|
||||
$find['near_store'] = $nearestStore;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $find;
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
}
|
||||
|
||||
try {
|
||||
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,price,cart_num')->select();
|
||||
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,price,purchase,cart_num')->select();
|
||||
$comm = new CommissionProductLogic();
|
||||
foreach ($info as $k => $v) {
|
||||
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship);
|
||||
|
Loading…
x
Reference in New Issue
Block a user