Browse Source

增加子订单接口

plate
fyf 1 year ago
parent
commit
7a8e11ddb7
7 changed files with 90 additions and 28 deletions
  1. +54
    -17
      app/src/main/java/com/bpa/scalage/MainActivity.java
  2. +2
    -2
      app/src/main/java/com/bpa/scalage/app/Main.java
  3. +2
    -6
      app/src/main/java/com/bpa/scalage/config/ConfigName.java
  4. +1
    -1
      app/src/main/java/com/bpa/scalage/config/MessageName.java
  5. +5
    -1
      app/src/main/java/com/bpa/scalage/data/DataBus.java
  6. +1
    -1
      app/src/main/java/com/bpa/scalage/helper/HttpUtils.java
  7. +25
    -0
      app/src/main/java/com/bpa/scalage/mode/Order/AddSubOrder.java

+ 54
- 17
app/src/main/java/com/bpa/scalage/MainActivity.java View File

@@ -21,6 +21,7 @@ import com.bpa.scalage.message.MessageLooper;
import com.bpa.scalage.message.MessageManager;
import com.bpa.scalage.mode.Foods.FoodModel;
import com.bpa.scalage.helper.T;
import com.bpa.scalage.mode.Order.AddSubOrder;
import com.bpa.scalage.mode.Order.BPA_Order;
import com.bpa.scalage.mode.Order.BPA_SubOrder;
import com.bpa.scalage.mode.UserAndCart.UserAndCartMerge;
@@ -444,21 +445,22 @@ public class MainActivity extends AppCompatActivity {
public void SendApiConsume()
{
//满足条件 创建子订单
if(DataBus.getInstance().xf_price>0 && DataBus.getInstance().selectMerge!=null && !DataBus.getInstance().selectMerge.orderId.isEmpty())
if(DataBus.getInstance().xf_price>0 && DataBus.getInstance().selectMerge!=null
&& !DataBus.getInstance().selectMerge.orderId.isEmpty() && DataBus.getInstance().selectMerge.orderList!=null
&& DataBus.getInstance().selectMerge.orderList.size()>0)
{
//判断是否查询到
String str=String.format("用户消费成功!\n当前用户:{0}\n当前消费重量:{1}g\n当前消费金额:{2}元\n",
DataBus.getInstance().selectuser.nickName,
DataBus.getInstance().xf_weight,
String.format("%.2f",DataBus.getInstance().xf_price));
Log.i("DEBUG", "");
Log.i("DEBUG", "当前用户:"+DataBus.getInstance().selectuser.nickName );
Log.i("DEBUG", "当前卡号:"+DataBus.getInstance().CartNo );
Log.i("DEBUG", "当前初重:"+DataBus.getInstance().start_weight+"g");
Log.i("DEBUG", "当前末重:"+DataBus.getInstance().weight+"g");
Log.i("DEBUG", "当前消费重量:"+DataBus.getInstance().xf_weight+"g");
Log.i("DEBUG", "当前消费金额:"+String.format("%.2f",DataBus.getInstance().xf_price)+"元");
T.show(MainActivity.this, str);
DataBus.getInstance().Ch=DataBus.getInstance().CartNo;
DataBus.getInstance().addsuborder=new AddSubOrder();
DataBus.getInstance().addsuborder.orderId=DataBus.getInstance().selectMerge.orderList.get(0).id;
DataBus.getInstance().addsuborder.goodId=DataBus.getInstance().SelectFood.id;
DataBus.getInstance().addsuborder.goodName=DataBus.getInstance().SelectFood.name;
DataBus.getInstance().addsuborder.storeId=ConfigName.getInstance().Shop_Id;
DataBus.getInstance().addsuborder.gooodOriginPrice=DataBus.getInstance().xf_price;
DataBus.getInstance().addsuborder.goodsRealPrice=DataBus.getInstance().xf_price;
DataBus.getInstance().addsuborder.remark="称重台主动创建";
DataBus.getInstance().addsuborder.cookingStatus=1;
DataBus.getInstance().addsuborder.consumeUnit=String.valueOf(DataBus.getInstance().xf_weight);
Main.getInstance().AddSubOrder(new Json<AddSubOrder>().objectToJson(AddSubOrder.class,DataBus.getInstance().addsuborder));
}
}

@@ -482,13 +484,16 @@ public class MainActivity extends AppCompatActivity {
if (msg != null) {
if((msg!=null) && (((String)msg).length()>2)){
ReceiveUserAndCartGXModel model=new Json<ReceiveUserAndCartGXModel>().jsonToobject(ReceiveUserAndCartGXModel.class,((String)msg));
DataBus.getInstance().selectMerge=model.data;
if(model.data==null || model.data.icardId.isEmpty()|| model.data.userId.isEmpty())
if(model.data==null)
DataBus.getInstance().selectMerge=null;
else
DataBus.getInstance().selectMerge=model.data;
if(model.data==null)
{
runOnUiThread(new Runnable() {
@Override
public void run() {
former_price.setText("¥"+ String.format("%.2f",0));//已消费
former_price.setText("¥"+ String.format("%.2f",0.00));//已消费
T.show(MainActivity.this,"请先用微信扫码下单!");
}
});
@@ -582,6 +587,38 @@ public class MainActivity extends AppCompatActivity {
}
}
});
//创建子订单返回
MessageManager.getInstance().registerMessageReceiver(this, MessageName.AddSuOrderUrl.name(), new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
if((msg!=null) && (((String)msg).length()>2)){
runOnUiThread(new Runnable() {
@Override
public void run() {

String str=String.format("用户消费成功!\n当前用户:{0}\n当前卡号:{1}\n当前消费重量:{2}g\n当前消费金额:{3}元\n",
DataBus.getInstance().selectuser.nickName,
DataBus.getInstance().Ch,
DataBus.getInstance().addsuborder.consumeUnit,
String.format("%.2f",DataBus.getInstance().addsuborder.goodsRealPrice));
Log.i("DEBUG", str);

T.show(MainActivity.this, str);
}
});
}
}else
{
runOnUiThread(new Runnable() {
@Override
public void run() {
T.show(MainActivity.this,"服务器异常,请稍后重试!");
}
});
}
}
});
}
//endregion
}

