...
|
...
|
@@ -222,13 +222,13 @@ class Shop extends Api |
|
|
})
|
|
|
*/
|
|
|
public function getAddressInfo(){
|
|
|
$map['id']=input('address_id');
|
|
|
$map['user_id']=$this->auth->id;
|
|
|
$address=UserAddress::get($map);
|
|
|
if (empty($address)){
|
|
|
$this->error('地址不存在');
|
|
|
}
|
|
|
$this->success('',$address);
|
|
|
$map['id']=input('address_id');
|
|
|
$map['user_id']=$this->auth->id;
|
|
|
$address=UserAddress::get($map);
|
|
|
if (empty($address)){
|
|
|
$this->error('地址不存在');
|
|
|
}
|
|
|
$this->success('',$address);
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
@@ -285,11 +285,11 @@ class Shop extends Api |
|
|
$map1['user_id']=$user_id;
|
|
|
$map1['defaultswitch']=1;
|
|
|
$update1['defaultswitch']=0;
|
|
|
$address=$UserAddress->get($map1);
|
|
|
if(!empty($address)){
|
|
|
$address->save($update1);
|
|
|
}
|
|
|
$UserAddress->get($map)->save($update);
|
|
|
$address=$UserAddress->get($map1);
|
|
|
if(!empty($address)){
|
|
|
$address->save($update1);
|
|
|
}
|
|
|
$UserAddress->get($map)->save($update);
|
|
|
$this->success('设置成功!');
|
|
|
}
|
|
|
|
...
|
...
|
@@ -314,7 +314,7 @@ class Shop extends Api |
|
|
if (empty($one)){
|
|
|
$this->error('地址不存在');
|
|
|
}
|
|
|
$result=$one->delete();
|
|
|
$result=$one->delete();
|
|
|
if ($result>0){
|
|
|
$this->success('操作成功!');
|
|
|
}else{
|
...
|
...
|
@@ -469,100 +469,95 @@ class Shop extends Api |
|
|
case 2: //现金支付
|
|
|
//需要查看用户积分数量 判断出现金支付金额
|
|
|
if ($good['good_data']==2){
|
|
|
$this->error('现金类型商品无法用现金支付');
|
|
|
$this->error('现金类型商品无法用现金支付');
|
|
|
}
|
|
|
|
|
|
if ($user['score']>=($good['price']*$site['good_ratio'])){
|
|
|
$real_fee=0;
|
|
|
$cost_score=$good['price']*$site['good_ratio'];
|
|
|
/*扣除相应积分*/
|
|
|
$insert['order_sn']=cmf_get_order_sn();
|
|
|
$insert['user_id']=$user_id;
|
|
|
$insert['user_name']=$address['user_name'];
|
|
|
$insert['tel']=$address['tel'];
|
|
|
$insert['address']=$address['address'];
|
|
|
$insert['good_id']=$good_id;
|
|
|
$insert['score']=$cost_score;
|
|
|
$insert['price']=$real_fee;
|
|
|
$insert['status']=1;
|
|
|
$insert['pay_type']=2;
|
|
|
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
Orders::create($insert);
|
|
|
$User->where('id',$user_id)->setDec('score',$good['price']);
|
|
|
$insert_log['user_id']=$user_id;
|
|
|
$insert_log['score']=0-$good['price'];
|
|
|
$insert_log['memo']='积分兑换';
|
|
|
|
|
|
$Goods=new Goods();
|
|
|
$Goods->where('id',$good_id)->setDec('kucun');
|
|
|
ScoreLog::create($insert_log);
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
// 回滚事务
|
|
|
dump($e->getMessage());
|
|
|
Db::rollback();
|
|
|
$this->error('支付失败!');
|
|
|
}
|
|
|
$this->success('支付成功!');
|
|
|
|
|
|
}else{
|
|
|
$real_fee=ceil(($good['money']-$user['score']/$site['good_ratio'])*100)/100;
|
|
|
$cost_score=$user['score'];
|
|
|
|
|
|
$insert['order_sn']=cmf_get_order_sn();
|
|
|
$insert['user_id']=$user_id;
|
|
|
$insert['user_name']=$address['user_name'];
|
|
|
$insert['tel']=$address['tel'];
|
|
|
$insert['address']=$address['address'];
|
|
|
$insert['good_id']=$good_id;
|
|
|
$insert['score']=$cost_score;
|
|
|
$insert['price']=$real_fee;
|
|
|
$insert['status']=0;
|
|
|
$insert['pay_type']=2;
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
Orders::create($insert);
|
|
|
$User->where('id',$user_id)->setDec('score',$cost_score);
|
|
|
$insert_log['user_id']=$user_id;
|
|
|
$insert_log['score']=0-$cost_score;
|
|
|
$insert_log['memo']='积分兑换';
|
|
|
$Goods=new Goods();
|
|
|
$Goods->where('id',$good_id)->setDec('kucun');
|
|
|
ScoreLog::create($insert_log);
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
// 回滚事务
|
|
|
dump($e->getMessage());
|
|
|
Db::rollback();
|
|
|
$this->error('支付失败!');
|
|
|
}
|
|
|
$third=Third::get(['user_id'=>$user_id]);
|
|
|
/*调用微信支付*/
|
|
|
$notify_url=url('/api/common/notifyx1','','',true);
|
|
|
$params = [
|
|
|
<<<<<<< HEAD
|
|
|
if ($user['score']>=($good['price']*$site['good_ratio'])){
|
|
|
$real_fee=0;
|
|
|
$cost_score=$good['price']*$site['good_ratio'];
|
|
|
/*扣除相应积分*/
|
|
|
$insert['order_sn']=cmf_get_order_sn();
|
|
|
$insert['user_id']=$user_id;
|
|
|
$insert['user_name']=$address['user_name'];
|
|
|
$insert['tel']=$address['tel'];
|
|
|
$insert['address']=$address['address'];
|
|
|
$insert['good_id']=$good_id;
|
|
|
$insert['score']=$cost_score;
|
|
|
$insert['price']=$real_fee;
|
|
|
$insert['status']=1;
|
|
|
$insert['pay_type']=2;
|
|
|
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
Orders::create($insert);
|
|
|
$User->where('id',$user_id)->setDec('score',$good['price']);
|
|
|
$insert_log['user_id']=$user_id;
|
|
|
$insert_log['score']=0-$good['price'];
|
|
|
$insert_log['memo']='积分兑换';
|
|
|
|
|
|
$Goods=new Goods();
|
|
|
$Goods->where('id',$good_id)->setDec('kucun');
|
|
|
ScoreLog::create($insert_log);
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
// 回滚事务
|
|
|
dump($e->getMessage());
|
|
|
Db::rollback();
|
|
|
$this->error('支付失败!');
|
|
|
}
|
|
|
$this->success('支付成功!');
|
|
|
|
|
|
}else{
|
|
|
$real_fee=ceil(($good['money']-$user['score']/$site['good_ratio'])*100)/100;
|
|
|
$cost_score=$user['score'];
|
|
|
|
|
|
$insert['order_sn']=cmf_get_order_sn();
|
|
|
$insert['user_id']=$user_id;
|
|
|
$insert['user_name']=$address['user_name'];
|
|
|
$insert['tel']=$address['tel'];
|
|
|
$insert['address']=$address['address'];
|
|
|
$insert['good_id']=$good_id;
|
|
|
$insert['score']=$cost_score;
|
|
|
$insert['price']=$real_fee;
|
|
|
$insert['status']=0;
|
|
|
$insert['pay_type']=2;
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
Orders::create($insert);
|
|
|
$User->where('id',$user_id)->setDec('score',$cost_score);
|
|
|
$insert_log['user_id']=$user_id;
|
|
|
$insert_log['score']=0-$cost_score;
|
|
|
$insert_log['memo']='积分兑换';
|
|
|
$Goods=new Goods();
|
|
|
$Goods->where('id',$good_id)->setDec('kucun');
|
|
|
ScoreLog::create($insert_log);
|
|
|
// 提交事务
|
|
|
Db::commit();
|
|
|
} catch (\Exception $e) {
|
|
|
// 回滚事务
|
|
|
dump($e->getMessage());
|
|
|
Db::rollback();
|
|
|
$this->error('支付失败!');
|
|
|
}
|
|
|
$third=Third::get(['user_id'=>$user_id]);
|
|
|
/*调用微信支付*/
|
|
|
$notify_url=url('/api/common/notifyx1','','',true);
|
|
|
$params = [
|
|
|
'amount'=>$real_fee,
|
|
|
=======
|
|
|
/* 'amount'=>$real_fee,*/
|
|
|
'amount'=>0.01,
|
|
|
>>>>>>> 59772386ba3ea29fef294ae3f7567114ff84f119
|
|
|
'orderid'=>"$insert[order_sn]",
|
|
|
'type'=>"wechat",
|
|
|
'title'=>"$good[good_name]",
|
|
|
'notifyurl'=>$notify_url,
|
|
|
'returnurl'=>$notify_url,
|
|
|
'method'=>"miniapp",
|
|
|
'openid'=>"$third->openid",
|
|
|
'auth_code'=>"1111"
|
|
|
];
|
|
|
$payment=\addons\epay\library\Service::submitOrder($params);
|
|
|
$payment=json_decode($payment,true);
|
|
|
$this->success('支付信息',$payment);
|
|
|
}
|
|
|
'orderid'=>"$insert[order_sn]",
|
|
|
'type'=>"wechat",
|
|
|
'title'=>"$good[good_name]",
|
|
|
'notifyurl'=>$notify_url,
|
|
|
'returnurl'=>$notify_url,
|
|
|
'method'=>"miniapp",
|
|
|
'openid'=>"$third->openid",
|
|
|
'auth_code'=>"1111"
|
|
|
];
|
|
|
$payment=\addons\epay\library\Service::submitOrder($params);
|
|
|
$payment=json_decode($payment,true);
|
|
|
$this->success('支付信息',$payment);
|
|
|
}
|
|
|
break;
|
|
|
default;
|
|
|
}
|
...
|
...
|
@@ -648,5 +643,5 @@ class Shop extends Api |
|
|
$this->success('操作成功!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|