1
This commit is contained in:
@@ -33,8 +33,8 @@ public class AddGoodsDialog extends CenterPopupView {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mListener != null) {
|
||||
mListener.onConfirm(etInfo.getText().toString().trim() + ":" + etPrice.getText().toString().trim() + ":" +
|
||||
etNum.getText().toString().trim(),etInfo.getText().toString().trim());
|
||||
mListener.onConfirm(etInfo.getText().toString().trim() + ":" + etNum.getText().toString().trim() + ":" +
|
||||
etPrice.getText().toString().trim() ,etInfo.getText().toString().trim());
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@@ -123,6 +123,7 @@ public class OrderActivity extends BaseActivity<ActivityOrderBinding> {
|
||||
b.btnCancel.setVisibility(View.VISIBLE);
|
||||
b.btnCancel.setText("取消订单");
|
||||
b.tvInfo.setVisibility(View.VISIBLE);
|
||||
|
||||
} else if (orderType == 2) {
|
||||
//待发货
|
||||
b.btnFk.setVisibility(View.VISIBLE);
|
||||
@@ -204,7 +205,9 @@ public class OrderActivity extends BaseActivity<ActivityOrderBinding> {
|
||||
public void onClick(View v) {
|
||||
if (b.btnFk.getText().equals("付款")) {
|
||||
//付款
|
||||
|
||||
Intent intent = new Intent(context, PayActivity.class);
|
||||
intent.putExtra("payment_amount", orderListBean.getOrder_money());
|
||||
startActivityForResult(intent, 18);
|
||||
} else if (b.btnFk.getText().equals("取消订单")) {
|
||||
new XPopup.Builder(context).asConfirm("", "确定要取消订单吗?", new OnConfirmListener() {
|
||||
@Override
|
||||
@@ -383,6 +386,9 @@ public class OrderActivity extends BaseActivity<ActivityOrderBinding> {
|
||||
if (requestCode == 15 && resultCode == 200) {
|
||||
page = 1;
|
||||
getList();
|
||||
} else if (requestCode == 18 && resultCode == 200) {
|
||||
page = 1;
|
||||
getList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.sl.house_property.order;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
@@ -195,7 +196,9 @@ public class OrderDetailActivity extends BaseActivity<ActivityOrderDetailBinding
|
||||
public void onClick(View v) {
|
||||
if (mDataBinding.btnFk.getText().equals("付款")) {
|
||||
//付款
|
||||
|
||||
Intent intent = new Intent(context, PayActivity.class);
|
||||
intent.putExtra("payment_amount", orderListBean.getOrder_money());
|
||||
startActivityForResult(intent, 18);
|
||||
} else if (mDataBinding.btnFk.getText().equals("取消订单")) {
|
||||
new XPopup.Builder(context).asConfirm("", "确定要取消订单吗?", new OnConfirmListener() {
|
||||
@Override
|
||||
@@ -229,6 +232,14 @@ public class OrderDetailActivity extends BaseActivity<ActivityOrderDetailBinding
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 18 && resultCode == 200) {
|
||||
getData();
|
||||
}
|
||||
}
|
||||
|
||||
private void orderAction(int action, String order_id, String info) {
|
||||
progressDialog.setMessage("提交中");
|
||||
progressDialog.show();
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
package com.sl.house_property.order;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.internal.LinkedTreeMap;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.sl.house_property.BaseActivity;
|
||||
import com.sl.house_property.R;
|
||||
import com.sl.house_property.databinding.ActivityPayBinding;
|
||||
import com.tencent.mm.opensdk.modelpay.PayReq;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -25,15 +32,23 @@ import utils.Md5;
|
||||
|
||||
public class PayActivity extends BaseActivity<ActivityPayBinding> {
|
||||
private Context context;
|
||||
private String goods_id;
|
||||
private String product_code;
|
||||
private String goods_num;
|
||||
private String sale_price;
|
||||
private String consignee_id;
|
||||
private String total_amount;
|
||||
private String payment_amount;
|
||||
private String goods_user_id;
|
||||
private String order_number;
|
||||
private BroadcastReceiver receiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent1) {
|
||||
if (type == 1) {
|
||||
Intent intent = new Intent(context, OrderActivity.class);
|
||||
intent.putExtra("type", 1);
|
||||
intent.putExtra("orderType", 2);
|
||||
startActivityForResult(intent, 0);
|
||||
} else {
|
||||
PayActivity.this.setResult(200);
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
private int type;
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
@@ -43,6 +58,7 @@ public class PayActivity extends BaseActivity<ActivityPayBinding> {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
context = this;
|
||||
progressDialog = new ProgressDialog(this);
|
||||
ImmersionBar.with(this)
|
||||
@@ -58,15 +74,9 @@ public class PayActivity extends BaseActivity<ActivityPayBinding> {
|
||||
});
|
||||
Intent intent = getIntent();
|
||||
mDataBinding.tvTitle.setText("支付");
|
||||
goods_id = intent.getStringExtra("goods_id");
|
||||
product_code = intent.getStringExtra("product_code");
|
||||
goods_num = intent.getStringExtra("goods_num");
|
||||
sale_price = intent.getStringExtra("sale_price");
|
||||
consignee_id = intent.getStringExtra("consignee_id");
|
||||
total_amount = intent.getStringExtra("total_amount");
|
||||
type = intent.getIntExtra("type", 0);
|
||||
payment_amount = intent.getStringExtra("payment_amount");
|
||||
goods_user_id = intent.getStringExtra("goods_user_id");
|
||||
order_number = intent.getStringExtra("order_number");
|
||||
|
||||
String wallet = intent.getStringExtra("wallet");
|
||||
mDataBinding.tv.setText("钱包支付(余额 ¥" + wallet + ")");
|
||||
mDataBinding.tvAmount.setText(payment_amount);
|
||||
@@ -114,7 +124,7 @@ public class PayActivity extends BaseActivity<ActivityPayBinding> {
|
||||
return;
|
||||
}
|
||||
if (mDataBinding.wxpaly.isChecked()) {
|
||||
setToast("微信支付" + payment_amount + "元");
|
||||
wxPay();
|
||||
return;
|
||||
}
|
||||
if (mDataBinding.qianbao2.isChecked()) {
|
||||
@@ -122,6 +132,50 @@ public class PayActivity extends BaseActivity<ActivityPayBinding> {
|
||||
}
|
||||
}
|
||||
});
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction("PaySuccess");
|
||||
registerReceiver(receiver, intentFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
unregisterReceiver(receiver);
|
||||
}
|
||||
|
||||
private void wxPay() {
|
||||
RegisterUser user =
|
||||
Config.getInstance(context).getUser();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (user != null) {
|
||||
map.put("userid", user.getUserid());
|
||||
} else {
|
||||
map.put("userid", 0 + "");
|
||||
}
|
||||
map.put("app", "System");
|
||||
map.put("class", "OrderPrePayId");
|
||||
map.put("amount", payment_amount);
|
||||
map.put("sign", Md5.md5("System" + "OrderPrePayId" + Md5.secret));
|
||||
loader.getMovie(ApiConfig.BASE_URL, map).subscribe(new Action1<Resultcode>() {
|
||||
@Override
|
||||
public void call(Resultcode resultcode) {
|
||||
if (resultcode.status == 0) {
|
||||
LinkedTreeMap adta = (LinkedTreeMap) resultcode.data;
|
||||
WxPayEntity wxPayEntity = new Gson().fromJson(new Gson().toJson(adta), WxPayEntity.class);
|
||||
|
||||
IWXAPI wxapi = WXAPIFactory.createWXAPI(PayActivity.this, wxPayEntity.getAppid());
|
||||
PayReq payReq = new PayReq();
|
||||
payReq.appId = wxPayEntity.getAppid();
|
||||
payReq.partnerId = wxPayEntity.getPartnerid();
|
||||
payReq.prepayId = wxPayEntity.getPrepayid();
|
||||
payReq.packageValue = "Sign=WXPay";
|
||||
payReq.nonceStr = wxPayEntity.getNoncestr();
|
||||
payReq.timeStamp = wxPayEntity.getTimestamp();
|
||||
payReq.sign = wxPayEntity.getPaySign();
|
||||
wxapi.sendReq(payReq);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loader loader = new Loader();
|
||||
@@ -139,7 +193,7 @@ public class PayActivity extends BaseActivity<ActivityPayBinding> {
|
||||
}
|
||||
map.put("app", "Order");
|
||||
map.put("class", "PayBalance");
|
||||
map.put("order_number", order_number);
|
||||
map.put("order_number", payment_amount);
|
||||
map.put("sign", Md5.md5("Order" + "PayBalance" + Md5.secret));
|
||||
loader.getMovie(ApiConfig.BASE_URL, map).subscribe(new Action1<Resultcode>() {
|
||||
@Override
|
||||
|
||||
@@ -285,6 +285,7 @@ public class SettleActivity extends BaseActivity<ActivitySettleBinding> {
|
||||
|
||||
Intent intent = new Intent(context, PayActivity.class);
|
||||
intent.putExtra("goods_id", goods_id);
|
||||
intent.putExtra("type", 1);
|
||||
intent.putExtra("product_code", product_code);
|
||||
intent.putExtra("goods_num", goods_num);
|
||||
intent.putExtra("sale_price", sale_price);
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.sl.house_property.order;
|
||||
|
||||
import android.support.annotation.Keep;
|
||||
|
||||
@Keep
|
||||
public class WxPayEntity {
|
||||
|
||||
private String appid;
|
||||
private String partnerid;
|
||||
private String timestamp;
|
||||
private String noncestr;
|
||||
private String prepayid;
|
||||
private String paySign;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WxPayEntity{" +
|
||||
"appid='" + appid + '\'' +
|
||||
", partnerid='" + partnerid + '\'' +
|
||||
", timestamp='" + timestamp + '\'' +
|
||||
", noncestr='" + noncestr + '\'' +
|
||||
", prepayid='" + prepayid + '\'' +
|
||||
", paySign='" + paySign + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public String getAppid() {
|
||||
return appid;
|
||||
}
|
||||
|
||||
public void setAppid(String appid) {
|
||||
this.appid = appid;
|
||||
}
|
||||
|
||||
public String getPartnerid() {
|
||||
return partnerid;
|
||||
}
|
||||
|
||||
public void setPartnerid(String partnerid) {
|
||||
this.partnerid = partnerid;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(String timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getNoncestr() {
|
||||
return noncestr;
|
||||
}
|
||||
|
||||
public void setNoncestr(String noncestr) {
|
||||
this.noncestr = noncestr;
|
||||
}
|
||||
|
||||
public String getPrepayid() {
|
||||
return prepayid;
|
||||
}
|
||||
|
||||
public void setPrepayid(String prepayid) {
|
||||
this.prepayid = prepayid;
|
||||
}
|
||||
|
||||
public String getPaySign() {
|
||||
return paySign;
|
||||
}
|
||||
|
||||
public void setPaySign(String paySign) {
|
||||
this.paySign = paySign;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.sl.house_property.wxapi;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.tencent.mm.opensdk.constants.ConstantsAPI;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseReq;
|
||||
import com.tencent.mm.opensdk.modelbase.BaseResp;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
|
||||
|
||||
public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {
|
||||
@Override
|
||||
public void onReq(BaseReq baseReq) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResp(BaseResp baseResp) {
|
||||
if (baseResp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
|
||||
if (baseResp.errCode == 0) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction("PaySuccess");
|
||||
this.sendBroadcast(intent);
|
||||
// val intent = Intent()
|
||||
// intent.action = "PaySuccess"
|
||||
// intent.putExtra("payCode", p0.errCode)
|
||||
// this.sendBroadcast(intent)
|
||||
// finish()
|
||||
}
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user