Merge branch 'feature/purchase_record' into dev
# Conflicts: # vendor/composer/installed.php
This commit is contained in:
commit
758687c8bd
@ -114,7 +114,7 @@ class StoreCartDao extends BaseDao
|
|||||||
->append(['bc_extension_one', 'bc_extension_two']);
|
->append(['bc_extension_one', 'bc_extension_two']);
|
||||||
},
|
},
|
||||||
'merchant' => function (Relation $query) use ($uid) {
|
'merchant' => function (Relation $query) use ($uid) {
|
||||||
$query->field('mer_id,mer_name,mer_state,mer_avatar,delivery_way,commission_rate,category_id,credit_buy')->with(['coupon' => function ($query) use ($uid) {
|
$query->field('mer_id,mer_name,mer_state,mer_avatar,delivery_way,commission_rate,category_id,credit_buy,settle_cycle,interest_rate')->with(['coupon' => function ($query) use ($uid) {
|
||||||
$query->where('uid', $uid);
|
$query->where('uid', $uid);
|
||||||
},
|
},
|
||||||
'config' => function ($query) {
|
'config' => function ($query) {
|
||||||
|
@ -91,6 +91,9 @@ class StoreOrderDao extends BaseDao
|
|||||||
->when(isset($where['activity_type']) && $where['activity_type'] != '', function ($query) use ($where) {
|
->when(isset($where['activity_type']) && $where['activity_type'] != '', function ($query) use ($where) {
|
||||||
$query->where('activity_type', $where['activity_type']);
|
$query->where('activity_type', $where['activity_type']);
|
||||||
})
|
})
|
||||||
|
->when(isset($where['product_type']) && $where['product_type'] != '', function ($query) use ($where) {
|
||||||
|
$query->where('activity_type', $where['product_type']);
|
||||||
|
})
|
||||||
->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
|
->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
|
||||||
switch ($where['status']) {
|
switch ($where['status']) {
|
||||||
case 0 :
|
case 0 :
|
||||||
|
@ -49,6 +49,9 @@ class MerchantDao extends BaseDao
|
|||||||
->when($is_del !== null, function ($query) use ($is_del) {
|
->when($is_del !== null, function ($query) use ($is_del) {
|
||||||
$query->where('is_del', $is_del);
|
$query->where('is_del', $is_del);
|
||||||
})
|
})
|
||||||
|
->when(isset($where['credit_buy']) && $where['credit_buy'] !== '', function ($query) use ($where) {
|
||||||
|
$query->where('credit_buy', $where['credit_buy']);
|
||||||
|
})
|
||||||
->when(isset($where['is_trader']) && $where['is_trader'] !== '', function ($query) use ($where) {
|
->when(isset($where['is_trader']) && $where['is_trader'] !== '', function ($query) use ($where) {
|
||||||
$query->where('is_trader', $where['is_trader']);
|
$query->where('is_trader', $where['is_trader']);
|
||||||
})
|
})
|
||||||
|
@ -110,4 +110,10 @@ class StoreGroupOrder extends BaseModel
|
|||||||
}
|
}
|
||||||
return $params;
|
return $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function interest()
|
||||||
|
{
|
||||||
|
return $this->hasOne(StoreOrderInterest::class, 'group_order_id', 'group_order_id');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@ use app\common\repositories\store\MerchantTakeRepository;
|
|||||||
class StoreOrder extends BaseModel
|
class StoreOrder extends BaseModel
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const STATUS_WAIT_CONFIRM = 12; //待确认
|
||||||
|
const STATUS_WAIT_PAY = 0; //待支付
|
||||||
|
|
||||||
public static function tablePk(): ?string
|
public static function tablePk(): ?string
|
||||||
{
|
{
|
||||||
return 'order_id';
|
return 'order_id';
|
||||||
@ -177,4 +180,15 @@ class StoreOrder extends BaseModel
|
|||||||
{
|
{
|
||||||
return StoreRefundOrder::where('order_id',$this->order_id)->where('status',3)->sum('refund_price');
|
return StoreRefundOrder::where('order_id',$this->order_id)->where('status',3)->sum('refund_price');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function interest()
|
||||||
|
{
|
||||||
|
return $this->hasOne(StoreOrderInterest::class, 'order_id', 'order_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function allowCreditPay()
|
||||||
|
{
|
||||||
|
return $this->pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY && $this->status == self::STATUS_WAIT_PAY;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
35
app/common/model/store/order/StoreOrderInterest.php
Normal file
35
app/common/model/store/order/StoreOrderInterest.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\store\order;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
class StoreOrderInterest extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
const STATUS_SETTLED = 1; //已结算
|
||||||
|
const STATUS_UNSETTLED = 0; //未结算
|
||||||
|
|
||||||
|
public static function tablePk(): ?string
|
||||||
|
{
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tableName(): string
|
||||||
|
{
|
||||||
|
return 'store_order_interest';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算利息
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function calculateInterest()
|
||||||
|
{
|
||||||
|
$days = ceil((time() - strtotime($this->start_time)) / 86400);
|
||||||
|
$days = max($days ,0);
|
||||||
|
$money = bcmul($this->total_price, $this->rate, 2);
|
||||||
|
return bcmul($days, $money, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,7 @@ namespace app\common\repositories\store\order;
|
|||||||
|
|
||||||
use app\common\dao\store\order\StoreCartDao;
|
use app\common\dao\store\order\StoreCartDao;
|
||||||
use app\common\model\store\order\StoreGroupOrder;
|
use app\common\model\store\order\StoreGroupOrder;
|
||||||
|
use app\common\model\store\order\StoreOrder;
|
||||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||||
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
||||||
use app\common\repositories\store\product\ProductAssistSkuRepository;
|
use app\common\repositories\store\product\ProductAssistSkuRepository;
|
||||||
@ -96,6 +97,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($order_type == 98 && count($merchantCartList) > 1) {
|
||||||
|
throw new ValidateException('采购商品不支持跨店购买');
|
||||||
|
}
|
||||||
unset($merchantCart, $cart);
|
unset($merchantCart, $cart);
|
||||||
|
|
||||||
$order_price = 0;
|
$order_price = 0;
|
||||||
@ -925,7 +929,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
$extend = [];
|
$extend = [];
|
||||||
}
|
}
|
||||||
$orderType = $orderInfo['order_type'];
|
$orderType = $orderInfo['order_type'];
|
||||||
if (!in_array($orderType, [98, 0]) && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))) {
|
if ($orderType != 0 && (count($orderInfo['order']) > 1 || ($orderType != 10 && count($orderInfo['order'][0]['list']) > 1))) {
|
||||||
throw new ValidateException('活动商品请单独购买');
|
throw new ValidateException('活动商品请单独购买');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1216,6 +1220,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository
|
|||||||
$orderProduct = [];
|
$orderProduct = [];
|
||||||
$orderStatus = [];
|
$orderStatus = [];
|
||||||
foreach ($orderList as $order) {
|
foreach ($orderList as $order) {
|
||||||
|
if ($order['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
||||||
|
$order['status'] = StoreOrder::STATUS_WAIT_CONFIRM;
|
||||||
|
}
|
||||||
$cartInfo = $order['cartInfo'];
|
$cartInfo = $order['cartInfo'];
|
||||||
unset($order['cartInfo']);
|
unset($order['cartInfo']);
|
||||||
//创建子订单
|
//创建子订单
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\repositories\store\order;
|
||||||
|
|
||||||
|
use app\common\model\store\order\StoreOrderInterest;
|
||||||
|
use app\common\repositories\BaseRepository;
|
||||||
|
|
||||||
|
class StoreOrderInterestRepository extends BaseRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
public function create($data)
|
||||||
|
{
|
||||||
|
$data['status'] = StoreOrderInterest::STATUS_UNSETTLED;
|
||||||
|
$model = new StoreOrderInterest();
|
||||||
|
return $model->insert($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getByGroupOrder($groupOrderId)
|
||||||
|
{
|
||||||
|
return StoreOrderInterest::where('group_order_id', $groupOrderId)->find();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getByOrder($orderId)
|
||||||
|
{
|
||||||
|
return StoreOrderInterest::where('order_id', $orderId)->find();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -14,6 +14,7 @@ namespace app\common\repositories\store\order;
|
|||||||
use app\common\dao\store\order\StoreOrderDao;
|
use app\common\dao\store\order\StoreOrderDao;
|
||||||
use app\common\model\store\order\StoreGroupOrder;
|
use app\common\model\store\order\StoreGroupOrder;
|
||||||
use app\common\model\store\order\StoreOrder;
|
use app\common\model\store\order\StoreOrder;
|
||||||
|
use app\common\model\store\order\StoreOrderInterest;
|
||||||
use app\common\model\user\User;
|
use app\common\model\user\User;
|
||||||
use app\common\repositories\BaseRepository;
|
use app\common\repositories\BaseRepository;
|
||||||
use app\common\repositories\delivery\DeliveryOrderRepository;
|
use app\common\repositories\delivery\DeliveryOrderRepository;
|
||||||
@ -1689,8 +1690,17 @@ class StoreOrderRepository extends BaseRepository
|
|||||||
$order->presell_price = $order->pay_price;
|
$order->presell_price = $order->pay_price;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($order->pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY && $order->interest) {
|
||||||
|
$order->interest_start_time = $order->interest->start_time;
|
||||||
|
$order->interest_status = $order->interest->status;
|
||||||
|
if ($order->interest_status == StoreOrderInterest::STATUS_SETTLED) {
|
||||||
|
$order->interest_money = $order->interest->interest;
|
||||||
|
} else {
|
||||||
|
$order->interest_money = $order->interest->calculateInterest();
|
||||||
|
}
|
||||||
|
}
|
||||||
$order->takeOrderCount = count($order['takeOrderList']);
|
$order->takeOrderCount = count($order['takeOrderList']);
|
||||||
unset($order['takeOrderList']);
|
unset($order['takeOrderList'], $order->interest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return compact( 'count','list');
|
return compact( 'count','list');
|
||||||
@ -2419,4 +2429,108 @@ class StoreOrderRepository extends BaseRepository
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单结算
|
||||||
|
* @param $id
|
||||||
|
* @param $type
|
||||||
|
* @param $user
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function settle($id, $type, $user)
|
||||||
|
{
|
||||||
|
/** @var StoreGroupOrderRepository $groupOrderRepository */
|
||||||
|
$groupOrderRepository = app()->make(StoreGroupOrderRepository::class);
|
||||||
|
$groupOrderRepository->getAll = true;
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$groupOrder = $groupOrderRepository->detail($user['uid'], $id, false);
|
||||||
|
if (!$groupOrder) {
|
||||||
|
throw new Exception('订单不存在或已支付');
|
||||||
|
}
|
||||||
|
if (!$groupOrder->interest || $groupOrder->interest->status == StoreOrderInterest::STATUS_SETTLED) {
|
||||||
|
throw new Exception('订单无需结算');
|
||||||
|
}
|
||||||
|
$interest = $groupOrder->interest->calculateInterest();
|
||||||
|
$payMoney = bcadd($groupOrder->interest->total_price, $interest, 2);
|
||||||
|
$result = true;
|
||||||
|
$data = ['type' => $type, 'order_id' => $groupOrder->group_order_id, 'paid' => true];
|
||||||
|
if ($payMoney > 0) {
|
||||||
|
if (!in_array($type, ['balance', 'scrcu'])) {
|
||||||
|
if (systemConfig('open_wx_combine')) {
|
||||||
|
$service = new CombinePayService($type, $groupOrder->getCombinePayParams());
|
||||||
|
} else {
|
||||||
|
$service = new PayService($type, $groupOrder->getPayParams($type === 'alipay' ? request()->param('return_url') : ''));
|
||||||
|
}
|
||||||
|
$result = $service->pay($user);
|
||||||
|
$data = array_merge($data, $result, ['paid' => false]);
|
||||||
|
} else {
|
||||||
|
$payTool = PayTool::instance($type);
|
||||||
|
$groupOrder->pay_price = $payMoney;
|
||||||
|
$result = $payTool->pay($groupOrder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($result === true) {
|
||||||
|
$groupOrder->interest->status = StoreOrderInterest::STATUS_SETTLED;
|
||||||
|
$groupOrder->interest->settle_time = date('Y-m-d H:i:s');
|
||||||
|
$groupOrder->interest->interest = $interest;
|
||||||
|
$groupOrder->interest->save();
|
||||||
|
|
||||||
|
/** @var UserBillRepository $userBillRepository */
|
||||||
|
$userBillRepository = app()->make(UserBillRepository::class);
|
||||||
|
$userBillRepository->decBill($user['uid'], 'now_money', 'pay_product', [
|
||||||
|
'link_id' => $groupOrder['group_order_id'],
|
||||||
|
'status' => 1,
|
||||||
|
'title' => '购买商品',
|
||||||
|
'number' => $groupOrder['pay_price'],
|
||||||
|
'mark' => '余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品',
|
||||||
|
'balance' => $user->now_money
|
||||||
|
]);
|
||||||
|
$unSettleCount = StoreOrderInterest::where('mer_id', $groupOrder->interest->mer_id)->where('status', 0)->count();
|
||||||
|
if ($unSettleCount === 0) {
|
||||||
|
/** @var MerchantRepository $merchantRepo */
|
||||||
|
$merchantRepo = app()->make(MerchantRepository::class);
|
||||||
|
$merchantRepo->unfreeze($groupOrder->interest->mer_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Db::commit();
|
||||||
|
return $data;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new Exception($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认接单
|
||||||
|
* @param $user
|
||||||
|
* @param $id
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function confirm($user, $id)
|
||||||
|
{
|
||||||
|
/** @var StoreGroupOrderRepository $groupOrderRepository */
|
||||||
|
$groupOrderRepository = app()->make(StoreGroupOrderRepository::class);
|
||||||
|
$groupOrderRepository->getAll = true;
|
||||||
|
Db::startTrans();
|
||||||
|
try {
|
||||||
|
$groupOrder = $groupOrderRepository->detail($user['uid'], $id, false);
|
||||||
|
if ($groupOrder->pay_type != StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
||||||
|
throw new Exception('订单类型错误');
|
||||||
|
}
|
||||||
|
$order = $groupOrder->orderList[0];
|
||||||
|
if ($order->status != StoreOrder::STATUS_WAIT_CONFIRM) {
|
||||||
|
throw new Exception('订单状态错误');
|
||||||
|
}
|
||||||
|
$order->status = StoreOrder::STATUS_WAIT_PAY;
|
||||||
|
$order->save();
|
||||||
|
Db::commit();
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
throw new Exception($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2299,4 +2299,51 @@ class ProductRepository extends BaseRepository
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入商品
|
||||||
|
* @param $product_id
|
||||||
|
* @param $user
|
||||||
|
* @return bool
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function import($product_id, $user)
|
||||||
|
{
|
||||||
|
$mer_id = Db::name('store_service')->where('uid', $user['uid'])->where('status', 1)->value('mer_id');
|
||||||
|
if ($mer_id == 0) {
|
||||||
|
throw new \Exception('商户不存在');
|
||||||
|
}
|
||||||
|
$find = Db::name('store_product')->where('product_id', $product_id)->find();
|
||||||
|
if ($find) {
|
||||||
|
if ($find['product_type'] != 0) {
|
||||||
|
throw new \Exception('该商品不是普通商品');
|
||||||
|
}
|
||||||
|
$exist = Db::name('store_product')->where('old_product_id', $product_id)->where('mer_id', $mer_id)->find();
|
||||||
|
if ($exist) {
|
||||||
|
throw new \Exception('已经导入过该商品了');
|
||||||
|
}
|
||||||
|
$find['attrValue'] = Db::name('store_product_attr_value')->where('product_id', $find['product_id'])->field('image,price,cost,ot_price,svip_price,stock,bar_code,weight,volume')->select();
|
||||||
|
$find['content'] = Db::name('store_product_content')->where('product_id', $find['product_id'])->value('content');
|
||||||
|
$find['is_show'] = 0;
|
||||||
|
$find['mer_id'] = $mer_id;
|
||||||
|
$find['temp_id'] = "";
|
||||||
|
$find['give_coupon_ids'] = [];
|
||||||
|
$find['params'] = [];
|
||||||
|
$find['extend'] = [];
|
||||||
|
$find['param_temp_id'] = [];
|
||||||
|
$find['mer_labels'] = [];
|
||||||
|
$find['attr'] = [];
|
||||||
|
$find['delivery_way'] = [0 => "2"];
|
||||||
|
$find["guarantee_template_id"] = "";
|
||||||
|
$find['product_type'] = 0;
|
||||||
|
$find['mer_cate_id'] = [0 => 0];
|
||||||
|
$find['is_used'] = 1;
|
||||||
|
$find['status'] = 1;
|
||||||
|
$find['mer_status'] = 1;
|
||||||
|
$find['old_product_id'] = $product_id;
|
||||||
|
$find['slider_image'] = explode(',', $find['slider_image']);
|
||||||
|
unset($find['product_id'], $find['create_time']);
|
||||||
|
}
|
||||||
|
return $this->create($find, 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ class MerchantRepository extends BaseRepository
|
|||||||
*/
|
*/
|
||||||
public function getList($where, $page, $limit, $userInfo)
|
public function getList($where, $page, $limit, $userInfo)
|
||||||
{
|
{
|
||||||
$field = 'care_count,is_trader,type_id,mer_id,mer_banner,mini_banner,mer_name, mark,mer_avatar,product_score,service_score,postage_score,sales,status,is_best,create_time,long,lat,is_margin,service_phone,mer_address,mer_info';
|
$field = 'care_count,is_trader,type_id,mer_id,mer_banner,mini_banner,mer_name, mark,mer_avatar,product_score,service_score,postage_score,sales,status,is_best,create_time,long,lat,is_margin,service_phone,mer_address,mer_info,credit_buy,settle_cycle,interest_rate';
|
||||||
$where['status'] = 1;
|
$where['status'] = 1;
|
||||||
$where['mer_state'] = 1;
|
$where['mer_state'] = 1;
|
||||||
$where['is_del'] = 0;
|
$where['is_del'] = 0;
|
||||||
@ -743,5 +743,34 @@ class MerchantRepository extends BaseRepository
|
|||||||
return [$income, $finance, true];
|
return [$income, $finance, true];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 冻结商户提现
|
||||||
|
* @param $merchantId
|
||||||
|
* @return void
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function freeze($merchantId)
|
||||||
|
{
|
||||||
|
$merchant = $this->get($merchantId);
|
||||||
|
$merchant->is_fronze = 1;
|
||||||
|
$merchant->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解冻商户提现
|
||||||
|
* @param $merchantId
|
||||||
|
* @return void
|
||||||
|
* @throws DataNotFoundException
|
||||||
|
* @throws DbException
|
||||||
|
* @throws ModelNotFoundException
|
||||||
|
*/
|
||||||
|
public function unfreeze($merchantId)
|
||||||
|
{
|
||||||
|
$merchant = $this->get($merchantId);
|
||||||
|
$merchant->is_fronze = 0;
|
||||||
|
$merchant->save();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class Merchant extends BaseController
|
|||||||
public function lst()
|
public function lst()
|
||||||
{
|
{
|
||||||
[$page, $limit] = $this->getPage();
|
[$page, $limit] = $this->getPage();
|
||||||
$where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id', 'type_id','is_trader', 'street_id']);
|
$where = $this->request->params(['keyword', 'order', 'is_best', 'location', 'category_id', 'type_id','is_trader', 'street_id', 'credit_buy']);
|
||||||
if (empty($where['type_id'])) {
|
if (empty($where['type_id'])) {
|
||||||
$where['type_id'] = [MerchantModel::TypeCloudWarehouse, MerchantModel::TypeStore, MerchantModel::TypeSupplyChain, MerchantModel::TypePlatform];
|
$where['type_id'] = [MerchantModel::TypeCloudWarehouse, MerchantModel::TypeStore, MerchantModel::TypeSupplyChain, MerchantModel::TypePlatform];
|
||||||
}
|
}
|
||||||
@ -283,6 +283,9 @@ class Merchant extends BaseController
|
|||||||
if ($this->userInfo['uid'] != $merchant->uid){
|
if ($this->userInfo['uid'] != $merchant->uid){
|
||||||
return app('json')->fail('你不是管理员无法进行提现操作');
|
return app('json')->fail('你不是管理员无法进行提现操作');
|
||||||
}
|
}
|
||||||
|
if ($merchant->is_frozen){
|
||||||
|
return app('json')->fail('账户被冻结,无法进行提现操作');
|
||||||
|
}
|
||||||
$bankInfo = [
|
$bankInfo = [
|
||||||
'name' => $data['financial_bank_name'],
|
'name' => $data['financial_bank_name'],
|
||||||
'bank' => $data['financial_bank_bank'],
|
'bank' => $data['financial_bank_bank'],
|
||||||
|
@ -106,11 +106,11 @@ class StoreOrder extends BaseController
|
|||||||
return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $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);
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($groupOrder['pay_price'] == 0 || $groupOrder['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
if ($groupOrder['pay_price'] == 0) {
|
||||||
$this->repository->paySuccess($groupOrder);
|
$this->repository->paySuccess($groupOrder);
|
||||||
return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]);
|
return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]);
|
||||||
}
|
}
|
||||||
if ($isPc) {
|
if ($isPc || $groupOrder['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
||||||
return app('json')->success(['order_id' => $groupOrder->group_order_id]);
|
return app('json')->success(['order_id' => $groupOrder->group_order_id]);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -240,6 +240,9 @@ class StoreOrder extends BaseController
|
|||||||
if (!$groupOrder)
|
if (!$groupOrder)
|
||||||
return app('json')->fail('订单不存在或已支付');
|
return app('json')->fail('订单不存在或已支付');
|
||||||
$this->repository->changePayType($groupOrder, array_search($type, StoreOrderRepository::PAY_TYPE));
|
$this->repository->changePayType($groupOrder, array_search($type, StoreOrderRepository::PAY_TYPE));
|
||||||
|
if ($groupOrder['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY && !$groupOrder->orderList[0]->allowCreditPay()) {
|
||||||
|
return app('json')->fail('请等待商家确认订单');
|
||||||
|
}
|
||||||
if ($groupOrder['pay_price'] == 0 || $groupOrder['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
if ($groupOrder['pay_price'] == 0 || $groupOrder['pay_type'] == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
|
||||||
$this->repository->paySuccess($groupOrder);
|
$this->repository->paySuccess($groupOrder);
|
||||||
return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]);
|
return app('json')->status('success', '支付成功', ['order_id' => $groupOrder['group_order_id']]);
|
||||||
@ -298,4 +301,37 @@ class StoreOrder extends BaseController
|
|||||||
$res = $orderRepository->show($id, $this->request->uid());
|
$res = $orderRepository->show($id, $this->request->uid());
|
||||||
return app('json')->success($res);
|
return app('json')->success($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单结算
|
||||||
|
* @return mixed
|
||||||
|
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function settle()
|
||||||
|
{
|
||||||
|
$id = $this->request->param('id/d');
|
||||||
|
$type = $this->request->param('type');
|
||||||
|
try {
|
||||||
|
$data = $this->repository->settle($id, $type, $this->request->userInfo());
|
||||||
|
return app('json')->success('success', $data);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return app('json')->fail($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认接单
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function confirm()
|
||||||
|
{
|
||||||
|
$id = $this->request->param('id/d');
|
||||||
|
try {
|
||||||
|
$this->repository->confirm($this->request->userInfo(), $id);
|
||||||
|
return app('json')->success('success');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return app('json')->fail($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,42 +50,13 @@ class StoreMicro extends BaseController
|
|||||||
public function ProductImport(){
|
public function ProductImport(){
|
||||||
$product_id = $this->request->param('id', 0);
|
$product_id = $this->request->param('id', 0);
|
||||||
$user = $this->request->userInfo();
|
$user = $this->request->userInfo();
|
||||||
$mer_id =Db::name('store_service')->where('uid',$user['uid'])->where('status',1)->value('mer_id');
|
try {
|
||||||
if ($mer_id==0) return app('json')->fail('商户id不能为空');
|
/** @var ProductRepository $productRepository */
|
||||||
$find=Db::name('store_product')->where('product_id',$product_id)->find();
|
$productRepository = app()->make(ProductRepository::class);
|
||||||
if($find){
|
$a = $productRepository->import($product_id, $user);
|
||||||
if($find['product_type']!=0){
|
} catch (\Exception $e) {
|
||||||
return app('json')->fail('该商品不是普通商品');
|
return app('json')->fail($e->getMessage());
|
||||||
}
|
|
||||||
$exist = Db::name('store_product')->where('old_product_id', $product_id)->where('mer_id', $mer_id)->find();
|
|
||||||
if($exist){
|
|
||||||
return app('json')->fail('已经导入过该商品了');
|
|
||||||
}
|
|
||||||
$find['attrValue']=Db::name('store_product_attr_value')->where('product_id',$find['product_id'])->field('image,price,cost,ot_price,svip_price,stock,bar_code,weight,volume')->select();
|
|
||||||
$find['content']=Db::name('store_product_content')->where('product_id',$find['product_id'])->value('content');
|
|
||||||
$find['is_show']=0;
|
|
||||||
$find['mer_id']=$mer_id;
|
|
||||||
$find['temp_id']="";
|
|
||||||
$find['give_coupon_ids']=[];
|
|
||||||
$find['params']=[];
|
|
||||||
$find['extend']=[];
|
|
||||||
$find['param_temp_id']=[];
|
|
||||||
$find['mer_labels']=[];
|
|
||||||
$find['attr']=[];
|
|
||||||
$find['delivery_way']=[ 0 => "2"];
|
|
||||||
$find["guarantee_template_id"] = "";
|
|
||||||
$find['product_type']=0;
|
|
||||||
$find['mer_cate_id']=[0 => 0];
|
|
||||||
$find['is_used']=1;
|
|
||||||
$find['status']=1;
|
|
||||||
$find['mer_status']=1;
|
|
||||||
$find['old_product_id']=$product_id;
|
|
||||||
$find['slider_image']=explode(',',$find['slider_image']);
|
|
||||||
unset($find['product_id'],$find['create_time']);
|
|
||||||
}
|
}
|
||||||
/** @var ProductRepository $make */
|
|
||||||
$make = app()->make(ProductRepository::class);
|
|
||||||
$a=$make->create($find,0);
|
|
||||||
if($a){
|
if($a){
|
||||||
return app('json')->success(['data'=>$a,'msg'=>'导入成功']);
|
return app('json')->success(['data'=>$a,'msg'=>'导入成功']);
|
||||||
}else{
|
}else{
|
||||||
|
@ -55,6 +55,7 @@ return [
|
|||||||
\crmeb\listens\AuthCancelActivityListen::class,
|
\crmeb\listens\AuthCancelActivityListen::class,
|
||||||
\crmeb\listens\CloseUserSvipListen::class,
|
\crmeb\listens\CloseUserSvipListen::class,
|
||||||
\crmeb\listens\SendSvipCouponListen::class,
|
\crmeb\listens\SendSvipCouponListen::class,
|
||||||
|
\crmeb\listens\AutoUnfreezeMerchantListen::class,
|
||||||
] : [],
|
] : [],
|
||||||
'pay_success_user_recharge' => [\crmeb\listens\pay\UserRechargeSuccessListen::class],
|
'pay_success_user_recharge' => [\crmeb\listens\pay\UserRechargeSuccessListen::class],
|
||||||
'pay_success_user_order' => [\crmeb\listens\pay\UserOrderSuccessListen::class],
|
'pay_success_user_order' => [\crmeb\listens\pay\UserOrderSuccessListen::class],
|
||||||
@ -67,6 +68,7 @@ return [
|
|||||||
'product.create'=>[\app\listener\ProductCreate::class],
|
'product.create'=>[\app\listener\ProductCreate::class],
|
||||||
'product.sell'=>[\app\listener\CloudProduct::class], //商品上下架
|
'product.sell'=>[\app\listener\CloudProduct::class], //商品上下架
|
||||||
'refund.after'=>[\app\listener\AfterRefund::class],
|
'refund.after'=>[\app\listener\AfterRefund::class],
|
||||||
|
'order.take'=>[\app\listener\OrderTake::class],
|
||||||
],
|
],
|
||||||
|
|
||||||
'subscribe' => [],
|
'subscribe' => [],
|
||||||
|
37
app/listener/OrderTake.php
Normal file
37
app/listener/OrderTake.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare (strict_types=1);
|
||||||
|
|
||||||
|
namespace app\listener;
|
||||||
|
|
||||||
|
use app\common\model\system\merchant\Merchant;
|
||||||
|
use app\common\repositories\store\order\StoreOrderInterestRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单确认收货后置事件
|
||||||
|
*/
|
||||||
|
class OrderTake
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
$order = $event['order'];
|
||||||
|
if ($order['merchant']['interest_rate'] <= 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/** @var StoreOrderInterestRepository $storeOrderInterestRepository */
|
||||||
|
$storeOrderInterestRepository = app()->make(StoreOrderInterestRepository::class);
|
||||||
|
$merchantId = Merchant::where('uid', $order['uid'])->value('mer_id');
|
||||||
|
$data = [
|
||||||
|
'group_order_id' => $order['group_order_id'],
|
||||||
|
'order_id' => $order['order_id'],
|
||||||
|
'mer_id' => $merchantId,
|
||||||
|
'to_mer_id' => $order['mer_id'],
|
||||||
|
'total_price' => $order['total_price'],
|
||||||
|
'rate' => $order['merchant']['interest_rate'],
|
||||||
|
'start_time' => date('Y-m-d H:i:s', strtotime("+{$order['merchant']['settle_cycle']} days")),
|
||||||
|
];
|
||||||
|
return $storeOrderInterestRepository->create($data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -29,6 +29,7 @@ class MerchantUpdateValidate extends Validate
|
|||||||
'mer_address|店铺地址' => 'require|max:128',
|
'mer_address|店铺地址' => 'require|max:128',
|
||||||
'long|店铺经度' => 'max:24',
|
'long|店铺经度' => 'max:24',
|
||||||
'lat|店铺纬度' => 'max:24',
|
'lat|店铺纬度' => 'max:24',
|
||||||
|
'interest_rate|利率' => 'max:0.05',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function isPhone($val)
|
protected function isPhone($val)
|
||||||
|
35
crmeb/listens/AutoUnfreezeMerchantListen.php
Normal file
35
crmeb/listens/AutoUnfreezeMerchantListen.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: CRMEB Team <admin@crmeb.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
namespace crmeb\listens;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\store\order\StoreOrderInterest;
|
||||||
|
use app\common\repositories\system\merchant\MerchantRepository;
|
||||||
|
use crmeb\interfaces\ListenerInterface;
|
||||||
|
use crmeb\services\TimerService;
|
||||||
|
|
||||||
|
class AutoUnfreezeMerchantListen extends TimerService implements ListenerInterface
|
||||||
|
{
|
||||||
|
public function handle($event): void
|
||||||
|
{
|
||||||
|
$this->tick(1000 * 60, function () {
|
||||||
|
request()->clearCache();
|
||||||
|
$unSettle = StoreOrderInterest::whereTime('start_time', '<=', time())->where('status', 0)->group('mer_id')->column('mer_id');
|
||||||
|
/** @var MerchantRepository $merchantRepo */
|
||||||
|
$merchantRepo = app()->make(MerchantRepository::class);
|
||||||
|
foreach ($unSettle as $merId) {
|
||||||
|
$merchantRepo->freeze($merId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
82
crmeb/services/payTool/Balance.php
Normal file
82
crmeb/services/payTool/Balance.php
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace crmeb\services\payTool;
|
||||||
|
|
||||||
|
class Balance extends PayTool
|
||||||
|
{
|
||||||
|
|
||||||
|
public $order;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发起支付
|
||||||
|
* @param $order
|
||||||
|
* @return bool
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function pay($order)
|
||||||
|
{
|
||||||
|
$user = request()->userInfo();
|
||||||
|
if (!systemConfig('yue_pay_status')) {
|
||||||
|
throw new \Exception('未开启余额支付');
|
||||||
|
}
|
||||||
|
if ($user['now_money'] < $order['pay_price']) {
|
||||||
|
throw new \Exception('余额不足,请更换支付方式');
|
||||||
|
}
|
||||||
|
$user->now_money = bcsub($user->now_money, $order['pay_price'], 2);
|
||||||
|
if (!$user->save()) {
|
||||||
|
throw new \Exception('用户余额扣减失败');
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询
|
||||||
|
* @param $order
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function query($order)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款
|
||||||
|
* @param $order
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function refund($order)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发起请求
|
||||||
|
* @param $body
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function request($body)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function success()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function callback($request = null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function refundQuery($refundOrder)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function transfer($withdraw)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -7,21 +7,16 @@ abstract class PayTool
|
|||||||
|
|
||||||
public $config;
|
public $config;
|
||||||
public $error = ['success' => false];
|
public $error = ['success' => false];
|
||||||
const Scrcu = 'scrcu';
|
|
||||||
|
|
||||||
const ClassMap = [
|
|
||||||
self::Scrcu => Scrcu::class,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param $params
|
* @param $params
|
||||||
* @return mixed|Scrcu
|
* @return mixed|PayTool
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function instance($name, $params = [])
|
public static function instance($name, $params = [])
|
||||||
{
|
{
|
||||||
$class = self::ClassMap[$name];
|
$class = 'crmeb\services\payTool\\' . ucfirst($name);
|
||||||
if (class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
return new $class($params);
|
return new $class($params);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,8 @@ Route::group('api/', function () {
|
|||||||
Route::get('verify_code/:id', '/verifyCode');
|
Route::get('verify_code/:id', '/verifyCode');
|
||||||
Route::post('receipt/:id', '/createReceipt');
|
Route::post('receipt/:id', '/createReceipt');
|
||||||
Route::get('delivery/:id', '/getOrderDelivery');
|
Route::get('delivery/:id', '/getOrderDelivery');
|
||||||
|
Route::post('settle', '/settle');
|
||||||
|
Route::post('confirm', '/confirm');
|
||||||
})->prefix('api.store.order.StoreOrder');
|
})->prefix('api.store.order.StoreOrder');
|
||||||
|
|
||||||
// 预售
|
// 预售
|
||||||
|
Loading…
x
Reference in New Issue
Block a user