Merge pull request 'dev' (#112) from dev into master

Reviewed-on: https://gitea.lihaink.cn/mkm/shop-php/pulls/112
This commit is contained in:
mkm 2024-01-06 14:28:31 +08:00
commit 011c26a173
17 changed files with 182 additions and 194 deletions

2
.gitignore vendored
View File

@ -2,6 +2,7 @@
/.vscode
*.log
.env
.example.env
.user.ini
.phpstorm.meta.php
.constant
@ -17,3 +18,4 @@ runtime/*
cert_crmeb copy.key
dump.rdb
config/swoole.php
.example.env

View File

@ -72,7 +72,7 @@ class StoreCartDao extends BaseDao
public function getAll(int $uid,$product_type,$source=0)
{
$where=['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0,'product_type' => $product_type,'source'=>$source];
if($product_type==0 &&$source>0){
if($source==103){
$where=['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0,'source'=>$source];
}
$query = ($this->getModel())::where($where)
@ -87,7 +87,6 @@ class StoreCartDao extends BaseDao
$query->field('mer_id,mer_name,mer_state,mer_avatar,is_trader,type_id,credit_buy,street_id')->with(['type_names']);
}
])->select();
return $query;
}
@ -153,7 +152,11 @@ class StoreCartDao extends BaseDao
*/
public function getCartCount(int $uid,$product_type,$source=0)
{
$count = ($this->getModel()::getDB())->where(['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0,'product_type' => $product_type,'is_fail'=>0,'source'=>$source])->count();
$where=['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0,'product_type' => $product_type,'is_fail'=>0,'source'=>$source];
if($source==103){
$where=['uid' => $uid, 'is_del' => 0, 'is_new' => 0, 'is_pay' => 0,'is_fail'=>0,'source'=>$source];
}
$count = ($this->getModel()::getDB())->where($where)->count();
$data[0]['count'] = $count;
return $data;
}

View File

@ -138,6 +138,9 @@ class StoreOrderDao extends BaseDao
->when(isset($where['order_ids']) && $where['order_ids'] !== '', function ($query) use ($where) {
$query->whereIn('order_id', $where['order_ids']);
})
->when(isset($where['source']) && $where['source'] !== '', function ($query) use ($where) {
$query->whereIn('source', $where['source']);
})
->when(isset($where['order_id']) && $where['order_id'] !== '', function ($query) use ($where) {
if (is_array($where['order_id'])) {
$query->whereIn('order_id', $where['order_id']);

View File

@ -93,8 +93,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
}
if ($cart['product_type'] > 0) {
$order_type = $cart['product_type'];
$source = $cart['source'];
}
$source = $cart['source'];
if ($cart['product_type'] <= 97 && $cart['product_type'] > 0 && (($cart['product_type'] != 10 && count($merchantCart['list']) != 1) || count($merchantCartList) != 1)) {
throw new ValidateException('活动商品必须单独购买');
}
@ -105,30 +105,24 @@ class StoreOrderCreateRepository extends StoreOrderRepository
if ($cart['product']['extend']) {
$order_extend = json_decode($cart['product']['extend'], true);
}
if ($address) {
if ($cart['source'] == 0) {
$userAddressCode = ($address['province_code'] ?? '') . ',' . ($address['city_code'] ?? '') . ',' . ($address['district_code'] ?? '') . ',' . ($address['street_code'] ?? '') . ',' . ($address['village_code'] ?? '') . ',' . ($address['brigade_id'] ?? 0);
$getUrl = env('LOGISTICS_HOST_URL') . '/api/hasCourier?user_address_code=' . $userAddressCode;
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', $getUrl);
$courierData = json_decode($response->getBody(), true);
if (empty($courierData['code']) || $courierData['code'] != 1) {
throw new ValidateException('该收货区域未设置快递员');
}
}
}
}
}
// if (($order_type == 98 || $order_type == 99) && count($merchantCartList) > 1) {
// throw new ValidateException('采购、委托商品不支持跨店购买');
// }
$community = [];
// if ($order_type == 98) {
// $sourceIdArray = [];
// foreach($merchantCart['list'] as $prod){
// if ($prod['source_id'] > 0) {
// $sourceIdArray[] = $prod['source_id'];
// }
// }
// if (count($sourceIdArray)) {
// if (count(array_unique($sourceIdArray)) > 1) {
// throw new ValidateException('转售商品数据异常');
// }
// $community = Db::name('Community')->where('community_id', $sourceIdArray[0] ?? 0)->field('community_id, title, image')->fetchSql(false)->find();
// if ($community) {
// $deliverMethod = Db::name('resale')->where('community_id', $sourceIdArray[0] ?? 0)->value('deliver_method');
// $deliverMethodArray = explode(',', $deliverMethod);
// }
// }
// }
unset($merchantCart, $cart);
$order_price = 0;
$total_true_price = 0;
@ -422,6 +416,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
$cart['coupon_price'] = bcsub($_cartTotalPrice, $cartTotalPrice, 2);
$cart['true_price'] = $cartTotalPrice;
}
$procure = $this->cartByPrice($cart, 1);
$procure_price = bcmul($cart['cart_num'], $procure, 2);
unset($cart, $_k);
$total_true_price = bcadd($_pay_price, $total_true_price, 2);
if (count($merchantCartList) > 1 || count($merchantCart['list']) > 1) {
@ -447,6 +443,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
'delivery_status' => $deliveryStatus,
'svip_discount' => $total_svip_discount,
'use_svip' => $use_svip,
'procure_price' => $procure_price
];
$order_total_postage = bcadd($order_total_postage, $postage_price, 2);
$order_svip_discount = bcadd($total_svip_discount, $order_svip_discount, 2);
@ -549,6 +546,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
$merchantCart['order']['org_price'] = $org_price;
$merchantCart['order']['pay_price'] = $pay_price;
$merchantCart['order']['coupon_price'] = $coupon_price;
$merchantCart['order']['postage_price'] = $merchantCart['order']['postage_price'];
$merchantCart['order']['procure_price'] = $merchantCart['order']['procure_price'];
$order_price = bcadd($order_price, $pay_price, 2);
$order_total_price = bcadd($order_total_price, $total_price, 2);
@ -805,7 +804,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository
'mark' => $mark[$merchantCart['mer_id']] ?? '',
'coupon_price' => bcadd($merchantCart['order']['coupon_price'], $merchantCart['order']['platform_coupon_price'], 2),
'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'],
'pay_type' => $pay_type
'pay_type' => $pay_type,
'procure_price' => $merchantCart['order']['procure_price'],
];
$allUseCoupon = array_merge($allUseCoupon, $merchantCart['order']['useCouponIds']);
$orderList[] = $_order;

View File

@ -311,16 +311,12 @@ class StoreOrderRepository extends BaseRepository
'financial_record_sn' => $financeSn . ($i++)
];
$_payPrice = bcsub($order->pay_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
if ($presell) {
if (isset($order->orderProduct[0]['cart_info']['presell_extension_one']) && $order->orderProduct[0]['cart_info']['presell_extension_one'] > 0) {
$_payPrice = bcadd($_payPrice, $order->orderProduct[0]['cart_info']['presell_extension_one'], 2);
}
if (isset($order->orderProduct[0]['cart_info']['presell_extension_two']) && $order->orderProduct[0]['cart_info']['presell_extension_two'] > 0) {
$_payPrice = bcadd($_payPrice, $order->orderProduct[0]['cart_info']['presell_extension_two'], 2);
}
}
if($order->source==103){
$_payPrice = $order->procure_price;
//计算手续费
$_order_rate=bcsub($order->pay_price,$_payPrice,2);
}else{
$_payPrice = $order->pay_price;
$_order_rate = 0;
//平台手续费
@ -332,40 +328,23 @@ class StoreOrderRepository extends BaseRepository
$_payPrice = bcsub($_payPrice, $_order_rate, 2);
// 结算各镇 小组佣金
event('order.paySuccessOrder', compact('order', '_order_rate'));
// event('order.paySuccessOrder', compact('order', '_order_rate'));
}
}
// bcsub($order->pay_price, bcadd($order['extension_one'], $order['extension_two'], 3), 2);
// if ($presell) {
// if (isset($order->orderProduct[0]['cart_info']['presell_extension_one']) && $order->orderProduct[0]['cart_info']['presell_extension_one'] > 0) {
// $_payPrice = bcadd($_payPrice, $order->orderProduct[0]['cart_info']['presell_extension_one'], 2);
// }
// if (isset($order->orderProduct[0]['cart_info']['presell_extension_two']) && $order->orderProduct[0]['cart_info']['presell_extension_two'] > 0) {
// $_payPrice = bcadd($_payPrice, $order->orderProduct[0]['cart_info']['presell_extension_two'], 2);
// }
// }
if (!$presell) {
if ($order['extension_one'] > 0) {
$finance[] = [
'order_id' => $order->order_id,
'order_sn' => $order->order_sn,
'user_info' => $groupOrder->user->nickname,
'user_id' => $uid,
'financial_type' => 'brokerage_one',
'financial_pm' => 0,
'type' => 1,
'number' => $order['extension_one'],
'mer_id' => $order->mer_id,
'financial_record_sn' => $financeSn . ($i++)
];
}
if ($order['extension_two'] > 0) {
$finance[] = [
'order_id' => $order->order_id,
'order_sn' => $order->order_sn,
'user_info' => $groupOrder->user->nickname,
'user_id' => $uid,
'financial_type' => 'brokerage_two',
'financial_pm' => 0,
'type' => 1,
'number' => $order['extension_two'],
'mer_id' => $order->mer_id,
'financial_record_sn' => $financeSn . ($i++)
];
}
if ($order['commission_rate'] > 0) {
$finance[] = [
'order_id' => $order->order_id,
@ -401,21 +380,21 @@ class StoreOrderRepository extends BaseRepository
'financial_record_sn' => $financeSn . ($i++)
];
if ($order->platform_coupon_price > 0) {
$finance[] = [
'order_id' => $order->order_id,
'order_sn' => $order->order_sn,
'user_info' => $groupOrder->user->nickname,
'user_id' => $uid,
'financial_type' => $isVipCoupon ? 'order_svip_coupon' : 'order_platform_coupon',
'financial_pm' => 0,
'type' => 1,
'number' => $order->platform_coupon_price,
'mer_id' => $order->mer_id,
'financial_record_sn' => $financeSn . ($i++)
];
$_payPrice = bcadd($_payPrice, $order->platform_coupon_price, 2);
}
// if ($order->platform_coupon_price > 0) {
// $finance[] = [
// 'order_id' => $order->order_id,
// 'order_sn' => $order->order_sn,
// 'user_info' => $groupOrder->user->nickname,
// 'user_id' => $uid,
// 'financial_type' => $isVipCoupon ? 'order_svip_coupon' : 'order_platform_coupon',
// 'financial_pm' => 0,
// 'type' => 1,
// 'number' => $order->platform_coupon_price,
// 'mer_id' => $order->mer_id,
// 'financial_record_sn' => $financeSn . ($i++)
// ];
// $_payPrice = bcadd($_payPrice, $order->platform_coupon_price, 2);
// }
if (!$is_combine) {
app()->make(MerchantRepository::class)->addLockMoney($order->mer_id, 'order', $order->order_id, $_payPrice);
}
@ -561,7 +540,7 @@ class StoreOrderRepository extends BaseRepository
}
}
public function cartByPrice($cart)
public function cartByPrice($cart,$type=0)
{
if ($cart['product_type'] == '2') {
return $cart['productPresellAttr']['presell_price'];
@ -584,8 +563,12 @@ class StoreOrderRepository extends BaseRepository
// } else {
// return $cart['productAttr']['price'];
// }
if (in_array($cart['source'],[9,10,11,12,13])) {
if (in_array($cart['source'],[9,10,11,12,13,103])) {
if($type==0){
return $cart['productAttr']['price'];
}else{
return $cart['productAttr']['procure_price'];
}
} else {
return $cart['productAttr']['price'];
}
@ -602,7 +585,11 @@ class StoreOrderRepository extends BaseRepository
return $cart['productAttr']['price'];
}
} else {
if($type==0){
return $cart['productAttr']['price'];
}else{
return $cart['productAttr']['procure_price'];
}
}
}
@ -1798,7 +1785,6 @@ class StoreOrderRepository extends BaseRepository
$arr = $this->getOrderType($status);
$query = $this->dao->search($where)->where($arr)->where('StoreOrder.is_del', 0);
}
$count = $query->count();
$list = $query->with([
'orderProduct',

View File

@ -373,7 +373,11 @@ class Auth extends BaseController
if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') {
$data['is_wsxx'] = 1;
}
if($bank_info){
$data['mer_info'] = array_merge($mer_arr,$bank_info);
}else{
$data['mer_info'] =$mer_arr;
}
$typCode = Db::name('merchant_type')->where('mer_type_id', $mer_arr['type_id'] ?? 0)->value('type_code');
$data['mer_info']['type_code'] = $typCode;
$data['mer_info']['setting_status'] = 0;

View File

@ -97,7 +97,8 @@ class MerchantIntention extends BaseController
'village' => $data['village_id'] ?? '',
'address' => $data['address'] ?? '',
'mer_intention_id' => $intention->mer_intention_id,
'type_id'=>$data['mer_type_id']??''
'type_id'=>$data['mer_type_id']??'',
'is_company'=>$data['is_company']??'',
];
$postUrl = env('TASK_WORKER_HOST_URL') . '/adminapi/company/createShopMerchant';
$res = $this->sendMerIntentionApply($sendData, $postUrl);
@ -214,7 +215,8 @@ class MerchantIntention extends BaseController
'cardno_front' => $data['cardno_front'] ?? '',
'cardno_back' => $data['cardno_back'] ?? '',
'mer_intention_id' => $intentionId,
'type_id'=>$merInfo['type_id']??''
'type_id'=>$merInfo['type_id']??'',
'is_company'=>$intenInfo['is_company']??'',
];
$postUrl = env('TASK_WORKER_HOST_URL') . '/adminapi/company/createShopMerchant';
@ -311,7 +313,8 @@ class MerchantIntention extends BaseController
'village' => $data['village_id'] ?? '',
'address' => $data['address'] ?? '',
'mer_intention_id' => $id,
'type_id'=>$data['mer_type_id']??''
'type_id'=>$data['mer_type_id']??'',
'is_company'=>$data['is_company']??'',
];
$postUrl = env('TASK_WORKER_HOST_URL') . '/adminapi/company/createShopMerchant';

