commit
6c8caccbad
@ -92,6 +92,11 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
->each(function ($item) {
|
||||
// 计算总库存
|
||||
$unit_name=StoreProductUnit::where('id',$item->unit)->value('name');
|
||||
if($item->total_stock){
|
||||
$item->total_stock=bcadd($item->total_stock??0,$item->warehouse_stock??0,2).'|'.$unit_name;
|
||||
}else{
|
||||
$item->total_stock='';
|
||||
}
|
||||
$item->sales=$item->sales.'|'.$unit_name;
|
||||
$item->store_stock=$item->store_stock.'|'.$unit_name;
|
||||
$item->warehouse_stock=$item->warehouse_stock.'|'.$unit_name;
|
||||
@ -115,11 +120,6 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
}else{
|
||||
$item->total_price='0元';
|
||||
}
|
||||
if($item->total_stock){
|
||||
$item->total_stock=bcadd($item->total_stock,$item->warehouse_stock,2).'|'.$unit_name;
|
||||
}else{
|
||||
$item->total_stock='';
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
return $list;
|
||||
|
@ -148,6 +148,8 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
'nickname' => '用户',
|
||||
'total_price' => '总金额',
|
||||
'pay_price' => '实际支付',
|
||||
'status_name' => '状态',
|
||||
'refund_price' => '退款金额',
|
||||
'pay_time' => '支付时间',
|
||||
];
|
||||
return $data;
|
||||
|
@ -51,7 +51,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
|
||||
public function lists(): array
|
||||
{
|
||||
return StoreOrderCartInfo::where($this->searchWhere)
|
||||
->field('oid,uid,cart_info,product_id,store_id,cart_num,price,total_price,create_time')->limit($this->limitOffset, $this->limitLength)
|
||||
->field('oid,uid,product_id,store_id,cart_num,price,total_price,create_time')->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->each(function ($item) {
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->find();
|
||||
if($find){
|
||||
@ -75,6 +75,8 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
|
||||
$item['store_info']=$find['store_info'];//商品规格
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name')??"";
|
||||
$item['cate_name'] = StoreCategory::where('id', $find['cate_id'])->value('name')??"";
|
||||
$item['pay_price'] =$item['total_price'];
|
||||
$item['cart_info'] = $item->toArray()??[];
|
||||
}else{
|
||||
$item['image']='';//商品图片
|
||||
$item['unit_name']='';//商品图片
|
||||
@ -83,6 +85,7 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
|
||||
$item['store_info']='';//商品规格-(数据库叫商品简介)
|
||||
$item['nickname']='';
|
||||
$item['system_store']='';
|
||||
$item['cart_info']=[];
|
||||
}
|
||||
return $item; //返回处理后的数据。
|
||||
})
|
||||
|
@ -7,13 +7,14 @@ use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\user_recharge\UserRecharge;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\user\User;
|
||||
use app\common\lists\ListsExcelInterface;
|
||||
|
||||
/**
|
||||
* 充值记录列表
|
||||
* Class UserRechargeLists
|
||||
* @package app\admin\listsuser_recharge
|
||||
*/
|
||||
class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
|
||||
{
|
||||
|
||||
|
||||
@ -88,4 +89,34 @@ class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
return UserRecharge::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 导出文件名
|
||||
* @return string
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setFileName(): string
|
||||
{
|
||||
return '订单列表';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 导出字段
|
||||
* @return string[]
|
||||
* @author 乔峰
|
||||
* @date 2022/11/24 16:17
|
||||
*/
|
||||
public function setExcelFields(): array
|
||||
{
|
||||
$data = [
|
||||
'id' => 'ID',
|
||||
'order_id'=>'订单号',
|
||||
'nickname' => '用户',
|
||||
'price' => '实际支付',
|
||||
'paid_name' => '状态',
|
||||
'pay_time' => '支付时间',
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
}
|
@ -118,42 +118,44 @@ class StoreOrderLogic extends BaseLogic
|
||||
public static function refund($detail, $params)
|
||||
{
|
||||
if (isset($params['product_arr']) && count($params['product_arr']) > 0) {
|
||||
$refund_price = $params['refund_price'];
|
||||
$refund_num = 0;
|
||||
foreach ($params['product_arr'] as $k => $v) {
|
||||
$find = StoreOrderCartInfo::where('oid', $detail['id'])->where('product_id', $v['product_id'])->find();
|
||||
if ($find) {
|
||||
$refund_num += $v['cart_num'];
|
||||
$cart_num = bcsub($find['cart_num'], $v['cart_num']);
|
||||
$total_price = bcmul($find['price'], $cart_num);
|
||||
$data = ['cart_num' => $cart_num, 'total_price' => $total_price];
|
||||
StoreOrderCartInfo::where('id', $find['id'])->update($data);
|
||||
$arr = StoreFinanceFlowProduct::where('oid', $detail['id'])->where('product_id', $v['product_id'])->select()->toArray();
|
||||
foreach ($arr as $key => $value) {
|
||||
$value['cart_num'] = $cart_num;
|
||||
$value['total_price'] = bcmul($cart_num, $value['price'], 2);
|
||||
$value['number'] = bcmul($value['total_price'], $value['rate'], 2);
|
||||
StoreFinanceFlowProduct::where('id', $value['id'])->update(['delete_time' => time()]);
|
||||
unset($value['id']);
|
||||
$value['create_time'] = strtotime($value['create_time']);
|
||||
$value['update_time'] = strtotime($value['update_time']);
|
||||
StoreFinanceFlowProduct::create($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
$village_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 14)->value('other_uid');
|
||||
$brigade_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 15)->value('other_uid');
|
||||
$transaction_id = StoreFinanceFlow::where('order_id', $detail['id'])->value('transaction_id');
|
||||
StoreFinanceFlow::where('order_id', $detail['id'])->update(['delete_time' => time()]);
|
||||
CommissionnLogic::setStore($detail, $village_uid, $brigade_uid, $transaction_id);
|
||||
|
||||
StoreOrder::where('id', $detail['oid'])->update(['refund_price' => $refund_price, 'refund_num' => $refund_num]);
|
||||
//微信支付
|
||||
if (in_array($detail['pay_type'], [PayEnum::WECHAT_PAY_MINI, PayEnum::WECHAT_PAY_BARCODE])) {
|
||||
$money = (int)bcmul($params['refund_price'], 100);
|
||||
$pay_price = (int)bcmul($detail['pay_price'], 100);
|
||||
$refund = (new \app\common\logic\store_order\StoreOrderLogic())
|
||||
->refund($params['order_id'], $money, $detail['pay_price']);
|
||||
->refund($params['order_id'], $money, $pay_price);
|
||||
if ($refund) {
|
||||
$refund_price = $params['refund_price'];
|
||||
$refund_num = 0;
|
||||
foreach ($params['product_arr'] as $k => $v) {
|
||||
$find = StoreOrderCartInfo::where('oid', $detail['id'])->where('product_id', $v['product_id'])->find();
|
||||
if ($find) {
|
||||
$refund_num += $v['cart_num'];
|
||||
$cart_num = bcsub($find['cart_num'], $v['cart_num']);
|
||||
$total_price = bcmul($find['price'], $cart_num);
|
||||
$data = ['cart_num' => $cart_num, 'total_price' => $total_price];
|
||||
StoreOrderCartInfo::where('id', $find['id'])->update($data);
|
||||
$arr = StoreFinanceFlowProduct::where('oid', $detail['id'])->where('product_id', $v['product_id'])->select()->toArray();
|
||||
foreach ($arr as $key => $value) {
|
||||
$value['cart_num'] = $cart_num;
|
||||
$value['total_price'] = bcmul($cart_num, $value['price'], 2);
|
||||
$value['number'] = bcmul($value['total_price'], $value['rate'], 2);
|
||||
StoreFinanceFlowProduct::where('id', $value['id'])->update(['delete_time' => time()]);
|
||||
unset($value['id']);
|
||||
$value['create_time'] = strtotime($value['create_time']);
|
||||
$value['update_time'] = strtotime($value['update_time']);
|
||||
StoreFinanceFlowProduct::create($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
$village_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 14)->value('other_uid');
|
||||
$brigade_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 15)->value('other_uid');
|
||||
$transaction_id = StoreFinanceFlow::where('order_id', $detail['id'])->value('transaction_id');
|
||||
StoreFinanceFlow::where('order_id', $detail['id'])->update(['delete_time' => time()]);
|
||||
$detail['refund_price']=$refund_price;
|
||||
CommissionnLogic::setStore($detail, $village_uid, $brigade_uid, $transaction_id);
|
||||
|
||||
StoreOrder::where('id', $detail['oid'])->update(['refund_price' => $refund_price, 'refund_num' => $refund_num]);
|
||||
return '退款成功';
|
||||
}
|
||||
}
|
||||
|
@ -302,8 +302,6 @@ class OrderLogic extends BaseLogic
|
||||
if ($uid > 0) {
|
||||
$address = UserAddress::where(['uid' => $uid])->find();
|
||||
if ($address) {
|
||||
$_order['real_name'] = $address['real_name'];
|
||||
$_order['user_phone'] = $address['phone'];
|
||||
if ($address['area']) {
|
||||
$_order['user_address'] = Db::name('geo_area')->where('area_code', $address['area'])->value('area_name') ?? '';
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_finance_flow_product\StoreFinanceFlowProduct;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\user\User;
|
||||
use PDO;
|
||||
use support\Log;
|
||||
|
||||
@ -51,8 +52,8 @@ class CommissionProductLogic extends BaseLogic
|
||||
*/
|
||||
public function a($find, $order, $village_uid, $brigade_uid, $user_ship, $product)
|
||||
{
|
||||
$total_price = bcmul($product['price'], $find['cart_num']);
|
||||
$purchase_price = bcmul($product['purchase'], $find['cart_num']);
|
||||
$total_price = bcmul($product['price'], $find['cart_num'], 2);
|
||||
$purchase_price = bcmul($product['purchase'], $find['cart_num'], 2);
|
||||
$price = $product['purchase'];
|
||||
|
||||
$brigade_number = bcmul($purchase_price, 0.02, 2); //队长
|
||||
@ -69,43 +70,60 @@ class CommissionProductLogic extends BaseLogic
|
||||
$number4 = bcadd($attrition_number, $number2, 2);
|
||||
|
||||
//会员
|
||||
if ($order['spread_uid'] > 0 || $user_ship > 0) {
|
||||
if (in_array($user_ship, [2, 3])) {
|
||||
$vip_number = bcmul($purchase_price, 0.05, 2); //会员利润
|
||||
$data[] = [
|
||||
'nickname' => '会员',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'price' => $price,
|
||||
'other_uid' => $order['spread_uid'],
|
||||
'total_price' => $purchase_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.05,
|
||||
'number' => $vip_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 0,
|
||||
'status' => 1,
|
||||
];
|
||||
$number4=bcadd($number4, $vip_number, 2);
|
||||
} else {
|
||||
$vip_number = bcmul($purchase_price, 0.07, 2); //会员利润
|
||||
$data[] = [
|
||||
'nickname' => '会员',
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => $order['spread_uid'],
|
||||
'price' => $price,
|
||||
'total_price' => $purchase_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.07,
|
||||
'number' => $vip_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 0,
|
||||
'status' => 1,
|
||||
];
|
||||
$number4=bcadd($number4, $vip_number, 2);
|
||||
$uid = 0;
|
||||
if ($order['spread_uid'] > 0) {
|
||||
$uid = $order['spread_uid'];
|
||||
}
|
||||
if ($order['uid'] > 0) {
|
||||
$uid = $order['uid'];
|
||||
}
|
||||
$user = User::where('id', $uid)->find();
|
||||
$delete_time=null;
|
||||
$nickname='会员';
|
||||
if ($user) {
|
||||
$moeny = bcsub($user['total_recharge_amount'], $user['purchase_funds'], 2);
|
||||
if ($moeny < $user['first_purchase_funds']) {
|
||||
$delete_time=1;
|
||||
$nickname='首充没用完,会员不分配';
|
||||
}
|
||||
}
|
||||
if (in_array($user_ship, [2, 3])) {
|
||||
$vip_number = bcmul($purchase_price, 0.05, 2); //会员利润
|
||||
$data[] = [
|
||||
'nickname' => $nickname,
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'price' => $price,
|
||||
'other_uid' => $uid,
|
||||
'total_price' => $purchase_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.05,
|
||||
'number' => $vip_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 0,
|
||||
'status' => 1,
|
||||
'delete_time'=>$delete_time
|
||||
];
|
||||
$number4 = bcadd($number4, $vip_number, 2);
|
||||
} else {
|
||||
$vip_number = bcmul($purchase_price, 0.07, 2); //会员利润
|
||||
$data[] = [
|
||||
'nickname' => $nickname,
|
||||
'store_id' => $order['store_id'],
|
||||
'product_id' => $find['product_id'],
|
||||
'other_uid' => $uid,
|
||||
'price' => $price,
|
||||
'total_price' => $purchase_price,
|
||||
'cart_num' => $find['cart_num'],
|
||||
'rate' => 0.07,
|
||||
'number' => $vip_number,
|
||||
'oid' => $order['id'],
|
||||
'type' => 0,
|
||||
'status' => 1,
|
||||
'delete_time'=>$delete_time
|
||||
];
|
||||
$number4 = bcadd($number4, $vip_number, 2);
|
||||
}
|
||||
//门店利润
|
||||
if ($number3 <= 0) {
|
||||
$store_number = 0;
|
||||
@ -202,8 +220,8 @@ class CommissionProductLogic extends BaseLogic
|
||||
*/
|
||||
public function b($find, $order, $product, $user_ship)
|
||||
{
|
||||
$total_price = bcmul($product['price'], $find['cart_num']);
|
||||
$purchase_price = bcmul($product['purchase'], $find['cart_num']);
|
||||
$total_price = bcmul($product['price'], $find['cart_num'], 2);
|
||||
$purchase_price = bcmul($product['purchase'], $find['cart_num'], 2);
|
||||
$price = $product['purchase'];
|
||||
|
||||
$brigade_number = bcmul($purchase_price, 0.02, 2); //队长
|
||||
@ -312,8 +330,8 @@ class CommissionProductLogic extends BaseLogic
|
||||
public function c($find, $order, $village_uid, $brigade_uid, $user_ship, $product)
|
||||
{
|
||||
// $rose = bcdiv($product['rose'], 100, 2);
|
||||
$total_price = bcmul($product['price'], $find['cart_num']);
|
||||
$purchase_price = bcmul($product['purchase'], $find['cart_num']);
|
||||
$total_price = bcmul($product['price'], $find['cart_num'], 2);
|
||||
$purchase_price = bcmul($product['purchase'], $find['cart_num'], 2);
|
||||
$price = $product['price'];
|
||||
$brigade_number = bcmul($total_price, 0.02, 2); //队长
|
||||
$village_number = bcmul($brigade_number, 0.1, 2); //村长
|
||||
|
@ -106,7 +106,7 @@ class CommissionnLogic extends BaseLogic
|
||||
$financeLogic = new StoreFinanceFlowLogic();
|
||||
$financeLogic->order = $order;
|
||||
$financeLogic->user['uid'] = $order['uid'];
|
||||
$pay_price = $order['pay_price'];
|
||||
$pay_price=bcsub($order['pay_price'],$order['refund_price'],2);
|
||||
$number = StoreFinanceFlowProduct::where('oid', $order['id'])->sum('number');
|
||||
$fees = bcsub($pay_price, $number, 2);
|
||||
if ($fees > 0) {
|
||||
@ -124,7 +124,7 @@ class CommissionnLogic extends BaseLogic
|
||||
$financeLogic->user['uid'] = $order['uid'];
|
||||
$financeLogic->other_arr['vip_uid'] = $uid;
|
||||
$financeLogic->order = $order;
|
||||
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付
|
||||
$financeLogic->in($transaction_id, bcsub($order['pay_price'],$order['refund_price'],2), OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付
|
||||
|
||||
//缴纳齐全了就加商户没有就加到平台
|
||||
$money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find();
|
||||
|
@ -67,7 +67,7 @@ class UserSignLogic extends BaseLogic
|
||||
$write = self::write($order, $total_vip, 0, 1, 9);
|
||||
self::write_log($write, $total_vip, 0, 7);
|
||||
self::write_log($write, $total_vip, 0, 9, 0);
|
||||
User::where('id', $order->uid)->inc('integral', $total_vip)->update();
|
||||
User::where('id', $order->uid)->update(['integral'=>$total_vip,'first_purchase_funds'=>$order['price']]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -250,12 +250,31 @@ class StoreOrderLogic extends BaseLogic
|
||||
if ($order['pay_type'] == 19){
|
||||
$order['deduction_price'] = "0.00";
|
||||
}
|
||||
|
||||
$detail =StoreOrderCartInfo::where('oid',$order['id'])->find()->toArray();
|
||||
$product=StoreOrderCartInfo::where(['oid'=>$order['id']])
|
||||
->field('oid,uid,product_id,store_id,cart_num,price,total_price,create_time')
|
||||
->select()->each(function ($item) {
|
||||
$find=StoreProduct::where('id',$item['product_id'])->field('image,unit,store_name,store_info')->find();
|
||||
if($find){
|
||||
$item['image']=$find['image'];//商品图片
|
||||
$item['name']=$find['store_name'];//商品名称
|
||||
$item['store_info']=$find['store_info'];//商品规格
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name')??"";
|
||||
$item['pay_price'] =$item['total_price'];
|
||||
$item['cart_info'] = $item->toArray()??[];
|
||||
}else{
|
||||
$item['image']='';//商品图片
|
||||
$item['unit_name']='';//商品图片
|
||||
$item['cate_name']='';//商品图片
|
||||
$item['store_name']='';//商品名称
|
||||
$item['store_info']='';//商品规格-(数据库叫商品简介)
|
||||
$item['nickname']='';
|
||||
$item['system_store']='';
|
||||
$item['cart_info']=[];
|
||||
}
|
||||
return $item; //返回处理后的数据。
|
||||
});
|
||||
$order['product']=$product;
|
||||
$vip =0;
|
||||
if(isset($detail['cart_info']['vip']) && $detail['cart_info']['vip'] == 1){
|
||||
$vip = 1;
|
||||
}
|
||||
$order['vip'] = $vip;
|
||||
return $order->toArray();
|
||||
}
|
||||
@ -371,7 +390,7 @@ class StoreOrderLogic extends BaseLogic
|
||||
return false;
|
||||
} catch (Exception $e) {
|
||||
\support\Log::info($e->extra['message'] ?? $e->getMessage());
|
||||
throw new BusinessException($e->getMessage());
|
||||
throw new BusinessException($e->extra['message'] ?? $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user