admin/addon/cashier/shop/controller/Test.php

82 lines
2.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* ThinkShop商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2019-2029 成都云之牛科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.cdcloudshop.com
* =========================================================
*/
namespace addon\cashier\shop\controller;
use addon\cashier\model\order\CashierOrderCalculate;
use addon\cashier\model\order\CashierOrderCreate as CashierOrderCreateModel;
use addon\cashier\model\order\CashierOrderPay;
use app\shop\controller\BaseShop;
/**
* Class User
* @package app\shop\controller
*/
class Test extends BaseShop
{
public function test()
{
$order_create_model = new CashierOrderCreateModel();
$data = [
'site_id' => $this->site_id,//站点id
// 'sku_array' => [["sku_id" => 9399,"num" => 1],["sku_id" => 9400,"num" => 1]],
'sku_array' => [ [ "money" => 1000, "num" => 1 ] ],
'member_id' => 555,//购买会员(可有可无)
'store_id' => 1,
'mobile' => '',
'order_from' => 'h5',
'order_from_name' => 'h5',
'type' => 'recharge',
'source' => $this->params[ 'source' ] ?? '',// is_buy 普通购买 cart 购物车 参与活动,
'cashier_type' => 'cashier',
'create_time' => time(),
];
$res = $order_create_model->create($data);
dd($res);
}
public function test1()
{
$promotion = [ 'reduction' => 20 ];
$data = array (
'pay_type' => '',
'site_id' => $this->site_id,//站点id
'out_trade_no' => '166391531754635551000',
'store_id' => 1,
'promotion' => $promotion,
'member_id' => 555,
'cash' => 20
);
$cashier_order_calculate_model = new CashierOrderCalculate();
dd($result = $cashier_order_calculate_model->calculate($data));
}
public function test3()
{
$promotion = !empty($this->params[ 'promotion' ]) ? json_decode($this->params[ 'promotion' ], true) : [];
$cashier_order_pay_model = new CashierOrderPay();
$data = array (
'pay_type' => 'cash',
'site_id' => $this->site_id,//站点id
'out_trade_no' => '166401355934055551000',
'store_id' => 1,
'promotion' => $promotion,
'member_id' => 555,
'cash' => 20000
);
$result = $cashier_order_pay_model->confirm($data);
dd($result);
}
}