Browse Source

Merge branch 'master-new-炒锅' of http://10.2.1.24:10244/fyf/AndroidSmartClient into master-new-炒锅

授权码生成工具
liup 4 months ago
parent
commit
a8cbcc2921
7 changed files with 141 additions and 22 deletions
  1. +1
    -1
      app/src/main/java/com/bonait/bnframework/common/db/util/GoodsClassifyDBUtil.java
  2. +26
    -7
      app/src/main/java/com/bonait/bnframework/common/db/util/GoodsDBUtil.java
  3. +1
    -2
      app/src/main/java/com/bonait/bnframework/common/db/util/PropClassifyDBUtil.java
  4. +101
    -7
      app/src/main/java/com/bonait/bnframework/ui/activity/GoodEditClassifyFragment.java
  5. +1
    -3
      app/src/main/java/com/bonait/bnframework/ui/activity/PropEditClassifyFragment.java
  6. +1
    -1
      app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java
  7. +10
    -1
      app/src/main/res/layout/fragment_good_edit_classify.xml

+ 1
- 1
app/src/main/java/com/bonait/bnframework/common/db/util/GoodsClassifyDBUtil.java View File

@@ -229,7 +229,7 @@ public class GoodsClassifyDBUtil {
List<BPA_GOODS_CLASSIFY> classifyList = getAll();
for(BPA_GOODS_CLASSIFY classify :classifyList){
AttributeDBUtil.deleteByClassifyId(classify.id);
GoodsDBUtil.deleteByClassifyId(classify.id);
GoodsDBUtil.deleteByGoodClassifyId(classify.id);
SubAttributeGroupDBUtil.deleteByClassifyId(classify.id);
SubAttributeDBUtil.deleteByClassifyId(classify.id);
}


+ 26
- 7
app/src/main/java/com/bonait/bnframework/common/db/util/GoodsDBUtil.java View File

@@ -106,16 +106,35 @@ public class GoodsDBUtil {
}

/**
* 删除商品数据
* 根据属性id删除商品数据
*
* @param classifyId
* @param propClassifyId
* @return 是否成功
*/
public static boolean deleteByClassifyId(String classifyId) {
public static boolean deleteByPropClassifyId(String propClassifyId) {
boolean result = true;
SQLiteDatabase db = DBHelper.getInstance(ConfigName.getInstance().dishesCon).getWritableDatabase();
long delete = db.delete(BPA_GOODS.class.getSimpleName(), "classifyId=?",
new String[]{classifyId});
long delete = db.delete(BPA_GOODS.class.getSimpleName(), "propClassifyId=?",
new String[]{propClassifyId});
if(delete <= 0){
result = false;
}
db.close();
LogUtils.d("deleteByClassifyId 删除属性数据 result=" + result);
return result;
}

/**
* 根据商品分类id删除商品数据
*
* @param goodClassifyId
* @return 是否成功
*/
public static boolean deleteByGoodClassifyId(String goodClassifyId) {
boolean result = true;
SQLiteDatabase db = DBHelper.getInstance(ConfigName.getInstance().dishesCon).getWritableDatabase();
long delete = db.delete(BPA_GOODS.class.getSimpleName(), "goodClassifyid=?",
new String[]{goodClassifyId});
if(delete <= 0){
result = false;
}
@@ -140,14 +159,14 @@ public class GoodsDBUtil {
}

/**
* 根据商品id获取商品
* 根据属性id获取商品
*
* @param classifyId
* @return BPA_GOODS
*/
public static BPA_GOODS getClassifyId(String classifyId) {
String orderby = QueryDB.Desc_Sort_Up;
String where = "isDelete=? and classifyId=?";
String where = "isDelete=? and propClassifyId=?";
String[] args = new String[]{"0", classifyId};
ArrayList<Object> obj = QueryDB.Get(BPA_GOODS.class, where, args, orderby);



+ 1
- 2
app/src/main/java/com/bonait/bnframework/common/db/util/PropClassifyDBUtil.java View File

@@ -9,7 +9,6 @@ import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.file.DBHelper;
import com.bonait.bnframework.common.db.mode.BPA_PROPERTY_CLASSIFY;
import com.bonait.bnframework.common.db.mode.BPA_PROPERTY_CLASSIFY;
import com.bonait.bnframework.common.helper.Tools;

import java.util.ArrayList;
@@ -230,7 +229,7 @@ public class PropClassifyDBUtil {
List<BPA_PROPERTY_CLASSIFY> classifyList = getAll();
for(BPA_PROPERTY_CLASSIFY classify :classifyList){
AttributeDBUtil.deleteByClassifyId(classify.id);
GoodsDBUtil.deleteByClassifyId(classify.id);
GoodsDBUtil.deleteByPropClassifyId(classify.id);
SubAttributeGroupDBUtil.deleteByClassifyId(classify.id);
SubAttributeDBUtil.deleteByClassifyId(classify.id);
}


+ 101
- 7
app/src/main/java/com/bonait/bnframework/ui/activity/GoodEditClassifyFragment.java View File

@@ -18,25 +18,23 @@ import com.bonait.bnframework.R;
import com.bonait.bnframework.business.RecordManager;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY;
import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE;
import com.bonait.bnframework.common.db.util.AttributeDBUtil;
import com.bonait.bnframework.common.db.util.GoodsDBUtil;
import com.bonait.bnframework.common.db.util.GoodsClassifyDBUtil;
import com.bonait.bnframework.common.db.util.SubAttributeDBUtil;
import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.databinding.DialogAddClassifyBinding;
import com.bonait.bnframework.databinding.DialogDeleteClassifyBinding;
import com.bonait.bnframework.databinding.FragmentGoodEditClassifyBinding;
import com.bonait.bnframework.ui.adapter.classify.AttributeAdapter;
import com.bonait.bnframework.ui.adapter.classify.SubattributeAdapter;
import com.bonait.bnframework.ui.adapter.goods.LocalGoodsAdapter;
import com.bonait.bnframework.ui.util.DisplayManager;
import com.bonait.bnframework.ui.widget.NewToastUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -62,7 +60,26 @@ public class GoodEditClassifyFragment extends BaseFragment {
private final List<String> classifyNameList = new ArrayList<>();
private boolean isUserClicked = false;
private int classifyPosition = 0;//选中位置
private LocalGoodsAdapter goodsAdapter;
private boolean isEdit = false;

private String CurrentGoodClassifyId;
/**
* 判断重复点击
*/
private long lastTime;
private long lastTime2;

private ArrayList<BPA_GOODS> goodsList = new ArrayList<>();

public boolean isFast2Click(){
long curTime = System.currentTimeMillis();
if(curTime - lastTime2 < 1000){
return true;
}
lastTime2 = curTime;
return false;
}

@Override
protected View onCreateView() {
@@ -79,6 +96,7 @@ public class GoodEditClassifyFragment extends BaseFragment {
DisplayManager.scaleViewGroup(viewBinding.getRoot());
initData();
initView();

// EventBus.getDefault().register(this);
}

@@ -89,6 +107,7 @@ public class GoodEditClassifyFragment extends BaseFragment {
for(BPA_GOODS_CLASSIFY goodsClassify:GoodsClassifyDBUtil.getAll()){
classifyList.put(goodsClassify.name,goodsClassify.id);
}

}

/**
@@ -103,6 +122,13 @@ public class GoodEditClassifyFragment extends BaseFragment {
}
}

private void setSelectStatus(int value){
for(BPA_GOODS good:goodsList){
good.status=value;
}
goodsAdapter.notifyDataSetChanged();
}

/**
* 初始化
* 修改子属性
@@ -131,6 +157,26 @@ public class GoodEditClassifyFragment extends BaseFragment {
{
selectClassify(i);
isUserClicked = false;
if(i>0 && i<classifyNameList.size()){
BPA_GOODS_CLASSIFY goodClassify = GoodsClassifyDBUtil.getByName(classifyNameList.get(i));
if(goodClassify!=null){
CurrentGoodClassifyId=goodClassify.id;
ArrayList<BPA_GOODS> goods = GoodsDBUtil.getByClassifyId(goodClassify.id);
Map<String,BPA_GOODS> goodMap = new HashMap<>();
if(goods!=null){
for (BPA_GOODS good:goods){
goodMap.put(good.name,good);
}
for(BPA_GOODS good:goodsList){
good.status=goodMap.containsKey(good.name)?1:2;
}
goodsAdapter.notifyDataSetChanged();
}
}
}else{
setSelectStatus(0);
CurrentGoodClassifyId="";
}
}
}

@@ -138,9 +184,57 @@ public class GoodEditClassifyFragment extends BaseFragment {
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
}

goodsAdapter = new LocalGoodsAdapter(){

@Override
protected void onItemClick(View v, int position) {
}

@Override
protected void uploadGoods(View v, int position) {

}

@Override
protected void deleteGoods(View v, int position) {
}

@Override
protected void selectGoods(View v, int position,boolean isSelect){
if(!CurrentGoodClassifyId.equals("")){
mData.get(position).goodClassifyid=isSelect?CurrentGoodClassifyId:"";
BPA_GOODS bg = new BPA_GOODS();
bg.name=mData.get(position).name;
bg.url=mData.get(position).url;
bg.sort=mData.get(position).sort;
bg.status=0;
bg.isCollect=mData.get(position).isCollect;
bg.propClassifyId=mData.get(position).propClassifyId;
bg.goodClassifyid=mData.get(position).goodClassifyid;

bg.id=mData.get(position).id;
bg.createTime=mData.get(position).createTime;
bg.updateTime=mData.get(position).updateTime;
bg.deleteTime=mData.get(position).deleteTime;
bg.deviceID=mData.get(position).deviceID;
bg.userID=mData.get(position).userID;
bg.isDelete=mData.get(position).isDelete;
bg.exp=mData.get(position).exp;

GoodsDBUtil.update(bg);
}
}

@Override
protected void addGoods() {
}
};
viewBinding.recyclerGoods.setAdapter(goodsAdapter);
goodsList.clear();
goodsList.addAll(GoodsDBUtil.getAll());
goodsAdapter.setNewData(goodsList);
}

@SuppressLint("NonConstantResourceId")
@OnClick({R.id.btn_add_classify,R.id.btn_update_classify,R.id.btn_delete_classify})
@@ -286,7 +380,7 @@ public class GoodEditClassifyFragment extends BaseFragment {
if(GoodsClassifyDBUtil.deleteById(classifyId)){
GoodsClassifyDBUtil.DeleteList(GoodsClassifyDBUtil.getListByName(classifyName));
AttributeDBUtil.deleteByClassifyId(classifyId);
GoodsDBUtil.deleteByClassifyId(classifyId);
GoodsDBUtil.deleteByGoodClassifyId(classifyId);
SubAttributeGroupDBUtil.deleteByClassifyId(classifyId);
SubAttributeDBUtil.deleteByClassifyId(classifyId);



+ 1
- 3
app/src/main/java/com/bonait/bnframework/ui/activity/PropEditClassifyFragment.java View File

@@ -38,8 +38,6 @@ import com.bonait.bnframework.ui.adapter.classify.SubattributeAdapter;
import com.bonait.bnframework.ui.util.DisplayManager;
import com.bonait.bnframework.ui.widget.NewToastUtil;

import org.greenrobot.eventbus.EventBus;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@@ -432,7 +430,7 @@ public class PropEditClassifyFragment extends BaseFragment {
if(PropClassifyDBUtil.deleteById(classifyId)){
PropClassifyDBUtil.DeleteList(PropClassifyDBUtil.getListByName(classifyName));
AttributeDBUtil.deleteByClassifyId(classifyId);
GoodsDBUtil.deleteByClassifyId(classifyId);
GoodsDBUtil.deleteByPropClassifyId(classifyId);
SubAttributeGroupDBUtil.deleteByClassifyId(classifyId);
SubAttributeDBUtil.deleteByClassifyId(classifyId);



+ 1
- 1
app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java View File

@@ -351,7 +351,7 @@ public class HomeGoodsViewModel extends ViewModel {
PropClassifyDBUtil.DeleteList(dataHas);
for(BPA_PROPERTY_CLASSIFY bean : dataHas){
AttributeDBUtil.deleteByClassifyId(bean.id);
GoodsDBUtil.deleteByClassifyId(bean.id);
GoodsDBUtil.deleteByPropClassifyId(bean.id);
SubAttributeGroupDBUtil.deleteByClassifyId(bean.id);
SubAttributeDBUtil.deleteByClassifyId(bean.id);
}


+ 10
- 1
app/src/main/res/layout/fragment_good_edit_classify.xml View File

@@ -94,7 +94,16 @@
/>



<androidx.recyclerview.widget.RecyclerView
android:layout_marginLeft="@dimen/dp_21"
android:layout_marginTop="180dp"
android:id="@+id/recycler_goods"
android:layout_width="match_parent"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:spanCount="3"
android:layout_height="match_parent">
</androidx.recyclerview.widget.RecyclerView>


</androidx.constraintlayout.widget.ConstraintLayout>


Loading…
Cancel
Save