commit
dafbf30f85
@ -0,0 +1,132 @@ |
||||
<?php |
||||
// +---------------------------------------------------------------------- |
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||
// +---------------------------------------------------------------------- |
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||
// +---------------------------------------------------------------------- |
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||
// +---------------------------------------------------------------------- |
||||
// | Author: 萤火科技 <admin@yiovo.com> |
||||
// +---------------------------------------------------------------------- |
||||
declare (strict_types=1); |
||||
|
||||
namespace app\admin\controller; |
||||
|
||||
use think\response\Json; |
||||
use app\admin\controller\Controller; |
||||
use app\admin\model\Channel as ChannelModel; |
||||
use app\common\model\UploadFile; |
||||
/** |
||||
* 商家后台菜单控制器 |
||||
* Class Menu |
||||
* @package app\store\controller |
||||
*/ |
||||
class Channel extends Controller |
||||
{ |
||||
/** |
||||
* 菜单列表 |
||||
* @return Json |
||||
* @throws \think\db\exception\DataNotFoundException |
||||
* @throws \think\db\exception\DbException |
||||
* @throws \think\db\exception\ModelNotFoundException |
||||
*/ |
||||
public function index(): Json |
||||
{ |
||||
$model = new ChannelModel; |
||||
$list = $model->getList()->toArray(); |
||||
foreach ($list['data'] as $kr => &$r) { |
||||
$r['licenseImg'] = []; |
||||
if ($r['license_img_id']) { |
||||
$img_ids = explode(",", $r['license_img_id']); |
||||
$files = UploadFile::getFileList($img_ids, 0); |
||||
$r['licenseImg'] = $files ?: null; |
||||
} |
||||
} |
||||
return $this->renderSuccess(compact('list')); |
||||
} |
||||
|
||||
/** |
||||
* 菜单详情 |
||||
* @param int $menuId |
||||
* @return Json |
||||
* @throws \think\db\exception\DataNotFoundException |
||||
* @throws \think\db\exception\DbException |
||||
* @throws \think\db\exception\ModelNotFoundException |
||||
*/ |
||||
public function info(int $id): Json |
||||
{ |
||||
// 菜单详情 |
||||
$model = ChannelModel::detail($id); |
||||
return $this->renderSuccess(['info' => $model]); |
||||
} |
||||
|
||||
/** |
||||
* 新增菜单 |
||||
* @return Json |
||||
*/ |
||||
public function add(): Json |
||||
{ |
||||
// 新增记录 |
||||
$model = new ChannelModel; |
||||
if ($model->add($this->postForm())) { |
||||
return $this->renderSuccess('添加成功'); |
||||
} |
||||
return $this->renderError($model->getError() ?: '添加失败'); |
||||
} |
||||
|
||||
/** |
||||
* 编辑菜单 |
||||
* @param $menuId |
||||
* @return Json |
||||
* @throws \think\db\exception\DataNotFoundException |
||||
* @throws \think\db\exception\DbException |
||||
* @throws \think\db\exception\ModelNotFoundException |
||||
*/ |
||||
public function edit(int $id): Json |
||||
{ |
||||
// 菜单详情 |
||||
$model = ChannelModel::detail($id); |
||||
// 更新记录 |
||||
if ($model->edit($this->postForm())) { |
||||
return $this->renderSuccess('更新成功'); |
||||
} |
||||
return $this->renderError($model->getError() ?: '更新失败'); |
||||
} |
||||
|
||||
/** |
||||
* 设置菜单绑定的Api |
||||
* @param int $menuId |
||||
* @return Json |
||||
* @throws \think\db\exception\DataNotFoundException |
||||
* @throws \think\db\exception\DbException |
||||
* @throws \think\db\exception\ModelNotFoundException |
||||
*/ |
||||
public function setApis(int $menuId): Json |
||||
{ |
||||
// 菜单详情 |
||||
$model = MenuModel::detail($menuId); |
||||
// 更新记录 |
||||
if ($model->setApis($this->postForm())) { |
||||
return $this->renderSuccess('操作成功'); |
||||
} |
||||
return $this->renderError($model->getError() ?: '操作失败'); |
||||
} |
||||
|
||||
/** |
||||
* 删除菜单 |
||||
* @param int $menuId |
||||
* @return Json |
||||
* @throws \think\db\exception\DataNotFoundException |
||||
* @throws \think\db\exception\DbException |
||||
* @throws \think\db\exception\ModelNotFoundException |
||||
*/ |
||||
public function delete(int $menuId): Json |
||||
{ |
||||
// 菜单详情 |
||||
$model = MenuModel::detail($menuId); |
||||
if (!$model->remove()) { |
||||
return $this->renderError($model->getError() ?: '删除失败'); |
||||
} |
||||
return $this->renderSuccess('删除成功'); |
||||
} |
||||
} |
@ -0,0 +1,105 @@ |
||||
<?php |
||||
// +---------------------------------------------------------------------- |
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||
// +---------------------------------------------------------------------- |
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||
// +---------------------------------------------------------------------- |
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||
// +---------------------------------------------------------------------- |
||||
// | Author: 萤火科技 <admin@yiovo.com> |
||||
// +---------------------------------------------------------------------- |
||||
declare (strict_types=1); |
||||
|
||||
namespace app\admin\model; |
||||
|
||||
use app\common\model\Channel as ChannelModel; |
||||
|
||||
/** |
||||
* 商家后台菜单模型 |
||||
* Class Menu |
||||
* @package app\admin\model\store |
||||
*/ |
||||
class Channel extends ChannelModel |
||||
{ |
||||
|
||||
|
||||
|
||||
/** |
||||
* 新增记录 |
||||
* @param array $data |
||||
* @return bool |
||||
*/ |
||||
public function add(array $data): bool |
||||
{ |
||||
return $this->save($data); |
||||
} |
||||
|
||||
/** |
||||
* 更新记录 |
||||
* @param array $data |
||||
* @return bool |
||||
* @throws \think\db\exception\DataNotFoundException |
||||
* @throws \think\db\exception\DbException |
||||
* @throws \think\db\exception\ModelNotFoundException |
||||
*/ |
||||
public function edit(array $data): bool |
||||
{ |
||||
|
||||
return $this->save($data); |
||||
} |
||||
|
||||
/** |
||||
* 设置菜单的API权限 |
||||
* @param array $data |
||||
* @return bool |
||||
*/ |
||||
public function setApis(array $data): bool |
||||
{ |
||||
if (empty($data['apiIds'])) { |
||||
$this->error = 'API权限不能为空'; |
||||
return false; |
||||
} |
||||
// 根据菜单id批量更新API关联记录 |
||||
return (new MenuApiModel)->updateByMenuId($this['menu_id'], $data['apiIds']); |
||||
} |
||||
|
||||
/** |
||||
* 删除菜单 |
||||
* @return bool |
||||
* @throws \think\db\exception\DataNotFoundException |
||||
* @throws \think\db\exception\DbException |
||||
* @throws \think\db\exception\ModelNotFoundException |
||||
* @throws \Exception |
||||
*/ |
||||
public function remove(): bool |
||||
{ |
||||
// 判断是否存在下级菜单 |
||||
if (self::detail(['parent_id' => $this['menu_id']])) { |
||||
$this->error = '当前菜单下存在子菜单或操作,请先删除'; |
||||
return false; |
||||
} |
||||
return $this->delete(); |
||||
} |
||||
|
||||
/** |
||||
* 获取所有上级id集 |
||||
* @param int $menuId |
||||
* @param null $menuList |
||||
* @return array |
||||
* @throws \think\db\exception\DataNotFoundException |
||||
* @throws \think\db\exception\DbException |
||||
* @throws \think\db\exception\ModelNotFoundException |
||||
*/ |
||||
private function getTopMenuIds(int $menuId, $menuList = null): array |
||||
{ |
||||
static $ids = []; |
||||
is_null($menuList) && $menuList = $this->getAll(); |
||||
foreach ($menuList as $item) { |
||||
if ($item['menu_id'] == $menuId && $item['parent_id'] > 0) { |
||||
$ids[] = $item['parent_id']; |
||||
$this->getTopMenuIds($item['parent_id'], $menuList); |
||||
} |
||||
} |
||||
return $ids; |
||||
} |
||||
} |
@ -0,0 +1,206 @@ |
||||
<?php |
||||
|
||||
declare (strict_types=1); |
||||
|
||||
namespace app\command; |
||||
|
||||
use think\console\Command; |
||||
use think\console\Output; |
||||
use think\console\Input; |
||||
use think\facade\Db; |
||||
use app\common\model\Order; |
||||
use app\common\model\Store; |
||||
use app\common\enum\payment\Method as PaymentMethodEnum; |
||||
use app\common\model\MerchantPay as merchantPayModel; |
||||
use app\common\model\Merchant as merchantModel; |
||||
use EasyWeChat\Factory; |
||||
use app\common\model\PaymentTemplate; |
||||
use app\common\model\Payment; |
||||
use app\common\model\PaymentTrade; |
||||
use app\common\model\wxapp\Setting; |
||||
use app\common\enum\Client as ClientEnum; |
||||
use app\common\library\payment\Facade as PaymentFacade; |
||||
use app\common\library\Log; |
||||
|
||||
// /www/server/php/74/bin/php /server/wwwroot/yanzong/think test |
||||
class ProfitSharing extends Command |
||||
{ |
||||
protected function configure() |
||||
{ |
||||
// 指令配置 |
||||
$this->setName('ProfitSharing')->setDescription('自动分账'); |
||||
$this->addArgument("store_id"); |
||||
$this->addArgument("div"); |
||||
$this->addArgument("mod"); |
||||
} |
||||
|
||||
protected function execute(Input $input, Output $output) |
||||
{ |
||||
$store_id = $input->getArgument("store_id"); |
||||
$div = $input->getArgument("div"); |
||||
$mod = $input->getArgument("mod"); |
||||
$limit = 100; |
||||
while (TRUE) { |
||||
echo $store_id.PHP_EOL; |
||||
$sql = "SELECT store_id FROM `yoshop_store` WHERE store_id > " . $store_id . " AND store_id % ". $div . " = ". $mod ." AND store_version = 1 AND is_delete = 0 AND is_recycle = 0 AND status = 1 order by store_id asc LIMIT ".$limit; |
||||
$stores = Db::query($sql); |
||||
if (!$stores) { |
||||
echo "没有多商户商城了".PHP_EOL; |
||||
return false; |
||||
} |
||||
//var_dump($stores); |
||||
foreach ($stores as $store) { |
||||
|
||||
$where = []; |
||||
//查询已完成的订单,并且未分账的订单 |
||||
$where[] = ['order_status','=', 30]; |
||||
$where[] = ['pay_status','=', 20]; |
||||
$where[] = ['is_refund','=', 10]; |
||||
$where[] = ['is_delete','=', 0]; |
||||
$where[] = ['profitsharing_status','=', 0]; |
||||
$where[] = ['store_id','=', $store['store_id']]; |
||||
$where[] = ['merchant_id','>', 0]; |
||||
$where[] = ['commission_ratio','>', 0]; |
||||
$orders = Order::where($where) |
||||
->field('order_id,total_price,order_price,pay_price,pay_method,cost_price,merchant_id,store_id,order_status,pay_status,delivery_status,receipt_status,delivery_type,delivery_time,create_time,trade_id,commission_ratio') |
||||
->select(); |
||||
// var_dump($orders->toArray()); |
||||
// exit(); |
||||
if ($orders->isEmpty()) { |
||||
echo $store['store_id']."没有已完成的订单要分账".PHP_EOL; |
||||
continue; |
||||
} |
||||
//微信支付订单抽佣给平台、余额支付抽佣给平台,把订单金额记录到商户账上 |
||||
foreach ($orders as $order) { |
||||
try { |
||||
//余额支付 |
||||
if ($order->pay_method == PaymentMethodEnum::BALANCE) { |
||||
//增加商户支付详情 |
||||
$model = \app\store\model\Merchant::detail($order->merchant_id, $order->store_id); |
||||
$precent = 1; |
||||
if ($model['commission_ratio'] > 0) { |
||||
$precent = (1 - $model['commission_ratio'] / 1000); |
||||
} |
||||
$precentPrice = round($precent * $order->pay_price, 2); |
||||
(new merchantPayModel())->addDetail($order, $precentPrice); |
||||
|
||||
//累计商户余额支付金额 |
||||
merchantModel::setIncTotal($order->merchant_id, $precentPrice); |
||||
|
||||
//更新 |
||||
$ret = Order::where('order_id',$order->order_id)->update(['profitsharing_status' => 2, 'profitsharing_time' => time()]); |
||||
echo "余额支付分账成功".PHP_EOL; |
||||
var_dump($ret); |
||||
} elseif($order->pay_method == PaymentMethodEnum::WECHAT){//微信支付 |
||||
//商户微信支付配置 |
||||
$payment = Payment::where('store_id', $order->store_id)->where('merchant_id', $order->merchant_id)->where('method',PaymentMethodEnum::WECHAT)->where('is_enable', 1)->find(); |
||||
if (!$payment) { |
||||
echo $store['store_id']."微信支付方式没有配置".PHP_EOL; |
||||
continue; |
||||
} |
||||
$payment_template = PaymentTemplate::where('template_id', $payment->template_id)->where('is_delete', 0)->find(); |
||||
if (!$payment_template) { |
||||
echo $store['store_id']." ".$payment->template_id."微信支付模版没有配置".PHP_EOL; |
||||
continue; |
||||
} |
||||
$wechat_config = $payment_template['config'] ?? []; |
||||
if (!$wechat_config) { |
||||
echo $store['store_id'].$payment->template_id."微信支付模版没有配置11".PHP_EOL; |
||||
continue; |
||||
} |
||||
$wechat_config = $wechat_config['wechat']['normal'] ?? []; |
||||
//小程序配置 |
||||
$mini = Setting::where('store_id', $order->store_id)->find(); |
||||
if (!$mini) { |
||||
echo $store['store_id']."小程序配置没有".PHP_EOL; |
||||
continue; |
||||
} |
||||
$mini_config = $mini['values'] ?? []; |
||||
if (!$mini_config) { |
||||
echo $store['store_id'].$payment->template_id."微信支付模版没有配置11".PHP_EOL; |
||||
continue; |
||||
} |
||||
//支付信息初始化 |
||||
$PaymentModel = new Payment; |
||||
$templateInfo = $PaymentModel->getPaymentInfo(PaymentMethodEnum::WECHAT, ClientEnum::MP_WEIXIN, $order->store_id, $order->merchant_id); |
||||
$options = $templateInfo['template']['config'][PaymentMethodEnum::WECHAT]; |
||||
$payment = PaymentFacade::store(PaymentMethodEnum::WECHAT)->setOptions($options, ClientEnum::MP_WEIXIN); |
||||
|
||||
//平台微信支付配置信息 |
||||
$platform_payment = Payment::where('store_id', $order->store_id)->where('merchant_id', 0)->where('method',PaymentMethodEnum::WECHAT)->where('is_enable', 1)->find(); |
||||
if (!$platform_payment) { |
||||
echo $store['store_id']."微信支付方式没有配置".PHP_EOL; |
||||
continue; |
||||
} |
||||
$platform_payment_template = PaymentTemplate::where('template_id', $platform_payment->template_id)->where('is_delete', 0)->find(); |
||||
if (!$platform_payment_template) { |
||||
echo $store['store_id'].$platform_payment->template_id."微信支付模版没有配置".PHP_EOL; |
||||
continue; |
||||
} |
||||
$platform_wechat_config = $platform_payment_template['config'] ?? []; |
||||
if (!$platform_wechat_config) { |
||||
echo $store['store_id'].$platform_payment->template_id."微信支付模版没有配置11".PHP_EOL; |
||||
continue; |
||||
} |
||||
$platform_wechat_config = $platform_wechat_config['wechat']['normal'] ?? []; |
||||
|
||||
var_dump($order->trade_id); |
||||
$payment_trade = PaymentTrade::where('trade_id', $order->trade_id)->field('trade_no')->find(); |
||||
if (!$payment_trade) { |
||||
echo $store['store_id'].$platform_payment->template_id."没有交易流水号".PHP_EOL; |
||||
continue; |
||||
} |
||||
|
||||
if ($order->commission_ratio <= 0) { |
||||
echo $order->merchant_id."当前商户无需抽佣".PHP_EOL; |
||||
continue; |
||||
} |
||||
$precent = $order->commission_ratio / 1000; |
||||
$precentPrice = round($precent * $order->pay_price * 100, 2); |
||||
var_dump($precentPrice); |
||||
//$precentPrice = 100; |
||||
if ($precentPrice <= 0) { |
||||
echo $order->order_id.":当前订单抽佣金额小于等于0".$precentPrice.PHP_EOL; |
||||
continue; |
||||
} |
||||
//var_dump($payment); |
||||
//$ret = $payment->addReceiver("MERCHANT_ID", $platform_wechat_config['mchId'], "武汉市汉阳区静好电子商务商行(个体工商户)", "HEADQUARTER"); |
||||
$ret = $payment->addReceiver("MERCHANT_ID", $platform_wechat_config['mchId'], $platform_payment_template['name'], "HEADQUARTER"); |
||||
//exit(); |
||||
$transaction_id = $payment_trade->trade_no; |
||||
$out_trade_no = "ps".date("YmdHis").mt_rand(1000,9999); |
||||
$receivers = [ |
||||
[ |
||||
"type" => "MERCHANT_ID", |
||||
"account" => $platform_wechat_config['mchId'], |
||||
"amount" => $precentPrice, |
||||
"description" => "分到平台" |
||||
] |
||||
]; |
||||
var_dump($receivers); |
||||
$sharing = $payment->profitsharing($transaction_id, $out_trade_no, $receivers); |
||||
var_dump($sharing); |
||||
|
||||
//更新 |
||||
$ret = Order::where('order_id',$order->order_id)->update(['profitsharing_status' => 1, 'profitsharing_time' => time(),'out_order_no' => $out_trade_no]); |
||||
echo "微信支付分账中".PHP_EOL; |
||||
var_dump($ret); |
||||
} |
||||
} catch (\Exception $e) { |
||||
Log::append('微信支付分账失败', [$order->order_id.":".$e->getMessage()]); |
||||
echo $order->order_id.":".$e->getMessage(); |
||||
//$ret = Order::where('order_id',$order->order_id)->update(['profitsharing_status' => 3, 'profitsharing_time' => time(),'out_order_no' => $out_trade_no]); |
||||
continue; |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
$store_id = end($stores)['store_id']; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,131 @@ |
||||
<?php |
||||
|
||||
declare (strict_types=1); |
||||
|
||||
namespace app\command; |
||||
|
||||
use think\console\Command; |
||||
use think\console\Output; |
||||
use think\console\Input; |
||||
use think\facade\Db; |
||||
use app\common\model\Order; |
||||
use app\common\model\Store; |
||||
use app\common\enum\payment\Method as PaymentMethodEnum; |
||||
use app\common\model\MerchantPay as merchantPayModel; |
||||
use app\common\model\Merchant as merchantModel; |
||||
use EasyWeChat\Factory; |
||||
use app\common\model\PaymentTemplate; |
||||
use app\common\model\Payment; |
||||
use app\common\model\PaymentTrade; |
||||
use app\common\model\wxapp\Setting; |
||||
use app\common\enum\Client as ClientEnum; |
||||
use app\common\library\payment\Facade as PaymentFacade; |
||||
|
||||
// /www/server/php/74/bin/php /server/wwwroot/yanzong/think test |
||||
class ProfitSharingResult extends Command |
||||
{ |
||||
protected function configure() |
||||
{ |
||||
// 指令配置 |
||||
$this->setName('ProfitSharingResult')->setDescription('自动分账'); |
||||
$this->addArgument("order_id"); |
||||
} |
||||
|
||||
protected function execute(Input $input, Output $output) |
||||
{ |
||||
$order_id = $input->getArgument("order_id"); |
||||
if ($order_id) { |
||||
$where[] = ['order_id','=', $order_id]; |
||||
} else { |
||||
//查询已完成的订单,并且未分账的订单 |
||||
$where[] = ['order_status','=', 30]; |
||||
$where[] = ['pay_status','=', 20]; |
||||
$where[] = ['is_refund','=', 10]; |
||||
$where[] = ['is_delete','=', 0]; |
||||
$where[] = ['profitsharing_status','=', 1]; |
||||
$where[] = ['merchant_id','>', 0]; |
||||
$where[] = ['pay_method','=', PaymentMethodEnum::WECHAT]; |
||||
} |
||||
|
||||
$orders = Order::where($where) |
||||
->field('order_id,total_price,order_price,pay_price,pay_method,cost_price,merchant_id,store_id,order_status,pay_status,delivery_status,receipt_status,delivery_type,delivery_time,create_time,out_order_no,trade_id,commission_ratio') |
||||
->select(); |
||||
// var_dump($orders->toArray()); |
||||
// exit(); |
||||
if ($orders->isEmpty()) { |
||||
echo "没有已完成的订单要分账".PHP_EOL; |
||||
return false; |
||||
} |
||||
//微信支付订单抽佣给平台、余额支付抽佣给平台,把订单金额记录到商户账上 |
||||
foreach ($orders as $order) { |
||||
|
||||
try { |
||||
//商户微信支付配置 |
||||
$payment = Payment::where('store_id', $order->store_id)->where('merchant_id', $order->merchant_id)->where('method',PaymentMethodEnum::WECHAT)->where('is_enable', 1)->find(); |
||||
if (!$payment) { |
||||
echo $order['store_id']."微信支付方式没有配置".PHP_EOL; |
||||
continue; |
||||
} |
||||
$payment_template = PaymentTemplate::where('template_id', $payment->template_id)->where('is_delete', 0)->find(); |
||||
if (!$payment_template) { |
||||
echo $order['store_id'].$payment->template_id."微信支付模版没有配置".PHP_EOL; |
||||
continue; |
||||
} |
||||
$wechat_config = $payment_template['config'] ?? []; |
||||
if (!$wechat_config) { |
||||
echo $order['store_id'].$payment->template_id."微信支付模版没有配置11".PHP_EOL; |
||||
continue; |
||||
} |
||||
$wechat_config = $wechat_config['wechat']['normal'] ?? []; |
||||
//小程序配置 |
||||
$mini = Setting::where('store_id', $order->store_id)->find(); |
||||
if (!$mini) { |
||||
echo $order['store_id']."小程序配置没有".PHP_EOL; |
||||
continue; |
||||
} |
||||
$mini_config = $mini['values'] ?? []; |
||||
if (!$mini_config) { |
||||
echo $order['store_id'].$payment->template_id."微信支付模版没有配置11".PHP_EOL; |
||||
continue; |
||||
} |
||||
//分账 |
||||
//支付信息初始化 |
||||
$PaymentModel = new Payment; |
||||
$templateInfo = $PaymentModel->getPaymentInfo(PaymentMethodEnum::WECHAT, ClientEnum::MP_WEIXIN, $order->store_id, $order->merchant_id); |
||||
|
||||
$options = $templateInfo['template']['config'][PaymentMethodEnum::WECHAT]; |
||||
$payment = PaymentFacade::store(PaymentMethodEnum::WECHAT)->setOptions($options, ClientEnum::MP_WEIXIN); |
||||
|
||||
// var_dump($payment); |
||||
// exit(); |
||||
|
||||
$payment_trade = PaymentTrade::where('trade_id', $order->trade_id)->field('trade_no')->find(); |
||||
if (!$payment_trade) { |
||||
echo $order['store_id']."没有交易流水号".PHP_EOL; |
||||
continue; |
||||
} |
||||
$transaction_id = $payment_trade->trade_no; |
||||
$sharing = $payment->profitsharingQuery($order->out_order_no, $transaction_id); |
||||
var_dump($sharing); |
||||
|
||||
if ($sharing['state'] == "FINISHED") { |
||||
//更新 |
||||
$ret = Order::where('order_id',$order->order_id)->update(['profitsharing_status' => 2, 'profitsharing_time' => time()]); |
||||
echo "微信支付分账结果".PHP_EOL; |
||||
var_dump($ret); |
||||
} |
||||
|
||||
} catch (\Exception $e) { |
||||
echo $e->getMessage(); |
||||
continue; |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,71 @@ |
||||
<?php |
||||
// +---------------------------------------------------------------------- |
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||
// +---------------------------------------------------------------------- |
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||
// +---------------------------------------------------------------------- |
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||
// +---------------------------------------------------------------------- |
||||
// | Author: 萤火科技 <admin@yiovo.com> |
||||
// +---------------------------------------------------------------------- |
||||
declare (strict_types=1); |
||||
|
||||
namespace app\common\model; |
||||
|
||||
use cores\BaseModel; |
||||
use think\model\relation\HasOne; |
||||
|
||||
/** |
||||
* Class Store |
||||
* @package app\common\model |
||||
*/ |
||||
class MerchantPay extends BaseModel |
||||
{ |
||||
// 定义表名 |
||||
protected $name = 'merchant_pay'; |
||||
|
||||
// 定义主键 |
||||
protected $pk = 'merchant_pay_id'; |
||||
|
||||
|
||||
/** |
||||
* 累积用户可用余额 |
||||
* @param int $userId |
||||
* @param float $money |
||||
* @return mixed |
||||
*/ |
||||
public function addDetail($orderInfo, $precentPrice) |
||||
{ |
||||
if (!empty($orderInfo['merchant_id'])) { |
||||
$data = [ |
||||
'order_id' => $orderInfo['order_id'], |
||||
//'store_id' => $orderInfo['store_id'], |
||||
'merchant_id' => $orderInfo['merchant_id'], |
||||
'total_amount' => $precentPrice, |
||||
]; |
||||
return $this->save($this->createData($data)); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 创建数据 |
||||
* @param array $data |
||||
* @return array |
||||
*/ |
||||
private function createData(array $data): array |
||||
{ |
||||
$data['store_id'] = self::$storeId; |
||||
return $data; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 软删除 |
||||
* @return bool |
||||
*/ |
||||
public function setDelete(): bool |
||||
{ |
||||
return $this->save(['is_delete' => 1]); |
||||
} |
||||
} |
@ -0,0 +1,65 @@ |
||||
<?php |
||||
// +---------------------------------------------------------------------- |
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||
// +---------------------------------------------------------------------- |
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||
// +---------------------------------------------------------------------- |
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||
// +---------------------------------------------------------------------- |
||||
// | Author: 萤火科技 <admin@yiovo.com> |
||||
// +---------------------------------------------------------------------- |
||||
declare (strict_types=1); |
||||
|
||||
namespace app\store\model; |
||||
|
||||
use app\common\model\MerchantPay as StoreModel; |
||||
|
||||
/** |
||||
* 商家记录表模型 |
||||
* Class Store |
||||
* @package app\store\model |
||||
*/ |
||||
class MerchantPay extends StoreModel |
||||
{ |
||||
/** |
||||
* 更新记录 |
||||
* @param array $data |
||||
* @return bool |
||||
*/ |
||||
public function edit(array $data): bool |
||||
{ |
||||
// 是否删除图片 |
||||
!isset($data['logo_image_id']) && $data['logo_image_id'] = 0; |
||||
return $this->save($data) !== false; |
||||
} |
||||
|
||||
/** |
||||
* 新增记录 |
||||
* @param array $data |
||||
* @return bool |
||||
*/ |
||||
public function add(array $data): bool |
||||
{ |
||||
return $this->save($this->createData($data)); |
||||
} |
||||
|
||||
/** |
||||
* 创建数据 |
||||
* @param array $data |
||||
* @return array |
||||
*/ |
||||
private function createData(array $data): array |
||||
{ |
||||
$data['store_id'] = self::$storeId; |
||||
return $data; |
||||
} |
||||
|
||||
/** |
||||
* 软删除 |
||||
* @return bool |
||||
*/ |
||||
public function setDelete(): bool |
||||
{ |
||||
return $this->save(['is_delete' => 1]); |
||||
} |
||||
} |
Loading…
Reference in new issue