Merge pull request 'dev' (#352) from dev into main

Reviewed-on: #352
This commit is contained in:
mkm 2024-11-20 17:00:02 +08:00
commit 1d80c39e7a
5 changed files with 33 additions and 33 deletions

View File

@ -166,12 +166,13 @@ class BeforehandOrderLogic extends BaseLogic
Db::startTrans(); Db::startTrans();
try { try {
$cart_info = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select()->toArray(); $cart_info = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select()->toArray();
$user = User::where('id', $params['user_id'])->find();
$cart_select = []; $cart_select = [];
$total_price = 0; $total_price = 0;
$pay_price = 0; $pay_price = 0;
$cost_price = 0; $cost_price = 0;
foreach ($cart_info as $k => $v) { foreach ($cart_info as $k => $v) {
$total_prices=$v['total_price'];
$v['uid'] = $params['user_id']; $v['uid'] = $params['user_id'];
$v['store_id'] = $params['store_id']; $v['store_id'] = $params['store_id'];
$find = StoreBranchProduct::where('store_id', $params['store_id'])->where('product_id', $v['product_id'])->find(); $find = StoreBranchProduct::where('store_id', $params['store_id'])->where('product_id', $v['product_id'])->find();
@ -179,26 +180,25 @@ class BeforehandOrderLogic extends BaseLogic
$product = StoreProduct::where('id', $v['product_id'])->find(); $product = StoreProduct::where('id', $v['product_id'])->find();
$find = StoreProductLogic::ordinary($product, $params['store_id'], 0, $product); $find = StoreProductLogic::ordinary($product, $params['store_id'], 0, $product);
} }
if (in_array($order['order_type'], [2, 3])) {
if (isset($v['purchase']) && $v['purchase'] > 0) {
$purchase = $v['purchase'];
} else {
$purchase = StoreProduct::where('id', $v['product_id'])->withTrashed()->value('purchase');
$find['purchase'] = $purchase;
// $purchase = $v['price'];
}
$find->save(['price' => $v['price'], 'vip_price' => $v['price'], 'cost' => $v['price'], 'purchase' => $purchase]);
}
$cart_select[$k]['price'] = $v['price']; $cart_select[$k]['price'] = $v['price'];
//判断如果采购价小于售价,则采购价等于售价
if ($v['price']<$find['purchase'] && $find['purchase']!=0) {
$cart_select[$k]['price'] = $find['purchase'];
}
if ($user['user_ship'] == 4 && $find['cost']!=0) {
$cart_select[$k]['price'] = $find['cost'];
$total_prices=bcmul($find['cost'], $v['cart_num'], 2);
}
$cart_select[$k]['cost'] = $find['cost']; $cart_select[$k]['cost'] = $find['cost'];
$cart_select[$k]['purchase'] = $find['purchase'];
$cart_select[$k]['vip'] = 0; $cart_select[$k]['vip'] = 0;
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name') ?? ''; //单位名称 $cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name') ?? ''; //单位名称
//利润 //利润
$cart_select[$k]['total_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'] = $v['total_price']; //订单支付金额 $cart_select[$k]['pay_price'] = $total_prices; //订单支付金额
$cart_select[$k]['total_price'] = $v['total_price']; //订单支付金额 $cart_select[$k]['total_price'] = $total_prices; //订单支付金额
$cart_select[$k]['store_price'] = 0; //商户价 $cart_select[$k]['store_price'] = 0; //商户价
$cart_select[$k]['vip_price'] = 0; //vip售价 $cart_select[$k]['vip_price'] = 0; //vip售价
$cart_select[$k]['product_id'] = $v['product_id']; $cart_select[$k]['product_id'] = $v['product_id'];
@ -215,19 +215,12 @@ class BeforehandOrderLogic extends BaseLogic
$cart_select[$k]['cart_info'] = json_encode($cartInfo); $cart_select[$k]['cart_info'] = json_encode($cartInfo);
//理论上每笔都是拆分了 //理论上每笔都是拆分了
$cart_select[$k]['name'] = $find['store_name']; $cart_select[$k]['name'] = $find['store_name'];
if ($find['purchase'] < $v['price']) {
$cart_select[$k]['purchase'] = $find['purchase'];
} else {
$cart_select[$k]['purchase'] = $v['price'];
}
$cart_select[$k]['store_id'] = $params['store_id'] ?? 0;
$total_price = bcadd($total_price, $v['total_price'], 2); $cart_select[$k]['store_id'] = $params['store_id'] ?? 0;
$pay_price = bcadd($pay_price, $v['total_price'], 2); $total_price = bcadd($total_price, $total_prices, 2);
$pay_price = bcadd($pay_price, $total_prices, 2);
$cost_price = bcadd($pay_price, $cart_select[$k]['total_purchase'], 2); $cost_price = bcadd($pay_price, $cart_select[$k]['total_purchase'], 2);
} }
$user = User::where('id', $params['user_id'])->find();
$order_id = getNewOrderId('PF'); $order_id = getNewOrderId('PF');
$code = rand(1, 10) . '-' . substr($order_id, -5); $code = rand(1, 10) . '-' . substr($order_id, -5);

