支付频道修改
This commit is contained in:
parent
fca629fecb
commit
c643e82f69
@ -33,4 +33,9 @@ abstract class Model extends Eloquent
|
||||
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
public function getDateFormat()
|
||||
{
|
||||
return 'Y-m-d H:i:s.u';
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ class Dicts extends Repository
|
||||
'permission_status' => ['关闭', '启用'],
|
||||
'week' => ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
|
||||
'weekIso' => ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
||||
'pay_channel' => [ '银行转账' => ['yhzz'], '余额支付' => ['account'], '微信支付' => ['wx', 'wx_pub', 'wx_pub_qr', 'wx_pub_scan', 'wx_wap', 'wx_lite'], '支付宝' => ['alipay', 'alipay_wap', 'alipay_qr', 'alipay_scan', 'alipay_pc_direct'], '天猫续费' => ['tmxx']],
|
||||
'pay_channel' => ['银行转账' => ['bank'], '余额支付' => ['account'], '微信支付' => ['wx', 'wx_pub', 'wx_pub_qr', 'wx_pub_scan', 'wx_wap', 'wx_lite'], '支付宝' => ['alipay', 'alipay_wap', 'alipay_qr', 'alipay_scan', 'alipay_pc_direct'], '天猫续费' => ['tmall']],
|
||||
'carrier_operator' => ['联通', '移动', '电信', '全网'],
|
||||
'service_type' => ['套餐开通', '套餐续费', '套餐更换', '套餐销售'],
|
||||
'card_status' => ['测试期', '沉默期', '服务期', '已注销'],
|
||||
|
@ -33,8 +33,9 @@ class BootstrapController extends Controller
|
||||
|
||||
$order_status = json_decode(json_encode(['已下单', '已取消', '已出库', '已签收'], JSON_FORCE_OBJECT));
|
||||
$transaction_status = json_decode(json_encode(['未收款', '已收款'], JSON_FORCE_OBJECT));
|
||||
$pay_channels = ['bank' => '银行转账', 'alipay' => '支付宝转账'];
|
||||
|
||||
$res = compact('carrier_operator', 'pay_types', 'order_status', 'transaction_status');
|
||||
$res = compact('carrier_operator', 'pay_channels', 'pay_types', 'order_status', 'transaction_status');
|
||||
|
||||
return res($res, '程序初始化', 201);
|
||||
}
|
||||
|
@ -2,10 +2,12 @@
|
||||
namespace App\Domains\Company\Http\Controllers;
|
||||
|
||||
use App\Dicts;
|
||||
use Carbon\Carbon;
|
||||
use App\Core\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Exceptions\NotAllowedException;
|
||||
use App\Domains\Virtual\Services\OrderService;
|
||||
use App\Domains\Virtual\Services\CommonService;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
@ -28,23 +30,21 @@ class OrderController extends Controller
|
||||
public function paginate(Dicts $dicts)
|
||||
{
|
||||
$conditions = $this->request->all();
|
||||
|
||||
|
||||
$conditions['company_id'] = $this->account->company_id;
|
||||
|
||||
$res = $this->orderService->paginate($conditions);
|
||||
|
||||
$carrierOperators = $dicts->get('carrier_operator');
|
||||
$payChannels = array_keys($dicts->get('pay_channel'));
|
||||
$orderStatues = $dicts->get('order_status');
|
||||
$transactionStatuses = $dicts->get('transaction_status');
|
||||
|
||||
|
||||
$list = $res->map(function ($item) use ($carrierOperators, $payChannels, $orderStatues, $transactionStatuses) {
|
||||
$list = $res->map(function ($item) use ($carrierOperators, $orderStatues, $transactionStatuses) {
|
||||
return [
|
||||
'id' => $item->id,
|
||||
'sn' => $item->sn,
|
||||
'package_name' => $item->package->name,
|
||||
'pay_channel' => $payChannels[$item->pay_channel],
|
||||
'pay_channel' => CommonService::namePayChannel($item->pay_channel),
|
||||
'carrier_operator' => $carrierOperators[$item->package->carrier_operator],
|
||||
'unit_price' => $item->unit_price,
|
||||
'counts' => $item->counts,
|
||||
@ -60,11 +60,16 @@ class OrderController extends Controller
|
||||
return err('没有更多数据');
|
||||
}
|
||||
|
||||
$order_at = $list->last()->order_at;
|
||||
$order_at = Carbon::parse($list->last()->order_at);
|
||||
$conditions['starttime'] = $order_at->copy()->startOfMonth()->startOfDay()->format('Y-m-d H:i:s');
|
||||
$conditions['endtime'] = $order_at->copy()->endOfMonth()->endOfDay()->format('Y-m-d H:i:s');
|
||||
|
||||
|
||||
$count = $this->orderService->count($conditions);
|
||||
$count['starttime'] = $conditions['starttime'];
|
||||
$count['endtime'] = $conditions['endtime'];
|
||||
|
||||
return res($list, '订单列表', 201);
|
||||
return res(['count' => $count, 'orders' => $list], '订单列表', 201);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,23 +121,13 @@ class AddedOrderSync extends Command
|
||||
->where('create_time', '>=', $starttime->timestamp)
|
||||
->where('create_time', '<=', $endtime->timestamp)
|
||||
->orderBy('create_time')->get()->toArray();
|
||||
|
||||
$pay_channel = app(Dicts::class)->get('pay_channel');
|
||||
$pay_channel = array_values($pay_channel);
|
||||
|
||||
foreach ($orders as &$item) {
|
||||
$item = (array)$item;
|
||||
$item['company_id'] = $this->companies[$item['company_id']]['id'] ?? 0;
|
||||
$item['total_price'] = floatval($item['total_price']) * 100;
|
||||
$item['counts'] = !empty($item['counts']) ? $item['counts'] : 1;
|
||||
$item['pay_channel'] = 0;
|
||||
|
||||
foreach ($pay_channel as $key => $value) {
|
||||
if (in_array($item['pay_channel'], $value)) {
|
||||
$item['pay_channel'] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
$item['pay_channel'] = CommonService::transformerPayChannel($item['pay_channel']);
|
||||
$item['unit_price'] = intval($item['total_price']/$item['counts']);
|
||||
$item['order_at'] = date('Y-m-d H:i:s', $item['order_at']);
|
||||
$item['created_at'] = $item['order_at'];
|
||||
|
@ -108,7 +108,7 @@ class OrderBaseSync extends Command
|
||||
'company_id' => $this->companies[$item['o_customer_number']]['id'] ?? 0,
|
||||
'package_id' => $this->packages[$item['o_p_number']]['id'] ?? 0,
|
||||
'transaction_no' => '',
|
||||
'pay_channel' => 0,
|
||||
'pay_channel' => 'bank',
|
||||
'unit_price' => floatval($item['o_price']) * 100,
|
||||
'counts' => $item['o_card_counts'],
|
||||
'total_price' => floatval($item['o_amount']) * 100,
|
||||
|
@ -3,19 +3,6 @@ namespace App\Domains\Real\Services;
|
||||
|
||||
class CommonService
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* 将字符串转换为数字
|
||||
*
|
||||
* @param string $companyId
|
||||
* @return int
|
||||
*/
|
||||
public static function parseCompanyId($companyId)
|
||||
{
|
||||
return intval(str_replace('No', '', $companyId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将数字转换为字符串
|
||||
*
|
||||
@ -27,4 +14,26 @@ class CommonService
|
||||
return sprintf('No%011d', $companyId);
|
||||
return intval(str_replace('No', '', $companyId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化支付频道
|
||||
*
|
||||
* @param int $int
|
||||
* @return string
|
||||
*/
|
||||
public static function transformerPayChannel($payChannel)
|
||||
{
|
||||
switch ($payChannel) {
|
||||
case 'tmxx':
|
||||
$payChannel = 'tmall';
|
||||
break;
|
||||
case 'yhzz':
|
||||
$payChannel = 'bank';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return $payChannel;
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ class OrderRepository extends Repository
|
||||
}
|
||||
|
||||
if (isset($conditions['pay_channel'])) {
|
||||
$this->model = $this->model->whereIn('pay_channel', CommonService::arrayPayChannel($conditions['pay_channel']));
|
||||
$this->model = $this->model->whereIn('pay_channel', $conditions['pay_channel']);
|
||||
}
|
||||
|
||||
if (isset($conditions['package_name'])) {
|
||||
@ -92,11 +92,11 @@ class OrderRepository extends Repository
|
||||
}
|
||||
|
||||
if (isset($conditions['starttime'])) {
|
||||
$this->model = $this->model->where('created_at', '>=', $conditions['starttime']);
|
||||
$this->model = $this->model->where('order_at', '>=', $conditions['starttime']);
|
||||
}
|
||||
|
||||
if (isset($conditions['endtime'])) {
|
||||
$this->model = $this->model->where('created_at', '>=', $conditions['endtime']);
|
||||
$this->model = $this->model->where('order_at', '<=', $conditions['endtime']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
@ -6,29 +6,6 @@ use App\Core\Service;
|
||||
|
||||
class CommonService
|
||||
{
|
||||
/**
|
||||
* 获取支付方式数组
|
||||
*
|
||||
* @param string $payChannel
|
||||
* @return array
|
||||
*/
|
||||
public static function arrayPayChannel($payChannel)
|
||||
{
|
||||
switch ($payChannel) {
|
||||
case 'wx':
|
||||
$payChannel = app(Dicts::class)->get('pay_channel')['微信支付'];
|
||||
break;
|
||||
case 'alipay':
|
||||
$payChannel = app(Dicts::class)->get('pay_channel')['支付宝'];
|
||||
break;
|
||||
default:
|
||||
$payChannel = array_wrap($payChannel);
|
||||
break;
|
||||
}
|
||||
|
||||
return $payChannel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付方式中文
|
||||
*
|
||||
@ -47,23 +24,4 @@ class CommonService
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付方式编号
|
||||
*
|
||||
* @param string $payChannel
|
||||
* @return int
|
||||
*/
|
||||
public static function intPayChannel($payChannel)
|
||||
{
|
||||
$payChannels = array_values(app(Dicts::class)->get('pay_channel'));
|
||||
|
||||
foreach ($payChannels as $key => $value) {
|
||||
if (in_array($payChannel, $value)) {
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,12 @@ class OrderService extends Service
|
||||
DB::raw('SUM(custom_price*transaction_status) as transacted_price'),
|
||||
];
|
||||
|
||||
$res = $this->orderRepository->select($select)->withConditions($conditions)->get();
|
||||
$res = $this->orderRepository->select($select)->withConditions($conditions)->first()->toArray();
|
||||
|
||||
$res['total_price'] = $res['total_price'] ?: 0;
|
||||
$res['transacted_price'] = $res['transacted_price'] ?: 0;
|
||||
unset($res['company']);
|
||||
unset($res['package']);
|
||||
|
||||
return $res;
|
||||
}
|
||||
@ -111,7 +116,6 @@ class OrderService extends Service
|
||||
$attributes['total_price'] = $attributes['unit_price'] * $attributes['counts'];
|
||||
$attributes['custom_price'] = $attributes['unit_price'] * $attributes['counts'];
|
||||
$attributes['order_at'] = date('Y-m-d H:i:s');
|
||||
$attributes['pay_channel'] = CommonService::intPayChannel($attributes['pay_channel']);
|
||||
$attributes['package_id'] = $attributes['package_id'] ?? $product->package_id;
|
||||
|
||||
if (!$attributes['id']) {
|
||||
|
@ -107,7 +107,7 @@ class CreateBaseTables extends Migration
|
||||
$table->tinyInteger('type')->unsigned()->default(0)->comment('订单类型(0:基础套餐)');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment("企业ID");
|
||||
$table->string('transaction_no', 64)->comment('交易流水号');
|
||||
$table->tinyInteger('pay_channel')->unsigned()->default(0)->comment('支付方式(0:银行转账 1:账户余额 2:微信支付 3:支付宝 4:天猫续费)');
|
||||
$table->string('pay_channel', 20)->default('')->comment('支付频道');
|
||||
$table->integer('unit_price')->unsigned()->default(0)->comment('单价');
|
||||
$table->integer('counts')->unsigned()->default(0)->comment('数量');
|
||||
$table->integer('total_price')->unsigned()->default(0)->comment('总价');
|
||||
|
@ -21,7 +21,7 @@ class CreateVirtualOrdersTable extends Migration
|
||||
$table->integer('package_id')->unsigned()->default(0)->after('company_id')->comment('套餐ID');
|
||||
$table->integer('product_id')->unsigned()->default(0)->after('package_id')->comment('定价ID');
|
||||
$table->string('transaction_no', 64)->default('')->comment('交易流水号');
|
||||
$table->tinyInteger('pay_channel')->unsigned()->default(0)->comment('支付方式(0:银行转账 1:账户余额 2:微信支付 3:支付宝 4:天猫续费)');
|
||||
$table->string('pay_channel', 20)->default('')->comment('支付频道');
|
||||
$table->integer('unit_price')->unsigned()->default(0)->comment('单价');
|
||||
$table->integer('counts')->unsigned()->default(0)->comment('数量');
|
||||
$table->integer('total_price')->unsigned()->default(0)->comment('总价');
|
||||
|
Loading…
x
Reference in New Issue
Block a user