gengx
This commit is contained in:
parent
c3252e528a
commit
143f9c5ce2
|
|
@ -70,7 +70,8 @@ class Fenxiao extends BaseApi
|
|||
if (!empty($three_commission[ 'data' ][ 'commission' ])) $commission += $three_commission[ 'data' ][ 'commission' ];
|
||||
|
||||
$info[ 'data' ][ 'today_commission' ] = $commission;
|
||||
|
||||
$info[ 'data' ][ 'one_commission' ] = $one_commission[ 'data' ][ 'commission' ]??0;
|
||||
$info[ 'data' ][ 'two_commission' ] = $two_commission[ 'data' ][ 'commission' ]??0;
|
||||
// 总销售额
|
||||
$fenxiao_order_info = $fenxiao_order_model->getFenxiaoOrderInfoNew([ [ 'fo.one_fenxiao_id|fo.two_fenxiao_id|fo.three_fenxiao_id', '=', $info[ 'data' ][ 'fenxiao_id' ] ], [ "", 'exp', Db::raw("fo.is_refund=0 or (o.order_status=10 and fo.is_refund=1) ") ] ], 'sum(fo.real_goods_money) as real_goods_money');
|
||||
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ class Futures extends BaseApi{
|
|||
'o.pay_money',
|
||||
'o.order_id',
|
||||
'seller.nickname as buyer_name',
|
||||
'seller.username as buyer_username',
|
||||
'f.seller_uid as fseller_uid',
|
||||
];
|
||||
// 表关联
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@ class Ordercreate extends BaseApi
|
|||
'order_from' => $this->params[ 'app_type' ],
|
||||
'is_balance' => $this->params[ 'is_balance' ] ?? 0,//是否使用余额
|
||||
'order_from_name' => $this->params[ 'app_type_name' ],
|
||||
|
||||
'latitude' => $this->params[ 'latitude' ] ?? '',
|
||||
'longitude' => $this->params[ 'longitude' ] ?? '',
|
||||
'default_store_id' => $this->params[ 'default_store_id' ] ?? 0,
|
||||
|
|
@ -138,6 +137,7 @@ class Ordercreate extends BaseApi
|
|||
return $this->response($res);
|
||||
}
|
||||
|
||||
|
||||
public function memberAddress(){
|
||||
$token = $this->checkToken();
|
||||
if ($token[ 'code' ] < 0) return $this->response($token);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace addon\futures\model;
|
|||
use addon\futures\model\Futures as FuturesModel;
|
||||
use addon\fenxiao\model\FenxiaoOrder;
|
||||
use app\model\BaseModel;
|
||||
use think\facade\Db;
|
||||
class Forder extends BaseModel
|
||||
{
|
||||
/**
|
||||
|
|
@ -22,12 +23,14 @@ class Forder extends BaseModel
|
|||
*/
|
||||
public function calculate($order)
|
||||
{
|
||||
|
||||
$site_id=$order['site_id'];
|
||||
$futuresModel = new FuturesModel;
|
||||
$basics = $futuresModel->getBasicsConfig($site_id)['data']['value'];
|
||||
if(!empty(model("fenxiao_order")->getValue(['order_id'=>$order[ 'order_id' ]],'fenxiao_order_id'))){
|
||||
if(!empty(model("fenxiao_order")->getValue(['order_id'=>$order[ 'order_id' ]],'fenxiao_order_id'))){//判断是否重复计算
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
//检测分销商上级关系
|
||||
$member_info = model("member")->getInfo([ [ 'member_id', '=', $order[ 'member_id' ] ] ], 'fenxiao_id,is_fenxiao');
|
||||
//如果没有分销商直接返回不计算,没有考虑首次付款上下级绑定
|
||||
|
|
@ -51,10 +54,20 @@ class Forder extends BaseModel
|
|||
$is_range=$basics['is_range'];
|
||||
if($is_range && $parent_fenxiao_info){ //减去极差奖励
|
||||
$direct_push -=$indirect_push;
|
||||
}else{
|
||||
$direct_push +5; //管理直推
|
||||
}
|
||||
$unit_price=Db::name('futures')->alias('a')
|
||||
->where([
|
||||
'a.order_id'=>$order['order_id'],
|
||||
'a.seller_uid'=>$order[ 'member_id' ]]
|
||||
)
|
||||
->join( 'futures f','a.old_futures_id=f.id')
|
||||
->value('f.unit_price'); //获取上次买入价格
|
||||
|
||||
$order_goods = model("order_goods")->getInfo(['order_id'=>$order[ 'order_id' ]]);
|
||||
$commission_rate=$direct_push+$indirect_push; //总佣金比例
|
||||
$service_charge=$order['order_money']*$basics['service_price']/100;//总服务费
|
||||
$service_charge=$unit_price * $basics['service_price']/100;//总服务费
|
||||
$commission=$commission_rate*$service_charge/100;//总佣金
|
||||
$order_fenxiao_data = [
|
||||
'one_rate' => $direct_push,
|
||||
|
|
@ -74,9 +87,9 @@ class Forder extends BaseModel
|
|||
'sku_id' => $order_goods[ 'sku_id' ],
|
||||
'sku_name' => $order_goods[ 'sku_name' ],
|
||||
'sku_image' => $order_goods[ 'sku_image' ],
|
||||
'price' => $order[ 'order_money' ],
|
||||
'price' => $unit_price,
|
||||
'num' => $order_goods[ 'num' ],
|
||||
'real_goods_money' =>$order[ 'order_money' ],
|
||||
'real_goods_money' =>$unit_price,
|
||||
'member_id' => $order[ 'member_id' ],
|
||||
'member_name' => $order[ 'name' ],
|
||||
'member_mobile' => $order[ 'mobile' ],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace addon\futures\model;
|
||||
|
||||
use addon\fenxiao\model\FenxiaoAccount;
|
||||
use addon\futures\model\Futures as FuturesModel;
|
||||
use addon\message\model\Message;
|
||||
|
|
@ -11,7 +12,8 @@ use Psr\SimpleCache\InvalidArgumentException;
|
|||
use think\facade\Cache;
|
||||
use think\facade\Db;
|
||||
|
||||
class Futures extends BaseModel{
|
||||
class Futures extends BaseModel
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
|
|
@ -29,16 +31,18 @@ class Futures extends BaseModel{
|
|||
$list = model('futures')->pageList($condition, $field, $order, $page, $page_size, $alias, $join);
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
* @param $id
|
||||
* @param $site_id
|
||||
* @return array
|
||||
*/
|
||||
public function detail($id, $site_id){
|
||||
public function detail($id, $site_id)
|
||||
{
|
||||
$condition = [
|
||||
['a.id', '=', $id],
|
||||
['a.site_id','=',$site_id]
|
||||
['a.site_id', '=', $site_id]
|
||||
];
|
||||
// 获取内容
|
||||
$field = [
|
||||
|
|
@ -68,7 +72,7 @@ class Futures extends BaseModel{
|
|||
'a.take_time',
|
||||
'o.order_no',
|
||||
'o.buyer_message',
|
||||
'buyer.nickname as buyer_name',
|
||||
'seller.nickname as buyer_name'
|
||||
];
|
||||
// 表关联
|
||||
$join = [
|
||||
|
|
@ -79,22 +83,22 @@ class Futures extends BaseModel{
|
|||
['futures f', 'f.id = a.old_futures_id', 'left'],// 获取旧订单信息
|
||||
['member old_seller', 'old_seller.member_id = f.seller_uid', 'left'],// 获取旧卖家信息
|
||||
];
|
||||
|
||||
$detail = model('futures')->getInfo($condition, $field, 'a', $join);
|
||||
return $this->success($detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加库存
|
||||
* @param $data
|
||||
* @return array
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function add($data){
|
||||
public function add($data)
|
||||
{
|
||||
$id = model('futures')->add($data);
|
||||
if(!($id > 0)){
|
||||
return $this->error('','添加失败');
|
||||
if (!($id > 0)) {
|
||||
return $this->error('', '添加失败');
|
||||
}
|
||||
Cache::store('redis_concurrent')->set('addon_futures_stock_'.$id,'1');
|
||||
return $this->success($id);
|
||||
}
|
||||
|
||||
|
|
@ -105,23 +109,21 @@ class Futures extends BaseModel{
|
|||
* @return array
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function release($id, $price, $agree_split_order = 0){
|
||||
public function release($id, $price, $agree_split_order = 0)
|
||||
{
|
||||
$date = model('futures')->getInfo([['id', '=', $id]]);
|
||||
if(empty($date) || $date['status'] !== 1){
|
||||
return $this->error('','发布失败-db');
|
||||
}
|
||||
if(!Cache::store('redis_concurrent')->delete('addon_futures_stock_'.$id)){
|
||||
return $this->error('','发布失败-chche'.'addon_futures_stock_'.$id);
|
||||
if (empty($date) || $date['status'] !== 1) {
|
||||
return $this->error('', '发布失败-db');
|
||||
}
|
||||
$basics = $this->getBasicsConfig($date['site_id'])['data']['value'];
|
||||
model('futures')->startTrans();
|
||||
try{
|
||||
try {
|
||||
//拆单
|
||||
$futuresInfo = $this->detail($id,$date['site_id'])['data'];
|
||||
$futuresInfo = $this->detail($id, $date['site_id'])['data'];
|
||||
$futuresInfo['status'] = 2;
|
||||
if($price >= $futuresInfo['market_price'] * $futuresInfo['total']){
|
||||
if ($price >= $futuresInfo['market_price'] * $futuresInfo['total']) {
|
||||
$futuresInfo['total'] *= 2;
|
||||
if($futuresInfo['total'] > pow(2,$basics['order_total_double_times'])){// 配置单订单商品最大裂变次数
|
||||
if ($futuresInfo['total'] > pow(2, $basics['order_total_double_times'])) {// 配置单订单商品最大裂变次数
|
||||
// if($agree_split_order == 0){
|
||||
// model('futures')->rollback();
|
||||
// Cache::store('redis_concurrent')->set('addon_futures_stock_'.$id,'1');
|
||||
|
|
@ -130,62 +132,59 @@ class Futures extends BaseModel{
|
|||
//拆单
|
||||
$futuresInfo['status'] = 8;
|
||||
$splitOrderNum = $basics['split_order_num'];
|
||||
// for($i = 0;$i < $futuresInfo['total'];$i++){
|
||||
for($i = 0; $i < $splitOrderNum; $i++){
|
||||
for ($i = 0; $i < $splitOrderNum; $i++) {
|
||||
$newSmallFuturesId = $this->add([
|
||||
'site_id' => $futuresInfo['site_id'],
|
||||
'seller_uid' => $futuresInfo['seller_uid'],
|
||||
'site_id' => $futuresInfo['site_id'],
|
||||
'seller_uid' => $futuresInfo['seller_uid'],
|
||||
'old_futures_id' => $id,
|
||||
'goods_id' => $futuresInfo['goods_id'],
|
||||
'total' => $futuresInfo['total'] / $splitOrderNum,
|
||||
'unit_price' => $futuresInfo['unit_price'] / $splitOrderNum,
|
||||
'status' => 1,
|
||||
'order_id' => $futuresInfo['order_id'],
|
||||
'created_time' => time()
|
||||
'goods_id' => $futuresInfo['goods_id'],
|
||||
'total' => $futuresInfo['total'] / $splitOrderNum,
|
||||
'unit_price' => $futuresInfo['unit_price'] / $splitOrderNum,
|
||||
'status' => 1,
|
||||
'order_id' => $futuresInfo['order_id'],
|
||||
'created_time' => time()
|
||||
])['data'];
|
||||
$this->release($newSmallFuturesId,$price / $futuresInfo['total']);
|
||||
$this->release($newSmallFuturesId, $price / $splitOrderNum);
|
||||
}
|
||||
model('futures')->commit();
|
||||
return $this->success();
|
||||
}
|
||||
}
|
||||
$service_price = $price * $basics['service_price'] / 100;
|
||||
$technical_range=$service_price*$basics['technical_range']/100;
|
||||
if(model('member')->getValue(['member_id'=>$date['seller_uid']],'balance_money')<$service_price){
|
||||
Cache::store('redis_concurrent')->set('addon_futures_stock_'.$id,'1');
|
||||
$service_price = $date['unit_price'] * $basics['service_price'] / 100; //更改为买入价格
|
||||
$technical_range = $service_price * $basics['technical_range'] / 100;
|
||||
if (model('member')->getValue(['member_id' => $date['seller_uid']], 'balance_money') < $service_price) {
|
||||
return error(-800, '您余额不足!');
|
||||
}
|
||||
model('futures')->update([
|
||||
'status' => $futuresInfo['status'],
|
||||
'status' => $futuresInfo['status'],
|
||||
'release_time' => time() + $basics['release_wait'] * 24 * 60 * 60,// 配置上线延迟时间
|
||||
'price' => $price,
|
||||
'total' => $futuresInfo['total'],
|
||||
'price' => $price,
|
||||
'total' => $futuresInfo['total'],
|
||||
'service_price' => $service_price,
|
||||
'real_income' => $price,
|
||||
],[['id','=',$id]]);
|
||||
], [['id', '=', $id]]);
|
||||
//扣除服务费
|
||||
$memberAccountModel = new MemberAccount();
|
||||
$memberAccountModel->addMemberAccount($date['site_id'], $date['seller_uid'], 'balance_money', -$technical_range, 'service_price', $date['id'], '服务费', $date['id']);
|
||||
$memberAccountModel->addMemberAccount($date['site_id'], $date['seller_uid'], 'balance_money', -$service_price-$technical_range, 'service_price', $date['id'], '商家分账', $date['id']);
|
||||
$memberAccountModel->addMemberAccount($date['site_id'], $date['seller_uid'], 'balance_money', -($service_price - $technical_range), 'service_price', $date['id'], '商家分账', $date['id']);
|
||||
model('futures')->commit();
|
||||
Cache::store('redis_concurrent')->set('addon_futures_'.$id,'1');
|
||||
return $this->success();
|
||||
} catch (\Exception $e) {
|
||||
model('futures')->rollback();
|
||||
Cache::store('redis_concurrent')->set('addon_futures_stock_'.$id,'1');
|
||||
return $this->error('', $e->getMessage() . $e->getFile() . $e->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下架到库存
|
||||
* @return array
|
||||
*/
|
||||
public function stock($id){
|
||||
public function stock($id)
|
||||
{
|
||||
$date = model('futures')->getInfo([['id', '=', $id]]);
|
||||
if(empty($date) || $date['status'] !== 2){
|
||||
return $this->error('','下架失败');
|
||||
}
|
||||
if(!Cache::store('redis_concurrent')->delete('addon_futures_'.$id)){
|
||||
return $this->error('','下架失败');
|
||||
if (empty($date) || $date['status'] !== 2) {
|
||||
return $this->error('', '下架失败');
|
||||
}
|
||||
model('futures')->update([
|
||||
'status' => 1,
|
||||
|
|
@ -193,49 +192,46 @@ class Futures extends BaseModel{
|
|||
//扣除服务费
|
||||
$memberAccountModel = new MemberAccount();
|
||||
$memberAccountModel->addMemberAccount($date['site_id'], $date['seller_uid'], 'balance_money', $date['service_price'], 'service_price', $date['id'], '退回服务费与商家分账', $date['id']);
|
||||
Cache::store('redis_concurrent')->set('addon_futures_stock_'.$id,'1');
|
||||
Cache::store('redis_concurrent')->delete('addon_futures_' . $id);
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提货
|
||||
* @param $id
|
||||
* @return array
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function pickUp($id){
|
||||
public function pickUp($id)
|
||||
{
|
||||
$date = model('futures')->getInfo([['id', '=', $id]]);
|
||||
if(empty($date) || $date['status'] !== 1){
|
||||
return $this->error($date,'提货失败');
|
||||
if (empty($date) || $date['status'] !== 1) {
|
||||
return $this->error($date, '提货失败');
|
||||
}
|
||||
$member_address = input( 'member_address', []);
|
||||
$member_address = input('member_address', []);
|
||||
$member_address = isset($member_address) && !empty($member_address) ? json_decode($member_address, true) : [];
|
||||
if(empty($member_address)){
|
||||
return $this->error($date,'提货失败-无收获地址');
|
||||
}
|
||||
if(!Cache::store('redis_concurrent')->delete('addon_futures_stock_'.$id)){
|
||||
return $this->error('','提货失败');
|
||||
if (empty($member_address)) {
|
||||
return $this->error($date, '提货失败-无收获地址');
|
||||
}
|
||||
model('futures')->update([
|
||||
'status' => 5,
|
||||
], [['id', '=', $id]]);
|
||||
$order_info = [
|
||||
'name' => $member_address[ 'name' ] ?? '',
|
||||
'mobile' => $member_address[ 'mobile' ] ?? '',
|
||||
'telephone' => $member_address[ 'telephone' ] ?? '',
|
||||
'province_id' => $member_address[ 'province_id' ] ?? '',
|
||||
'city_id' => $member_address[ 'city_id' ] ?? '',
|
||||
'district_id' => $member_address[ 'district_id' ] ?? '',
|
||||
'community_id' => $member_address[ 'community_id' ] ?? '',
|
||||
'address' => $member_address[ 'address' ] ?? '',
|
||||
'full_address' => $member_address[ 'full_address' ] ?? '',
|
||||
'longitude' => $member_address[ 'longitude' ] ?? '',
|
||||
'latitude' => $member_address[ 'latitude' ] ?? '',
|
||||
'name' => $member_address['name'] ?? '',
|
||||
'mobile' => $member_address['mobile'] ?? '',
|
||||
'telephone' => $member_address['telephone'] ?? '',
|
||||
'province_id' => $member_address['province_id'] ?? '',
|
||||
'city_id' => $member_address['city_id'] ?? '',
|
||||
'district_id' => $member_address['district_id'] ?? '',
|
||||
'community_id' => $member_address['community_id'] ?? '',
|
||||
'address' => $member_address['address'] ?? '',
|
||||
'full_address' => $member_address['full_address'] ?? '',
|
||||
'longitude' => $member_address['longitude'] ?? '',
|
||||
'latitude' => $member_address['latitude'] ?? '',
|
||||
'promotion_type' => 'futures_tihuo',
|
||||
];
|
||||
|
||||
model('order')->update($order_info,[['order_id', '=', $date['order_id']]]);
|
||||
|
||||
$basics = $this->getBasicsConfig($date['site_id'])[ 'data' ][ 'value' ];
|
||||
model('order')->update($order_info, [['order_id', '=', $date['order_id']]]);
|
||||
$basics = $this->getBasicsConfig($date['site_id'])['data']['value'];
|
||||
// 提货用来减少用户买入限制
|
||||
Db::name('futures_user')
|
||||
->where('member_id', $date['member_id'])
|
||||
|
|
@ -249,32 +245,36 @@ class Futures extends BaseModel{
|
|||
* 订单创建
|
||||
* @return array
|
||||
*/
|
||||
public function orderCreate($id, $order_id, $member_id){
|
||||
public function orderCreate($id, $order_id, $member_id)
|
||||
{
|
||||
|
||||
$date = model('futures')->getInfo([['id', '=', $id]]);
|
||||
if(empty($date) || ($date['status'] !== 2 && $date['status'] !== 7)){
|
||||
return $this->error($date,'下单失败-1001');
|
||||
if (empty($date) || ($date['status'] !== 2 && $date['status'] !== 7)) {
|
||||
return $this->error($date, '下单失败-1001');
|
||||
}
|
||||
if(!Cache::store('redis_concurrent')->delete('addon_futures_'.$id)){
|
||||
return $this->error('','下单失败-1002');
|
||||
}
|
||||
model('futures')->update(
|
||||
// if (!Cache::store('redis_concurrent')->delete('addon_futures_' . $id)) {
|
||||
// return $this->error('', '下单失败-1002');
|
||||
// }
|
||||
if(Cache::store('redis_concurrent')->get('addon_futures_' . $id)){
|
||||
return $this->error('', '你太慢了已被抢购');
|
||||
}
|
||||
model('futures')->update(
|
||||
[
|
||||
'status' => 6,
|
||||
'created_time' => time(),
|
||||
'member_id' => $member_id,
|
||||
'order_id' => $order_id,
|
||||
'status' => 6,
|
||||
'created_time' => time(),
|
||||
'member_id' => $member_id,
|
||||
'order_id' => $order_id,
|
||||
],
|
||||
[['id', '=', $id]]);
|
||||
// 增加用户已下单次数
|
||||
$res=Db::name('futures_user')
|
||||
->where('member_id',$member_id)
|
||||
//增加用户已下单次数
|
||||
Db::name('futures_user')
|
||||
->where('member_id', $member_id)
|
||||
->update([
|
||||
'business_num' => Db::raw('business_num +1'),
|
||||
'business_num' => Db::raw('business_num +1'),
|
||||
'total_business_num' => Db::raw('total_business_num +1'),
|
||||
]);
|
||||
(new Message())->addMessage($date['site_id'],'订单创建',1,$member_id,$id);
|
||||
Cache::store('redis_concurrent')->set('addon_futures_pay_'.$id,'1');
|
||||
(new Message())->addMessage($date['site_id'], '订单创建', 1, $member_id, $id);
|
||||
Cache::store('redis_concurrent')->set('addon_futures_' . $id, '1');
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
|
|
@ -282,13 +282,11 @@ class Futures extends BaseModel{
|
|||
* 订单完成
|
||||
* @return array
|
||||
*/
|
||||
public function orderComplete($id,$order_id){
|
||||
public function orderComplete($id, $order_id)
|
||||
{
|
||||
$date = model('futures')->getInfo([['id', '=', $id]]);
|
||||
if(empty($date) || $date['status'] !== 6){
|
||||
return $this->error($date,'完成失败');
|
||||
}
|
||||
if(!Cache::store('redis_concurrent')->delete('addon_futures_pay_'.$id)){
|
||||
return $this->error('','完成失败');
|
||||
if (empty($date) || $date['status'] !== 6) {
|
||||
return $this->error($date, '完成失败');
|
||||
}
|
||||
$date = model('futures')->getInfo([['id', '=', $id]]);
|
||||
model('futures')->update([
|
||||
|
|
@ -297,32 +295,34 @@ class Futures extends BaseModel{
|
|||
], [['id', '=', $id]]);
|
||||
$this->add(
|
||||
[
|
||||
'order_id' => $order_id,
|
||||
'site_id' => $date['site_id'],
|
||||
'seller_uid' => $date['member_id'],
|
||||
'old_futures_id' => $id,
|
||||
'goods_id' => (int)$date['goods_id'],
|
||||
'total' => (int)$date['total'],
|
||||
'unit_price' => $date['price'],
|
||||
'status' => 1,
|
||||
'created_time' => time()
|
||||
'order_id' => $order_id,
|
||||
'site_id' => $date['site_id'],
|
||||
'seller_uid' => $date['member_id'],
|
||||
'member_id' => $date['member_id'],
|
||||
'old_futures_id' => $id,
|
||||
'goods_id' => (int)$date['goods_id'],
|
||||
'total' => (int)$date['total'],
|
||||
'unit_price' => $date['price'],
|
||||
'status' => 1,
|
||||
'created_time' => time()
|
||||
]
|
||||
);
|
||||
(new Message())->addMessage($date['site_id'],'订单完成',1,$date['member_id'],$id);
|
||||
(new Message())->addMessage($date['site_id'],'订单售卖完成',1,$date['seller_uid'],$id);
|
||||
(new Message())->addMessage($date['site_id'], '订单完成', 1, $date['member_id'], $id);
|
||||
(new Message())->addMessage($date['site_id'], '订单售卖完成', 1, $date['seller_uid'], $id);
|
||||
// 给用户增加余额
|
||||
$memberAccountModel = new MemberAccount();
|
||||
$memberAccountModel->addMemberAccount($date['site_id'], $date['seller_uid'], 'balance_money', $date['price'], 'sell', $date['id'], '售卖产品', $date['id']);
|
||||
$futuresModel = new FuturesModel;
|
||||
$basics = $futuresModel->getBasicsConfig($date['site_id'])['data']['value'];
|
||||
if ($basics['give_integral'] > 0) { //首单赠送积分
|
||||
if (model('futures')->getCount(['seller_uid'=>$date['member_id']])==1) {
|
||||
if (model('futures')->getCount(['seller_uid' => $date['member_id']]) == 1) {
|
||||
$memberAccountModel->addMemberAccount($date['site_id'], $date['member_id'], 'point', $basics['give_integral'], 'sell', $date['id'], '秒杀首单赠送积分', $date['id']);
|
||||
}
|
||||
}
|
||||
$point=$date['price']*$basics['order_give_points_ratio']/100;
|
||||
$point = $date['price'] * $basics['order_give_points_ratio'] / 100;
|
||||
//赠送积分
|
||||
$memberAccountModel->addMemberAccount($date['site_id'], $date['member_id'], 'point', intval($point), 'sell', $date['id'], '秒杀赠送积分', $date['id']);
|
||||
Cache::store('redis_concurrent')->delete('addon_futures_' . $id);
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
|
|
@ -330,43 +330,45 @@ class Futures extends BaseModel{
|
|||
* 订单取消
|
||||
* @return array
|
||||
*/
|
||||
public function orderClose($id){
|
||||
public function orderClose($id)
|
||||
{
|
||||
$date = model('futures')->getInfo([['id', '=', $id]]);
|
||||
if(empty($date) || $date['status'] !== 6){
|
||||
return $this->error($date,'取消失败');
|
||||
}
|
||||
if(!Cache::store('redis_concurrent')->delete('addon_futures_pay_'.$id)){
|
||||
return $this->error('','取消失败');
|
||||
if (empty($date) || $date['status'] !== 6) {
|
||||
return $this->error($date, '取消失败');
|
||||
}
|
||||
// if(!Cache::store('redis_concurrent')->delete('addon_futures_pay_'.$id)){
|
||||
// return $this->error('','取消失败');
|
||||
// }
|
||||
// Cache::store('redis_concurrent')->delete('addon_futures_pay_' . $id);
|
||||
model('futures')->update(['status' => 7], [['id', '=', $id]]);
|
||||
Cache::store('redis_concurrent')->set('addon_futures_'.$id,'1');
|
||||
(new Message())->addMessage($date['site_id'],'订单取消',1,$date['member_id'],$id);
|
||||
Cache::store('redis_concurrent')->set('addon_futures_' . $id, '1');
|
||||
(new Message())->addMessage($date['site_id'], '订单取消', 1, $date['member_id'], $id);
|
||||
// 订单取消后 添加违规次数
|
||||
Db::name('futures_user')
|
||||
->where('member_id',$date['member_id'])
|
||||
->where('member_id', $date['member_id'])
|
||||
->update([
|
||||
'violation_num' => Db::raw('violation_num+1'),
|
||||
'violation_num' => Db::raw('violation_num+1'),
|
||||
'total_violation_num' => Db::raw('total_violation_num+1'),
|
||||
]);
|
||||
Db::name('futures_user_violation_records')
|
||||
->insert([
|
||||
'site_id' => $date['site_id'],
|
||||
'member_id' => $date['member_id'],
|
||||
'futures_id' => $id,
|
||||
'site_id' => $date['site_id'],
|
||||
'member_id' => $date['member_id'],
|
||||
'futures_id' => $id,
|
||||
'created_time' => time(),
|
||||
]);
|
||||
// 判断:如果当前次数已经到达限制 进行惩罚操作
|
||||
$futuresUserInfo = Db::name('futures_user')
|
||||
$futuresUserInfo = Db::name('futures_user')
|
||||
->field('violation_num,site_id,punish_time')
|
||||
->where('member_id',$date['member_id'])
|
||||
->where('member_id', $date['member_id'])
|
||||
->find();
|
||||
$basics = (new Futures())->getBasicsConfig($futuresUserInfo['site_id'])[ 'data' ][ 'value' ];
|
||||
$basics = (new Futures())->getBasicsConfig($futuresUserInfo['site_id'])['data']['value'];
|
||||
$violationHour = $basics['violation_hour'] ?? 0;
|
||||
$violationUnpaid = $basics['violation_unpaid'] ?? 0;
|
||||
if($violationUnpaid > 0 && $futuresUserInfo['violation_num'] >= $violationUnpaid){
|
||||
if ($violationUnpaid > 0 && $futuresUserInfo['violation_num'] >= $violationUnpaid) {
|
||||
$startTime = $futuresUserInfo['punish_time'] > time() ? $futuresUserInfo['punish_time'] : time();
|
||||
Db::name('futures_user')
|
||||
->where('member_id',$date['member_id'])
|
||||
->where('member_id', $date['member_id'])
|
||||
->update([
|
||||
'punish_time' => strtotime("+{$violationHour} hours", $startTime),// 添加惩罚时间
|
||||
'violation_num' => Db::raw("violation_num - {$violationUnpaid}")// 减少违规次数
|
||||
|
|
@ -400,6 +402,7 @@ class Futures extends BaseModel{
|
|||
$config = new ConfigModel();
|
||||
return $config->getConfig([['site_id', '=', $site_id], ['app_module', '=', 'shop'], ['config_key', '=', 'MIAOSHA_BASICS_CONFIG']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前时间是否在秒杀开启时间,并区分有无钻石用户
|
||||
* @param $site_id
|
||||
|
|
@ -407,13 +410,14 @@ class Futures extends BaseModel{
|
|||
* @param $status
|
||||
* @return array
|
||||
*/
|
||||
public function checkTimes($site_id, $member_id, $status = 2){
|
||||
switch($status){
|
||||
public function checkTimes($site_id, $member_id, $status = 2)
|
||||
{
|
||||
switch ($status) {
|
||||
case '2':
|
||||
$startTimeKey = 'miaosha_start_time';
|
||||
$endTimeKey = 'miaosha_end_time';
|
||||
$fenxiao = model('member')->getInfo([['member_id', '=', $member_id]]);
|
||||
if(!empty($fenxiao) && $fenxiao['diamond'] > 0){
|
||||
if (!empty($fenxiao) && $fenxiao['diamond'] > 0) {
|
||||
$startTimeKey = 'miaosha_early_start_time';
|
||||
}
|
||||
break;
|
||||
|
|
@ -422,18 +426,18 @@ class Futures extends BaseModel{
|
|||
$endTimeKey = 'jianlou_end_time';
|
||||
break;
|
||||
default:
|
||||
return $this->error('','参数不合法');
|
||||
return $this->error('', '参数不合法');
|
||||
}
|
||||
$nowTime = time() - strtotime("today");
|
||||
$is_read = FALSE;
|
||||
$nowtimes = [];
|
||||
$basics = $this->getBasicsConfig($site_id)['data']['value'];
|
||||
if(empty($basics['times'])){
|
||||
return $this->error('','暂无秒杀活动');
|
||||
if (empty($basics['times'])) {
|
||||
return $this->error('', '暂无秒杀活动');
|
||||
}
|
||||
$recentlyTimes = [];
|
||||
foreach($basics['times'] as $times){
|
||||
if($times[$startTimeKey] <= $nowTime && $times[$endTimeKey] >= $nowTime){
|
||||
foreach ($basics['times'] as $times) {
|
||||
if ($times[$startTimeKey] <= $nowTime && $times[$endTimeKey] >= $nowTime) {
|
||||
$is_read = TRUE;
|
||||
$nowtimes = [
|
||||
'original' => $times,
|
||||
|
|
@ -442,25 +446,25 @@ class Futures extends BaseModel{
|
|||
];
|
||||
break;
|
||||
}
|
||||
if(empty($recentlyTimes) && $times['miaosha_start_time'] >= $nowTime){
|
||||
if (empty($recentlyTimes) && $times['miaosha_start_time'] >= $nowTime) {
|
||||
$recentlyTimes = $times;
|
||||
foreach($recentlyTimes as $timeKey => $time){
|
||||
foreach ($recentlyTimes as $timeKey => $time) {
|
||||
$recentlyTimes[$timeKey] += strtotime(date("Y-m-d", time()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(empty($recentlyTimes)){
|
||||
if (empty($recentlyTimes)) {
|
||||
$recentlyTimes = $basics['times'][0];
|
||||
foreach($recentlyTimes as $timeKey => $time){
|
||||
foreach ($recentlyTimes as $timeKey => $time) {
|
||||
$recentlyTimes[$timeKey] += strtotime(date("Y-m-d", time())) + 24 * 60 * 60;
|
||||
}
|
||||
}
|
||||
if(!$is_read){
|
||||
return error(-801,'未到秒杀时间', $recentlyTimes);
|
||||
if (!$is_read) {
|
||||
return error(-801, '未到秒杀时间', $recentlyTimes);
|
||||
}
|
||||
//判断是否是提前秒杀
|
||||
$nowtimes['is_early'] = FALSE;
|
||||
if($times['miaosha_early_start_time'] <= $nowTime && $times['miaosha_start_time'] >= $nowTime){
|
||||
if ($times['miaosha_early_start_time'] <= $nowTime && $times['miaosha_start_time'] >= $nowTime) {
|
||||
$nowtimes['is_early'] = TRUE;
|
||||
}
|
||||
return $this->success($nowtimes);
|
||||
|
|
|
|||
|
|
@ -113,28 +113,19 @@ class User extends BaseModel{
|
|||
try{
|
||||
$futuresModel = new Futures();
|
||||
$time = time();
|
||||
$insert = [];
|
||||
for($i=0;$i<$info['order_num'];$i++){
|
||||
$futuresModel->add([
|
||||
'site_id' => $this->site_id,
|
||||
'seller_uid' => $memberId,
|
||||
'member_id' => $memberId,
|
||||
'goods_id' => (int)$info['goods_id'],
|
||||
'total' => (int)$info['goods_num'],
|
||||
'price' => sprintf("%.2f",$info['unit_price'] * $info['goods_num']),
|
||||
'unit_price' => sprintf("%.2f",$info['unit_price'] * $info['goods_num']),
|
||||
'status' => 1,
|
||||
'created_time' => $time,
|
||||
]);
|
||||
// $insert[] = [
|
||||
// 'site_id' => $this->site_id,
|
||||
// 'seller_uid' => $memberId,
|
||||
// 'goods_id' => (int)$info['goods_id'],
|
||||
// 'total' => (int)$info['goods_num'],
|
||||
// 'unit_price' => sprintf("%.2f",$info['unit_price'] * $info['goods_num']),
|
||||
// 'status' => 1,
|
||||
// 'created_time' => $time,
|
||||
// ];
|
||||
}
|
||||
// Db::name('futures')->insertAll($insert);
|
||||
return $this->success();
|
||||
}catch(Exception $e){
|
||||
return $this->error('',$e->getMessage());
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ class FuturesOrderCreate extends OrderCreate
|
|||
$calculate_data[ 'shop_goods_list' ][ 'goods_list' ][ $k_order_goods ][ 'order_goods_id' ] = $order_goods_id;
|
||||
}
|
||||
$futures_model = new Futures;
|
||||
$futures_info = $futures_model->orderCreate($data['futures_id'],$order_id,$data['member_id']);
|
||||
$futures_info = $futures_model->orderCreate($data['futures_id'],$order_id,$member_id);
|
||||
if ($futures_info[ 'code' ] != 0) {
|
||||
model('order')->rollback();
|
||||
return $futures_info;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
namespace app\pay\controller;
|
||||
use addon\aliapp\model\CloudPay;
|
||||
use addon\aliapp\model\OpenPay;
|
||||
use addon\futures\model\Forder;
|
||||
use app\Controller;
|
||||
use think\Validate;
|
||||
use think\facade\Db;
|
||||
|
|
@ -30,7 +31,14 @@ class Test extends Controller
|
|||
|
||||
public function s(){
|
||||
|
||||
var_dump(329*1/100);
|
||||
|
||||
$order=model('order')->getInfo(['order_id'=>258]);
|
||||
|
||||
|
||||
$res= (new Forder())->calculate($order); //计算订单佣金
|
||||
|
||||
var_dump($res);
|
||||
// var_dump(329*1/100);
|
||||
// $paydata='{"item_code":"AM010201000000117823","charset":"UTF-8","notify_time":"2023-02-02 10:41:48","commodity_order_id":"202302020000000008847076","quantity":"1","total_price":"0.00","method":"alipay.open.servicemarket.order.notify","sign":"PrqlBU8y1sIIS962JrLmAuggPH89kSTy1cPLur9z0ynHI0YurAVVahaxxt9iWErUMOQGNKehyilyMtCeZdRh84hSdHKktSTHpDvy423sX9xVLYvPBii05joMBJUZ3PM4y7BbizyPamie3yPqdomDuGQ539AYTA\/9YtmwUoh62zjloIoq4UefDOihwuESGFmB5B3HYbw6HpSiVbe8lHEGNSKOGBTCi2OowaSk1sGaT9\/5dQgBCARDGb+amg4pKGMkw105ERlD2EEW9qoGQNwQVP7o9R5UP+7KqgOhg+X95kW5qcIjltjF6rRPa2cH\/j1WQ1RSeTfTuuRBOMLAOr3xuw==","order_time":"2023-02-02 10:38:00","title":"客单豹","specifications":"客单豹","version":"1.0","notify_id":"2023020200222103800094771410174673","merchant_pid":"2088402283167085","package_count":"0","notify_type":"servicemarket_order_notify","period_day":"-1","phone":"18980669271","name":"*敏","order_item_num":"1","contactor":"柏鸿凯","app_id":"2021003167617037","sign_type":"RSA2","timestamp":"2023-02-02 10:41:48"}';
|
||||
// $res= event('AliAuthNotify',json_decode($paydata,true));
|
||||
// var_dump($res);
|
||||
|
|
|
|||
Loading…
Reference in New Issue