View File

@ -102,22 +102,6 @@ class StoreOrder extends BaseController
if (!($count = count($cartId)) || $count != count($cartRepository->validIntersection($cartId, $uid)))
return app('json')->fail('数据无效');
if ($addressId) {
$addressRepository = app()->make(UserAddressRepository::class);
$address = $addressRepository->getWhere(['uid' => $uid, 'address_id' => $addressId]);
$cartProductType = Db::name('StoreCart')->where('cart_id', $cartId[0] ?? 0)->value('product_type');
$deliveryWay = !empty($takes) ? $takes : [];
if ($cartProductType == 0 && count($deliveryWay) == 0) {
$userAddressCode = ($address['province_code'] ?? '') . ',' . ($address['city_code'] ?? '') . ',' . ($address['district_code'] ?? '') . ',' . ($address['street_code'] ?? '') . ',' . ($address['village_code'] ?? '') . ',' . ($address['brigade_id'] ?? 0);
$getUrl = env('LOGISTICS_HOST_URL') . '/api/hasCourier?user_address_code=' . $userAddressCode;
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', $getUrl);
$courierData = json_decode($response->getBody(), true);
if (empty($courierData['code']) || $courierData['code'] != 1) {
throw new ValidateException('该收货区域未设置快递员');
}
}
}
$groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post) {
return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post);
});

