Browse Source

更新最新接口信息、增加已有订单展示

plate
fyf 1 year ago
parent
commit
79b7b3542a
5 changed files with 197 additions and 89 deletions
  1. +0
    -1
      .idea/gradle.xml
  2. +17
    -5
      app/src/main/java/com/bpa/scalage/MainActivity.java
  3. +53
    -0
      app/src/main/java/com/bpa/scalage/control/ConsumedAdapter.java
  4. +72
    -83
      app/src/main/res/layout/activity_main.xml
  5. +55
    -0
      app/src/main/res/layout/controlview/layout/consumed_item.xml

+ 0
- 1
.idea/gradle.xml View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>


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

@@ -8,12 +8,15 @@ import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bpa.scalage.app.Main;
import com.bpa.scalage.config.ConfigName;
import com.bpa.scalage.config.MessageName;
import com.bpa.scalage.control.ConsumedAdapter;
import com.bpa.scalage.control.FruitAdapter;
import com.bpa.scalage.data.DataBus;
import com.bpa.scalage.helper.ByteHelper;
import com.bpa.scalage.helper.Json;
@@ -31,6 +34,9 @@ import com.bpa.scalage.mode.apimode.ReceiveUserModel;
import com.lztek.toolkit.SerialPort;
import com.pc_rfid.api.PC_API;
import com.pc_rfid.api.RFdata;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
@@ -51,8 +57,6 @@ public class MainActivity extends AppCompatActivity {
private TextView is_affiliate1;
//用户名称
private TextView username;
// //余额
// private TextView balance;
//已消费
private TextView former_price;
//初重
@@ -68,6 +72,8 @@ public class MainActivity extends AppCompatActivity {
//有卡无卡
private LinearLayout iscartz;
private RelativeLayout iscartr,iscartk;
//已消费信息
public ListView fragment_yxx;
//endregion

//region 菜品放置区串口
@@ -169,6 +175,7 @@ public class MainActivity extends AppCompatActivity {
iscartz=findViewById(R.id.tv_iscartz);
iscartr=findViewById(R.id.tv_iscartr);
iscartk=findViewById(R.id.tv_iscartk);
fragment_yxx=findViewById(R.id.tv_item_consume);
//当前售卖商品
RefreshFruit(DataBus.getInstance().SelectFood);
storename.setText(ConfigName.getInstance().Shop_Name);
@@ -396,10 +403,10 @@ public class MainActivity extends AppCompatActivity {
}else //计算实时消费,与显示消费
{
int tmp=DataBus.getInstance().start_weight-DataBus.getInstance().weight;
if(tmp>=0)//80g
if(tmp>=0 && DataBus.getInstance().selectuser!=null)//80g
{
//非会员
double pic= DataBus.getInstance().SelectFood.price;//6.9
double pic=DataBus.getInstance().selectuser.Isvip? DataBus.getInstance().SelectFood.vipPrice: DataBus.getInstance().SelectFood.price;//6.9
DataBus.getInstance().xf_weight=tmp;
DataBus.getInstance().xf_price=((double)(pic))*tmp;
}else
@@ -456,7 +463,7 @@ public class MainActivity extends AppCompatActivity {
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.remark=new java.text.DecimalFormat("#.00").format(DataBus.getInstance().selectuser.Isvip? DataBus.getInstance().SelectFood.vipPrice: DataBus.getInstance().SelectFood.price);
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));
@@ -509,17 +516,22 @@ public class MainActivity extends AppCompatActivity {
iscartk.setVisibility(View.VISIBLE);
//region 获取已消费金额
double yxfprice=0;

List<BPA_SubOrder> orders = new ArrayList<>();
if(DataBus.getInstance().selectMerge.orderList!=null && DataBus.getInstance().selectMerge.orderList.size()>0)
{
BPA_Order order= DataBus.getInstance().selectMerge.orderList.get(0);
if(order!=null && order.subOrderList!=null && order.subOrderList.size()>0)
{
orders=order.subOrderList;
for (BPA_SubOrder suorder :order.subOrderList)
{
yxfprice+= suorder.goodsRealPrice;
}
}
}
ConsumedAdapter adapter = new ConsumedAdapter(MainActivity.this, R.layout.menu_item, orders);
fragment_yxx.setAdapter(adapter);
//endregion
former_price.setText("¥"+ String.format("%.2f",yxfprice));//已消费
}


+ 53
- 0
app/src/main/java/com/bpa/scalage/control/ConsumedAdapter.java View File

@@ -0,0 +1,53 @@
package com.bpa.scalage.control;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bpa.scalage.MainActivity;
import com.bpa.scalage.R;
import com.bpa.scalage.data.DataBus;
import com.bpa.scalage.mode.Foods.FoodModel;
import com.bpa.scalage.mode.Order.BPA_SubOrder;

import java.util.List;

/**
* 以消费列表
*/
public class ConsumedAdapter extends ArrayAdapter<BPA_SubOrder> {

public ConsumedAdapter(@NonNull Context context, int resource, @NonNull List<BPA_SubOrder> objects) {
super(context, resource, objects);
}
//每个子项被滚动到屏幕内的时候会被调用
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
BPA_SubOrder order=(BPA_SubOrder)getItem(position);//得到当前项的 Fruit 实例
//为每一个子项加载设定的布局
View view= LayoutInflater.from(getContext()).inflate(R.layout.consumed_item,parent,false);
//分别获取 image view 和 textview 的实例
TextView name =view.findViewById(R.id.tv_consumed_name);
TextView weight =view.findViewById(R.id.tv_consumed_weight);
TextView price =view.findViewById(R.id.tv_consumed_price);
TextView dj =view.findViewById(R.id.tv_consumed_dj);

// 设置要显示的图片和文字
name.setText(order.goodName);
weight.setText(order.consumeUnit+"g");
dj.setText(order.remark+"¥/g");
price.setText("¥"+new java.text.DecimalFormat("#.00").format(order.goodsRealPrice));

return view;
}

}

+ 72
- 83
app/src/main/res/layout/activity_main.xml View File

@@ -13,7 +13,7 @@
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical">
@@ -85,7 +85,6 @@
android:layout_marginTop="70dp"
android:layout_height="2dp"
android:background="@color/dc_ts" />

<LinearLayout
android:id="@+id/tv_iscartz"
android:layout_marginTop="20dp"
@@ -137,30 +136,6 @@
android:layout_marginLeft="10dp"
android:text="李四"/>
</RelativeLayout>

<!-- <RelativeLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginTop="20dp"-->
<!-- android:orientation="horizontal">-->
<!-- <TextView-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:textColor="@color/dc_wz"-->
<!-- android:text="余额"-->
<!-- android:textSize="30dp"-->
<!-- />-->
<!-- <TextView-->
<!-- android:id="@+id/tv_balance"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_alignParentRight="true"-->
<!-- android:textColor="@color/dc_wz"-->
<!-- android:textSize="30dp"-->
<!-- android:layout_marginLeft="10dp"-->
<!-- android:text="¥153.05"/>-->
<!-- </RelativeLayout>-->

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -183,7 +158,6 @@
android:layout_marginLeft="10dp"
android:text="¥0"/>
</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -206,7 +180,6 @@
android:layout_marginLeft="10dp"
android:text="9666g"/>
</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -229,66 +202,82 @@
android:layout_marginLeft="10dp"
android:text="9656g"/>
</RelativeLayout>
<View
android:layout_width="fill_parent"
android:layout_marginTop="40dp"
android:layout_marginBottom="10dp"
android:layout_height="2dp"
android:background="@color/dc_ts" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/tv_item_consume"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3.0" />
</LinearLayout>
</LinearLayout>

</LinearLayout>

<RelativeLayout
android:id="@+id/tv_iscartr"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-240dp">
<TextView
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="打菜完毕,请将夹子放回!"
android:textAlignment="center"
android:textColor="@color/dc_ts"
android:textSize="50dp" />
</RelativeLayout>
</LinearLayout>

<RelativeLayout
android:id="@+id/tv_iscartk"
android:layout_alignParentBottom="true"
<!-- 底部描述语 -->
<RelativeLayout
android:id="@+id/tv_iscartr"
android:layout_alignParentBottom="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="120dp">
<TextView
android:layout_marginTop="30dp"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="-100dp"
android:background="@color/dc_ts">
<TextView
android:layout_marginTop="24dp"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black_overlay"
android:text="本次消费"
android:textSize="40dp"
/>
<TextView
android:id="@+id/tv_spend_weight"
android:layout_marginTop="24dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textColor="@color/black_overlay"
android:text="45g"
android:textSize="40dp"
/>
<TextView
android:id="@+id/tv_spend_price"
android:layout_marginTop="24dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="@color/black_overlay"
android:text="¥2.70"
android:textSize="40dp"
/>
</RelativeLayout>
</LinearLayout>
android:layout_height="wrap_content"
android:text="打菜完毕,请将夹子放回!"
android:textAlignment="center"
android:textColor="@color/dc_ts"
android:textSize="50dp" />
</RelativeLayout>

<!--底部消费记录 -->
<RelativeLayout
android:id="@+id/tv_iscartk"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/dc_ts">
<TextView
android:layout_marginTop="24dp"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/black_overlay"
android:text="本次消费"
android:textSize="40dp"
/>
<TextView
android:id="@+id/tv_spend_weight"
android:layout_marginTop="24dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textColor="@color/black_overlay"
android:text="45g"
android:textSize="40dp"
/>
<TextView
android:id="@+id/tv_spend_price"
android:layout_marginTop="24dp"
android:layout_marginRight="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="@color/black_overlay"
android:text="¥2.70"
android:textSize="40dp"
/>
</RelativeLayout>

<RelativeLayout
android:id="@+id/tv_welcome"


+ 55
- 0
app/src/main/res/layout/controlview/layout/consumed_item.xml View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="horizontal">

<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:stretchColumns="0">
<TableRow>
<TextView
android:id="@+id/tv_consumed_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="回锅肉"
android:textColor="@color/dc_wz"
android:textSize="30dp"
/>
<TextView
android:id="@+id/tv_consumed_weight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="45g"
android:textColor="@color/dc_wz"
android:textSize="30dp"
/>

<TextView
android:id="@+id/tv_consumed_dj"
android:layout_width="121dp"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:text="00.00¥/g"
android:textAlignment="textEnd"
android:textColor="@color/dc_wz"
android:textSize="30dp" />
<TextView
android:id="@+id/tv_consumed_price"
android:layout_marginLeft="100dp"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="¥220.70"
android:textColor="@color/dc_wz"
android:textSize="30dp"
/>
</TableRow>

</TableLayout>
</RelativeLayout>

Loading…
Cancel
Save