Browse Source

奖金设置列表接口

master
wanghongjun 3 years ago
parent
commit
03f50c41cc
  1. 17
      app/common.php
  2. 37
      app/controller/AdminZoneManage.php
  3. 3
      app/validate/Zone.php
  4. 1
      route/app.php

17
app/common.php

@ -124,7 +124,7 @@ function give_symbol(&$value,$symbol = '+')
* @param $phoneNumber * @param $phoneNumber
* @return string * @return string
*/ */
function format_phone_number($phoneNumber) function format_phone_number($phoneNumber):string
{ {
$prefix = substr($phoneNumber, 0, 3); $prefix = substr($phoneNumber, 0, 3);
$suffix = substr($phoneNumber, -4); $suffix = substr($phoneNumber, -4);
@ -146,22 +146,23 @@ function rand_avatar()
* @param $number * @param $number
* @return string * @return string
*/ */
function format_money($number) { function format_money($number):string
$units = array("万元", "亿元"); {
$units = array('元',"万元", "亿元");
$unitMaxValue = 10000; // 单位最大值 $unitMaxValue = 10000; // 单位最大值
$unitIndex = 0; // 单位索引 $unitIndex = 0; // 单位索引
if ($number >= $unitMaxValue && $number % $unitMaxValue === 0) { if ($number >= $unitMaxValue && $number % $unitMaxValue === 0) {
while (abs($number) >= $unitMaxValue && $unitIndex < count($units) - 1) { while ($number >= $unitMaxValue && $unitIndex <= count($units) - 1) {
$number = $number / $unitMaxValue; $number = round($number / $unitMaxValue);
$unitIndex++; $unitIndex++;
} }
$formattedNumber = number_format($number, 0) . $units[$unitIndex]; $formattedNumber = round($number, 0) . $units[$unitIndex];
} elseif ($number % $unitMaxValue === 0) { } elseif ($number % $unitMaxValue === 0) {
$formattedNumber = $number / $unitMaxValue . $units[0]; $formattedNumber = round($number / $unitMaxValue,0) . $units[0];
} else { } else {
$formattedNumber = $number . '元'; $formattedNumber = round($number,0) . '元';
} }
return $formattedNumber; return $formattedNumber;

37
app/controller/AdminZoneManage.php

@ -5,6 +5,7 @@ namespace app\controller;
use app\BaseController; use app\BaseController;
use app\model\ZoneGoods; use app\model\ZoneGoods;
use app\model\ZoneGoodsParam;
use app\validate\Zone as ZoneValidate; use app\validate\Zone as ZoneValidate;
use think\exception\ValidateException; use think\exception\ValidateException;
use think\facade\Request; use think\facade\Request;
@ -47,4 +48,40 @@ class AdminZoneManage extends BaseController
return $this->renderError($validateException->getMessage()); return $this->renderError($validateException->getMessage());
} }
} }
/**
* 奖金设置列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function goodsParamList()
{
$param = Request::param();
try {
validate(ZoneValidate::class)->scene('goodsParamList')->check($param);
$zone_goods_id = $param['zone_goods_id'];
$ZoneGoodsParam = new ZoneGoodsParam();
$list = $ZoneGoodsParam->where('zone_goods_id',$zone_goods_id)
->field('id,amount,image,probability')
->order('amount','desc')
->select()
->toArray();
foreach ($list as &$item) {
$item['probability'] = ($item['probability'] * 100) .'%';
$item['amount_str'] = format_money($item['amount']);
$item['image'] = get_image_url($item['image']);
}
return $this->renderSuccess('数据返回成功',['list' => $list]);
} catch (ValidateException $validateException) {
return $this->renderError($validateException->getMessage());
}
}
} }

3
app/validate/Zone.php

@ -29,6 +29,7 @@ class Zone extends Validate
protected $message = []; protected $message = [];
protected $scene = [ protected $scene = [
'changeStatus' => ['zone_goods_id','status'] 'changeStatus' => ['zone_goods_id','status'],
'goodsParamList' => ['zone_goods_id'],
]; ];
} }

1
route/app.php

@ -82,6 +82,7 @@ Route::group('adminUser',function() {
Route::group('adminZoneManage',function() { Route::group('adminZoneManage',function() {
Route::post('zoneGoodsList','adminZoneManage/zoneGoodsList')->middleware(CheckAdmin::class)->allowCrossDomain(); Route::post('zoneGoodsList','adminZoneManage/zoneGoodsList')->middleware(CheckAdmin::class)->allowCrossDomain();
Route::post('zoneGoodsChangeStatus','adminZoneManage/zoneGoodsChangeStatus')->middleware(CheckAdmin::class)->allowCrossDomain(); Route::post('zoneGoodsChangeStatus','adminZoneManage/zoneGoodsChangeStatus')->middleware(CheckAdmin::class)->allowCrossDomain();
Route::post('goodsParamList','adminZoneManage/goodsParamList');
}); });
# 支付(待开发) # 支付(待开发)

Loading…
Cancel
Save