View File

@ -77,16 +77,19 @@ class StoreOrderBehalf extends BaseController
}else{
$where['status']=['=',$status];
}
$column = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where($where)->page($page)->limit($limit)->column('order_id');
if ($column) {
$where['order_id'] = $column;
// $column = Db::name('store_order_behalf')->where('mer_id', $mer_id)->where($where)->page($page)->limit($limit)->column('order_id');
// if ($column) {
// $where['order_id'] = $column;
// }
if ($status == 0) {
$where['status'] = 2;
} elseif ($status == 1) {
$where['status'] = 3;
}
return app('json')->success($this->repository->getList($where, 1, 100));
}
$where['source']=103;
return app('json')->success($this->repository->getList($where, $page, $limit));
}
return app('json')->success([]);
}

View File

@ -33,23 +33,23 @@ class paySuccess
try {
$orderList = $event['groupOrder']['orderList'];
foreach ($orderList as $k => $order) {
$merchant = Merchant::find($order['mer_id']);
// $merchant = Merchant::find($order['mer_id']);
//添加到代发订单表里
if ($merchant['type_id'] == Merchant::TypeSupplyChain) {
$codes = explode(',', $order['user_address_code']);
if (count($codes) > 4) {
$merchant_two = Db::name('merchant')->where('street_id', $codes[3])->where('type_id', 17)->where('category_id', $merchant['category_id'])->find();
if ($merchant_two) {
$datas = [
'master_mer_id' => $order['mer_id'],
'mer_id' => $merchant_two['mer_id'],
'order_id' => $order['order_id'],
'status' => 0
];
Db::name('store_order_behalf')->insert($datas);
}
}
}
// if ($merchant['type_id'] == Merchant::TypeSupplyChain) {
// $codes = explode(',', $order['user_address_code']);
// if (count($codes) > 4) {
// $merchant_two = Db::name('merchant')->where('street_id', $codes[3])->where('type_id', 17)->where('category_id', $merchant['category_id'])->find();
// if ($merchant_two) {
// $datas = [
// 'master_mer_id' => $order['mer_id'],
// 'mer_id' => $merchant_two['mer_id'],
// 'order_id' => $order['order_id'],
// 'status' => 0
// ];
// Db::name('store_order_behalf')->insert($datas);
// }
// }
// }
$this->recordOrderAddr($order);
}
} catch (\Exception $e) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0e276e"],{"7f8a":function(a,t,e){"use strict";e.r(t);var n=function(){var a=this,t=a.$createElement,e=a._self._c||t;return e("div",{staticClass:"divBox"},[e("el-card",{staticClass:"box-card"},[a.FormData?e("form-create",{directives:[{name:"loading",rawName:"v-loading",value:a.loading,expression:"loading"}],ref:"fc",staticClass:"formBox",attrs:{option:a.option,rule:a.FormData.rule,"handle-icon":"false"},on:{submit:a.onSubmit}}):a._e()],1)],1)},o=[],s=e("c7eb"),r=(e("96cf"),e("1da1")),c=e("30ba"),i=e.n(c),u=e("2801"),l=e("0c6d"),m=(e("83d6"),{name:"payType",data:function(){return{option:{form:{labelWidth:"150px"},global:{upload:{props:{onSuccess:function(a,t){200===a.status&&(t.url=a.data.src)}}}}},FormData:null,loading:!1}},components:{formCreate:i.a.$form()},mounted:function(){this.getFrom()},methods:{getFrom:function(){var a=this;this.loading=!0,Object(u["o"])().then(function(){var t=Object(r["a"])(Object(s["a"])().mark((function t(e){return Object(s["a"])().wrap((function(t){while(1)switch(t.prev=t.next){case 0:a.FormData=e.data,a.loading=!1;case 2:case"end":return t.stop()}}),t)})));return function(a){return t.apply(this,arguments)}}()).catch((function(t){a.$message.error(t.message),a.loading=!1}))},onSubmit:function(a){var t=this;l["a"][this.FormData.method.toLowerCase()](this.FormData.api,a).then((function(a){t.$message.success(a.message||"提交成功")})).catch((function(a){t.$message.error(a.message||"提交失败")}))}}}),d=m,f=e("2877"),p=Object(f["a"])(d,n,o,!1,null,"c11bae1c",null);t["default"]=p.exports}}]);

