Commit e9a86dd5 by 宁斌

N5清機接口對接

parent 48137b07
......@@ -9,7 +9,7 @@
android:screenOrientation="portrait" />
<activity
android:name=".mvp.ui.activity.NewMainActivity"
android:launchMode="singleTask" />
android:launchMode="singleTop" />
<activity
android:name=".mvp.ui.activity.ExpandListActivity"
android:screenOrientation="portrait" />
......
......@@ -18,7 +18,9 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".mvp.ui.activity.menu.ShellActivity" />
<activity android:name=".mvp.ui.activity.NewMainActivity" />
<activity
android:name=".mvp.ui.activity.NewMainActivity"
android:launchMode="singleTop" />
<activity android:name=".mvp.ui.activity.ExpandListActivity" />
<activity android:name=".mvp.ui.activity.RestaurantQrCodeActivity" />
<activity android:name=".mvp.ui.activity.LanguageActivity" />
......
......@@ -42,5 +42,9 @@ public interface NewMainContract {
Observable<Object> clearHeartbeat(RequestBody requestBody);
Observable<BaseResult> addSettlementOperation();
Observable<BaseResult> updateSettlementOperation(RequestBody requestBody);
}
}
......@@ -73,4 +73,16 @@ public class NewMainModel extends BaseModel implements NewMainContract.Model {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.clearHeartbeat(requestBody);
}
@Override
public Observable<BaseResult> addSettlementOperation() {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.addSettlementOperation();
}
@Override
public Observable<BaseResult> updateSettlementOperation(RequestBody requestBody) {
return mRepositoryManager.obtainRetrofitService(MainService.class)
.updateSettlementOperation(requestBody);
}
}
\ No newline at end of file
......@@ -40,4 +40,14 @@ public interface MainService {
@GET("restaurant/getUrlInfo" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<RestaurantQrBean> getRestaurantQrCode(@Query("restaurantId") String restaurantId);
@POST("SystemButtonLanguage/getLanguageByBrandId" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> getLanguageByBrandId(@Body RequestBody requestBody);
@POST("posPay/addOperation" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> addSettlementOperation();
@POST("posPay/updateOperation" + RetrofitUrlManager.IDENTIFICATION_PATH_SIZE + 2)
Observable<BaseResult> updateSettlementOperation(@Body RequestBody requestBody);
}
......@@ -8,11 +8,15 @@ import android.text.TextUtils;
import com.billy.cc.core.component.CC;
import com.gingersoft.gsa.cloud.common.core.restaurant.RestaurantInfoManager;
import com.gingersoft.gsa.cloud.common.bean.BaseResult;
import com.gingersoft.gsa.cloud.common.utils.gson.GsonUtils;
import com.gingersoft.gsa.cloud.common.webview.WebviewHelper;
import com.gingersoft.gsa.cloud.component.ComponentName;
import com.gingersoft.gsa.cloud.main.mvp.contract.NewMainContract;
import com.gingersoft.gsa.cloud.main.mvp.model.bean.CheckVersionRequest;
import com.gingersoft.gsa.cloud.main.mvp.ui.activity.NewMainActivity;
import com.gingersoft.gsa.cloud.pay.pos.OnPosActionListener;
import com.gingersoft.gsa.cloud.pay.pos.PosPay;
import com.gingersoft.gsa.cloud.pay.pos.hywebpos.bean.response.pos.HywebPosResponse;
import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
......@@ -157,6 +161,98 @@ public class NewMainPresenter extends BasePresenter<NewMainContract.Model, NewMa
});
}
public void addSettlementOperation(int restaurantId) {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId",String.valueOf(restaurantId))
.build();
mModel.addSettlementOperation()
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null && info.isSuccess()) {
if (info.getData() != null) {
PosPay.settlement(IActivity, IActivity, new OnPosActionListener() {
@Override
public void onPosSuccess(HywebPosResponse response) {
mRootView.showMessage("Success");
updateSettlementOperation(restaurantId, GsonUtils.GsonString(response),1);
}
@Override
public void onPosException(Exception e) {
mRootView.showMessage("Exception :"+e.getMessage());
updateSettlementOperation(restaurantId, e.getMessage(),0);
}
@Override
public void onPosInvalid(String e) {
mRootView.showMessage("Exception :"+e);
updateSettlementOperation(restaurantId, e,2);
}
@Override
public void onUpdateStatusSuccess(HywebPosResponse response) {
}
@Override
public void onUpdateStatusError(Throwable e) {
}
});
}
} else {
mRootView.showMessage("調起POS清機失敗");
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
}
});
}
public void updateSettlementOperation(int restaurantId,String content,int status) {
RequestBody requestBody = new FormBody.Builder()
.add("restaurantId",String.valueOf(restaurantId))
.add("content",content)
.add("status",String.valueOf(status))
.build();
mModel.updateSettlementOperation(requestBody)
.subscribeOn(Schedulers.io())
.doOnSubscribe(disposable -> mRootView.showLoading(null))
.subscribeOn(AndroidSchedulers.mainThread())
.observeOn(AndroidSchedulers.mainThread())
.doAfterTerminate(() -> mRootView.hideLoading())
.compose(RxLifecycleUtils.bindToLifecycle(mRootView))
.subscribe(new ErrorHandleSubscriber<BaseResult>(mErrorHandler) {
@Override
public void onNext(@NonNull BaseResult info) {
if (info != null && info.isSuccess()) {
if (info.getData() != null) {
mRootView.showMessage("Update Settlement Success");
}
}else {
mRootView.showMessage("Update Settlement Failure");
}
}
@Override
public void onError(Throwable t) {
super.onError(t);
mRootView.showMessage("Update Settlement error");
}
});
}
public void clearHeartbeat(){
RequestBody requestBody = new FormBody.Builder()
......
......@@ -373,7 +373,7 @@ public class NewMainActivity extends BaseFragmentActivity<NewMainPresenter> impl
private void functionClick(String name, int status) {
switch (name) {
case "N5清機":
mPresenter.addSettlementOperation(RestaurantInfoManager.newInstance().getRestaurantId());
break;
case "餐檯模式":
CC.obtainBuilder(ComponentName.COMPONENT_TABLE)
......
......@@ -276,6 +276,7 @@ public class SoldoutCtrlPresenter extends BasePresenter<SoldoutCtrlContract.Mode
public void initFoodData() {
List<Food> foodGroupList = mModel.queryDB_FoodGroupList();
IActivity.initFoodGroupAdapter(foodGroupList);
if (foodGroupList != null && foodGroupList.size() > 0) {
mFoodGroupList.addAll(foodGroupList);
//默認選中第一組
......
......@@ -229,6 +229,18 @@ public class SoldoutCtrlActivity extends BaseFragmentActivity<SoldoutCtrlPresent
foodColumn = GsaCloudApplication.uiStyleConfiguration.getFoodColumnValue();
}
public void initFoodGroupAdapter(List<Food> foodGroupList){
// 使用原生的 Adapter 即可
mFoodGroupAdapter = new FoodGroupAdapter(this, foodGroupList, 2);
mFoodGroupAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
@Override
public void onChanged() {
super.onChanged();
}
});
recycle_food_group.setAdapter(mFoodGroupAdapter);
}
public void initFoodGroupView(List<Food> foodGroupList) {
//总的页数向上取整
......@@ -252,17 +264,6 @@ public class SoldoutCtrlActivity extends BaseFragmentActivity<SoldoutCtrlPresent
PagerGridSnapHelper pageSnapHelper = new PagerGridSnapHelper();
pageSnapHelper.attachToRecyclerView(recycle_food_group);
// 使用原生的 Adapter 即可
mFoodGroupAdapter = new FoodGroupAdapter(this, foodGroupList, 2);
mFoodGroupAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
@Override
public void onChanged() {
super.onChanged();
}
});
recycle_food_group.setAdapter(mFoodGroupAdapter);
mFoodGroupAdapter.setOnItemClickListener(new FoodGroupAdapter.OnItemClickListener() {
@Override
public void onItemClick(Food datasBean, int position) {
......
......@@ -30,6 +30,7 @@ import com.jess.arms.base.BaseFragmentActivity;
import com.jess.arms.base.delegate.IActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.qmuiteam.qmui.alpha.QMUIAlphaButton;
import com.qmuiteam.qmui.arch.QMUIFragmentPagerAdapter;
import com.qmuiteam.qmui.util.QMUIDisplayHelper;
import com.qmuiteam.qmui.util.QMUIResHelper;
......@@ -73,6 +74,11 @@ public class OrderCenterActivity extends BaseFragmentActivity<OrderCenterPresent
@BindView(R2.id.ll_bottom)
LinearLayout ll_bottom;
@BindView(R2.id.btn_refund)
QMUIAlphaButton btn_refund;
@BindView(R2.id.btn_tips)
QMUIAlphaButton btn_tips;
private AllOrderFragment mNormalOrderFragment, mCancelOrderFragment, mVoidOrderFragment;
//當前顯示頁下標
private int mCurrentFragmentIndex = 0;
......
......@@ -36,4 +36,80 @@
android:id="@+id/rl_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:id="@+id/ll_bottom"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_40"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:background="@color/theme_white_color">
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_print_order"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_weight="1"
android:background="@color/orange_400"
android:text="打印訂單"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_modify_order"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_weight="1"
android:background="@color/blue_300"
android:text="修改訂單"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13"
android:visibility="visible" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_order_status"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_weight="1"
android:background="@color/gray"
android:clickable="false"
android:text="已取消"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13"
android:visibility="gone" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_cancel_order"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_weight="1"
android:background="@color/red_400"
android:text="取消訂單"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13"
android:visibility="visible" />
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_refund"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_weight="1"
android:background="@color/red_500"
android:text="退款"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13"
android:visibility="gone"/>
<com.qmuiteam.qmui.alpha.QMUIAlphaButton
android:id="@+id/btn_tips"
android:layout_width="0dp"
android:layout_height="@dimen/dp_40"
android:layout_weight="1"
android:background="@color/green_400"
android:text="貼士"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_13"
android:visibility="gone"/>
</LinearLayout>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>
\ No newline at end of file
......@@ -167,7 +167,7 @@
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:layout_weight="3"
android:orientation="vertical">
<LinearLayout
......@@ -204,6 +204,22 @@
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_30"
android:textStyle="bold" />
<Button
android:id="@+id/btn_exact"
android:layout_width="1dip"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:layout_marginRight="1dp"
android:layout_weight="1"
android:background="@color/green_400"
android:focusable="true"
android:tag="100"
android:text="@string/Key_exact"
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_22"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
......@@ -241,17 +257,28 @@
android:text="."
android:textColor="@color/theme_white_color"
android:textSize="@dimen/sp_30"/>
<ImageButton
android:id="@+id/btn_sure"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:background="@drawable/selector_paybill_keyboard"
android:focusable="true"
android:tag="98"
android:src="@drawable/table_input_money_sure" />
</LinearLayout>
</LinearLayout>
<ImageButton
android:id="@+id/btn_sure"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_marginTop="1dp"
android:background="@drawable/selector_paybill_keyboard"
android:focusable="true"
android:tag="98"
android:src="@drawable/table_input_money_sure" />
<!-- <ImageButton-->
<!-- android:id="@+id/btn_sure"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_weight="1"-->
<!-- android:layout_height="match_parent"-->
<!-- android:layout_marginTop="1dp"-->
<!-- android:background="@drawable/selector_paybill_keyboard"-->
<!-- android:focusable="true"-->
<!-- android:tag="98"-->
<!-- android:src="@drawable/table_input_money_sure" />-->
</LinearLayout>
</LinearLayout>
......@@ -21,6 +21,7 @@
<string name="Key_add_20">+20</string>
<string name="Key_add_50">+50</string>
<string name="Key_exact">Exact</string>
<string name="Key_right"></string>
<string name="Key_clear">clr</string>
<string name="Key_s">numkey</string>
......
......@@ -5,6 +5,8 @@ import org.greenrobot.greendao.annotation.Entity;
import lombok.Data;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
@Data
@Entity
......@@ -20,8 +22,9 @@ public class ColorBean {
* createTime : Dec 12, 2018 6:03:58 PM
* editTime : Dec 12, 2018 6:03:58 PM
*/
private int colorId;
@Property(nameInDb = "_id")
@Id(autoincrement = true)
private Long colorId;
private String colorStart;
private String colorStop;
private String fontColor;
......@@ -30,8 +33,8 @@ public class ColorBean {
private String createTime;
private String editTime;
@Generated(hash = 703020793)
public ColorBean(int colorId, String colorStart, String colorStop,
@Generated(hash = 548645969)
public ColorBean(Long colorId, String colorStart, String colorStop,
String fontColor, String androidColor, String androidFontColor,
String createTime, String editTime) {
this.colorId = colorId;
......@@ -46,10 +49,11 @@ public class ColorBean {
@Generated(hash = 521532773)
public ColorBean() {
}
public int getColorId() {
public Long getColorId() {
return this.colorId;
}
public void setColorId(int colorId) {
public void setColorId(Long colorId) {
this.colorId = colorId;
}
public String getColorStart() {
......
......@@ -8,6 +8,10 @@ import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Transient;
import java.util.Date;
import org.greenrobot.greendao.DaoException;
import com.gingersoft.gsa.cloud.database.greendao.DaoSession;
import com.gingersoft.gsa.cloud.database.greendao.ColorBeanDao;
import com.gingersoft.gsa.cloud.database.greendao.FoodDao;
/**
* 作者:ELEGANT_BIN
......@@ -287,8 +291,8 @@ public class Food {
/**
* 顏色ID
*/
private long colorId;
@Transient
private Long colorId;
@ToOne(joinProperty = "colorId") //这个是注解绑定 hid就是上面一行的colorId
private ColorBean colorBean;
......@@ -328,12 +332,22 @@ public class Food {
/**是否组合食品*/
@Transient
private boolean isComboFood = false;
/** Used to resolve relations */
@Generated(hash = 2040040024)
private transient DaoSession daoSession;
/** Used for active entity operations. */
@Generated(hash = 1296197325)
private transient FoodDao myDao;
@Generated(hash = 60268763)
@Generated(hash = 763243435)
public Food(Long id, long parentId, long restaurantId, byte isParent,
long seqNo, String foodName, String foodName1, String foodName2,
String plu, String posFid, String foodDesc, long limitAmount,
......@@ -351,7 +365,7 @@ public class Food {
byte serviceCharge, long conditions, long isRt, long deletes,
long isTimingFood, long minLongTime, long unitTime, double unitPrice,
long freeLongTime, Date freePeriodBegin, long isStatistic,
long colorId) {
Long colorId) {
this.id = id;
this.parentId = parentId;
this.restaurantId = restaurantId;
......@@ -425,6 +439,13 @@ public class Food {
public Food() {
}
@Generated(hash = 292980300)
private transient Long colorBean__resolvedKey;
......@@ -1229,4 +1250,77 @@ public class Food {
this.isStatistic = isStatistic;
}
/** To-one relationship, resolved on first access. */
@Generated(hash = 247966240)
public ColorBean getColorBean() {
Long __key = this.colorId;
if (colorBean__resolvedKey == null
|| !colorBean__resolvedKey.equals(__key)) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
ColorBeanDao targetDao = daoSession.getColorBeanDao();
ColorBean colorBeanNew = targetDao.load(__key);
synchronized (this) {
colorBean = colorBeanNew;
colorBean__resolvedKey = __key;
}
}
return colorBean;
}
/** called by internal mechanisms, do not call yourself. */
@Generated(hash = 1466636219)
public void setColorBean(ColorBean colorBean) {
synchronized (this) {
this.colorBean = colorBean;
colorId = colorBean == null ? null : colorBean.getColorId();
colorBean__resolvedKey = colorId;
}
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 128553479)
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 1942392019)
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 713229351)
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/** called by internal mechanisms, do not call yourself. */
@Generated(hash = 505459956)
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getFoodDao() : null;
}
}
......@@ -15,7 +15,7 @@ import com.gingersoft.gsa.cloud.database.bean.ColorBean;
/**
* DAO for table "COLOR_BEAN".
*/
public class ColorBeanDao extends AbstractDao<ColorBean, Void> {
public class ColorBeanDao extends AbstractDao<ColorBean, Long> {
public static final String TABLENAME = "COLOR_BEAN";
......@@ -24,7 +24,7 @@ public class ColorBeanDao extends AbstractDao<ColorBean, Void> {
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property ColorId = new Property(0, int.class, "colorId", false, "COLOR_ID");
public final static Property ColorId = new Property(0, Long.class, "colorId", true, "_id");
public final static Property ColorStart = new Property(1, String.class, "colorStart", false, "COLOR_START");
public final static Property ColorStop = new Property(2, String.class, "colorStop", false, "COLOR_STOP");
public final static Property FontColor = new Property(3, String.class, "fontColor", false, "FONT_COLOR");
......@@ -47,7 +47,7 @@ public class ColorBeanDao extends AbstractDao<ColorBean, Void> {
public static void createTable(Database db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"COLOR_BEAN\" (" + //
"\"COLOR_ID\" INTEGER NOT NULL ," + // 0: colorId
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: colorId
"\"COLOR_START\" TEXT," + // 1: colorStart
"\"COLOR_STOP\" TEXT," + // 2: colorStop
"\"FONT_COLOR\" TEXT," + // 3: fontColor
......@@ -66,7 +66,11 @@ public class ColorBeanDao extends AbstractDao<ColorBean, Void> {
@Override
protected final void bindValues(DatabaseStatement stmt, ColorBean entity) {
stmt.clearBindings();
stmt.bindLong(1, entity.getColorId());
Long colorId = entity.getColorId();
if (colorId != null) {
stmt.bindLong(1, colorId);
}
String colorStart = entity.getColorStart();
if (colorStart != null) {
......@@ -107,7 +111,11 @@ public class ColorBeanDao extends AbstractDao<ColorBean, Void> {
@Override
protected final void bindValues(SQLiteStatement stmt, ColorBean entity) {
stmt.clearBindings();
stmt.bindLong(1, entity.getColorId());
Long colorId = entity.getColorId();
if (colorId != null) {
stmt.bindLong(1, colorId);
}
String colorStart = entity.getColorStart();
if (colorStart != null) {
......@@ -146,14 +154,14 @@ public class ColorBeanDao extends AbstractDao<ColorBean, Void> {
}
@Override
public Void readKey(Cursor cursor, int offset) {
return null;
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
@Override
public ColorBean readEntity(Cursor cursor, int offset) {
ColorBean entity = new ColorBean( //
cursor.getInt(offset + 0), // colorId
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // colorId
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // colorStart
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // colorStop
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // fontColor
......@@ -167,7 +175,7 @@ public class ColorBeanDao extends AbstractDao<ColorBean, Void> {
@Override
public void readEntity(Cursor cursor, ColorBean entity, int offset) {
entity.setColorId(cursor.getInt(offset + 0));
entity.setColorId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setColorStart(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setColorStop(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setFontColor(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
......@@ -178,20 +186,23 @@ public class ColorBeanDao extends AbstractDao<ColorBean, Void> {
}
@Override
protected final Void updateKeyAfterInsert(ColorBean entity, long rowId) {
// Unsupported or missing PK type
return null;
protected final Long updateKeyAfterInsert(ColorBean entity, long rowId) {
entity.setColorId(rowId);
return rowId;
}
@Override
public Void getKey(ColorBean entity) {
return null;
public Long getKey(ColorBean entity) {
if(entity != null) {
return entity.getColorId();
} else {
return null;
}
}
@Override
public boolean hasKey(ColorBean entity) {
// TODO
return false;
return entity.getColorId() != null;
}
@Override
......
package com.gingersoft.gsa.cloud.database.greendao;
import java.util.List;
import java.util.ArrayList;
import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;
import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.SqlUtils;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;
import com.gingersoft.gsa.cloud.database.bean.ColorBean;
import com.gingersoft.gsa.cloud.database.bean.Food;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
......@@ -90,9 +95,11 @@ public class FoodDao extends AbstractDao<Food, Long> {
public final static Property FreeLongTime = new Property(63, long.class, "freeLongTime", false, "FREE_LONG_TIME");
public final static Property FreePeriodBegin = new Property(64, java.util.Date.class, "freePeriodBegin", false, "FREE_PERIOD_BEGIN");
public final static Property IsStatistic = new Property(65, long.class, "isStatistic", false, "IS_STATISTIC");
public final static Property ColorId = new Property(66, long.class, "colorId", false, "COLOR_ID");
public final static Property ColorId = new Property(66, Long.class, "colorId", false, "COLOR_ID");
}
private DaoSession daoSession;
public FoodDao(DaoConfig config) {
super(config);
......@@ -100,6 +107,7 @@ public class FoodDao extends AbstractDao<Food, Long> {
public FoodDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
this.daoSession = daoSession;
}
/** Creates the underlying database table. */
......@@ -172,7 +180,7 @@ public class FoodDao extends AbstractDao<Food, Long> {
"\"FREE_LONG_TIME\" INTEGER NOT NULL ," + // 63: freeLongTime
"\"FREE_PERIOD_BEGIN\" INTEGER," + // 64: freePeriodBegin
"\"IS_STATISTIC\" INTEGER NOT NULL ," + // 65: isStatistic
"\"COLOR_ID\" INTEGER NOT NULL );"); // 66: colorId
"\"COLOR_ID\" INTEGER);"); // 66: colorId
}
/** Drops the underlying database table. */
......@@ -322,7 +330,11 @@ public class FoodDao extends AbstractDao<Food, Long> {
stmt.bindLong(65, freePeriodBegin.getTime());
}
stmt.bindLong(66, entity.getIsStatistic());
stmt.bindLong(67, entity.getColorId());
Long colorId = entity.getColorId();
if (colorId != null) {
stmt.bindLong(67, colorId);
}
}
@Override
......@@ -466,7 +478,17 @@ public class FoodDao extends AbstractDao<Food, Long> {
stmt.bindLong(65, freePeriodBegin.getTime());
}
stmt.bindLong(66, entity.getIsStatistic());
stmt.bindLong(67, entity.getColorId());
Long colorId = entity.getColorId();
if (colorId != null) {
stmt.bindLong(67, colorId);
}
}
@Override
protected final void attachEntity(Food entity) {
super.attachEntity(entity);
entity.__setDaoSession(daoSession);
}
@Override
......@@ -543,7 +565,7 @@ public class FoodDao extends AbstractDao<Food, Long> {
cursor.getLong(offset + 63), // freeLongTime
cursor.isNull(offset + 64) ? null : new java.util.Date(cursor.getLong(offset + 64)), // freePeriodBegin
cursor.getLong(offset + 65), // isStatistic
cursor.getLong(offset + 66) // colorId
cursor.isNull(offset + 66) ? null : cursor.getLong(offset + 66) // colorId
);
return entity;
}
......@@ -616,7 +638,7 @@ public class FoodDao extends AbstractDao<Food, Long> {
entity.setFreeLongTime(cursor.getLong(offset + 63));
entity.setFreePeriodBegin(cursor.isNull(offset + 64) ? null : new java.util.Date(cursor.getLong(offset + 64)));
entity.setIsStatistic(cursor.getLong(offset + 65));
entity.setColorId(cursor.getLong(offset + 66));
entity.setColorId(cursor.isNull(offset + 66) ? null : cursor.getLong(offset + 66));
}
@Override
......@@ -644,4 +666,95 @@ public class FoodDao extends AbstractDao<Food, Long> {
return true;
}
private String selectDeep;
protected String getSelectDeep() {
if (selectDeep == null) {
StringBuilder builder = new StringBuilder("SELECT ");
SqlUtils.appendColumns(builder, "T", getAllColumns());
builder.append(',');
SqlUtils.appendColumns(builder, "T0", daoSession.getColorBeanDao().getAllColumns());
builder.append(" FROM FOOD T");
builder.append(" LEFT JOIN COLOR_BEAN T0 ON T.\"COLOR_ID\"=T0.\"_id\"");
builder.append(' ');
selectDeep = builder.toString();
}
return selectDeep;
}
protected Food loadCurrentDeep(Cursor cursor, boolean lock) {
Food entity = loadCurrent(cursor, 0, lock);
int offset = getAllColumns().length;
ColorBean colorBean = loadCurrentOther(daoSession.getColorBeanDao(), cursor, offset);
entity.setColorBean(colorBean);
return entity;
}
public Food loadDeep(Long key) {
assertSinglePk();
if (key == null) {
return null;
}
StringBuilder builder = new StringBuilder(getSelectDeep());
builder.append("WHERE ");
SqlUtils.appendColumnsEqValue(builder, "T", getPkColumns());
String sql = builder.toString();
String[] keyArray = new String[] { key.toString() };
Cursor cursor = db.rawQuery(sql, keyArray);
try {
boolean available = cursor.moveToFirst();
if (!available) {
return null;
} else if (!cursor.isLast()) {
throw new IllegalStateException("Expected unique result, but count was " + cursor.getCount());
}
return loadCurrentDeep(cursor, true);
} finally {
cursor.close();
}
}
/** Reads all available rows from the given cursor and returns a list of new ImageTO objects. */
public List<Food> loadAllDeepFromCursor(Cursor cursor) {
int count = cursor.getCount();
List<Food> list = new ArrayList<Food>(count);
if (cursor.moveToFirst()) {
if (identityScope != null) {
identityScope.lock();
identityScope.reserveRoom(count);
}
try {
do {
list.add(loadCurrentDeep(cursor, false));
} while (cursor.moveToNext());
} finally {
if (identityScope != null) {
identityScope.unlock();
}
}
}
return list;
}
protected List<Food> loadDeepAllAndCloseCursor(Cursor cursor) {
try {
return loadAllDeepFromCursor(cursor);
} finally {
cursor.close();
}
}
/** A raw-style query where you can pass any WHERE clause and arguments. */
public List<Food> queryDeep(String where, String... selectionArg) {
Cursor cursor = db.rawQuery(getSelectDeep() + where, selectionArg);
return loadDeepAllAndCloseCursor(cursor);
}
}
......@@ -181,7 +181,6 @@ public class FoodDaoUtils {
long currentTime = System.currentTimeMillis();
return queryBuilder.where(queryBuilder.and(
FoodDao.Properties.ParentId.eq(0),
// FoodDao.Properties.FoodSummary.like("%"+foodSummary+"%"),
FoodDao.Properties.StartDate.le(currentTime),
FoodDao.Properties.EndDate.ge(currentTime))).orderAsc(FoodDao.Properties.SeqNo).list();
}
......
......@@ -18,6 +18,7 @@ import com.gingersoft.gsa.cloud.pay.pos.hywebpos.imp.PrintPaymentStubImpl;
import com.gingersoft.gsa.cloud.pay.pos.hywebpos.imp.RefundActionImpl;
import com.gingersoft.gsa.cloud.pay.pos.hywebpos.imp.RetrievalActionImpl;
import com.gingersoft.gsa.cloud.pay.pos.hywebpos.imp.SaleActionImpl;
import com.gingersoft.gsa.cloud.pay.pos.hywebpos.imp.SettlementActionImpl;
import com.gingersoft.gsa.cloud.pay.pos.hywebpos.imp.TipsActionImpl;
import com.gingersoft.gsa.cloud.pay.pos.hywebpos.imp.VoidActionImpl;
import com.jess.arms.mvp.IView;
......@@ -67,4 +68,7 @@ public final class PosPay {
PosPay.sendRequest(new PrintPaymentStubImpl(context, iView, PosAction.PRINT, txnId,onPosActionListener,true));
}
public static void settlement(Context context, IView iView,OnPosActionListener onPosActionListener) {
PosPay.sendRequest(new SettlementActionImpl(context, iView, PosAction.SETTLEMENT,onPosActionListener,true));
}
}
......@@ -6,6 +6,7 @@ import android.content.Context;
import com.gingersoft.gsa.cloud.common.constans.HttpsConstans;
import com.gingersoft.gsa.cloud.common.utils.okhttpUtils.OkHttp3Utils;
import com.gingersoft.gsa.cloud.pay.pos.IPosAction;
import com.gingersoft.gsa.cloud.pay.pos.OnPosActionListener;
import com.gingersoft.gsa.cloud.pay.pos.PosAction;
import com.gingersoft.gsa.cloud.pay.pos.hywebpos.bean.response.pos.HywebPosResponse;
import com.gingersoft.gsa.cloud.pay.pos.hywebpos.bean.response.pos.SettlementRespose;
......@@ -29,12 +30,14 @@ import me.jessyan.rxerrorhandler.handler.ErrorHandleSubscriber;
public class SettlementActionImpl extends IPosAction<SettlementRespose> {
public SettlementActionImpl(Context context, IView iView, PosAction action, boolean showLoading) {
public SettlementActionImpl(Context context, IView iView, PosAction action, OnPosActionListener onPosActionListener, boolean showLoading) {
super(context,iView,action,showLoading);
this.mOnPosActionListener = onPosActionListener;
}
@Override
protected void onPosActionBefore() {
}
@Override
......
......@@ -609,13 +609,28 @@ public class OrderPayView extends LinearLayout {
}
public void showPayKeypadDialog(Context context, PayMethod method) {
double difference = getDifferenceMoney();
new PayKeypadDialog(context)
.setPayMethod(method.getPayName())
.builder()
.setComfirmListener(money -> {
method.setPayMoney(Double.parseDouble(money));
mBillMoneyAdapter.notifyDataSetChanged();
setDifferenceText(context);
.setPayKeyadListener(new PayKeypadDialog.OnPayKeyadListener() {
@Override
public void onComfirm(String money) {
method.setPayMoney(Double.parseDouble(money));
mBillMoneyAdapter.notifyDataSetChanged();
setDifferenceText(context);
}
@Override
public void makeUpDifference() {
//補齊差價
double difference = getDifferenceMoney();
if(difference > 0) {
method.setPayMoney(difference);
mBillMoneyAdapter.notifyDataSetChanged();
setDifferenceText(context);
}
}
})
.show();
}
......
......@@ -42,6 +42,7 @@ public class PayKeypadDialog {
@BindView(R2.id.ed_value)
EditText ed_value;
public PayKeypadDialog(Context context) {
this.mContext = context;
initView();
......@@ -73,7 +74,7 @@ public class PayKeypadDialog {
R2.id.btn_100, R2.id.btn_200, R2.id.btn_500, R2.id.btn_1000,
R2.id.btn_0, R2.id.btn_00, R2.id.btn_1, R2.id.btn_2, R2.id.btn_3,
R2.id.btn_4, R2.id.btn_5, R2.id.btn_6, R2.id.btn_7,
R2.id.btn_8, R2.id.btn_9, R2.id.btn_point, R2.id.btn_delete, R2.id.btn_sure})
R2.id.btn_8, R2.id.btn_9, R2.id.btn_point, R2.id.btn_delete, R2.id.btn_sure,R2.id.btn_exact})
public void onClick(View v) {
int id = v.getId();
if (id == R.id.btn_0 || id == R.id.btn_00 || id == R.id.btn_1 || id == R.id.btn_2 || id == R.id.btn_3 || id == R.id.btn_4 || id == R.id.btn_5 ||
......@@ -119,8 +120,13 @@ public class PayKeypadDialog {
editable.delete(ed_value.getText().length() - 1, ed_value.getText().length());
}
} else if (id == R.id.btn_sure) {
if (onComfirmListener != null && !TextUtils.isEmpty(getInputNumber())) {
onComfirmListener.onComfirm(getInputNumber());
if (onPayKeyadListener != null && !TextUtils.isEmpty(getInputNumber())) {
onPayKeyadListener.onComfirm(getInputNumber());
}
cancel();
} else if (id == R.id.btn_exact) {
if(onPayKeyadListener != null){
onPayKeyadListener.makeUpDifference();
}
cancel();
}
......@@ -158,15 +164,16 @@ public class PayKeypadDialog {
dialog.dismiss();
}
private OnComfirmListener onComfirmListener;
private OnPayKeyadListener onPayKeyadListener;
public PayKeypadDialog setComfirmListener(OnComfirmListener onComfirmListener) {
this.onComfirmListener = onComfirmListener;
public PayKeypadDialog setPayKeyadListener(OnPayKeyadListener onPayKeyadListener) {
this.onPayKeyadListener = onPayKeyadListener;
return this;
}
public interface OnComfirmListener {
public interface OnPayKeyadListener {
void onComfirm(String money);
void makeUpDifference();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment