mirror of
https://github.com/crmeb/CRMEB.git
synced 2025-12-14 20:42:49 +00:00
修复小程序bug
This commit is contained in:
parent
5b87b92452
commit
a9051f3d64
@ -368,7 +368,7 @@ class AuthApi extends AuthController{
|
||||
*/
|
||||
public function my(){
|
||||
$this->userInfo['couponCount'] = StoreCouponUser::getUserValidCouponCount($this->userInfo['uid']);
|
||||
$this->userInfo['like'] = StoreProductRelation::getUserIdLike($this->userInfo['uid']);;
|
||||
$this->userInfo['like'] = StoreProductRelation::getUserIdCollect($this->userInfo['uid']);;
|
||||
$this->userInfo['orderStatusNum'] = StoreOrder::getOrderStatusNum($this->userInfo['uid']);
|
||||
$this->userInfo['notice'] = UserNotice::getNotice($this->userInfo['uid']);
|
||||
$this->userInfo['statu'] = (int)SystemConfig::getValue('store_brokerage_statu');
|
||||
@ -802,6 +802,8 @@ class AuthApi extends AuthController{
|
||||
public function get_order($uni = ''){
|
||||
if($uni == '') return JsonService::fail('参数错误');
|
||||
$order = StoreOrder::getUserOrderDetail($this->userInfo['uid'],$uni);
|
||||
$order = $order->toArray();
|
||||
$order['add_time'] = date('Y-m-d H:i:s',$order['add_time']);
|
||||
if(!$order) return JsonService::fail('订单不存在');
|
||||
return JsonService::successful(StoreOrder::tidyOrder($order,true));
|
||||
}
|
||||
@ -1451,9 +1453,10 @@ class AuthApi extends AuthController{
|
||||
header('content-type:image/jpg');
|
||||
if(!$this->userInfo['uid']) return JsonService::fail('授权失败,请重新授权');
|
||||
$path = 'public/uploads/routine/'.$this->userInfo['uid'].'.jpg';
|
||||
if(file_exists($path)) return JsonService::successful($path);
|
||||
$domain=SystemConfigService::get('site_url').'/';
|
||||
if(file_exists($path)) return JsonService::successful($domain.$path);
|
||||
else file_put_contents($path,RoutineCode::getCode($this->userInfo['uid']));
|
||||
return JsonService::successful($path);
|
||||
return JsonService::successful($domain.$path);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1498,6 +1501,7 @@ class AuthApi extends AuthController{
|
||||
public function get_bargain($bargainId = 0){
|
||||
if(!$bargainId) return JsonService::fail('参数错误');
|
||||
$bargain = StoreBargain::getBargainTerm($bargainId);
|
||||
if(empty($bargain)) return JsonService::fail('砍价已结束');
|
||||
$bargain['time'] = time();
|
||||
return JsonService::successful($bargain);
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace app\routine\model\routine;
|
||||
|
||||
use app\admin\model\system\SystemConfig;
|
||||
|
||||
class RoutineServer{
|
||||
/**
|
||||
* curl get方式
|
||||
@ -59,7 +61,9 @@ class RoutineServer{
|
||||
* @param string $routineAppSecret
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getAccessToken($routineAppId = 'wx7bc36cccc15e4be2',$routineAppSecret = 'a13757487f35b0ad88c03455b1903c4d'){
|
||||
public static function getAccessToken($routineAppId = '',$routineAppSecret = ''){
|
||||
$routineAppId = SystemConfig::getValue('routine_appId');
|
||||
$routineAppSecret = SystemConfig::getValue('routine_appsecret');
|
||||
$url ="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$routineAppId."&secret=".$routineAppSecret;
|
||||
return json_decode(self::curlGet($url),true);
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ class StoreCart extends ModelBasic
|
||||
$productInfoField = 'id,image,slider_image,price,ot_price,vip_price,postage,mer_id,give_integral,cate_id,sales,stock,store_name,store_info,unit_name,is_show,is_del,is_postage,cost';
|
||||
$seckillInfoField = 'id,image,price,ot_price,postage,give_integral,sales,stock,title as store_name,unit_name,is_show,is_del,is_postage,cost';
|
||||
$bargainInfoField = 'id,image,min_price as price,price as ot_price,postage,give_integral,sales,stock,title as store_name,unit_name,status as is_show,is_del,is_postage,cost';
|
||||
$combinationInfoField = 'id,image,price,ot_price,postage,give_integral,sales,stock,title as store_name,is_show,is_del,is_postage,cost';
|
||||
$combinationInfoField = 'id,image,price,postage,sales,stock,title as store_name,is_show,is_del,is_postage,cost';
|
||||
$model = new self();
|
||||
$valid = $invalid = [];
|
||||
$model = $model->where('uid',$uid)->where('type','product')->where('is_pay',0)
|
||||
|
||||
@ -21,7 +21,7 @@ class StoreCategory extends ModelBasic
|
||||
|
||||
public static function pidBySidList($pid)
|
||||
{
|
||||
return self::where('pid',$pid)->field('id,cate_name')->select();
|
||||
return self::where('pid',$pid)->field('id,cate_name,pid')->select();
|
||||
}
|
||||
|
||||
public static function cateIdByPid($cateId)
|
||||
|
||||
@ -21,6 +21,7 @@ use app\routine\model\user\UserBill;
|
||||
use app\routine\model\user\WechatUser;
|
||||
use basic\ModelBasic;
|
||||
use behavior\wap\StoreProductBehavior;
|
||||
use behavior\routine\StoreProductBehavior as StoreProductBehaviorRoutine;
|
||||
use behavior\wechat\PaymentBehavior;
|
||||
use service\HookService;
|
||||
use service\RoutineService;
|
||||
@ -515,7 +516,7 @@ class StoreOrder extends ModelBasic
|
||||
if(false !== self::edit(['status'=>2],$order['id'],'id') &&
|
||||
false !== StoreOrderStatus::status($order['id'],'user_take_delivery','用户已收货')){
|
||||
try{
|
||||
HookService::listen('store_product_order_user_take_delivery',$order,$uid,false,StoreProductBehavior::class);
|
||||
HookService::listen('store_product_order_user_take_delivery',$order,$uid,false,StoreProductBehaviorRoutine::class);
|
||||
}catch (\Exception $e){
|
||||
return self::setErrorInfo($e->getMessage());
|
||||
}
|
||||
@ -680,7 +681,8 @@ class StoreOrder extends ModelBasic
|
||||
$noTake = self::where('uid',$uid)->where('paid',1)->where('is_del',0)->where('status',1)->where('pay_type','<>','offline')->count();
|
||||
$noReply = self::where('uid',$uid)->where('paid',1)->where('is_del',0)->where('status',2)->count();
|
||||
$noPink = self::where('o.uid',$uid)->alias('o')->join('StorePink p','o.pink_id = p.id')->where('p.status',1)->where('o.paid',1)->where('o.is_del',0)->where('o.status',0)->where('o.pay_type','<>','offline')->count();
|
||||
return compact('noBuy','noPostage','noTake','noReply','noPink');
|
||||
$noRefund = self::where('uid',$uid)->where('paid',1)->where('is_del',0)->where('refund_status','IN','1,2')->count();
|
||||
return compact('noBuy','noPostage','noTake','noReply','noPink','noRefund');
|
||||
}
|
||||
|
||||
public static function gainUserIntegral($order)
|
||||
|
||||
@ -117,8 +117,7 @@ class StorePink extends ModelBasic
|
||||
* @param $id
|
||||
* @return int|string
|
||||
*/
|
||||
public static function getIsPinkUid($id){
|
||||
$uid = User::getActiveUid();
|
||||
public static function getIsPinkUid($id = 0,$uid = 0){
|
||||
$pinkT = self::where('id',$id)->where('uid',$uid)->where('is_refund',0)->count();
|
||||
$pink = self::whereOr('k_id',$id)->where('uid',$uid)->where('is_refund',0)->count();
|
||||
if($pinkT) return true;
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
namespace app\routine\model\store;
|
||||
|
||||
|
||||
use app\admin\model\store\StoreProductAttrValue;
|
||||
use app\admin\model\store\StoreProductAttrValue as StoreProductAttrValuemodel;
|
||||
use basic\ModelBasic;
|
||||
use traits\ModelTrait;
|
||||
|
||||
@ -137,7 +137,7 @@ class StoreProduct extends ModelBasic
|
||||
public static function decProductStock($num,$productId,$unique = '')
|
||||
{
|
||||
if($unique){
|
||||
$res = false !== StoreProductAttrValue::decProductAttrStock($productId,$unique,$num);
|
||||
$res = false !== StoreProductAttrValuemodel::decProductAttrStock($productId,$unique,$num);
|
||||
$res = $res && self::where('id',$productId)->setInc('sales',$num);
|
||||
}else{
|
||||
$res = false !== self::where('id',$productId)->dec('stock',$num)->inc('sales',$num)->update();
|
||||
|
||||
@ -22,7 +22,7 @@ class StoreProductRelation extends ModelBasic
|
||||
use ModelTrait;
|
||||
|
||||
/**
|
||||
* 获取用户收藏所有产品的个数
|
||||
* 获取用户点赞所有产品的个数
|
||||
* @param $uid
|
||||
* @return int|string
|
||||
*/
|
||||
@ -31,6 +31,16 @@ class StoreProductRelation extends ModelBasic
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户收藏所有产品的个数
|
||||
* @param $uid
|
||||
* @return int|string
|
||||
*/
|
||||
public static function getUserIdCollect($uid = 0){
|
||||
$count = self::where('uid',$uid)->where('type','collect')->count();
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加点赞 收藏
|
||||
* @param $productId
|
||||
|
||||
@ -52,7 +52,7 @@ class StoreProductReply extends ModelBasic
|
||||
public static function getProductReplyList($productId,$order = 'All',$first = 0,$limit = 8)
|
||||
{
|
||||
$model = self::productValidWhere('A')->where('A.product_id',$productId)
|
||||
->field('A.product_score,A.service_score,A.comment,A.pics,A.add_time,B.nickname,B.avatar,C.cart_info,A.merchant_reply_content')
|
||||
->field('A.product_score,A.service_score,A.comment,A.merchant_reply_content,A.merchant_reply_time,A.pics,A.add_time,B.nickname,B.avatar,C.cart_info,A.merchant_reply_content')
|
||||
->join('__USER__ B','A.uid = B.uid')
|
||||
->join('__STORE_ORDER_CART_INFO__ C','A.unique = C.unique');
|
||||
$baseOrder = 'A.add_time DESC,A.product_score DESC, A.service_score DESC';
|
||||
@ -71,6 +71,7 @@ class StoreProductReply extends ModelBasic
|
||||
$res['cart_info'] = json_decode($res['cart_info'],true)?:[];
|
||||
$res['suk'] = isset($res['cart_info']['productInfo']['attrInfo']) ? $res['cart_info']['productInfo']['attrInfo']['suk'] : '';
|
||||
$res['nickname'] = UtilService::anonymity($res['nickname']);
|
||||
$res['merchant_reply_time'] = date('Y-m-d H:i',$res['merchant_reply_time']);
|
||||
$res['add_time'] = date('Y-m-d H:i',$res['add_time']);
|
||||
$res['star'] = ceil(($res['product_score'] + $res['service_score'])/2);
|
||||
$res['comment'] = $res['comment']?:'此用户没有填写评价';
|
||||
@ -86,7 +87,7 @@ class StoreProductReply extends ModelBasic
|
||||
public static function getRecProductReply($productId)
|
||||
{
|
||||
$res = self::productValidWhere('A')->where('A.product_id',$productId)
|
||||
->field('A.product_score,A.service_score,A.comment,A.pics,A.add_time,B.nickname,B.avatar,C.cart_info')
|
||||
->field('A.product_score,A.service_score,A.comment,A.merchant_reply_content,A.merchant_reply_time,A.pics,A.add_time,B.nickname,B.avatar,C.cart_info')
|
||||
->join('__USER__ B','A.uid = B.uid')
|
||||
->join('__STORE_ORDER_CART_INFO__ C','A.unique = C.unique')
|
||||
->order('LENGTH(A.comment) DESC,A.product_score DESC, A.service_score DESC, A.add_time DESC')->find();
|
||||
|
||||
@ -96,4 +96,14 @@ class StoreSeckill extends ModelBasic
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改秒杀库存
|
||||
* @param int $num
|
||||
* @param int $seckillId
|
||||
* @return bool
|
||||
*/
|
||||
public static function decSeckillStock($num = 0,$seckillId = 0){
|
||||
$res = false !== self::where('id',$seckillId)->dec('stock',$num)->inc('sales',$num)->update();
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,8 @@
|
||||
namespace app\routine\model\user;
|
||||
|
||||
use basic\ModelBasic;
|
||||
use service\SystemConfigService;
|
||||
use think\Request;
|
||||
use think\Session;
|
||||
use traits\ModelTrait;
|
||||
|
||||
@ -24,7 +26,9 @@ class User extends ModelBasic
|
||||
{
|
||||
return self::edit([
|
||||
'nickname'=>$wechatUser['nickname']?:'',
|
||||
'avatar'=>$wechatUser['headimgurl']?:''
|
||||
'avatar'=>$wechatUser['headimgurl']?:'',
|
||||
'last_time'=>time(),
|
||||
'last_ip'=>Request::instance()->ip(),
|
||||
],$uid,'uid');
|
||||
}
|
||||
|
||||
@ -45,6 +49,9 @@ class User extends ModelBasic
|
||||
'spread_uid'=>$spread_uid,
|
||||
'uid'=>$routineUser['uid'],
|
||||
'add_time'=>$routineUser['add_time'],
|
||||
'add_ip'=>Request::instance()->ip(),
|
||||
'last_time'=>time(),
|
||||
'last_ip'=>Request::instance()->ip(),
|
||||
'user_type'=>$routineUser['user_type']
|
||||
]);
|
||||
}
|
||||
@ -78,4 +85,62 @@ class User extends ModelBasic
|
||||
if($isPromoter) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序用户一级分销
|
||||
* @param $orderInfo
|
||||
* @return bool
|
||||
*/
|
||||
public static function backOrderBrokerage($orderInfo)
|
||||
{
|
||||
$userInfo = User::getUserInfo($orderInfo['uid']);
|
||||
if(!$userInfo || !$userInfo['spread_uid']) return true;
|
||||
$storeBrokerageStatu = SystemConfigService::get('store_brokerage_statu') ? : 1;//获取后台分销类型
|
||||
if($storeBrokerageStatu == 1){
|
||||
if(!User::be(['uid'=>$userInfo['spread_uid'],'is_promoter'=>1])) return true;
|
||||
}
|
||||
$brokerageRatio = (SystemConfigService::get('store_brokerage_ratio') ?: 0)/100;
|
||||
if($brokerageRatio <= 0) return true;
|
||||
$cost = isset($orderInfo['cost']) ? $orderInfo['cost'] : 0;//成本价
|
||||
if($cost > $orderInfo['pay_price']) return true;//成本价大于支付价格时直接返回
|
||||
$brokeragePrice = bcmul(bcsub($orderInfo['pay_price'],$cost,2),$brokerageRatio,2);
|
||||
if($brokeragePrice <= 0) return true;
|
||||
$mark = $userInfo['nickname'].'成功消费'.floatval($orderInfo['pay_price']).'元,奖励推广佣金'.floatval($brokeragePrice);
|
||||
self::beginTrans();
|
||||
$res1 = UserBill::income('获得推广佣金',$userInfo['spread_uid'],'now_money','brokerage',$brokeragePrice,$orderInfo['id'],0,$mark);
|
||||
$res2 = self::bcInc($userInfo['spread_uid'],'now_money',$brokeragePrice,'uid');
|
||||
$res = $res1 && $res2;
|
||||
self::checkTrans($res);
|
||||
if($res) self::backOrderBrokerageTwo($orderInfo);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序 二级推广
|
||||
* @param $orderInfo
|
||||
* @return bool
|
||||
*/
|
||||
public static function backOrderBrokerageTwo($orderInfo){
|
||||
$userInfo = User::getUserInfo($orderInfo['uid']);
|
||||
$userInfoTwo = User::getUserInfo($userInfo['spread_uid']);
|
||||
if(!$userInfoTwo || !$userInfoTwo['spread_uid']) return true;
|
||||
$storeBrokerageStatu = SystemConfigService::get('store_brokerage_statu') ? : 1;//获取后台分销类型
|
||||
if($storeBrokerageStatu == 1){
|
||||
if(!User::be(['uid'=>$userInfoTwo['spread_uid'],'is_promoter'=>1])) return true;
|
||||
}
|
||||
$brokerageRatio = (SystemConfigService::get('store_brokerage_ratio_two') ?: 0)/100;
|
||||
if($brokerageRatio <= 0) return true;
|
||||
$cost = isset($orderInfo['cost']) ? $orderInfo['cost'] : 0;//成本价
|
||||
if($cost > $orderInfo['pay_price']) return true;//成本价大于支付价格时直接返回
|
||||
$brokeragePrice = bcmul(bcsub($orderInfo['pay_price'],$cost,2),$brokerageRatio,2);
|
||||
if($brokeragePrice <= 0) return true;
|
||||
$mark = '二级推广人'.$userInfo['nickname'].'成功消费'.floatval($orderInfo['pay_price']).'元,奖励推广佣金'.floatval($brokeragePrice);
|
||||
self::beginTrans();
|
||||
$res1 = UserBill::income('获得推广佣金',$userInfoTwo['spread_uid'],'now_money','brokerage',$brokeragePrice,$orderInfo['id'],0,$mark);
|
||||
$res2 = self::bcInc($userInfoTwo['spread_uid'],'now_money',$brokeragePrice,'uid');
|
||||
$res = $res1 && $res2;
|
||||
self::checkTrans($res);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
@ -13,7 +13,7 @@ use service\SystemConfigService;
|
||||
use service\WechatTemplateService;
|
||||
use think\Url;
|
||||
use traits\ModelTrait;
|
||||
|
||||
use app\routine\model\user\WechatUser;
|
||||
class UserExtract extends ModelBasic
|
||||
{
|
||||
use ModelTrait;
|
||||
@ -25,9 +25,9 @@ class UserExtract extends ModelBasic
|
||||
//已提现
|
||||
const SUCCESS_STATUS = 1;
|
||||
|
||||
protected static $extractType = ['alipay','bank'];
|
||||
protected static $extractType = ['alipay','bank','weixin'];
|
||||
|
||||
protected static $extractTypeMsg = ['alipay'=>'支付宝','bank'=>'银行卡'];
|
||||
protected static $extractTypeMsg = ['alipay'=>'支付宝','bank'=>'银行卡','weixin'=>'微信'];
|
||||
|
||||
protected static $status = array(
|
||||
-1=>'未通过',
|
||||
@ -38,52 +38,66 @@ class UserExtract extends ModelBasic
|
||||
public static function userExtract($userInfo,$data){
|
||||
if(!in_array($data['extract_type'],self::$extractType))
|
||||
return self::setErrorInfo('提现方式不存在');
|
||||
if($userInfo['now_money'] < $data['extract_price'])
|
||||
return self::setErrorInfo('余额不足');
|
||||
if(!$data['real_name'])
|
||||
return self::setErrorInfo('输入姓名有误');
|
||||
$extractMinPrice = floatval(SystemConfigService::get('user_extract_min_price'))?:0;
|
||||
if($data['extract_price'] < $extractMinPrice)
|
||||
return self::setErrorInfo('提现金额不能小于'.$extractMinPrice);
|
||||
$balance = bcsub($userInfo['now_money'],$data['extract_price']);
|
||||
$balance = bcsub($userInfo['now_money'],$data['money']);
|
||||
$insertData = [
|
||||
'uid'=>$userInfo['uid'],
|
||||
'real_name'=>$data['real_name'],
|
||||
'extract_type'=>$data['extract_type'],
|
||||
'extract_price'=>($data['extract_price']),
|
||||
'extract_price'=>(int)$data['money'],
|
||||
'add_time'=>time(),
|
||||
'balance'=>$balance,
|
||||
'status'=>self::AUDIT_STATUS
|
||||
];
|
||||
if(isset($data['$name'])){
|
||||
$insertData['real_name']=$data['$name'];
|
||||
}else{
|
||||
$insertData['real_name']='';
|
||||
}
|
||||
if(isset($data['cardnum'])){
|
||||
$insertData['bank_code']=$data['cardnum'];
|
||||
}else{
|
||||
$insertData['bank_code']='';
|
||||
}
|
||||
if(isset($data['bankname'])){
|
||||
$insertData['bank_address']=$data['bankname'];
|
||||
}else{
|
||||
$insertData['bank_address']='';
|
||||
}
|
||||
if(isset($data['weixin'])){
|
||||
$insertData['wechat']=$data['weixin'];
|
||||
}else{
|
||||
$insertData['wechat']='';
|
||||
}
|
||||
if($data['extract_type'] == 'alipay'){
|
||||
if(!$data['alipay_code']) return self::setErrorInfo('请输入支付宝账号');
|
||||
$insertData['alipay_code'] = $data['alipay_code'];
|
||||
$mark = '使用支付宝提现'.$insertData['extract_price'].'元';
|
||||
}else{
|
||||
if(!$data['bank_code']) return self::setErrorInfo('请输入银行卡账号');
|
||||
if(!$data['bank_address']) return self::setErrorInfo('请输入开户行信息');
|
||||
$insertData['bank_code'] = $data['bank_code'];
|
||||
$insertData['bank_address'] = $data['bank_address'];
|
||||
}elseif($data['extract_type'] == 'bank'){
|
||||
if(!$data['cardnum']) return self::setErrorInfo('请输入银行卡账号');
|
||||
if(!$data['bankname']) return self::setErrorInfo('请输入开户行信息');
|
||||
$mark = '使用银联卡'.$insertData['bank_code'].'提现'.$insertData['extract_price'].'元';
|
||||
}else{
|
||||
if(!$data['weixin']) return self::setErrorInfo('请输入微信号');
|
||||
$mark = '使用微信提现'.$insertData['extract_price'].'元';
|
||||
}
|
||||
self::beginTrans();
|
||||
$res1 = self::set($insertData);
|
||||
if(!$res1) return self::setErrorInfo('提现失败');
|
||||
$res2 = User::edit(['now_money'=>$balance],$userInfo['uid'],'uid');
|
||||
$res3 = UserBill::expend('余额提现',$userInfo['uid'],'now_money','extract',$data['extract_price'],$res1['id'],$balance,$mark);
|
||||
$res3 = UserBill::expend('余额提现',$userInfo['uid'],'now_money','extract',$data['money'],$res1['id'],$balance,$mark);
|
||||
|
||||
$res = $res2 && $res3;
|
||||
WechatTemplateService::sendTemplate(
|
||||
WechatUser::uidToOpenid($userInfo['uid']),
|
||||
WechatTemplateService::USER_BALANCE_CHANGE,
|
||||
[
|
||||
'first'=>'你好,申请余额提现成功!',
|
||||
'keyword1'=>'余额提现',
|
||||
'keyword2'=>date('Y-m-d'),
|
||||
'keyword3'=>$data['extract_price'],
|
||||
'remark'=>'点击查看我的余额明细'
|
||||
],
|
||||
Url::build('wap/My/balance',[],true,true)
|
||||
);
|
||||
// WechatTemplateService::sendTemplate(
|
||||
// WechatUser::uidToOpenid($userInfo['uid']),
|
||||
// WechatTemplateService::USER_BALANCE_CHANGE,
|
||||
// [
|
||||
// 'first'=>'你好,申请余额提现成功!',
|
||||
// 'keyword1'=>'余额提现',
|
||||
// 'keyword2'=>date('Y-m-d'),
|
||||
// 'keyword3'=>$data['money'],
|
||||
// 'remark'=>'点击查看我的余额明细'
|
||||
// ],
|
||||
// Url::build('wap/My/balance',[],true,true)
|
||||
// );
|
||||
if($res)
|
||||
return true;
|
||||
else
|
||||
|
||||
@ -7,9 +7,8 @@
|
||||
|
||||
namespace app\routine\model\user;
|
||||
|
||||
use app\wap\model\user\WechatUser;
|
||||
use basic\ModelBasic;
|
||||
use service\WechatService;
|
||||
use service\RoutineService;
|
||||
use traits\ModelTrait;
|
||||
|
||||
class UserRecharge extends ModelBasic
|
||||
@ -37,7 +36,7 @@ class UserRecharge extends ModelBasic
|
||||
|
||||
public static function jsPay($orderInfo)
|
||||
{
|
||||
return WechatService::jsPay(WechatUser::uidToOpenid($orderInfo['uid']),$orderInfo['order_id'],$orderInfo['price'],'user_recharge','用户充值');
|
||||
return RoutineService::payRoutine(WechatUser::uidToOpenid($orderInfo['uid']),$orderInfo['order_id'],$orderInfo['price'],'user_recharge','用户充值');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -7,9 +7,10 @@
|
||||
|
||||
namespace app\routine\model\user;
|
||||
|
||||
use app\routine\model\store\StoreCouponUser;
|
||||
use basic\ModelBasic;
|
||||
use service\SystemConfigService;
|
||||
use traits\ModelTrait;
|
||||
|
||||
/**
|
||||
* 微信用户model
|
||||
* Class WechatUser
|
||||
@ -21,8 +22,22 @@ class WechatUser extends ModelBasic
|
||||
|
||||
public static function getOpenId($uid = ''){
|
||||
if($uid == '') return false;
|
||||
return self::where('uid',$uid)->value('openid');
|
||||
return self::where('uid',$uid)->value('routine_openid');
|
||||
}
|
||||
/**
|
||||
* 用uid获得openid
|
||||
* @param $uid
|
||||
* @return mixed
|
||||
*/
|
||||
public static function uidToOpenid($uid)
|
||||
{
|
||||
$openid = self::where('uid',$uid)->value('routine_openid');
|
||||
return $openid;
|
||||
}
|
||||
|
||||
|
||||
public static function userTakeOrderGiveCoupon($uid)
|
||||
{
|
||||
$couponId = SystemConfigService::get('store_order_give_coupon');
|
||||
if($couponId) StoreCouponUser::addUserCoupon($uid,$couponId);
|
||||
}
|
||||
}
|
||||
32
extend/behavior/routine/StoreProductBehavior.php
Normal file
32
extend/behavior/routine/StoreProductBehavior.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @author: xaboy<365615158@qq.com>
|
||||
* @day: 2017/12/18
|
||||
*/
|
||||
|
||||
namespace behavior\routine;
|
||||
|
||||
|
||||
use app\routine\model\store\StoreOrder;
|
||||
use app\routine\model\user\User;
|
||||
use app\routine\model\user\WechatUser;
|
||||
use service\SystemConfigService;
|
||||
|
||||
class StoreProductBehavior
|
||||
{
|
||||
/**
|
||||
* 用户确认收货
|
||||
* @param $order
|
||||
* @param $uid
|
||||
*/
|
||||
public static function storeProductOrderUserTakeDelivery($order, $uid)
|
||||
{
|
||||
$res1 = StoreOrder::gainUserIntegral($order);
|
||||
$res2 = User::backOrderBrokerage($order);
|
||||
StoreOrder::orderTakeAfter($order);
|
||||
$giveCouponMinPrice = SystemConfigService::get('store_give_con_min_price');
|
||||
if($order['total_price'] >= $giveCouponMinPrice) WechatUser::userTakeOrderGiveCoupon($uid);
|
||||
if(!($res1 && $res2)) exception('收货失败!');
|
||||
}
|
||||
}
|
||||
@ -58,12 +58,12 @@ class UpgradeService extends FileService
|
||||
* @param array $post_data
|
||||
*/
|
||||
public static function start(){
|
||||
$pach=APP_PATH.'version';
|
||||
$pach=APP_PATH.'version.php';
|
||||
$request=Request::instance();
|
||||
if(!file_exists($pach)) return self::getRet($pach.'升级文件丢失,请联系管理员');
|
||||
$version=@file($pach);
|
||||
if(!isset($version[0])) return self::getRet('获取失败');
|
||||
$lv=self::request_post(self::$isNowVersionUrl,['token'=>self::get_token($request->ip())]);
|
||||
$lv=self::request_post(self::$isNowVersionUrl,['token'=>self::get_token()]);
|
||||
if(isset($lv['code']) && $lv['code']==200)
|
||||
$version_lv=isset($lv['data']['version']) && $lv['data']['version'] ? $lv['data']['version'] : false;
|
||||
else
|
||||
|
||||
@ -32,17 +32,17 @@ class WechatService
|
||||
$wechat = SystemConfigService::more(['wechat_appid','wechat_appsecret','wechat_token']);
|
||||
$payment = SystemConfigService::more(['pay_weixin_mchid','pay_weixin_client_cert','pay_weixin_client_key','pay_weixin_key','pay_weixin_open']);
|
||||
$config = [
|
||||
'app_id'=>isset($wechat['wechat_appid']) ? $wechat['wechat_appid']:'',
|
||||
'secret'=>isset($wechat['wechat_appsecret']) ? $wechat['wechat_appsecret']:'',
|
||||
'token'=>isset($wechat['wechat_token']) ? $wechat['wechat_token']:'',
|
||||
'app_id'=>isset($wechat['wechat_appid']) ? trim($wechat['wechat_appid']):'',
|
||||
'secret'=>isset($wechat['wechat_appsecret']) ? trim($wechat['wechat_appsecret']):'',
|
||||
'token'=>isset($wechat['wechat_token']) ? trim($wechat['wechat_token']):'',
|
||||
'guzzle' => [
|
||||
'timeout' => 10.0, // 超时时间(秒)
|
||||
],
|
||||
];
|
||||
if(isset($payment['pay_weixin_open']) && $payment['pay_weixin_open'] == 1){
|
||||
$config['payment'] = [
|
||||
'merchant_id'=>$payment['pay_weixin_mchid'],
|
||||
'key'=>$payment['pay_weixin_key'],
|
||||
'merchant_id'=>trim($payment['pay_weixin_mchid']),
|
||||
'key'=>trim($payment['pay_weixin_key']),
|
||||
'cert_path'=>realpath('.'.$payment['pay_weixin_client_cert']),
|
||||
'key_path'=>realpath('.'.$payment['pay_weixin_client_key']),
|
||||
'notify_url'=>SystemConfigService::get('site_url').Url::build('wap/Wechat/notify')
|
||||
|
||||
@ -81,8 +81,7 @@ trait ModelTrait
|
||||
public static function page($model = null, $eachFn = null, $params = [], $limit = 20)
|
||||
{
|
||||
if(is_numeric($eachFn) && is_numeric($model)){
|
||||
parent::page($model,$eachFn);
|
||||
return new self;
|
||||
return parent::page($model,$eachFn);
|
||||
}
|
||||
|
||||
if(is_numeric($eachFn)){
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user