Option_account.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <?php
  2. namespace Agent\Lib;
  3. use Dever;
  4. Class Option_account{
  5. #列表展示
  6. public function show($id){
  7. $info = Dever::db('agent/option_account')->find($id);
  8. $data =array();
  9. $data['list'] = $info['name'].'<br/>'.$info['mobile'].'<br/>'.$info['idcard'];
  10. // $count = $info['price']+$info['zh_price']+$info['zj_price'];
  11. $data['price'] = $info['price'].'<br/>'.$info['zh_price'].'<br/>'.$info['zj_price'];
  12. $config = Dever::db('agent/option_account')->config['config_status'];
  13. $status = Dever::status($config,$info['status']);
  14. if($info['jf_date']){
  15. $jf_date = date('Y-m-d H:i',$info['jf_date']);
  16. }else{
  17. $jf_date = '-';
  18. }
  19. $data['date'] = $status.'<br/>'.$jf_date;
  20. // $audit = Dever::db('agent/option_account')->config['config_audit_type'];
  21. // $type = Dever::status($audit,$info['audit_type']);
  22. if($info['audit_type'] == 1){
  23. $type = '待审核';
  24. }elseif($info['audit_type'] == 2 || $info['audit_type'] == 3){
  25. $type = '审核通过';
  26. }else{
  27. $type = '审核不通过';
  28. }
  29. if($info['audit_date']){
  30. $audit_date = date('Y-m-d H:i',$info['audit_date']);
  31. }else{
  32. $audit_date = '-';
  33. }
  34. $data['audit'] = $type.'<br/>'.$audit_date;
  35. return $data;
  36. }
  37. #详情页
  38. public function list(){
  39. $id = Dever::input('id');
  40. $info = Dever::db('agent/option_account')->find($id);
  41. $type_name = '';
  42. if($info['type'] == 1){
  43. $type_name = '零售店';
  44. }
  45. $count = $info['price']+$info['zh_price']+$info['zj_price'];
  46. $info_price = '设备费:'.$info['price'].'万元;装修费:'.$info['zh_price'].'万元;租金费:'.$info['zj_price'].'万元';
  47. $area = Dever::load("area/api.string", $info['area']);
  48. $area = str_replace(',','',$area);
  49. $image = explode(',',$info['pic']);
  50. $pic = '';
  51. foreach($image as $k => $v){
  52. $pic .= '<a href="'.$v.'" target="_blank"><img src="'.$v.'" width="100" /></a>';
  53. }
  54. if($info['annex']){
  55. $pic .= '<a href="'.$info['annex'].'" target="_blank">点此查看</a>';
  56. }
  57. // $audit = Dever::db('agent/option_account')->config['config_audit_type'];
  58. // $audit_type = Dever::status($audit,$info['audit_type']);
  59. if($info['audit_type'] == 1){
  60. $audit_type = '待审核';
  61. }elseif($info['audit_type'] == 2 || $info['audit_type'] == 3){
  62. $audit_type = '审核通过';
  63. }else{
  64. $audit_type = '审核不通过';
  65. }
  66. $config = Dever::db('agent/option_account')->config['config_status'];
  67. $status = Dever::status($config,$info['status']);
  68. $policy = Dever::db('agent/option_policy')->find($info['policy_id']);
  69. $policy_name = '';
  70. if ($policy && $policy['name']) {
  71. $policy_name = $policy['name'];
  72. }
  73. $exe = explode(',', $info['exercise_id']);
  74. foreach ($exe as $k => $v) {
  75. $exer[] = Dever::db('agent/option_exercise')->find($v);
  76. }
  77. // print_R($exercise);die;
  78. $exercise_name = '';
  79. if ($exer) {
  80. $ex = array_column($exer,'name');
  81. if ($ex) {
  82. $exercise_name = implode(';', $ex);
  83. }
  84. }
  85. $release = Dever::db('agent/option_release')->find($info['release_id']);
  86. $release_name = '';
  87. if ($release && $release['name']) {
  88. $release_name = $release['name'];
  89. }
  90. $result = array();
  91. $result['期权记录详情'] = array
  92. (
  93. 'type' => 'info',
  94. 'content' => array
  95. (
  96. array
  97. (
  98. array('期权记录标题', $info['title']),
  99. array('记录说明', $info['desc']),
  100. array('备注', $info['remark']),
  101. ),
  102. array
  103. (
  104. array('记录类型', $type_name),
  105. array('开店投入金额', $info['price'].'元'),
  106. array('零售店政策', $policy_name),
  107. ),
  108. array
  109. (
  110. array('政策对应期权价值', $info['zh_price']),
  111. array('实际补贴期权价值', $info['zj_price']),
  112. array('行权条件', $exercise_name),
  113. ),
  114. array
  115. (
  116. array('释放比例', $release_name),
  117. ),
  118. ),
  119. );
  120. $result['受益人资料'] = array
  121. (
  122. 'type' => 'info',
  123. 'content' => array
  124. (
  125. array
  126. (
  127. array('受益人姓名', $info['name']),
  128. array('受益人电话', $info['mobile']),
  129. array('受益人身份证号', $info['idcard']),
  130. ),
  131. array
  132. (
  133. array('受益人邮箱', $info['email']),
  134. array('门店地址', $area.$info['address']),
  135. array('门店编号', $info['number']),
  136. ),
  137. ),
  138. );
  139. $result['凭证照片/附件'] = array
  140. (
  141. 'type' => 'info',
  142. 'content' => array
  143. (
  144. array
  145. (
  146. array('', $pic),
  147. ),
  148. ),
  149. );
  150. if($info['audit_type'] == 1){
  151. $result['审核结果'] = array
  152. (
  153. 'type' => 'info',
  154. 'content' => array
  155. (
  156. array
  157. (
  158. array('审核状态', $audit_type),
  159. array('交付状态', $status),
  160. ),
  161. ),
  162. );
  163. }else{
  164. $result['审核结果'] = array
  165. (
  166. 'type' => 'info',
  167. 'content' => array
  168. (
  169. array
  170. (
  171. array('审核状态', $audit_type),
  172. // array('确认期权数', $info['num']),
  173. array('审核备注', $info['audit_desc']),
  174. ),
  175. array
  176. (
  177. array('交付状态', $status),
  178. ),
  179. ),
  180. );
  181. }
  182. $button = array();
  183. if (Dever::load('manage/auth')->checkFunc('agent.option_account', 'edit', '备注')) {
  184. $purl = Dever::url('project/database/update?project=agent&table=option_account&where_id='.$info['id'].'&col=remark', 'manage');
  185. $button[] = array
  186. (
  187. 'type' => 'edit',
  188. 'link' => $purl,
  189. 'name' => '备注',
  190. );
  191. }
  192. if (Dever::load('manage/auth')->checkFunc('agent.option_account', 'edit1', '修改资料')) {
  193. $purl = Dever::url('project/database/update?project=agent&table=option_account&where_id='.$info['id'].'&audit='.$info['audit'].'&col=name,mobile,idcard,area,address,title,remark,type,price,zh_price,zj_price,policy_id,exercise_id,release_id','manage');
  194. $button[] = array
  195. (
  196. 'type' => 'edit',
  197. 'link' => $purl,
  198. 'name' => '修改资料',
  199. );
  200. }
  201. if (Dever::load('manage/auth')->checkFunc('agent.option_account', 'edit2', '财务终审')) {
  202. if($info['audit_type'] == 1 && $info['audit'] == 1){
  203. $purl = Dever::url('project/database/update?project=agent&table=option_account&where_id='.$info['id'].'&col=id,audit_type,audit,audit_desc,num', 'manage');
  204. $button[] = array
  205. (
  206. 'type' => 'edit',
  207. 'link' => $purl,
  208. 'name' => '财务终审',
  209. );
  210. }
  211. }
  212. if (Dever::load('manage/auth')->checkFunc('agent.option_account', 'edit3', '交付确认')) {
  213. if($info['audit_type'] == 2){
  214. $purl = Dever::url('project/database/update?project=agent&table=option_account&where_id='.$info['id'].'&audit_type=2&col=id', 'manage');
  215. $button[] = array
  216. (
  217. 'type' => 'action',
  218. 'link' => Dever::url('lib/option_account.setStatus?id=' . $info['id'] . '&value=2', 'agent'),
  219. 'name' => '交付确认',
  220. );
  221. }
  222. }
  223. $head = array
  224. (
  225. 'name' => '基本资料',
  226. 'btn' => $button,
  227. );
  228. $foot = $button;
  229. $html = Dever::show($head, $result, $foot);
  230. return $html;
  231. }
  232. public function setStatus_api()
  233. {
  234. $where['where_id'] = Dever::input('id');
  235. $where['set_audit_type'] = 3;
  236. $where['set_status'] = 2;
  237. $where['set_jf_date'] = time();
  238. Dever::db('agent/option_account')->update($where);
  239. return 'reload';
  240. }
  241. public function updateAccount($id,$name,$data)
  242. {
  243. $price = Dever::param('price',$data);
  244. $zh_price = Dever::param('zh_price',$data);
  245. $zj_price = Dever::param('zj_price',$data);
  246. $audit = Dever::param('audit',$data);
  247. $num = Dever::param('num',$data);
  248. $info = Dever::db('agent/option_account')->find($id);
  249. // if (!$info) {
  250. // if ($price <= $zh_price){
  251. // $zj_price = $price;
  252. // } elseif ($price > $zh_price) {
  253. // $zj_price = $price - $zh_price;
  254. // }
  255. // $w['where_id'] = $id;
  256. // $w['zj_price'] = $zj_price;
  257. // // print_R($w);die;
  258. // Dever::db('agent/option_account')->update($w);
  259. // }
  260. // if (!$info['zj_price'] || $info['zj_price'] <=0) {
  261. // if ($info['price'] <= $info['zh_price']) {
  262. // $zj_price = $info['price'];
  263. // } elseif ($info['price'] > $info['zh_price']) {
  264. // $zj_price = $info['price'] - $info['zh_price'];
  265. // }
  266. // $w['where_id'] = $info['id'];
  267. // $w['zj_price'] = $zj_price;
  268. // // print_R($w);die;
  269. // Dever::db('agent/option_account')->update($w);
  270. // }
  271. if($audit){
  272. if ($audit == 1) {
  273. $where['where_id'] = $id;
  274. $where['set_audit_date'] = time();
  275. $where['set_audit_type'] = 2;
  276. if($num){
  277. $where['set_num'] = $num;
  278. }
  279. Dever::db('agent/option_account')->update($where);
  280. }
  281. }
  282. if(!$audit){
  283. if($info['audit'] ==2){
  284. $update['where_id'] = $id;
  285. $update['audit'] = 1;
  286. Dever::db('agent/option_account')->update($update);
  287. }
  288. }
  289. if($id){
  290. $admin = Dever::load('manage/auth.data');
  291. $where['where_id'] = $id;
  292. $where['audit_admin'] = $admin['id'];
  293. Dever::db('agent/option_account')->update($where);
  294. }
  295. }
  296. }