View File

@ -173,7 +173,7 @@ class PurchaseProductOfferLogic extends BaseLogic
Db::commit(); Db::commit();
$offer['store_name']=$product['store_name']; $offer['store_name']=$product['store_name'];
$offer['unit_name']=$unit_name; $offer['unit_name']=$unit_name;
$offer['buyer_name']=User::where('id',$offer['buyer_id'])->value('real_name'); $offer['buyer_name']=DeliveryService::where('uid',$offer['buyer_id'])->value('nickname');
if($offer['pay_type']==1){ if($offer['pay_type']==1){
$offer['pay_type_name']='赊账'; $offer['pay_type_name']='赊账';
}elseif($offer['pay_type']==2){ }elseif($offer['pay_type']==2){

View File

@ -155,9 +155,14 @@ class StoreOrderLogic extends BaseLogic
} else { } else {
//微信支付 //微信支付
if (in_array($detail['pay_type'], [PayEnum::WECHAT_PAY_MINI, PayEnum::WECHAT_PAY_BARCODE])) { if (in_array($detail['pay_type'], [PayEnum::WECHAT_PAY_MINI, PayEnum::WECHAT_PAY_BARCODE])) {
if(!empty($params['refund_price']) && $params['refund_price']>0){
$money = (int)bcmul($params['refund_price'], 100);
}else{
$money = (int)bcmul($detail['pay_price'], 100); $money = (int)bcmul($detail['pay_price'], 100);
}
$pay_price = (int)bcmul($detail['pay_price'], 100);
$refund = (new \app\common\logic\store_order\StoreOrderLogic()) $refund = (new \app\common\logic\store_order\StoreOrderLogic())
->refund($params['order_id'], $money, $money); ->refund($params['order_id'], $money, $pay_price);
if ($refund) { if ($refund) {
StoreOrderCartInfo::where('oid', $detail['id'])->update(['is_pay' => -1]); StoreOrderCartInfo::where('oid', $detail['id'])->update(['is_pay' => -1]);
return '退款成功'; return '退款成功';

View File

@ -56,7 +56,7 @@ class PurchaseProductOfferListsTwo extends BaseApiDataLists implements ListsSear
$item->store_name=$find->store_name; $item->store_name=$find->store_name;
$item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name'); $item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name');
$item->category_name=StoreCategory::where('id',$find->top_cate_id)->value('name'); $item->category_name=StoreCategory::where('id',$find->top_cate_id)->value('name');
$item->buyer_name=User::where('id',$item['buyer_id'])->value('real_name'); $item->buyer_name=DeliveryService::where('uid',$item->buyer_id)->value('nickname');
}) })
->toArray(); ->toArray();

View File

@ -17,6 +17,7 @@ class ProductOffer
$num = $data['buyer_nums']; $num = $data['buyer_nums'];
$unit_name = $data['unit_name']; $unit_name = $data['unit_name'];
$price = $data['price']; $price = $data['price'];
$total_price = $data['total_price'];
$create_time = $data['create_time']; $create_time = $data['create_time'];
$buyer_name = $data['buyer_name']; $buyer_name = $data['buyer_name'];
$pay_type = $data['pay_type_name']; $pay_type = $data['pay_type_name'];
@ -26,7 +27,8 @@ class ProductOffer
>商品名称:<font color=\"comment\">$store_name</font> >商品名称:<font color=\"comment\">$store_name</font>
>数量/单位:<font color=\"comment\">$num/$unit_name</font> >数量/单位:<font color=\"comment\">$num/$unit_name</font>
>采购人:<font color=\"comment\">$buyer_name</font> >采购人:<font color=\"comment\">$buyer_name</font>
>采购金额:<font color=\"comment\">$price</font> >采购单价:<font color=\"comment\">$price</font>
>采购总价:<font color=\"comment\">$total_price</font>
>采购时间:<font color=\"comment\">$create_time</font> >采购时间:<font color=\"comment\">$create_time</font>
>支付方式:<font color=\"comment\">$pay_type</font> >支付方式:<font color=\"comment\">$pay_type</font>
[下载今日采购表格]($urls)"]]; [下载今日采购表格]($urls)"]];