+ 2
- 2
app/src/main/java/com/bpa/scalage/app/Main.java View File

@@ -121,9 +121,9 @@ public class Main {
* 发送菜品信息
* @param message
*/
public void PostUserPice(String message)
public void AddSubOrder(String message)
{
HttpUtils.httpPost("",ConfigName.getInstance().SetFruitUrl,message);
HttpUtils.httpPost(MessageName.AddSuOrderUrl.name(),ConfigName.getInstance().AddSuOrderUrl,message);
}
//endregion
}

+ 2
- 6
app/src/main/java/com/bpa/scalage/config/ConfigName.java View File

@@ -45,12 +45,8 @@ public class ConfigName {
public String GetVipUserUrl=SaasAddress+"/kitchen/api/member-helper/memberinfobymemberid_wechat/";
//获取用户与卡的订单的关联关系
public String GetUserOrCartGX="http://192.168.1.55:9092/api/User/Getorder?id=";
//设置用户菜品Url
public String SetFruitUrl="http://124.222.238.75:9092/api/User/SetFruit";
//获取订单详情接口 Get
public String GetOrderXX=SaasAddress+"/order/order/fullorderbynumber/";
//endregion

//创建子订单接口
public String AddSuOrderUrl="http://192.168.1.55:9092/api/User/AddOrder";
//endregion

//region 菜品放置区


+ 1
- 1
app/src/main/java/com/bpa/scalage/config/MessageName.java View File

@@ -16,6 +16,6 @@ public enum MessageName {
GetUserInformation,//获取用户信息
GetVipUserInformation,//获取用户信息
GetUserAndCartGX,//获取卡与订单的关联关系
SetDishesInformation,//设置用户菜品价格信息
AddSuOrderUrl,//增加用户子订单
Click
}

+ 5
- 1
app/src/main/java/com/bpa/scalage/data/DataBus.java View File

@@ -4,6 +4,8 @@ import android.content.Context;

import com.bpa.scalage.mode.Foods.FoodModel;
import com.bpa.scalage.mode.Foods.FoodTypes;
import com.bpa.scalage.mode.Order.AddSubOrder;
import com.bpa.scalage.mode.Order.BPA_Order;
import com.bpa.scalage.mode.UserAndCart.UserAndCartMerge;
import com.bpa.scalage.mode.Users.UserModel;

@@ -59,9 +61,11 @@ public class DataBus {
//region 用户信息
//当前卡与订单的关联关系
public UserAndCartMerge selectMerge;

//当前正在打菜的用户
public UserModel selectuser;
//准备提交的子订单
public AddSubOrder addsuborder;
public String Ch;
//endregion

//region 选择菜品界面


+ 1
- 1
app/src/main/java/com/bpa/scalage/helper/HttpUtils.java View File

@@ -77,7 +77,7 @@ public class HttpUtils {
conn.setDoOutput(true);// 设置允许输出
conn.setRequestMethod("POST");
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)");// "Fiddler"
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Charset", "UTF-8");
conn.setRequestProperty("TenantId", ConfigName.getInstance().Shop_Id);//设置header



+ 25
- 0
app/src/main/java/com/bpa/scalage/mode/Order/AddSubOrder.java View File

@@ -0,0 +1,25 @@
package com.bpa.scalage.mode.Order;

/**
* 创建子订单接口
*/
public class AddSubOrder {
//主订单id
public String orderId ;
//商品id
public String goodId ;
//商品名称
public String goodName ;
//店铺id
public String storeId ;
//应付价格
public double gooodOriginPrice ;
//实际价格
public double goodsRealPrice ;
//备注
public String remark ;
//状态
public int cookingStatus ;
//单位 (克)
public String consumeUnit ;
}

Loading…
Cancel
Save