View File

@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d0e276e"],{"7f8a":function(a,t,e){"use strict";e.r(t);var o=function(){var a=this,t=a.$createElement,e=a._self._c||t;return e("div",{staticClass:"divBox"},[e("el-card",{staticClass:"box-card"},[a.FormData?e("form-create",{directives:[{name:"loading",rawName:"v-loading",value:a.loading,expression:"loading"}],ref:"fc",staticClass:"formBox",attrs:{option:a.option,rule:a.FormData.rule,"handle-icon":"false"},on:{submit:a.onSubmit}}):a._e()],1)],1)},n=[],s=e("c7eb"),r=e("5530"),c=(e("96cf"),e("1da1")),i=e("30ba"),u=e.n(i),l=e("2801"),m=e("0c6d"),d=(e("83d6"),{name:"payType",data:function(){return{option:{form:{labelWidth:"150px"},global:{upload:{props:{onSuccess:function(a,t){200===a.status&&(t.url=a.data.src)}}}}},FormData:null,loading:!1}},components:{formCreate:u.a.$form()},mounted:function(){this.getFrom()},methods:{getFrom:function(){var a=this;this.loading=!0,Object(l["o"])().then(function(){var t=Object(c["a"])(Object(s["a"])().mark((function t(e){return Object(s["a"])().wrap((function(t){while(1)switch(t.prev=t.next){case 0:a.FormData=e.data,console.log(Object(r["a"])({},a.FormData)),a.loading=!1;case 3:case"end":return t.stop()}}),t)})));return function(a){return t.apply(this,arguments)}}()).catch((function(t){a.$message.error(t.message),a.loading=!1}))},onSubmit:function(a){var t=this;m["a"][this.FormData.method.toLowerCase()](this.FormData.api,a).then((function(a){t.$message.success(a.message||"提交成功")})).catch((function(a){t.$message.error(a.message||"提交失败")}))}}}),f=d,p=e("2877"),h=Object(p["a"])(f,o,n,!1,null,"333cd322",null);t["default"]=h.exports}}]);

File diff suppressed because one or more lines are too long